:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --panel-soft: #fafbfd;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #16202e;
  --text-mid: #46536a;
  --muted: #7b879a;
  --brand: #1a56db;
  --brand-soft: #e8f0fe;
  --p0: #d92d20;
  --p1: #e07b00;
  --p2: #b78103;
  --p3: #0b7ea8;
  --ok: #0f9d58;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 14px rgba(16, 24, 40, .05);
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
               "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- header ---------------- */
.app-header {
  background: linear-gradient(120deg, #0f2f6b 0%, #1a56db 62%, #2b7fff 100%);
  color: #fff;
  padding: 16px 24px 0;
}
.header-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding-bottom: 14px;
}
.brand-block { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; flex: 0 0 38px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px;
  padding: 4px; border-radius: 8px; background: rgba(255, 255, 255, .16);
}
.brand-mark i { background: rgba(255, 255, 255, .85); border-radius: 1px; }
.brand-mark i:nth-child(2) { background: rgba(255, 255, 255, .45); }
.brand-mark i:nth-child(3) { background: rgba(255, 255, 255, .45); }
.brand-title { font-size: 20px; font-weight: 700; letter-spacing: .5px; }
.brand-sub { font-size: 12px; opacity: .85; }
.header-meta { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12px; }
.header-meta div span { opacity: .78; }
.header-meta div b { font-size: 15px; font-weight: 700; margin-left: 4px; }

.tab-nav { display: flex; gap: 4px; overflow-x: auto; }
.tab-nav button {
  appearance: none; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, .12);
  color: #eaf1ff; font-size: 13px; padding: 9px 16px;
  border-radius: 8px 8px 0 0; white-space: nowrap;
  font-family: inherit;
}
.tab-nav button.active { background: var(--bg); color: var(--brand); font-weight: 700; }

/* ---------------- layout ---------------- */
.wrap { max-width: 1360px; margin: 0 auto; padding: 18px 24px 48px; }
.view { display: none; }
.view.active { display: block; }
.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-main { grid-template-columns: 1.35fr 1fr; }
@media (max-width: 1080px) {
  .grid-4, .grid-3, .grid-2, .grid-main { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .grid-4, .grid-3, .grid-2, .grid-main { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.panel + .panel { margin-top: 14px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 10px; flex-wrap: wrap;
}
.panel-title { font-size: 15px; font-weight: 700; margin: 0; }
.panel-hint { font-size: 12px; color: var(--muted); }

/* ---------------- kpi ---------------- */
.kpi {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px;
}
.kpi .k-label { font-size: 12px; color: var(--muted); }
.kpi .k-value { font-size: 26px; font-weight: 700; line-height: 1.25; }
.kpi .k-foot { font-size: 11px; color: var(--muted); }
.kpi.alert .k-value { color: var(--p0); }
.kpi.warn .k-value { color: var(--p1); }
.kpi.good .k-value { color: var(--ok); }

/* ---------------- table ---------------- */
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td {
  border-bottom: 1px solid var(--border); padding: 8px 10px;
  text-align: left; vertical-align: top;
}
table.data th { background: var(--panel-soft); color: var(--text-mid); font-weight: 600; white-space: nowrap; }
table.data tr:hover td { background: #f8fafc; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------- badges ---------------- */
.badge {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; line-height: 18px; border: 1px solid transparent; white-space: nowrap;
}
.badge.P0 { background: #fee4e2; color: var(--p0); border-color: #fecdca; }
.badge.P1 { background: #fef0c7; color: #93370d; border-color: #fedf89; }
.badge.P2 { background: #fef7c3; color: #90610a; border-color: #fde272; }
.badge.P3 { background: #e0f2fe; color: #075985; border-color: #b9e6fe; }
.badge.A { background: #e7f8ef; color: #08663c; border-color: #a6f4c5; }
.badge.B { background: #fef0c7; color: #93370d; border-color: #fedf89; }
.badge.C { background: #f1f3f7; color: #55627a; border-color: #d7dce5; }
.badge.gray { background: #f1f3f7; color: #55627a; border-color: #d7dce5; }
.badge.blue { background: var(--brand-soft); color: var(--brand); border-color: #c6dafc; }

.tag {
  display: inline-block; padding: 1px 6px; margin: 1px 3px 1px 0;
  font-size: 11px; border-radius: 4px; background: #f1f5f9; color: #46536a;
  border: 1px solid #e2e8f0;
}

/* ---------------- controls ---------------- */
.controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
select, input[type="search"], button.btn {
  font-family: inherit; font-size: 13px; padding: 6px 10px;
  border: 1px solid var(--border-strong); border-radius: 7px;
  background: #fff; color: var(--text);
}
button.btn { cursor: pointer; background: var(--brand); color: #fff; border-color: var(--brand); }
button.btn.ghost { background: #fff; color: var(--text-mid); }
button.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------------- map ---------------- */
#mapContainer { width: 100%; height: 520px; border-radius: 8px; background: #eef2f7; }
.map-fallback {
  width: 100%; min-height: 460px; border-radius: 8px;
  background: radial-gradient(circle at 50% 42%, #f7fafd 0%, #eaf0f8 70%);
  border: 1px solid var(--border);
}
.map-note { font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-mid); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }

/* ---------------- timeline ---------------- */
.timeline { position: relative; padding-left: 18px; }
.timeline::before {
  content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px;
  width: 2px; background: var(--border);
}
.tl-item { position: relative; padding: 0 0 14px 0; }
.tl-item::before {
  content: ""; position: absolute; left: -17px; top: 6px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--brand); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--border);
}
.tl-item.P0::before { background: var(--p0); }
.tl-item.P1::before { background: var(--p1); }
.tl-item.P2::before { background: var(--p2); }
.tl-item.P3::before { background: var(--p3); }
.tl-date { font-size: 12px; color: var(--muted); }
.tl-title { font-weight: 600; }
.tl-meta { font-size: 12px; color: var(--text-mid); }

/* ---------------- todo ---------------- */
.todo-item {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; background: #fff; margin-bottom: 8px;
}
.todo-item .t-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.todo-item .t-entity { font-weight: 700; }
.todo-item ul { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--text-mid); }
.todo-item.done { opacity: .6; }
.todo-item.done .t-entity { text-decoration: line-through; }

/* ---------------- misc ---------------- */
.empty { padding: 24px; text-align: center; color: var(--muted); font-size: 13px; }
.divider { height: 1px; background: var(--border); margin: 12px 0; }
.notice {
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
  border-radius: 8px; padding: 10px 12px; font-size: 12.5px;
}
.notice.blue { background: var(--brand-soft); border-color: #c6dafc; color: #1e40af; }
.footer-note { margin-top: 24px; font-size: 12px; color: var(--muted); text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
