:root {
  --bg: #ece7dc;
  --bg-2: #f7f3ea;
  --ink: #1a211c;
  --muted: #5d675f;
  --line: #d7d0c2;
  --paper: #fffcf6;
  --paper-2: #f3eee3;
  --teal: #0f6e5c;
  --teal-2: #1a8f78;
  --navy: #1d3a4d;
  --clay: #b85c38;
  --gold: #b0892c;
  --ok: #1f7a4d;
  --bad: #a33b2d;
  --shadow: 0 1px 0 rgba(26, 33, 28, 0.04);
  --font: "Noto Sans TC", "Source Sans 3", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "Consolas", monospace;
  --display: "Fraunces", "Noto Serif TC", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 0% -10%, #dde8e2 0%, transparent 55%),
    var(--bg);
  line-height: 1.45;
}

button, input, select { font-family: inherit; }

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 36px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.brand { display: flex; gap: 14px; align-items: flex-start; }
.mark {
  width: 42px; height: 42px;
  border-radius: 10px;
  background: var(--teal);
  color: #f7f3ea;
  display: grid; place-items: center;
  font-family: var(--display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.04em;
}
.brand h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 28px;
  font-weight: 560;
  letter-spacing: -0.03em;
}
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.header-meta { text-align: right; color: var(--muted); font-size: 12px; }
.header-meta strong { display: block; color: var(--ink); font-size: 13px; font-weight: 650; }
.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}
.lang-switch {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--paper-2);
}
.lang-switch button {
  border: 0;
  background: transparent;
  height: 32px;
  padding: 0 12px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.lang-switch button.active {
  background: var(--teal);
  color: #fff;
}

.layout { padding: 22px 36px 48px; display: grid; gap: 18px; }

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
}
.panel h2 {
  margin: 0 0 12px;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.dropzone {
  border: 1.5px dashed #c3bbaa;
  border-radius: 12px;
  background: var(--bg-2);
  padding: 22px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone.drag { border-color: var(--teal); background: #e7f3ee; }
.dropzone strong { display: block; font-size: 15px; margin-bottom: 4px; }
.dropzone span { color: var(--muted); font-size: 12px; }
.file-row {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px;
}
.chip {
  font-size: 12px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--navy);
}
.chip.ok { background: #e5f3ec; border-color: #b7d8c6; }
.chip.warn { background: #f8eadf; border-color: #e3c3b0; }

.controls {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}
.field label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 700;
}
.field input, .field select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
}
.seg {
  display: flex;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  height: 38px;
}
.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 650;
  font-size: 13px;
}
.seg button.active { background: var(--teal); color: #fff; }

.check {
  display: flex; align-items: center; gap: 8px;
  height: 38px; font-size: 13px; color: var(--ink);
}
.check input { width: 16px; height: 16px; }

.kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}
.kpis.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px 14px;
}
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 650; }
.kpi .value {
  font-family: var(--display);
  font-size: 30px;
  letter-spacing: -0.03em;
  margin: 6px 0 2px;
}
.kpi .delta { font-size: 12px; font-weight: 700; }
.kpi .delta.down { color: var(--ok); }
.kpi .delta.up { color: var(--bad); }
.kpi .delta.flat { color: var(--muted); }
.kpi .hint { font-size: 11px; color: var(--muted); margin-top: 4px; }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; }
.chart-box { position: relative; height: 300px; }
.chart-box.tall { height: 340px; }
.caption { margin: 8px 0 0; font-size: 11px; color: var(--muted); }

.compare {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: stretch;
}
.era { background: var(--bg-2); border-radius: 12px; padding: 14px 16px; }
.era h3 { margin: 0 0 10px; font-size: 14px; }
.era-row { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.era-row:last-child { border: 0; }
.era-row span:last-child { font-family: var(--mono); font-size: 12px; }
.vs {
  display: grid; place-items: center;
  font-family: var(--display);
  color: var(--clay);
  font-size: 20px;
  writing-mode: vertical-rl;
}

.insight {
  background: #1d3a4d;
  color: #f3eee3;
  border: 0;
}
.insight h2 { color: #c9d7cf; }
.insight p { margin: 0 0 10px; font-size: 14px; }
.insight strong { color: #fff; }
.calc {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,.12);
}
.calc input { background: #25485d; border-color: #3a647c; color: #fff; width: 120px; }
.calc-out { font-size: 13px; color: #d7e4dc; }
.apply-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: end;
}
.apply-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.apply-presets button {
  height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.25);
  background: #25485d;
  color: #d7e4dc;
  cursor: pointer;
  font-size: 12px;
}
.apply-presets button.active {
  background: #0f6e5c;
  border-color: #0f6e5c;
  color: #fff;
}
.apply-obs { font-size: 12px; color: #c9d7cf; margin: 0; }
.apply-result { display: grid; gap: 6px; font-size: 14px; color: #d7e4dc; }
.apply-result strong { color: #fff; font-size: 18px; }
.apply-k { color: #c9d7cf; margin-right: 8px; }
.apply-caveat { font-size: 11px; color: #9bb0a6; margin-top: 6px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
th, td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); }
th {
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}
td.num, th.num { text-align: right; font-family: var(--mono); font-size: 12px; }
.table-wrap { max-height: 420px; overflow: auto; }
.toolbar { display: flex; gap: 8px; margin-bottom: 10px; }
.toolbar input {
  flex: 1; height: 34px; border: 1px solid var(--line);
  border-radius: 8px; padding: 0 10px; background: var(--bg-2);
}
.btn {
  height: 34px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--paper); cursor: pointer;
  font-size: 12px; font-weight: 650;
}
.btn.primary { background: var(--teal); color: #fff; border-color: var(--teal); }

.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
}
.status-bar {
  font-size: 12px; color: var(--muted);
}

.sheet {
  background: #fff;
  border: 1px solid #cfc8bb;
  border-radius: 10px;
  overflow: auto;
}
.sheet + .sheet { margin-top: 18px; }
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #1f6f66;
  color: #fff;
  padding: 10px 14px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.sheet-head .btn {
  height: 30px;
  background: transparent;
  color: #fff;
  border-color: rgba(255,255,255,.45);
}
.sheet-note {
  background: #f4f1ea;
  color: #5d675f;
  font-size: 12px;
  padding: 8px 14px;
  line-height: 1.55;
}
.sheet table { width: 100%; min-width: 920px; }
.sheet th {
  background: #e67e22;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  cursor: default;
  white-space: nowrap;
  padding: 8px 10px;
  border-bottom: 0;
}
.sheet td {
  padding: 6px 10px;
  font-size: 13px;
  border-bottom: 1px solid #eee8dc;
  white-space: nowrap;
}
.sheet tbody tr:nth-child(even) td { background: #faf7f1; }
.sheet tbody tr.post td { background: #eef7f3; }
.sheet tbody tr.split td { background: #fff6ea; }
.sheet .mark-launch { color: var(--clay); font-weight: 700; font-size: 11px; margin-left: 6px; }

@media (max-width: 1100px) {
  .controls, .kpis, .grid-2, .grid-3, .compare { grid-template-columns: 1fr; }
  .vs { writing-mode: horizontal-tb; padding: 4px 0; }
  .app-header, .layout { padding-left: 16px; padding-right: 16px; }
  .app-header { flex-direction: column; align-items: flex-start; }
  .header-right { align-items: flex-start; width: 100%; }
}
