/* SolarLayout — 宣紙/米色柔和主題
   Warm paper-toned light theme: cream backgrounds + earthy accents + forest green */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@300;400;500;700&display=swap');

:root {
  --bg-deep: #E4E9EE;          /* 淡藍灰（頁面/畫布底色） */
  --bg-base: #F4F7FA;          /* 主面板藍紙白（柔和不刺眼） */
  --bg-surface: #EDF1F5;       /* input 欄位（微內陷） */
  --bg-elevated: #FAFCFE;      /* 凸起卡片（近白帶一絲藍） */
  --border: #CDD4DD;           /* 淡灰藍邊框 */
  --border-subtle: rgba(30,45,70,0.08);
  --text-primary: #1A2332;     /* 墨藍文字 */
  --text-secondary: #475569;   /* 輔助文字 */
  --text-muted: #7A8495;       /* 提示文字 */
  --green: #2F7D3A;            /* 綠地 — 森林綠（AA） */
  --green-dim: #24622D;
  --green-glow: rgba(47,125,58,0.10);
  --gold: #A6741A;             /* 陽光 — 暖金 */
  --gold-dim: #7D5613;
  --orange: #C35B28;
  --sky: #1E6FA8;              /* 藍天 — 沉穩藍 */
  --sky-dim: #114A78;
  --red: #B02A2A;
  --red-dim: #7D1E1E;
  --font: 'Noto Sans TC', system-ui, sans-serif;
  --mono: 'SF Mono', 'Cascadia Code', monospace;
  --radius: 4px;
  --transition: 180ms ease;
  --shadow-sm: 0 1px 2px rgba(30,45,70,0.06);
  --shadow-md: 0 2px 8px rgba(30,45,70,0.10);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--green); text-decoration: none; transition: color var(--transition); }
a:hover { color: #4ADE80; }

/* ─── Top Bar ─── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 52px;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-brand img { height: 28px; }

.topbar-brand span {
  font-weight: 500;
  font-size: 15px;
  letter-spacing: 0.5px;
  color: var(--text-primary);
}

.topbar-nav { display: flex; align-items: center; gap: 8px; }

.topbar-nav a, .topbar-nav button {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: var(--radius);
  transition: all var(--transition);
  border: none;
  cursor: pointer;
  font-family: var(--font);
}

.topbar-nav a { color: var(--text-secondary); }
.topbar-nav a:hover { color: var(--text-primary); background: var(--bg-surface); }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-surface);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn:hover { background: var(--bg-elevated); border-color: var(--text-muted); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--green-dim);
  border-color: var(--green);
  color: #fff;
}
.btn-primary:hover { background: var(--green); }
.btn-primary:disabled { background: var(--bg-surface); border-color: var(--border); }

.btn-gold {
  background: var(--gold-dim);
  border-color: var(--gold);
  color: #fff;
}
.btn-gold:hover { background: var(--gold); color: #000; }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger  { border-color: var(--red); color: var(--red); }
.btn-danger:hover  { background: var(--red-dim); color: #fff; }
.btn-warning { border-color: var(--orange); color: var(--orange); }
.btn-warning:hover { background: rgba(249,115,22,0.15); color: #fff; }

#poly-count-badge {
  display: none;
  background: var(--orange);
  color: #000;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 700;
  margin-left: 2px;
}

/* ─── Inputs ─── */
.input, select, textarea {
  padding: 8px 11px;
  font-size: 14px;
  font-family: var(--font);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  width: 100%;
  transition: border-color var(--transition);
}

.input:focus, select:focus { outline: none; border-color: var(--green); }
select { cursor: pointer; }

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.2px;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.form-group { margin-bottom: 12px; }

/* ─── Hero (Homepage) ─── */
.hero {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-height: 50vh;
  padding: 80px 60px;
  max-width: 900px;
}

.hero img { height: 48px; margin-bottom: 24px; }

.hero h1 {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 12px;
}

.hero p {
  font-size: 15px;
  color: var(--text-secondary);
  max-width: 560px;
  line-height: 1.7;
}

/* ─── Product Cards ─── */
.products {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 0 60px 80px;
  max-width: 900px;
}

.product-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 28px;
  background: var(--bg-base);
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
}

a.product-link { text-decoration: none; color: inherit; }

.product-card:hover {
  border-color: var(--text-muted);
  transform: translateY(-2px);
}

.product-card h3 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 8px;
}

.product-card p {
  font-size: 13px;
  color: var(--text-secondary);
  flex: 1;
  margin-bottom: 16px;
}

.product-card .tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 3px;
  text-transform: uppercase;
}

