:root {
  --bg: #F6F3EC;
  --bg-elev: #FFFFFF;
  --bg-subtle: #EFEAE0;
  --bg-sticky: #FCFBF8;
  --ink: #192026;
  --ink-2: #4A5560;
  --ink-3: #7A848E;
  --line: #E5DFD3;
  --line-soft: #EFEAE0;
  --accent: #166A5A;
  --accent-deep: #0F4F43;
  --accent-soft: #E6F3F0;
  --hi: #C53B28;
  --hi-bg: #FDECE9;
  --lo: #1E63B5;
  --lo-bg: #EAF2FD;
  --warn: #A66510;
  --warn-bg: #FDF3DF;
  --ok: #177052;
  --ok-bg: #E7F5EE;
  --shadow-sm: 0 2px 10px rgba(25, 32, 38, 0.04);
  --shadow-md: 0 10px 28px rgba(25, 32, 38, 0.09);
  --shadow-sheet: 0 -10px 36px rgba(25, 32, 38, 0.16);
  --radius: 16px;
  --radius-sm: 10px;
  --font-display: "Songti SC", "Noto Serif SC", "STSong", Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121517;
    --bg-elev: #1B2023;
    --bg-subtle: #232A2E;
    --bg-sticky: #181D20;
    --ink: #EDF1F3;
    --ink-2: #B3BDC5;
    --ink-3: #7F8C96;
    --line: #2C343A;
    --line-soft: #232A2F;
    --accent: #4BB59E;
    --accent-deep: #379984;
    --accent-soft: rgba(75, 181, 158, 0.14);
    --hi: #FF7B6B;
    --hi-bg: rgba(255, 123, 107, 0.16);
    --lo: #6AA9FF;
    --lo-bg: rgba(106, 169, 255, 0.16);
    --warn: #F0B454;
    --warn-bg: rgba(240, 180, 84, 0.16);
    --ok: #55C59A;
    --ok-bg: rgba(85, 197, 154, 0.15);
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.24);
    --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.42);
    --shadow-sheet: 0 -10px 40px rgba(0, 0, 0, 0.52);
  }
}

:root[data-theme="dark"] {
  --bg: #121517;
  --bg-elev: #1B2023;
  --bg-subtle: #232A2E;
  --bg-sticky: #181D20;
  --ink: #EDF1F3;
  --ink-2: #B3BDC5;
  --ink-3: #7F8C96;
  --line: #2C343A;
  --line-soft: #232A2F;
  --accent: #4BB59E;
  --accent-deep: #379984;
  --accent-soft: rgba(75, 181, 158, 0.14);
  --hi: #FF7B6B;
  --hi-bg: rgba(255, 123, 107, 0.16);
  --lo: #6AA9FF;
  --lo-bg: rgba(106, 169, 255, 0.16);
  --warn: #F0B454;
  --warn-bg: rgba(240, 180, 84, 0.16);
  --ok: #55C59A;
  --ok-bg: rgba(85, 197, 154, 0.15);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.42);
  --shadow-sheet: 0 -10px 40px rgba(0, 0, 0, 0.52);
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

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

