:root {
  --ink: #152238;
  --muted: #66758b;
  --line: #e4e9f0;
  --surface: #ffffff;
  --canvas: #f5f7fb;
  --primary: #3457d5;
  --primary-dark: #2743ad;
  --violet: #6c5ce7;
  --danger: #c73d5d;
  --warning: #bc7616;
  --success: #1b8969;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--canvas); }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 8px; color: var(--violet); font-size: 11px; font-weight: 800; letter-spacing: .15em; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; color: white; background: linear-gradient(135deg, var(--primary), var(--violet)); font-size: 22px; font-weight: 800; box-shadow: 0 10px 24px rgba(52,87,213,.22); }
.brand-mark.small { width: 30px; height: 30px; border-radius: 9px; font-size: 15px; box-shadow: none; }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 10% 10%, #e9edff, transparent 35%), var(--canvas); }
.auth-card { width: min(430px, 100%); padding: 38px; border: 1px solid rgba(255,255,255,.7); border-radius: 24px; background: rgba(255,255,255,.9); box-shadow: 0 24px 70px rgba(34,52,89,.14); }
.auth-card h1 { margin: 0 0 8px; font-size: 32px; letter-spacing: -.04em; }
.auth-card > .muted { margin: 0 0 28px; }
.stack-form { display: grid; gap: 16px; }
label { display: grid; gap: 7px; color: #3c4a60; font-size: 13px; font-weight: 700; }
input, select { width: 100%; min-height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; outline: none; color: var(--ink); background: #fff; }
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(52,87,213,.12); }
button { border: 0; border-radius: 10px; }
.primary { min-height: 44px; padding: 0 18px; color: white; background: linear-gradient(135deg, var(--primary), var(--violet)); font-weight: 800; }
.primary:hover { background: linear-gradient(135deg, var(--primary-dark), #5949cf); }
.secondary { min-height: 38px; padding: 0 14px; border: 1px solid #d8dfeb; color: var(--ink); background: white; font-weight: 700; }
.secondary:hover { border-color: var(--primary); color: var(--primary); }
.ghost { padding: 6px 10px; color: var(--muted); background: transparent; }
.ghost:hover { color: var(--primary); }
.demo-note { margin-top: 24px; padding: 12px 14px; border-radius: 12px; color: #5b6473; background: #f1f4fb; font-size: 12px; line-height: 1.7; }
.form-error { min-height: 18px; margin: 0; color: var(--danger); font-size: 13px; }
.topbar { min-height: 64px; display: flex; align-items: center; justify-content: space-between; padding: env(safe-area-inset-top, 0px) 28px 0; border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar-brand, .topbar-user { display: flex; align-items: center; gap: 11px; font-weight: 800; }
.topbar-user { color: #4d5b72; font-size: 13px; font-weight: 600; }
.app-layout { display: grid; grid-template-columns: 218px minmax(0, 1fr); min-height: calc(100vh - 64px); }
.sidebar { padding: 22px 14px; border-right: 1px solid var(--line); background: #fbfcff; }
.nav-item { width: 100%; margin-bottom: 7px; padding: 12px 14px; text-align: left; color: #617089; background: transparent; font-weight: 700; }
.nav-item:hover { color: var(--primary); background: #eef1ff; }
.nav-item.active { color: var(--primary); background: #e9edff; }
.main-content { width: min(1400px, 100%); margin: 0 auto; padding: 34px 38px calc(56px + env(safe-area-inset-bottom, 0px)); }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
h2 { margin: 0 0 7px; font-size: clamp(25px, 3vw, 34px); letter-spacing: -.04em; }
h3 { margin: 0; font-size: 18px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.stat-card .label { color: var(--muted); font-size: 12px; font-weight: 700; }
.stat-card .value { margin-top: 10px; font-size: 30px; font-weight: 850; letter-spacing: -.04em; }
.stat-card .hint { margin-top: 8px; color: var(--muted); font-size: 12px; }
.content-grid { display: grid; gap: 18px; }
.overview-regions-panel { margin-bottom: 18px; }
.two-col { grid-template-columns: repeat(2, minmax(0,1fr)); }
.panel { padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 8px 25px rgba(30,52,90,.04); }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.link-button { padding: 2px 0; color: var(--primary); background: transparent; font-size: 13px; font-weight: 800; }
.mini-list { display: grid; gap: 10px; }
.mini-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-top: 1px solid #f0f2f6; }
.mini-item:first-child { border-top: 0; padding-top: 0; }
.mini-name { font-weight: 800; }
.mini-meta { margin-top: 4px; color: var(--muted); font-size: 12px; }
.status { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.status-critical, .status-alert { color: #a72f4b; background: #fde9ef; }
.status-watch { color: #98600e; background: #fff1d9; }
.status-normal { color: var(--success); background: #e3f6ee; }
.status-insufficient_sample, .status-no_baseline { color: #5f6f87; background: #edf1f7; }
.status-data_missing { color: #806c4a; background: #f6f1e5; }
.filterbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 16px; }
.filterbar label { min-width: 164px; }
.table-panel { overflow: hidden; padding: 0; }
.processing-panel-heading { padding: 18px 22px 0; margin-bottom: 12px; }
.map-panel { display: grid; gap: 12px; }
.map-canvas { height: 560px; border-radius: 12px; background: #eef2f7; }
.map-legend { display: flex; flex-wrap: wrap; gap: 12px; min-height: 20px; color: #4d5b72; font-size: 12px; font-weight: 700; }
.map-legend .legend-item { display: inline-flex; align-items: center; gap: 6px; }
.map-legend .legend-item i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 14px 16px; text-align: left; color: #67758a; background: #f8f9fc; font-size: 11px; letter-spacing: .04em; white-space: nowrap; }
td { padding: 15px 16px; border-top: 1px solid #eef1f5; vertical-align: middle; white-space: nowrap; }
tr:hover td { background: #fbfcff; }
.subject-link { padding: 0; color: var(--primary); background: transparent; font-weight: 800; }
.number-negative { color: var(--danger); font-weight: 800; }
.number-positive { color: var(--success); font-weight: 800; }
.rankings-meta { min-height: 18px; margin: 0 0 12px; font-size: 12px; }
.rank-up { color: var(--success); font-weight: 800; }
.rank-down { color: var(--danger); font-weight: 800; }
.rank-flat { color: var(--muted); font-weight: 800; }
.action-button { padding: 7px 10px; color: var(--primary); background: #edf0ff; font-size: 12px; font-weight: 800; }
.action-button.danger { color: #a72f4b; background: #fde9ef; }
.empty { padding: 38px 20px; text-align: center; color: var(--muted); }
.account-form { display: grid; gap: 18px; }
.account-form h3 { margin-bottom: 0; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.bulk-panel { display: grid; gap: 14px; }
.bulk-panel h3 { margin-bottom: 0; }
.bulk-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.file-label { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 700; }
.file-label input { max-width: 260px; }
.bulk-panel textarea { width: 100%; min-height: 120px; padding: 12px; border: 1px solid #d7ddeb; border-radius: 10px; background: #f9fafd; font-family: inherit; font-size: 13px; resize: vertical; }
.bulk-summary { margin: 0; font-size: 13px; font-weight: 700; }
.bulk-ok td { color: var(--success); }
.bulk-skip td { color: #b07a12; }
.bulk-fail td { color: var(--danger); }
.detail-timeline { margin-top: 22px; }
.timeline-list { display: grid; gap: 6px; max-height: 280px; overflow: auto; padding: 4px 2px; }
.timeline-row { display: grid; grid-template-columns: 92px 52px 1fr; align-items: baseline; gap: 10px; padding: 7px 10px; border-radius: 8px; background: #f7f9fd; font-size: 12px; }
.timeline-date { color: var(--muted); font-weight: 700; }
.timeline-tag { justify-self: start; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.timeline-metric { color: #2440a7; background: #e5eaff; }
.timeline-alert { color: #a72f4b; background: #fde9ef; }
.timeline-action { color: #1d6b45; background: #e3f5ec; }
.timeline-assignment { color: #6a48c9; background: #efe9ff; }
.timeline-text { color: #26324b; font-weight: 600; }
.toast { position: fixed; right: 24px; top: 78px; z-index: 20; padding: 12px 16px; border: 1px solid #c8d3ff; border-radius: 10px; color: #2440a7; background: #eef1ff; box-shadow: 0 12px 28px rgba(35,55,120,.16); font-size: 13px; font-weight: 700; }
.modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 22px; background: rgba(18,28,48,.48); }
.modal-card { position: relative; width: min(760px, 100%); max-height: min(760px, 92vh); overflow: auto; padding: 30px; border-radius: 18px; background: var(--surface); box-shadow: 0 30px 80px rgba(16,27,53,.3); }
.modal-close { position: absolute; top: 12px; right: 15px; width: 34px; height: 34px; color: var(--muted); background: transparent; font-size: 26px; }
.detail-summary { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; margin: 24px 0; }
.detail-cell { padding: 12px; border-radius: 10px; background: #f6f8fc; }
.detail-cell span { display: block; color: var(--muted); font-size: 11px; }
.detail-cell strong { display: block; margin-top: 5px; font-size: 18px; }
.trend-list { display: grid; gap: 8px; }
.trend-row { display: grid; grid-template-columns: 100px 1fr 70px; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.trend-bar { height: 9px; overflow: hidden; border-radius: 999px; background: #edf0f6; }
.trend-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--violet)); }
.line-chart { padding: 8px 0 0; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 9px; height: 9px; display: inline-block; border-radius: 50%; background: var(--primary); }
.legend-dot.baseline { background: var(--violet); }
.trend-svg { display: block; width: 100%; min-height: 260px; overflow: visible; }
.chart-grid { stroke: #e9edf4; stroke-width: 1; }
.chart-axis { fill: #8290a5; font-size: 10px; }
.chart-line { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart-line.actual { stroke: var(--primary); }
.chart-line.baseline { stroke: var(--violet); stroke-dasharray: 7 5; }
.chart-line.series-0 { stroke: #3457d5; }
.chart-line.series-1 { stroke: #6c5ce7; }
.chart-line.series-2 { stroke: #1b8969; }
.chart-line.series-3 { stroke: #bc7616; }
.chart-line.series-4 { stroke: #c73d5d; }
.chart-line.series-5 { stroke: #0e7490; }
.chart-line.series-6 { stroke: #a16207; }
.chart-line.series-7 { stroke: #64748b; }
.legend-dot.series-0 { background: #3457d5; }
.legend-dot.series-1 { background: #6c5ce7; }
.legend-dot.series-2 { background: #1b8969; }
.legend-dot.series-3 { background: #bc7616; }
.legend-dot.series-4 { background: #c73d5d; }
.legend-dot.series-5 { background: #0e7490; }
.legend-dot.series-6 { background: #a16207; }
.legend-dot.series-7 { background: #64748b; }
.chart-dot.actual { fill: var(--primary); stroke: white; stroke-width: 2; }
.detail-drivers { margin-top: 30px; padding-top: 24px; border-top: 1px solid var(--line); }
.driver-heading { margin-bottom: 14px; }
.driver-heading .eyebrow { margin-bottom: 5px; }
.driver-heading h3 { margin-bottom: 5px; }
.driver-heading .muted { margin: 0; font-size: 12px; }
.driver-table-wrap { overflow-x: auto; }
.driver-table th, .driver-table td { padding: 11px 12px; }
@media (max-width: 900px) { .app-layout { grid-template-columns: 1fr; } .main-content { min-width: 0; } .sidebar { display: flex; overflow-x: auto; gap: 7px; padding: 10px max(14px, env(safe-area-inset-right, 0px)) 10px max(14px, env(safe-area-inset-left, 0px)); border-right: 0; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; } .nav-item { width: auto; min-width: max-content; margin: 0; padding: 9px 12px; text-align: center; } .main-content { padding: 24px 18px calc(42px + env(safe-area-inset-bottom, 0px)); } .stat-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } .two-col { grid-template-columns: 1fr; } .form-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 560px) {
  .topbar { padding: env(safe-area-inset-top, 0px) 16px 0; }
  .topbar-brand span:last-child { display: none; }
  .topbar-user { gap: 8px; font-size: 12px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  h2 { font-size: 24px; }
  .main-content { padding-left: 16px; padding-right: 16px; }
  .stat-grid { gap: 9px; }
  .stat-card { padding: 15px; }
  .stat-card .value { font-size: 24px; }
  .panel { padding: 16px; }
  .filterbar { gap: 10px; }
  .filterbar label { min-width: 0; flex: 1 1 calc(50% - 5px); }
  .filterbar input, .filterbar select { min-width: 0; }
  .filterbar .secondary { flex: 1 1 100%; }
  body { overflow-x: clip; }
  .secondary, .ghost, .action-button { min-height: 44px; }
  .nav-item { min-height: 42px; display: inline-flex; align-items: center; }
  th { padding: 10px 12px; }
  td { padding: 11px 12px; }
  .modal { padding: 12px; align-items: end; }
  .modal-card { width: 100%; max-height: 88dvh; padding: 24px 18px calc(24px + env(safe-area-inset-bottom, 0px)); border-radius: 16px; }
  .map-canvas { height: min(560px, 62dvh); }
  .map-drawer { width: 100%; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
  .toast { left: 16px; right: 16px; top: calc(70px + env(safe-area-inset-top, 0px)); }
  .form-grid { grid-template-columns: 1fr; }
  .detail-summary { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .trend-row { grid-template-columns: 82px 1fr 56px; gap: 8px; }
  .auth-shell { padding: 16px; padding-top: calc(16px + env(safe-area-inset-top, 0px)); padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
  .auth-card { padding: 26px 20px; }
}
.map-stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 0; }
.map-stat { flex: 1 1 140px; min-width: 140px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); display: flex; flex-direction: column; gap: 4px; }
.map-stat .label { font-size: 12px; color: #6b7890; font-weight: 600; }
.map-stat .value { font-size: 20px; font-weight: 800; color: #17233b; }
.map-stat .hint { font-size: 11px; color: #8a97ab; }
.map-panel { position: relative; overflow: hidden; }
.map-drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(420px, 92%); background: var(--surface); border-left: 1px solid var(--line); box-shadow: -12px 0 28px rgba(23,35,59,.12); transform: translateX(105%); transition: transform .22s ease; display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; z-index: 900; }
.map-drawer.on { transform: translateX(0); }
.map-drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.map-drawer-head h3 { margin: 2px 0 0; font-size: 16px; }
.map-drawer-head .muted { margin: 4px 0 0; }
.map-drawer-stats { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.map-drawer-stat { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.map-drawer-stat .label { font-size: 11px; color: #6b7890; font-weight: 600; }
.map-drawer-stat .value { font-size: 16px; font-weight: 800; }
.map-drawer-body { flex: 1; overflow: auto; min-height: 0; }
.map-drawer-body th, .map-drawer-body td { padding: 8px 10px; font-size: 12px; }
.map-drawer .muted { font-size: 11px; }
.map-cluster { border-radius: 50%; border: 2px solid #fff; box-shadow: 0 4px 12px rgba(23,35,59,.28); color: #fff; font-weight: 800; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.map-perm-tip { background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 3px 10px rgba(23,35,59,.12); color: #17233b; font-size: 11px; font-weight: 600; padding: 3px 8px; }
.map-perm-tip::before { display: none; }
@media (max-width: 560px) { .map-stats { gap: 8px; } .map-stat { flex: 1 1 0; min-width: 0; padding: 10px 12px; } .map-stat .value { font-size: 17px; } }