.tag-green { background: var(--green-glow); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.tag-orange { background: rgba(249,115,22,0.12); color: var(--orange); border: 1px solid rgba(249,115,22,0.3); }

/* ─── Solar Product Page ─── */
.solar-hero {
  padding: 60px;
  max-width: 1000px;
}

.solar-hero h1 { font-size: 32px; font-weight: 700; margin-bottom: 8px; }
.solar-hero h1 span { color: var(--green); }

.features {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 0 60px 48px;
  max-width: 1000px;
}

.feature {
  padding: 20px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: var(--bg-base);
}

.feature h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--green);
}

.feature p { font-size: 12px; color: var(--text-secondary); }

/* ─── Login Section ─── */
.login-section {
  position: fixed;
  top: 52px;
  right: 0;
  width: 300px;
  padding: 20px;
  background: var(--bg-base);
  border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  z-index: 50;
}

.user-info {
  padding: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
}

.user-info .company { font-weight: 600; color: var(--green); margin-bottom: 4px; }
.user-info .meta { font-size: 11px; color: var(--text-muted); }

/* ─── App Layout (Tool Page) ─── */
.app-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  height: calc(100vh - 52px);
  overflow: hidden;
}

.canvas-area {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-deep);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.toolbar .sep {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}

.toolbar .btn.active {
  background: var(--green-dim);
  border-color: var(--green);
  color: #fff;
}

.canvas-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.canvas-container canvas { border: 1px solid var(--border); }

/* ─── Control Panel (Right Side) ─── */
.control-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
  border-left: 1px solid var(--border);
  overflow-y: auto;
}

.panel-section {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.panel-section h3 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--text-primary);
  margin-bottom: 12px;
}

/* ─── Field Group (案件資料分組外框) ─── */
.field-group {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px 6px;
  margin-bottom: 14px;
  background: var(--bg-surface);
}
.field-group > .legend {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--sky-dim);
  margin-bottom: 10px;
  letter-spacing: 0.3px;
}

/* ─── Draw Hint (地圖上方雙擊提示浮條) ─── */
.draw-hint {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  padding: 9px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--sky);
  border-radius: 999px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
  box-shadow: 0 4px 14px rgba(30,45,70,0.15);
  pointer-events: none;
  transition: opacity 180ms ease, border-color 180ms ease, background 180ms ease;
}
.draw-hint.hidden { display: none; }
.draw-hint.ready {
  border-color: var(--green);
  background: var(--green-glow);
  color: var(--green-dim);
  box-shadow: 0 4px 14px rgba(47,125,58,0.22);
}
.draw-hint .count {
  color: var(--green);
  font-weight: 800;
  margin: 0 3px;
}

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ─── Results Section ─── */
.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.result-item {
  padding: 8px;
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
}

.result-item .value {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--green);
}

.result-item .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

/* ─── Multi-building breakdown colors ─── */
.result-building[data-bld="0"] { border-top: 2px solid #22C55E; }
.result-building[data-bld="1"] { border-top: 2px solid #3B82F6; }
.result-building[data-bld="2"] { border-top: 2px solid #F59E0B; }
.result-building[data-bld="3"] { border-top: 2px solid #EC4899; }
.result-building[data-bld="0"] .bld-label { color: #22C55E; }
.result-building[data-bld="1"] .bld-label { color: #3B82F6; }
.result-building[data-bld="2"] .bld-label { color: #F59E0B; }
.result-building[data-bld="3"] .bld-label { color: #EC4899; }
.bld-value { font-size: 1rem !important; }

/* ─── INV Options Table ─── */
.inv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.inv-table th {
  text-align: left;
  padding: 6px 8px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.inv-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.inv-table td:first-child { color: var(--text-primary); font-weight: 500; }

/* ─── Admin Page ─── */
.admin-layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px;
}

.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  padding: 16px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat-card .value {
  font-size: 24px;
  font-weight: 700;
  font-family: var(--mono);
}

.stat-card .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table tr:hover td { background: var(--bg-surface); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 3px;
  font-weight: 500;
}
.badge-ok { background: var(--green-glow); color: var(--green); }
.badge-warn { background: rgba(234,179,8,0.15); color: var(--gold); }
.badge-err { background: rgba(239,68,68,0.15); color: var(--red); }

/* ─── Footer ─── */
.footer {
  padding: 24px 60px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
}

/* ─── Utilities ─── */
.hidden { display: none !important; }
.text-green { color: var(--green); }
.text-gold { color: var(--gold); }
.text-muted { color: var(--text-muted); }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
