:root {
  --bg: #0e1116;
  --bg-elev: #161b22;
  --bg-elev2: #1c2330;
  --border: #2a3340;
  --text: #e6edf3;
  --text-dim: #9aa7b4;
  --text-faint: #6b7785;
  --green: #2ea043;
  --green-soft: #2ea04322;
  --yellow: #d9a514;
  --yellow-soft: #d9a51422;
  --red: #e5534b;
  --red-soft: #e5534b22;
  --grey: #6b7785;
  --accent: #4493f8;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px; }

/* Header */
.site-header {
  background: linear-gradient(180deg, #11151c 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  padding: 48px 0 36px;
}
.site-header h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.5px; }
.subtitle { color: var(--text-dim); font-size: 15px; margin-top: 6px; }
.tagline { color: var(--text-faint); font-size: 14px; margin-top: 16px; max-width: 720px; }
.tagline b { color: var(--text-dim); font-weight: 600; }

/* Dashboard */
.dashboard { background: var(--bg-elev); border-bottom: 1px solid var(--border); padding: 24px 0; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.dash-card {
  background: var(--bg-elev2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.dash-card .num { font-size: 26px; font-weight: 700; font-family: var(--mono); }
.dash-card .lbl { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.dash-card.span2 { grid-column: span 2; }
.mini-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin-top: 10px; }
.mini-bar span { display: block; }
.tier-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-dim); margin-top: 6px; }

/* Legend */
.legend { display: flex; flex-wrap: wrap; gap: 18px; padding: 18px 24px; font-size: 13px; color: var(--text-dim); }
.lg { display: inline-flex; align-items: center; gap: 7px; }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.green { background: var(--green); }
.dot.yellow { background: var(--yellow); }
.dot.red { background: var(--red); }
.dot.grey { background: var(--grey); }

/* Section titles */
.sec-title { font-size: 19px; font-weight: 650; margin: 34px 0 16px; display: flex; align-items: baseline; gap: 12px; }
.sec-title small { font-size: 13px; color: var(--text-faint); font-weight: 400; }

/* Atlas map */
.atlas-map { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.region-card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; transition: border-color .15s, transform .15s;
}
.region-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.region-card.active { border-color: var(--accent); background: var(--bg-elev2); }
.region-card .rname { font-size: 14px; font-weight: 600; }
.region-card .rcount { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.region-lamps { display: flex; gap: 4px; margin-top: 10px; flex-wrap: wrap; }
.region-lamps .dot { width: 9px; height: 9px; }

/* Table */
.table-controls { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 12px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 34px 0 16px; }
.filters input, .filters select {
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--text);
  padding: 8px 12px; border-radius: 8px; font-size: 13px; font-family: var(--sans);
}
.filters input { min-width: 240px; }
.filters input:focus, .filters select:focus { outline: none; border-color: var(--accent); }
.btn-clear { cursor: pointer; color: var(--text-dim); }
.btn-clear:hover { color: var(--text); }

.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  background: var(--bg-elev2); text-align: left; padding: 11px 14px; font-weight: 600;
  color: var(--text-dim); border-bottom: 1px solid var(--border); white-space: nowrap;
  cursor: pointer; user-select: none; position: sticky; top: 0;
}
thead th[data-sort]:hover { color: var(--text); }
thead th.sorted::after { content: " ↓"; color: var(--accent); }
thead th.sorted.asc::after { content: " ↑"; }
tbody tr { border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-elev); }
tbody td { padding: 11px 14px; vertical-align: middle; }
.cell-lamp { text-align: center; }
.cell-name { font-weight: 600; color: var(--text); }
.cell-name .nfunc { font-weight: 400; color: var(--text-faint); font-size: 12px; display: block; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11.5px; white-space: nowrap; }
.tag.green { background: var(--green-soft); color: #5cca6e; }
.tag.yellow { background: var(--yellow-soft); color: #e6bd4a; }
.tag.red { background: var(--red-soft); color: #f0827b; }
.tag.form { background: #4493f822; color: #79b3fa; }
.tag.grey-tag { background: #6b778522; color: var(--text-dim); }
.bottleneck-cell { color: var(--text-dim); font-size: 12.5px; max-width: 280px; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 20px; z-index: 100; overflow-y: auto;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 14px;
  max-width: 760px; width: 100%; position: relative; padding: 32px 36px 40px;
  animation: pop .18s ease;
}
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-close {
  position: absolute; top: 16px; right: 18px; background: none; border: none;
  color: var(--text-faint); font-size: 26px; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal h3 { font-size: 22px; font-weight: 700; padding-right: 30px; }
.modal .m-sub { color: var(--text-faint); font-size: 13px; margin-top: 4px; }
.modal .verdict-banner {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 10px;
  margin: 18px 0; font-size: 14px;
}
.verdict-banner.green { background: var(--green-soft); }
.verdict-banner.yellow { background: var(--yellow-soft); }
.verdict-banner.red { background: var(--red-soft); }
.verdict-banner b { font-size: 15px; }
.m-section { margin-top: 20px; }
.m-section h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-faint); margin-bottom: 7px; }
.m-section p { font-size: 14px; color: var(--text); }
.gate-box { background: var(--bg-elev2); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-top: 10px; }
.gate-box .gate-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.gate-box .reason { font-size: 13px; color: var(--text-dim); }
.checks { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.check { font-size: 12px; padding: 3px 9px; border-radius: 6px; }
.check.yes { background: var(--green-soft); color: #5cca6e; }
.check.no { background: var(--red-soft); color: #f0827b; }
.cite-list { list-style: none; margin-top: 8px; }
.cite-list li { font-size: 12.5px; padding: 7px 0; border-bottom: 1px solid var(--border); color: var(--text-dim); }
.cite-list li:last-child { border: none; }
.cite-list .ct-tier { font-family: var(--mono); font-size: 11px; padding: 1px 6px; border-radius: 4px; margin-right: 6px; }
.ct-tier.直接 { background: var(--green-soft); color: #5cca6e; }
.ct-tier.近似 { background: var(--yellow-soft); color: #e6bd4a; }
.ct-tier.远端 { background: #6b778522; color: var(--text-dim); }
.cite-list a { color: var(--accent); text-decoration: none; font-family: var(--mono); }
.cite-list a:hover { text-decoration: underline; }
.edge-list { list-style: none; margin-top: 8px; }
.edge-list li { font-size: 13px; padding: 6px 0; color: var(--text-dim); }
.edge-list .ar { color: var(--accent); }

@media (max-width: 640px) {
  .site-header { padding: 32px 0 24px; }
  .site-header h1 { font-size: 23px; }
  .filters input { min-width: 100%; }
  .modal { padding: 24px 20px 30px; }
  .bottleneck-cell { max-width: 160px; }
}
