:root {
  --bg: #0f141b;
  --surface: #151b24;
  --surface-2: #10161e;
  --surface-3: #1b2330;
  --surface-4: #252d3d;
  --line: #2a3543;
  --line-soft: #202a36;
  --line-strong: #334155;
  --text: #e8edf2;
  --muted: #8e9baa;
  --muted-2: #687584;
  --accent: #38bdf8;
  --accent-soft: rgba(56,189,248,0.12);
  --accent-line: rgba(56,189,248,0.24);
  --accent-hover: #0ea5e9;
  --accent-text: #7dd3fc;
  --primary: #38bdf8;
  --good: #2bb673;
  --good-soft: rgba(74,222,128,0.12);
  --good-text: #86efac;
  --warn: #d5a23a;
  --warn-soft: rgba(251,191,36,0.12);
  --warn-text: #fcd34d;
  --bad: #e06a5f;
  --bad-soft: rgba(248,113,113,0.12);
  --bad-text: #fca5a5;
  --danger: #f87171;
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-1: 0 1px 2px rgba(0,0,0,0.20), 0 0 0 1px rgba(255,255,255,0.02);
  --shadow-2: 0 8px 24px rgba(0,0,0,0.32), 0 0 0 1px rgba(255,255,255,0.03);
  --shadow-focus: 0 0 0 3px rgba(56,189,248,0.25);
  --motion-fast: 120ms;
  --motion-base: 180ms;
  --motion-slow: 240ms;
  --ease-out: cubic-bezier(0.16,1,0.3,1);
  --ease-in-out: cubic-bezier(0.4,0,0.2,1);
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "JetBrains Mono", "SF Mono", "Menlo", "Consolas", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 100vw;
}

/* ===== Top Bar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.topbar-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-title {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.2px;
  white-space: nowrap;
}

.topbar-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface-3);
  border: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.topbar-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--surface-3);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  border-radius: 6px;
  line-height: 1;
}

.icon-btn {
  border-radius: var(--radius);
  transition: background var(--motion-fast) var(--ease-out),
              border-color var(--motion-fast) var(--ease-out),
              color var(--motion-fast) var(--ease-out);
}
.icon-btn:hover {
  background: var(--surface-4);
  border-color: var(--line-strong);
  color: var(--accent);
}
.icon-btn:active { background: var(--surface-4); }

/* ===== Status Bar ===== */
.topbar-status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  align-self: center;
  max-width: 160px;
}

.topbar-status-main {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-status-hint {
  font-size: 10px;
  color: var(--muted-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.eye-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  transition: all 120ms;
}
.eye-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}

.topbar-status.live .topbar-status-main { color: var(--accent); }
.topbar-status.busy .topbar-status-main { color: var(--warn); }
.topbar-status.error .topbar-status-main { color: var(--bad); }

/* Pulse animation dots */
.topbar-status .topbar-status-main::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted-2);
  margin-right: 6px;
  vertical-align: 1px;
}
.topbar-status.live .topbar-status-main::before {
  background: var(--good);
  animation: pulse 1.6s ease-in-out infinite;
}
.topbar-status.busy .topbar-status-main::before {
  background: var(--warn);
  animation: pulse 1.4s ease-in-out infinite;
}
.topbar-status.error .topbar-status-main::before {
  background: var(--bad);
}

/* ===== Content Area ===== */
.content {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 14px 90px;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}

/* ===== View ===== */
.view { display: none; }
.view.active { display: block; }

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  min-height: 36px;
}

.view-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

/* ===== Bottom Nav ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 64px;
  padding-bottom: env(safe-area-inset-bottom, 0);
  background: var(--surface);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 1;
  height: 100%;
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 10px;
  cursor: pointer;
  padding: 4px;
}

.nav-item {
  transition: color var(--motion-fast) var(--ease-out),
              background var(--motion-fast) var(--ease-out);
}
.nav-item:hover { color: var(--text); }
.nav-item.active { color: var(--accent); }

.nav-icon { font-size: 20px; line-height: 1; }
.nav-label { font-weight: 600; }

/* ===== More Menu ===== */
.more-menu {
  position: fixed;
  top: 56px;
  right: 10px;
  z-index: 55;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  overflow: hidden;
  min-width: 160px;
}