.boot-loader {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--ink-3);
}
.boot-mark {
  width: 40px; height: 40px; border-radius: 12px;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ───────── Auth Screen ───────── */
.auth-page {
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(20px + var(--safe-t)) 16px calc(24px + var(--safe-b));
  background:
    radial-gradient(640px 360px at 10% 0%, rgba(22, 106, 90, 0.10), transparent 70%),
    radial-gradient(520px 320px at 95% 100%, rgba(197, 59, 40, 0.06), transparent 70%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 26px 22px 24px;
  box-shadow: var(--shadow-md);
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.auth-logo {
  width: 44px; height: 44px; border-radius: 13px;
  background: var(--accent);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.auth-logo svg { width: 28px; height: 28px; }
.auth-brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 23px;
  letter-spacing: 0.02em;
  line-height: 1.2;
}
.auth-brand p {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--ink-3);
}
.auth-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.auth-feat {
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 9px 8px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-2);
}
.auth-feat strong {
  display: block;
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 2px;
}
.seg-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 16px;
}
.seg-tab {
  border: 0;
  background: transparent;
  padding: 8px 10px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
}
.seg-tab.active {
  background: var(--bg-elev);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* ───────── Inputs & Buttons ───────── */
.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 5px;
}
.input, .select, .textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 11px;
  padding: 11px 13px;
  font-size: 15px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--bg-elev);
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.55; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform .08s, background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
}
.btn.primary:hover { background: var(--accent-deep); }
.btn.soft {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
}
.btn.danger {
  background: var(--hi-bg);
  border-color: transparent;
  color: var(--hi);
}
.btn.sm { min-height: 32px; padding: 5px 11px; font-size: 13px; border-radius: 9px; }
.btn.full { width: 100%; min-height: 44px; font-size: 15px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ───────── App Shell ───────── */
.shell {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(74px + var(--safe-b));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  padding: calc(10px + var(--safe-t)) 14px 10px;
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.brand-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.brand-dot {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.brand-dot svg { width: 18px; height: 18px; }
.brand-title {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.profile-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  max-width: 148px;
}
.profile-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.desk-nav { display: none; gap: 4px; }

.main-wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 12px 24px;
  flex: 1;
}

/* ───────── Summary Strip ───────── */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.kpi-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 10px 9px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-align: left;
  transition: border-color .15s;
}
.kpi-card.active {
  border-color: var(--hi);
  background: var(--hi-bg);
}
.kpi-label {
  font-size: 12px;
  color: var(--ink-3);
  display: block;
  white-space: nowrap;
}
.kpi-val {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 18px;
  font-weight: 700;
  margin-top: 2px;
  display: block;
}
.kpi-val.sm-date { font-size: 12.5px; padding-top: 4px; white-space: nowrap; letter-spacing: -0.02em; }
.kpi-val.is-hi { color: var(--hi); }
.kpi-val.is-ok { color: var(--ok); }

/* ───────── Search & Category Pills ───────── */
.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.search-box {
  flex: 1;
  position: relative;
}
.search-box input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  border-radius: 12px;
  padding: 0 32px 0 34px;
  font-size: 14px;
  outline: none;
}
.search-box input:focus { border-color: var(--accent); }
.search-ico {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
  pointer-events: none;
  font-size: 14px;
}
.search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--ink-3);
  width: 26px; height: 26px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 15px;
}