.more-item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.more-item:last-child { border-bottom: 0; }
.more-item:active { background: var(--surface-3); }
.more-item--primary { color: var(--accent); font-weight: 700; }

/* ===== Cards / KPI Grid ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.kpi-grid--2 { grid-template-columns: repeat(2, 1fr); }
.kpi-grid--3 { grid-template-columns: repeat(3, 1fr); }
.kpi-grid--4 { grid-template-columns: repeat(2, 1fr); }

.kpi-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 14px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  min-height: 80px;
  min-width: 0;
  transition: border-color var(--motion-fast) var(--ease-out),
              background var(--motion-fast) var(--ease-out);
}
.kpi-card:hover {
  border-color: color-mix(in srgb, var(--accent) 36%, var(--line));
}

.kpi-card.primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 9%, var(--surface)) 0%, var(--surface) 100%);
  border-color: color-mix(in srgb, var(--accent) 22%, var(--line));
}

.kpi-card .label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.kpi-card .value {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  word-break: break-word;
  font-feature-settings: "tnum" 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
  transition: color var(--motion-fast) var(--ease-out);
}
.kpi-card:hover .value { color: var(--accent); }

.kpi-card .sub {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
  word-break: break-word;
}

/* ===== Fold Panels ===== */
.fold-panel {
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.fold-panel summary {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  background: var(--surface-2);
  user-select: none;
  min-height: 44px;
}

.fold-panel summary::-webkit-details-marker { display: none; }
.fold-panel summary::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-right: 10px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform var(--motion-base) var(--ease-out);
}
.fold-panel[open] summary::before { transform: rotate(45deg); }

.fold-panel > .card,
.fold-panel > .card-list,
.fold-panel > .list-panel,
.fold-panel > .kpi-grid,
.fold-panel > .note-line,
.fold-panel > .matrix-summary,
.fold-panel > .filter-bar {
  padding: 12px 14px;
}

/* ===== Card List ===== */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  transition: border-color var(--motion-fast) var(--ease-out);
}
.card:hover { border-color: var(--line-strong); }

.card-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 6px;
}

.card-sub {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 10px;
  line-height: 1.5;
}

.card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
}

.card-row:last-child { border-bottom: 0; }

.card-row .key { font-size: 12px; color: var(--muted); }
.card-row .val { font-family: var(--mono); font-size: 13px; font-weight: 700; }

/* ===== List Panel ===== */
.list-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.list-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  min-height: 44px;
}

.list-row:last-child { border-bottom: 0; }
.list-row {
  transition: background var(--motion-fast) var(--ease-out);
}
.list-row:hover { background: var(--surface-3); }
.list-row[data-nav] { cursor: pointer; }
.list-row[data-nav]:hover {
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}
.list-row[data-nav]:active { background: var(--surface-3); }

.list-row .left {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.list-row .title {
  font-size: 13px;
  font-weight: 700;
  word-break: break-word;
}

.list-row .meta {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
  word-break: break-word;
}

.list-row .right {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
  white-space: normal;
  flex-shrink: 1;
  word-break: break-word;
  max-width: 60%;
  margin-top: 1px;
}

/* ===== Filter Bar ===== */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 0;
}

.filter-chip {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--surface-3);
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border-radius: var(--radius);
  white-space: nowrap;
  transition: background var(--motion-fast) var(--ease-out),
              border-color var(--motion-fast) var(--ease-out),
              color var(--motion-fast) var(--ease-out);
}
.filter-chip:hover:not(.active) {
  border-color: var(--line-strong);
  color: var(--text);
}
.filter-chip.active {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent-text);
}
.filter-chip:active { background: var(--surface-4); }

/* ===== Scenario Tabs ===== */
.scenario-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 2px;
}

.scenario-tab {
  min-height: 36px;
  padding: 0 16px;
  border: 1px solid var(--line);
  background: var(--surface-3);
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border-radius: var(--radius);
  white-space: nowrap;
  transition: background var(--motion-fast) var(--ease-out),
              border-color var(--motion-fast) var(--ease-out),
              color var(--motion-fast) var(--ease-out);
}
.scenario-tab:hover:not(.active) {
  border-color: var(--line-strong);
  color: var(--text);
}
.scenario-tab.active {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent-text);
}

/* ===== Analysis Tabs ===== */
.analysis-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.analysis-tab {
  min-height: 36px;
  padding: 0 16px;
  border: 1px solid var(--line);
  background: var(--surface-3);
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border-radius: var(--radius);
  white-space: nowrap;
  transition: background var(--motion-fast) var(--ease-out),
              border-color var(--motion-fast) var(--ease-out),
              color var(--motion-fast) var(--ease-out);
}
.analysis-tab:hover:not(.active) {
  border-color: var(--line-strong);
  color: var(--text);
}
.analysis-tab.active {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent-text);
}

/* ===== Review Queue ===== */
.review-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  align-items: center;
}

.review-filter-bar select {
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  padding: 5px 8px;
  border-radius: 6px;
  min-height: 32px;
}

.review-queue {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rq-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--motion-fast) var(--ease-out),
              background var(--motion-fast) var(--ease-out);
}
.rq-item:active { border-color: var(--accent); }
.rq-item:hover {
  border-color: color-mix(in srgb, var(--accent) 36%, var(--line));
  background: var(--surface-3);
}

.rq-item.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.rq-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}

.rq-head strong {
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
  flex: 1;
}

.rq-badges {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge--ready { background: color-mix(in srgb, var(--good) 12%, transparent); color: var(--good-text); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.badge--partial { background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn-text); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.badge--empty { background: color-mix(in srgb, var(--bad) 10%, transparent); color: var(--bad-text); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.badge--auto { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.badge--high { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad-text); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.badge--medium { background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn-text); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.badge--low { background: color-mix(in srgb, var(--good) 12%, transparent); color: var(--good-text); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.badge--manual-override {
  background: #fef3c7;
  color: #92400e;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
}

.rq-meta {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
  word-break: break-word;
}

.rq-diff {
  font-size: 11px;
  color: var(--muted-2);
  margin-top: 4px;
  line-height: 1.45;
}

.load-more {
  width: 100%;
  min-height: 40px;
  margin-top: 4px;
  border: 1px dashed var(--line);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border-radius: 8px;
}

/* ===== Drawer ===== */
.drawer {
  position: fixed;
  inset: 0;
  z-index: 100;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
}

.drawer-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 85vh;
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  animation: slideUp 200ms ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.drawer-handle {
  width: 36px;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  margin: 8px auto;
  flex-shrink: 0;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 14px 10px;
  border-bottom: 1px solid var(--line-soft);
  flex-shrink: 0;
}

.drawer-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px calc(14px + env(safe-area-inset-bottom, 0));
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}

.drawer-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0));
  border-top: 1px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 110;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.75);
}

.modal-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 90vh;
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  animation: slideUp 200ms ease-out;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.modal-header h3 { margin: 0; font-size: 16px; }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  -webkit-overflow-scrolling: touch;
}

.modal-note {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 12px;
}

/* ===== Forms ===== */
.form-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  padding-bottom: 2px;
}

.form-tab {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--surface-3);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  border-radius: 6px;
  white-space: nowrap;
}

.form-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

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

.form-group label {
  display: block;
  font-size: 12px;
  color: var(--muted-2);
  margin-bottom: 4px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  -webkit-appearance: none;
  transition: border-color var(--motion-fast) var(--ease-out),
              box-shadow var(--motion-fast) var(--ease-out);
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
  outline: none;
}

/* Restore native date-picker appearance so localized text (e.g. "年") renders correctly */
.form-group input[type="date"] {
  -webkit-appearance: auto;
  appearance: auto;
  min-width: 180px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.intake-field { display: none; }
.intake-field.active { display: block; }
.form-row.intake-field.active { display: grid; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

/* ===== Buttons ===== */
.btn {
  min-height: 36px;
  padding: 0 16px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface-3);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn--primary {
  background: var(--accent);
  color: #0b1220;
  border-color: var(--accent);
  font-weight: 700;
}
.btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #0b1220;
}

.btn--sm { min-height: 32px; padding: 0 12px; font-size: 12px; }
.btn--block { width: 100%; justify-content: center; margin-bottom: 8px; }
.preview-label { font-size: 12px; color: var(--muted); margin-bottom: 8px; }

.btn--approve {
  border-color: rgba(43,182,115,0.4);
  color: #8de0b7;
}
.btn--approve:hover {
  border-color: rgba(43,182,115,0.6);
  background: rgba(43,182,115,0.08);
}
.btn--reject {
  border-color: rgba(224,106,95,0.4);
  color: #ffb2a8;
}
.btn--reject:hover {
  border-color: rgba(224,106,95,0.6);
  background: rgba(224,106,95,0.08);
}
.btn--defer {
  border-color: rgba(213,162,58,0.4);
  color: #f0c979;
}
.btn--defer:hover {
  border-color: rgba(213,162,58,0.6);
  background: rgba(213,162,58,0.08);
}

/* ===== Workbench ===== */
.wb-status-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.wb-status-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
}