.abn-toggle {
  height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.abn-toggle.on {
  background: var(--hi-bg);
  border-color: color-mix(in srgb, var(--hi) 38%, transparent);
  color: var(--hi);
}

.cat-rail {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 0 10px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.cat-rail::-webkit-scrollbar { display: none; }
.cat-pill {
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.cat-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
}
.cat-badge {
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 0 5px;
  border-radius: 999px;
  background: var(--hi-bg);
  color: var(--hi);
}
.cat-pill.active .cat-badge {
  background: rgba(255, 255, 255, 0.24);
  color: #FFFFFF;
}

/* ───────── Excel Frozen-Column Matrix ───────── */
.matrix-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.matrix-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-sticky);
}
.matrix-wrap {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  position: relative;
}
.excel-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
}
.excel-table thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--bg-sticky);
  border-bottom: 1px solid var(--line);
  padding: 10px 10px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
  white-space: nowrap;
}
.excel-table th.col-name,
.excel-table td.col-name {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--bg-elev);
  width: 130px;
  min-width: 130px;
  max-width: 144px;
  border-right: 1px solid var(--line);
  box-shadow: 4px 0 10px -6px rgba(25, 32, 38, 0.16);
}
.excel-table thead th.col-name {
  z-index: 6;
  background: var(--bg-sticky);
}
.excel-table th.col-date,
.excel-table td.col-date {
  width: 96px;
  min-width: 96px;
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.excel-table th.col-date.latest {
  color: var(--accent);
}
.excel-table th.col-unit,
.excel-table td.col-unit {
  min-width: 72px;
  color: var(--ink-3);
  font-size: 12px;
  font-family: var(--font-mono);
  white-space: nowrap;
}
.excel-table th.col-ref,
.excel-table td.col-ref {
  min-width: 98px;
  color: var(--ink-3);
  font-size: 12px;
  font-family: var(--font-mono);
  white-space: nowrap;
}

.excel-table tr.cat-sep td {
  background: var(--bg-subtle);
  color: var(--ink-2);
  font-weight: 700;
  font-size: 12px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.excel-table tr.cat-sep td.sticky-cat {
  position: sticky;
  left: 0;
  z-index: 3;
}

.excel-table tbody tr.metric-row {
  cursor: pointer;
  transition: background .12s;
}
.excel-table tbody tr.metric-row td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.excel-table tbody tr.metric-row:hover td,
.excel-table tbody tr.metric-row:hover td.col-name {
  background: var(--accent-soft);
}

.m-name-wrap {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.m-dot {
  width: 7px; height: 7px; border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
  background: var(--ok);
}
.m-dot.hi { background: var(--hi); }
.m-dot.lo { background: var(--lo); }
.m-dot.warn { background: var(--warn); }
.m-title {
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  font-size: 13.5px;
}
.m-sub {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 2px;
  font-family: var(--font-mono);
}
.m-qmark {
  display: inline-grid;
  place-items: center;
  width: 15px; height: 15px;
  border-radius: 50%;
  border: 1px solid var(--line);
  font-size: 10px;
  color: var(--ink-3);
  font-family: var(--font-sans);
}

.val-pill {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  padding: 2px 7px;
  border-radius: 7px;
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.3;
}
.val-pill.ok { color: var(--ink); }
.val-pill.hi { background: var(--hi-bg); color: var(--hi); }
.val-pill.lo { background: var(--lo-bg); color: var(--lo); }
.val-pill.warn { background: var(--warn-bg); color: var(--warn); font-family: var(--font-sans); font-size: 12px; }
.val-pill.text-val {
  font-family: var(--font-sans);
  font-size: 12px;
  max-width: 88px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.val-delta {
  display: block;
  font-size: 10.5px;
  color: var(--ink-3);
  margin-top: 2px;
}
.val-delta.up { color: var(--hi); }
.val-delta.down { color: var(--ok); }
.val-empty { color: var(--ink-3); opacity: 0.45; }

/* ───────── Trend Charts Tab ───────── */
.trend-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.trend-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color .15s, transform .12s;
}
.trend-card:hover { border-color: var(--accent); }
.trend-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.trend-title { font-weight: 700; font-size: 15px; }
.trend-code { font-size: 12px; color: var(--ink-3); font-family: var(--font-mono); margin-left: 6px; }
.trend-latest {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.trend-latest strong { font-size: 17px; }
.trend-latest small { display: block; font-size: 11px; color: var(--ink-3); }
.trend-svg { width: 100%; height: 112px; display: block; }
.trend-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink-3);
}

/* ───────── Reports & Import Tab ───────── */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
}
.card-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.card-h h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
}
.ai-drop {
  border: 1.5px dashed color-mix(in srgb, var(--accent) 45%, var(--line));
  background: color-mix(in srgb, var(--accent-soft) 55%, var(--bg-elev));
  border-radius: 14px;
  padding: 16px 14px;
  text-align: center;
  margin-bottom: 12px;
}
.ai-drop p { margin: 6px 0 12px; font-size: 13px; color: var(--ink-2); }
.ai-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.rep-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  background: var(--bg);
  margin-bottom: 10px;
}
.rep-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.rep-date {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
}
.rep-title { font-weight: 700; font-size: 15px; margin-top: 2px; }
.rep-meta { font-size: 12.5px; color: var(--ink-3); margin-top: 4px; }
.rep-summary { font-size: 13px; color: var(--ink-2); margin-top: 6px; line-height: 1.5; }
.rep-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* ───────── Bottom Navigation (Mobile) ───────── */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg-elev) 94%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + var(--safe-b));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.bnav-btn {
  border: 0;
  background: transparent;
  padding: 6px 4px 4px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.bnav-btn svg { width: 21px; height: 21px; stroke-width: 1.9; }
.bnav-btn.active {
  color: var(--accent);
  background: var(--accent-soft);
}

/* ───────── Bottom Sheet / Detail Drawer ───────── */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 22, 27, 0.56);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet {
  width: 100%;
  max-width: 620px;
  max-height: 88svh;
  overflow-y: auto;
  background: var(--bg-elev);
  border-radius: 22px 22px 0 0;
  padding: 12px 18px calc(22px + var(--safe-b));
  box-shadow: var(--shadow-sheet);
  animation: slideUp .16s cubic-bezier(.22, 1, .36, 1);
}
@keyframes slideUp { from { transform: translateY(24px); } to { transform: none; } }
.sheet-handle {
  width: 38px; height: 4px; border-radius: 99px;
  background: var(--line);
  margin: 0 auto 12px;
}
.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
}
.sheet-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1.25;
}
.sheet-close {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

/* Bullet range bar inside detail sheet */
.gauge-box {
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.gauge-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}
.gauge-val { font-family: var(--font-mono); font-size: 24px; font-weight: 700; }
.gauge-track {
  position: relative;
  height: 10px;
  border-radius: 99px;
  background: var(--line);
  margin: 10px 0 6px;
}
.gauge-safe {
  position: absolute;
  top: 0; bottom: 0;
  background: color-mix(in srgb, var(--ok) 45%, transparent);
  border-radius: 99px;
}
.gauge-pin {
  position: absolute;
  top: 50%;
  width: 16px; height: 16px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 2.5px solid var(--bg-elev);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  background: var(--ok);
}
.gauge-pin.hi { background: var(--hi); }
.gauge-pin.lo { background: var(--lo); }

.kb-block {
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.kb-block h4 {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--accent);
}
.kb-block p {
  margin: 0;
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.6;
}

.hist-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.hist-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 10px;
  font-size: 13.5px;
}
.hist-row .d { font-family: var(--font-mono); color: var(--ink-2); }