.wb-status-item .num {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}

.wb-status-item .lbl {
  font-size: 10px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
}

.wb-section {
  margin-bottom: 14px;
}

.wb-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted-2);
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.wb-item {
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 6px;
}

.wb-item:last-child { margin-bottom: 0; }

.wb-item-header {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  margin-bottom: 4px;
}

.wb-severity {
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
}

.wb-module {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.wb-reason {
  color: var(--text);
  font-weight: 600;
}

.wb-item-body {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.55;
}

/* ===== Detail Blocks ===== */
.detail-block {
  margin-bottom: 14px;
}

.detail-block h4 {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.detail-block p {
  font-size: 12px;
  color: var(--text);
  line-height: 1.65;
  margin: 0;
}

.diff-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 6px;
}

.diff-table th,
.diff-table td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
}

.diff-table th {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.diff-old { color: var(--bad-text); font-family: var(--mono); }
.diff-new { color: var(--good-text); font-family: var(--mono); }

.source-chain {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chain-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--surface-2);
  border-radius: 4px;
  font-size: 11px;
}

.chain-tier {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--surface-3);
  color: var(--muted);
  white-space: nowrap;
}

.chain-tier.primary { background: color-mix(in srgb, var(--good) 12%, transparent); color: var(--good-text); }
.chain-tier.fallback { background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn-text); }

.chain-url {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.impact-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.impact-tag {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--bad) 10%, transparent);
  color: var(--bad-text);
  border: 1px solid color-mix(in srgb, var(--bad) 25%, transparent);
}

/* ===== Note Line ===== */
.note-line {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  padding: 8px 0;
}

/* ===== Matrix Summary (mobile vertical) ===== */
.matrix-summary {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.matrix-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.matrix-row .key { font-size: 12px; color: var(--muted); font-weight: 700; }
.matrix-row .val { font-size: 15px; font-weight: 700; }

/* ===== Empty State ===== */
.empty-state {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--line-strong); }

/* ===== Source Badges ===== */
.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  border: 1px solid transparent;
  margin-top: 4px;
}

.source-badge.official { border-color: color-mix(in srgb, var(--good) 28%, transparent); background: color-mix(in srgb, var(--good) 8%, transparent); color: var(--good-text); }
.source-badge.derived { border-color: color-mix(in srgb, var(--accent) 30%, transparent); background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent-text); }
.source-badge.assumption { border-color: color-mix(in srgb, var(--warn) 34%, transparent); background: color-mix(in srgb, var(--warn) 10%, transparent); color: var(--warn-text); }
.source-badge.missing { border-color: color-mix(in srgb, var(--bad) 34%, transparent); background: color-mix(in srgb, var(--bad) 10%, transparent); color: var(--bad-text); }

/* ===== Pills ===== */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  border: 1px solid transparent;
}

/* ===== Calibration actions ===== */
.cal-action {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--surface-3);
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border-radius: 6px;
}

.cal-action.active {
  border-color: var(--accent);
  color: var(--text);
}

.cal-action:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Foldable / Tablet Breakpoints ===== */

/* 600-760px: small foldable / narrow tablet */
@media (min-width: 600px) {
  .kpi-grid--3 { grid-template-columns: repeat(3, 1fr); }
  .kpi-grid--4 { grid-template-columns: repeat(4, 1fr); }

  .review-queue {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .wb-status-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* 760-980px: foldable inner screen main range */
@media (min-width: 760px) {
  .app {
    flex-direction: row;
  }

  .topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
  }

  .bottom-nav {
    position: fixed;
    left: 0;
    top: 50px;
    bottom: 0;
    right: auto;
    width: 72px;
    height: auto;
    flex-direction: column;
    justify-content: flex-start;
    padding-top: 12px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    border-top: none;
    border-right: 1px solid var(--line);
  }

  .nav-item {
    flex: 0 0 auto;
    height: 60px;
    width: 100%;
  }

  .topbar {
    height: 56px;
  }

  .content {
    margin-left: 72px;
    margin-top: 56px;
    padding: 12px 16px 24px 0;
    background: var(--surface);
  }

  .bottom-nav {
    top: 56px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Reset .review-queue from 600px grid so split view can use full width */
  .review-queue {
    display: block;
  }

  /* Review split view on foldable */
  .review-split {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 14px;
    align-items: start;
    width: 100%;
  }

  .review-split .review-queue {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
  }

  .review-detail-pane {
    position: sticky;
    top: 0;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: var(--surface);
  }

  .drawer-sheet {
    left: 72px;
    border-radius: 16px 0 0 0;
  }

  .modal-sheet {
    left: 72px;
    border-radius: 16px 0 0 0;
  }

  /* Phase C: dual column layouts */
  .wb-grid { grid-template-columns: 1fr 1fr; }
  .wb-grid-cell { display: flex; flex-direction: column; }
  .wb-grid-cell .fold-panel,
  .wb-grid-cell .card-list,
  .wb-grid-cell .list-panel { flex: 1; }
  .wb-conclusion--hero { grid-column: 1 / -1; }

  .section-grid { grid-template-columns: 1fr 1fr; }
  .section-grid--execution { grid-template-columns: repeat(3, 1fr); }
  .section-grid .fold-panel { display: flex; flex-direction: column; }
  .section-grid .fold-panel > .card,
  .section-grid .fold-panel > .card-list,
  .section-grid .fold-panel > .list-panel,
  .section-grid .fold-panel > .kpi-grid,
  .section-grid .fold-panel > .matrix-summary { flex: 1; }

  .analysis-body { grid-template-columns: 1fr 1fr; }
  .fold-panel--wide .list-panel { grid-template-columns: repeat(2, 1fr); }
  .fold-panel--wide .list-panel .list-row:nth-child(odd):last-child { border-bottom: none; }
  .fold-panel--wide .list-panel .list-row:nth-child(even):last-child { border-bottom: none; }

  /* Options split grid: 2 columns at 760px+ */
  .options-split-grid { grid-template-columns: 1fr 1fr; }
}

/* 760px-1023px: foldable / tablet range padding refinement */
@media (min-width: 760px) and (max-width: 1023px) {
  .content { padding: 16px 20px 24px 24px; }
}

/* 1024px+: Desktop / large tablet */
@media (min-width: 1024px) {
  /* Sidebar navigation: true desktop width */
  .bottom-nav {
    width: 220px;
    padding: 18px 12px;
    gap: 2px;
    background: var(--surface);
    border-right: 1px solid var(--line);
    box-shadow: 1px 0 0 var(--line-soft);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .bottom-nav::before {
    content: "导航";
    display: block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--muted-2);
    padding: 4px 12px 8px;
  }
  .nav-item {
    flex-direction: row;
    justify-content: flex-start;
    height: 40px;
    width: 100%;
    padding: 0 12px;
    gap: 12px;
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--muted);
  }
  .nav-icon { font-size: 16px; line-height: 1; }
  .nav-label { font-weight: 500; font-size: 13px; letter-spacing: 0.05px; }
  .nav-item:hover { background: var(--surface-3); color: var(--text); }
  .nav-item.active {
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    color: var(--accent);
  }
  .nav-item.active .nav-label { font-weight: 600; }

  /* Content area: wider padding, no bg tint */
  .content {
    margin-left: 220px;
    padding: 28px 40px 40px 40px;
    background: transparent;
  }
  .topbar { padding: 10px 24px; }

  /* Section grid: dual column at desktop */
  .section-grid { grid-template-columns: 1fr 1fr; }
  .section-grid--execution { grid-template-columns: repeat(3, 1fr); }
  .section-grid .fold-panel { display: flex; flex-direction: column; }
  .section-grid .fold-panel > .card,
  .section-grid .fold-panel > .card-list,
  .section-grid .fold-panel > .list-panel,
  .section-grid .fold-panel > .kpi-grid,
  .section-grid .fold-panel > .matrix-summary { flex: 1; }
  .options-split-grid { grid-template-columns: 1fr 1fr; }

  /* View header: larger */
  .view-header { margin-bottom: 20px; }
  .view-header h2 { font-size: 22px; }

  /* KPI grid: 4 columns, larger gap */
  .kpi-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
  .kpi-grid--2 { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid--3 { grid-template-columns: repeat(3, 1fr); }
  /* KPI grid inside section-grid: 2 columns */
  .section-grid .kpi-grid { grid-template-columns: repeat(2, 1fr); margin-bottom: 0; }
  .kpi-card { padding: 16px 18px; min-height: 88px; }
  .kpi-card .value { font-size: 26px; }

  /* Fold panels: larger padding */
  .fold-panel { margin-bottom: 14px; }
  .fold-panel summary { padding: 14px 18px; font-size: 14px; }
  .fold-panel > .card,
  .fold-panel > .card-list,
  .fold-panel > .list-panel,
  .fold-panel > .kpi-grid,
  .fold-panel > .note-line,
  .fold-panel > .matrix-summary,
  .fold-panel > .filter-bar { padding: 16px 18px; }

  /* List rows and cards */
  .list-row { padding: 12px 18px; }
  .card { padding: 16px 18px; }

  /* Drawer: right panel */
  .drawer-sheet {
    left: auto;
    right: 0;
    top: 0;
    bottom: 0;
    width: 520px;
    max-height: 100vh;
    border-radius: 16px 0 0 16px;
    animation: slideRight 200ms ease-out;
  }
  @keyframes slideRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
  }
  .drawer-handle { display: none; }
  .drawer-body { padding: 20px; }

  /* Review split */
  .review-split {
    grid-template-columns: 400px 1fr;
    width: 100%;
  }
  .review-detail-pane {
    padding: 20px;
    max-height: calc(100vh - 160px);
  }

  /* Execution matrix */
  .execution-matrix-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
  }
  .execution-matrix-grid .matrix-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  /* Phase C: hero glow */
  .wb-conclusion--hero::before {
    top: -60px;
    right: -60px;
    width: 180px;
    height: 180px;
    background: radial-gradient(circle, rgba(79,163,255,0.18), transparent 70%);
  }

  /* Phase C: data health 2x2 inner grid */
  .wb-data-health-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Phase C: review filter bar */
  .review-filter-bar {
    gap: 10px 14px;
  }
}