/* Desktop Hover Tooltip */
.hover-tip {
  position: fixed;
  z-index: 80;
  max-width: 310px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 13px;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  font-size: 13px;
}
.hover-tip strong { display: block; font-size: 14px; margin-bottom: 4px; color: var(--ink); }
.hover-tip p { margin: 0; color: var(--ink-2); line-height: 1.5; }
.hover-tip small { display: block; margin-top: 6px; color: var(--accent); font-size: 11.5px; }

/* Report Editor Grid */
.edit-row {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 0.8fr 1fr auto;
  gap: 6px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
}
.edit-row input, .edit-row select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 8px;
  padding: 7px 8px;
  font-size: 13px;
}

.empty-state {
  text-align: center;
  padding: 36px 18px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.empty-state h3 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 20px;
}
.empty-state p { margin: 0 0 18px; font-size: 14px; color: var(--ink-2); }
.empty-btns { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--ink-2);
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.hi { background: var(--hi-bg); color: var(--hi); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(82px + var(--safe-b));
  transform: translateX(-50%) translateY(16px);
  background: var(--ink);
  color: var(--bg);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  z-index: 90;
  transition: opacity .2s, transform .2s;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.muted { color: var(--ink-3); font-size: 13px; }
.mono { font-family: var(--font-mono); }

/* ───────── Desktop Enhancements ───────── */
@media (min-width: 820px) {
  .shell { padding-bottom: 32px; }
  .bottom-nav { display: none; }
  .desk-nav { display: flex; }
  .desk-nav-btn {
    border: 0;
    background: transparent;
    padding: 7px 14px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-2);
    cursor: pointer;
  }
  .desk-nav-btn.active {
    background: var(--accent-soft);
    color: var(--accent);
  }
  .main-wrap { padding: 18px 20px 40px; }
  .excel-table th.col-name,
  .excel-table td.col-name { width: 208px; min-width: 208px; max-width: 240px; }
  .trend-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .sheet-backdrop { align-items: center; padding: 24px; }
  .sheet { border-radius: 22px; max-height: 84vh; }
  .toast { bottom: 26px; }
}
@media (min-width: 1120px) {
  .trend-grid { grid-template-columns: repeat(3, 1fr); }
}