/* ===== Workbench Action Dashboard ===== */
.wb-conclusion {
  padding: 14px;
  background: linear-gradient(180deg, rgba(79,163,255,0.08), var(--surface));
  border: 1px solid rgba(79,163,255,0.2);
  border-radius: 8px;
  margin-bottom: 14px;
}

.wb-conclusion .title {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 6px;
}

.wb-conclusion .body {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 10px;
}

.wb-conclusion .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.wb-section-heading {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted-2);
  margin: 14px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.list-row[data-nav] { cursor: pointer; }
.list-row[data-nav]:active { background: var(--surface-3); }

/* ===== Image Upload Preview ===== */
.image-preview-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.image-preview-item {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg);
  flex-shrink: 0;
}

.image-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-preview-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

/* ===== Attachments in Review Detail ===== */
.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.attachment-thumb {
  display: block;
  width: 80px;
  height: 80px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg);
  flex-shrink: 0;
}

.attachment-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ocr-text {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 8px;
  padding: 8px;
  background: var(--surface-2);
  border-radius: 4px;
  border: 1px solid var(--line-soft);
  max-height: 120px;
  overflow-y: auto;
}

.ocr-text strong {
  color: var(--text);
  font-size: 11px;
}

/* ===== Admin / Config ===== */
.admin-layout {
  display: flex;
  gap: 12px;
  height: calc(100vh - 160px);
  min-height: 400px;
}
.admin-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-y: auto;
  padding: 8px;
}
.admin-sidebar-header {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  padding: 6px 8px 8px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 4px;
}
.admin-cat {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 8px 4px;
}
.admin-file-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 2px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  gap: 8px;
}
.admin-file-btn:hover {
  background: var(--surface-2);
}
.admin-file-btn.active {
  background: rgba(79,163,255,0.12);
  color: #9cccff;
}
.admin-file-meta {
  font-size: 10px;
  color: var(--muted-2);
  flex-shrink: 0;
}
.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.admin-toolbar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
.admin-guide-box {
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}
.admin-editor-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
}
.admin-divider {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  padding: 4px 0;
  letter-spacing: 0.3px;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.admin-table th,
.admin-table td {
  border: 1px solid var(--line-soft);
  padding: 6px 8px;
  text-align: left;
  white-space: nowrap;
}
.admin-table th {
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 700;
  font-size: 11px;
  position: sticky;
  top: 0;
  z-index: 1;
}
.admin-td-idx {
  color: var(--muted-2);
  font-size: 11px;
  width: 28px;
}
.admin-td-input {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 12px;
  width: 100%;
  min-width: 60px;
  outline: none;
  padding: 2px 0;
  font-family: inherit;
}
.admin-td-input:focus {
  border-bottom: 1px solid var(--primary);
}
.admin-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.admin-form-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
}
.admin-form-row:last-child {
  border-bottom: none;
}
.admin-form-label {
  width: 160px;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-align: right;
  line-height: 1.4;
}
.admin-form-input,
.admin-form-select,
.admin-form-textarea {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.admin-form-input:focus,
.admin-form-select:focus,
.admin-form-textarea:focus {
  border-color: var(--primary);
}
.admin-form-input[type="number"] {
  text-align: right;
}
.admin-form-textarea {
  min-height: 60px;
  resize: vertical;
  line-height: 1.5;
}
.admin-form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23687584' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.admin-toggle {
  position: relative;
  width: 40px;
  height: 22px;
  background: var(--line);
  border-radius: 11px;
  cursor: pointer;
  transition: background 150ms;
  flex-shrink: 0;
}
.admin-toggle.active {
  background: var(--good);
}
.admin-toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--text);
  border-radius: 50%;
  transition: transform 150ms;
}
.admin-toggle.active::after {
  transform: translateX(18px);
}
.admin-nested-form {
  margin-left: 20px;
  padding-left: 12px;
  border-left: 2px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.admin-form-actions {
  display: flex;
  gap: 8px;
  padding: 8px 0;
}
.admin-add-row {
  width: 100%;
  padding: 8px;
  border: 1px dashed var(--line);
  background: rgba(79,163,255,0.06);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border-radius: 6px;
  margin-top: 6px;
}
.admin-delete-row {
  background: transparent;
  border: none;
  color: var(--bad);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
}
.admin-delete-row:hover {
  color: #ff8a7a;
}
.admin-empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted-2);
  font-size: 13px;
}
.admin-form-hint {
  font-size: 11px;
  color: var(--muted-2);
  padding-top: 2px;
}
.admin-backups {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
.admin-backup-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.admin-backup-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  padding: 6px 8px;
  background: var(--bg);
  border-radius: 6px;
}
.admin-backup-item span:first-child {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, Menlo, monospace;
}
/* ===== Phase C: Workbench Grid ===== */
.wb-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.wb-grid-cell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  padding: 12px 14px 14px;
}

.wb-grid-cell .wb-section-heading {
  margin: 0 0 10px;
}

.wb-grid-cell .fold-panel {
  margin-bottom: 0;
  border: none;
  border-radius: 0;
}

/* Hero conclusion banner */
.wb-conclusion--hero {
  position: relative;
  padding: 18px 16px;
  background: linear-gradient(180deg, rgba(79,163,255,0.10), var(--surface));
  border: 1px solid rgba(79,163,255,0.22);
  border-radius: 10px;
  margin-bottom: 10px;
  overflow: hidden;
}

.wb-conclusion--hero::before {
  content: "";
  position: absolute;
  top: -40px;
  right: -40px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(79,163,255,0.15), transparent 70%);
  pointer-events: none;
}

.wb-conclusion--hero .title {
  position: relative;
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 8px;
}

.wb-conclusion--hero .body {
  position: relative;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
  margin: 0 0 12px;
}

.wb-conclusion--hero .meta {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Data health inner grid */
.wb-data-health-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.wb-data-health-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

.wb-data-health-item .lbl {
  font-size: 11px;
  color: var(--muted);
}

.wb-data-health-item .val {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
}

.wb-data-health-item .sub {
  font-size: 11px;
  color: var(--muted-2);
}

/* ===== Phase C: Section Grid (holdings / operating / projection / valuation / execution / source / strategy) ===== */
.section-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

.section-grid .fold-panel {
  margin-bottom: 0;
}

/* ===== Phase C: Holdings Layout ===== */
/* KPI grid inside section-grid: 2 columns, no extra margin */
.section-grid .kpi-grid {
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: 0;
}

/* Options split: call / put columns */
.options-split-grid {
  display: grid;
  gap: 14px;
  padding: 12px 14px;
}

.options-col-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted-2);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* Option card lists inside split grid */
#holdings-options-call .card-list,
#holdings-options-put .card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* CN 红涨绿跌: LONG = red (涨), SHORT = green (跌) */
.card--long {
  border-color: rgba(224, 106, 95, 0.35);
  background: linear-gradient(180deg, rgba(224,106,95,0.06), var(--surface-2));
}

.card--short {
  border-color: rgba(43, 182, 115, 0.35);
  background: linear-gradient(180deg, rgba(43,182,115,0.06), var(--surface-2));
}

.badge--long {
  background: rgba(224, 106, 95, 0.12);
  color: #e06a5f;
  border-color: rgba(224, 106, 95, 0.3);
}

.badge--short {
  background: rgba(43, 182, 115, 0.12);
  color: #2bb673;
  border-color: rgba(43, 182, 115, 0.3);
}

/* ===== Phase C: Analysis Body ===== */
.analysis-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.analysis-body .fold-panel {
  margin-bottom: 0;
}

/* First fold-panel in analysis as hero accent */
.analysis-body .fold-panel:first-child {
  border-color: rgba(79,163,255,0.25);
}

.analysis-body .fold-panel:first-child summary {
  background: linear-gradient(180deg, rgba(79,163,255,0.08), var(--surface-2));
}

/* Full-width fold panel with dual-column list */
.fold-panel--wide {
  grid-column: 1 / -1;
}

.fold-panel--wide .list-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

/* ===== Phase C: Execution Matrix ===== */
.execution-matrix-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

/* ===== Phase C: Review Filter Bar Spacing ===== */
.review-filter-bar {
  gap: 8px 10px;
  padding: 10px 0;
}

/* ===== Phase C: Admin Editor Cardified ===== */
.admin-editor-area .admin-form-group {
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.admin-backups {
  opacity: 0.85;
  border-style: dashed;
}

/* ===== Phase C: Admin sidebar width (760px+) ===== */
@media (min-width: 760px) {
  .admin-sidebar {
    width: 240px;
  }
}

@media (min-width: 1440px) {
  .content { padding: 32px 56px 48px 56px; }
  .kpi-grid { gap: 16px; }
  .kpi-card .value { font-size: 28px; }
  .view-header h2 { font-size: 24px; }
}

@media (min-width: 1680px) {
  .content { padding: 36px 72px 56px 72px; }
}

/* ===== Mobile spacing optimization (<760px) ===== */
@media (max-width: 759px) {
  .content { padding: 14px 18px 90px; }
  .view-header { margin-bottom: 16px; }
  .kpi-grid { gap: 12px; margin-bottom: 16px; }
  .kpi-card { padding: 16px 16px 14px; }
  .section-grid { gap: 12px; margin-bottom: 12px; }
  .fold-panel { margin-bottom: 12px; }
  .fold-panel summary { padding: 14px 18px; }
  .fold-panel > .card,
  .fold-panel > .card-list,
  .fold-panel > .list-panel,
  .fold-panel > .kpi-grid,
  .fold-panel > .note-line,
  .fold-panel > .matrix-summary,
  .fold-panel > .filter-bar { padding: 14px 18px; }
  .card { padding: 16px; }
  .card-list { gap: 12px; }
  .list-row { padding: 12px 18px; }
  .scenario-tabs { margin-bottom: 16px; }
  .analysis-tabs { margin-bottom: 16px; }
  .options-split-grid { padding: 14px 18px; gap: 16px; }
  .admin-layout {
    flex-direction: column;
    height: auto;
  }
  .admin-sidebar {
    width: 100%;
    max-height: 240px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ===== Phase 5 — Global focus-visible ring ===== */
:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn:focus-visible, .icon-btn:focus-visible, .filter-chip:focus-visible,
.scenario-tab:focus-visible, .analysis-tab:focus-visible,
.nav-item:focus-visible, .cal-action:focus-visible, .form-tab:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}
