/* ============================================================
   卤代多环芳烃毒性参数数据库 —— 样式
   ============================================================ */

:root {
  --ink:        #17293b;
  --navy:       #14314f;
  --navy-deep:  #0d2338;
  --blue:       #1f6fa8;
  --blue-lt:    #2e88c4;
  --blue-wash:  #eaf3fa;
  --teal:       #0f7c76;
  --amber:      #c07a12;
  --red:        #b23b32;
  --green:      #2a7d4f;
  --purple:     #6b52a8;

  --bg:         #f4f6f9;
  --panel:      #ffffff;
  --line:       #e3e9f0;
  --line-soft:  #eef2f7;
  --muted:      #6b7b8c;
  --muted-lt:   #93a1b0;

  --radius:     10px;
  --radius-sm:  6px;
  --shadow:     0 1px 2px rgba(20, 49, 79, .05), 0 4px 16px rgba(20, 49, 79, .05);
  --shadow-lift:0 2px 6px rgba(20, 49, 79, .08), 0 12px 32px rgba(20, 49, 79, .10);

  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", "Helvetica Neue",
          "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Menlo", "Consolas", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-lt); }

/* ───────────── 顶栏 ───────────── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.topbar-inner {
  max-width: 1340px; margin: 0 auto;
  padding: 0 28px; height: 66px;
  display: flex; align-items: center; gap: 34px;
}
.brand { display: flex; align-items: center; gap: 11px; flex-shrink: 0; }
.brand-mark { width: 38px; height: 38px; border-radius: 9px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong {
  color: #fff; font-size: 15.5px; font-weight: 600; letter-spacing: .2px;
}
.brand-text em {
  color: #8fb2cd; font-size: 10.5px; font-style: normal;
  letter-spacing: .5px; text-transform: uppercase;
}

.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a {
  position: relative;
  color: #b9cfe0; font-size: 14px; padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: color .15s, background .15s;
}
.nav a:hover { color: #fff; background: rgba(255, 255, 255, .07); }
.nav a.active { color: #fff; background: rgba(95, 176, 224, .16); }
.nav a.active::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px;
  height: 2px; background: #5fb0e0; border-radius: 2px;
}

.topbar-meta {
  margin-left: auto; display: flex; align-items: center; gap: 7px;
  color: #8fb2cd; font-size: 12px; white-space: nowrap;
}
.dot-live {
  width: 6px; height: 6px; border-radius: 50%;
  background: #4ec27a; box-shadow: 0 0 0 3px rgba(78, 194, 122, .18);
}

/* ───────────── 主区域 ───────────── */
.app { max-width: 1340px; margin: 0 auto; padding: 26px 28px 56px; min-height: 60vh; }

.page-head { margin-bottom: 22px; }
.page-head h1 {
  margin: 0 0 6px; font-size: 25px; font-weight: 600; letter-spacing: -.2px;
  color: var(--navy);
}
.page-head p { margin: 0; color: var(--muted); font-size: 13.5px; max-width: 900px; }

.section-title {
  display: flex; align-items: baseline; gap: 10px;
  margin: 30px 0 14px;
}
.section-title h2 {
  margin: 0; font-size: 16px; font-weight: 600; color: var(--navy);
  padding-left: 10px; border-left: 3px solid var(--blue);
  line-height: 1.2;
}
.section-title span { color: var(--muted-lt); font-size: 12.5px; }

/* ───────────── KPI ───────────── */
.kpi-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px;
}
.kpi-grid.c4 { grid-template-columns: repeat(4, 1fr); }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 17px 18px 15px; position: relative; overflow: hidden;
}
.kpi::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--blue);
}
.kpi.k-teal::before { background: var(--teal); }
.kpi.k-amber::before { background: var(--amber); }
.kpi.k-green::before { background: var(--green); }
.kpi.k-purple::before { background: var(--purple); }
.kpi.k-red::before { background: var(--red); }
.kpi-label { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.kpi-value {
  font-size: 30px; font-weight: 650; color: var(--navy); line-height: 1.15;
  margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -.5px;
}
.kpi-value small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.kpi-sub { font-size: 11.5px; color: var(--muted-lt); margin-top: 3px; }

/* ───────────── 面板 ───────────── */
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.panel-head h3 { margin: 0; font-size: 14.5px; font-weight: 600; color: var(--navy); }
.panel-head .hint { font-size: 12px; color: var(--muted-lt); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-2-1 { display: grid; grid-template-columns: 1.55fr 1fr; gap: 16px; }
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }
.chart-box.short { height: 200px; }

/* ───────────── 表格 ───────────── */
.table-wrap {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: auto; max-height: 640px;
}
table.data {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
table.data th {
  position: sticky; top: 0; z-index: 2;
  background: #f7f9fc; color: var(--navy);
  font-weight: 600; font-size: 12.5px; text-align: left;
  padding: 10px 12px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--blue); }
table.data th .arrow { color: var(--muted-lt); font-size: 10px; margin-left: 3px; }
table.data td {
  padding: 9px 12px; border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
table.data tbody tr:hover { background: #f8fbfd; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tr.clickable { cursor: pointer; }
.num { font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

/* ───────────── 徽标 ───────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px; font-size: 11.5px;
  border: 1px solid transparent; white-space: nowrap; line-height: 1.7;
}
.b-high   { background: #fbeceb; color: var(--red);   border-color: #f2d3d0; }
.b-mid    { background: #fdf3e2; color: var(--amber); border-color: #f3e0c0; }
.b-low    { background: #eaf5ee; color: var(--green); border-color: #cfe7d9; }
.b-none   { background: #f2f4f7; color: var(--muted); border-color: #e5e9ef; }
.b-tested { background: var(--blue-wash); color: var(--blue); border-color: #cfe3f2; }
.b-pend   { background: #f2f4f7; color: var(--muted); border-color: #e5e9ef; }
.b-good   { background: #eaf5ee; color: var(--green); border-color: #cfe7d9; }
.b-fair   { background: #fdf3e2; color: var(--amber); border-color: #f3e0c0; }
.b-poor   { background: #fbeceb; color: var(--red);   border-color: #f2d3d0; }
.b-nd     { background: #f2f4f7; color: var(--muted); border-color: #e5e9ef; }
.b-teal   { background: #e6f3f2; color: var(--teal); border-color: #cbe5e3; }

.chip {
  display: inline-block; padding: 1px 7px; margin: 1px 3px 1px 0;
  background: #f2f5f9; border: 1px solid var(--line); border-radius: 4px;
  font-size: 11.5px; color: var(--muted);
}

/* ───────────── 表单 ───────────── */
.filters {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 14px;
  display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11.5px; color: var(--muted); font-weight: 500; }
input[type="text"], input[type="number"], input[type="password"], select, textarea {
  font-family: var(--font); font-size: 13px; color: var(--ink);
  background: #fff; border: 1px solid #cfd9e3; border-radius: var(--radius-sm);
  padding: 7px 10px; outline: none; transition: border .15s, box-shadow .15s;
  min-width: 0;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--blue-lt); box-shadow: 0 0 0 3px rgba(46, 136, 196, .12);
}
select { cursor: pointer; padding-right: 26px; }
.search-input { min-width: 260px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 15px; border-radius: var(--radius-sm); font-size: 13px;
  border: 1px solid #cfd9e3; background: #fff; color: var(--ink);
  cursor: pointer; transition: all .15s; white-space: nowrap; font-family: var(--font);
}
.btn:hover { border-color: var(--blue-lt); color: var(--blue); }
.btn-primary {
  background: var(--blue); border-color: var(--blue); color: #fff;
}
.btn-primary:hover { background: var(--blue-lt); border-color: var(--blue-lt); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--blue); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ───────────── 分页 ───────────── */
.pager {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 4px; color: var(--muted); font-size: 12.5px;
}
.pager-btns { display: flex; gap: 6px; align-items: center; }
.pager-btns button {
  min-width: 32px; height: 30px; padding: 0 9px;
  border: 1px solid #cfd9e3; background: #fff; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 12.5px; color: var(--ink); font-family: var(--font);
}
.pager-btns button:hover:not(:disabled) { border-color: var(--blue-lt); color: var(--blue); }
.pager-btns button.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.pager-btns button:disabled { opacity: .4; cursor: not-allowed; }

/* ───────────── 空状态 ───────────── */
.empty {
  border: 1px dashed #cfd9e3; border-radius: var(--radius);
  padding: 42px 24px; text-align: center; color: var(--muted);
  background: #fbfcfe;
}
.empty strong { display: block; color: var(--navy); font-size: 14px; margin-bottom: 6px; }
.empty p { margin: 0; font-size: 12.5px; line-height: 1.8; }
.empty code {
  background: #eef2f7; padding: 1px 6px; border-radius: 4px;
  font-family: var(--mono); font-size: 11.5px;
}

/* ───────────── 详情页 ───────────── */
.detail-top {
  display: grid; grid-template-columns: 300px 1fr; gap: 18px; margin-bottom: 6px;
}
.structure-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; display: flex; align-items: center; justify-content: center;
  min-height: 220px;
}
.structure-card img, .structure-card svg { max-width: 100%; height: auto; }
.structure-ph {
  color: var(--muted-lt); font-size: 12.5px; text-align: center; line-height: 1.9;
}
.info-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px;
}
.info-card h1 {
  margin: 0 0 4px; font-size: 23px; font-weight: 600; color: var(--navy);
  letter-spacing: -.2px;
}
.info-sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.meta-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 18px;
  padding-top: 14px; border-top: 1px solid var(--line-soft);
}
.meta-item .k { font-size: 11.5px; color: var(--muted-lt); }
.meta-item .v {
  font-size: 13.5px; color: var(--ink); font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.crumb { font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--blue); }
.crumb span { margin: 0 6px; color: var(--muted-lt); }

/* ───────────── 风险看板 ───────────── */
.risk-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.risk-col {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.risk-col-head {
  padding: 12px 16px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line-soft);
}
.risk-col-head .t { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.risk-col-head .c { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.risk-col.h .risk-col-head { background: #fdf6f5; color: var(--red); }
.risk-col.m .risk-col-head { background: #fdfaf3; color: var(--amber); }
.risk-col.l .risk-col-head { background: #f5faf7; color: var(--green); }
.risk-list { padding: 6px 0; max-height: 460px; overflow: auto; }
.risk-item {
  padding: 9px 16px; border-bottom: 1px solid var(--line-soft);
  cursor: pointer; transition: background .12s;
}
.risk-item:last-child { border-bottom: none; }
.risk-item:hover { background: #f8fbfd; }
.risk-item .n { font-size: 13.5px; color: var(--ink); font-weight: 500; }
.risk-item .m { font-size: 11.5px; color: var(--muted); display: flex; gap: 10px; margin-top: 1px; }
.risk-item .rep { color: var(--blue); font-family: var(--mono); }
.risk-note {
  font-size: 12px; color: var(--muted); background: #f8fafc;
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  padding: 10px 14px; margin-bottom: 16px; line-height: 1.75;
}

/* ───────────── 完整度 ───────────── */
.quality-row {
  display: grid; grid-template-columns: 120px 1fr 150px; gap: 14px;
  align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line-soft);
}
.quality-row:last-child { border-bottom: none; }
.quality-label { font-size: 13px; color: var(--ink); }
.quality-bar { height: 8px; background: #eef2f7; border-radius: 6px; overflow: hidden; }
.quality-bar i { display: block; height: 100%; background: var(--blue); border-radius: 6px; }
.quality-bar i.low { background: #c7d3df; }
.quality-val { text-align: right; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ───────────── 管理页 ───────────── */
.admin-gate {
  max-width: 460px; margin: 40px auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 28px;
  box-shadow: var(--shadow);
}
.admin-gate h2 { margin: 0 0 6px; font-size: 18px; color: var(--navy); }
.admin-gate p { margin: 0 0 18px; color: var(--muted); font-size: 13px; line-height: 1.8; }
.admin-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.admin-tabs button {
  padding: 10px 16px; border: none; background: none; cursor: pointer;
  font-size: 13.5px; color: var(--muted); border-bottom: 2px solid transparent;
  font-family: var(--font); margin-bottom: -1px;
}
.admin-tabs button.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { margin-top: 20px; display: flex; gap: 10px; align-items: center; }
.help-text { font-size: 12px; color: var(--muted-lt); }

.upload-zone {
  border: 2px dashed #cfd9e3; border-radius: var(--radius);
  padding: 34px 20px; text-align: center; color: var(--muted);
  cursor: pointer; transition: all .15s; background: #fbfcfe;
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--blue-lt); background: var(--blue-wash); }
.upload-zone strong { display: block; color: var(--navy); margin-bottom: 6px; font-size: 14px; }

.log-row {
  display: grid; grid-template-columns: 150px 90px 1fr 90px; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 12.5px;
}
.log-row:last-child { border-bottom: none; }
.log-row .ts { color: var(--muted-lt); font-family: var(--mono); font-size: 11.5px; }

/* ───────────── 提示 ───────────── */
.toast-wrap {
  position: fixed; right: 24px; bottom: 24px; z-index: 999;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
}
.toast {
  background: var(--navy); color: #fff; padding: 11px 18px;
  border-radius: var(--radius-sm); font-size: 13px; box-shadow: var(--shadow-lift);
  animation: slideIn .25s ease; max-width: 420px;
}
.toast.err { background: #8f2d25; }
.toast.ok { background: #1d5e46; }
@keyframes slideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.loading { text-align: center; padding: 90px 0; color: var(--muted); }
.spinner {
  width: 30px; height: 30px; margin: 0 auto 14px;
  border: 2.5px solid #dde5ee; border-top-color: var(--blue);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.footer {
  border-top: 1px solid var(--line); background: #fbfcfe; padding: 20px 0;
  margin-top: 20px;
}
.footer-inner {
  max-width: 1340px; margin: 0 auto; padding: 0 28px;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  color: var(--muted); font-size: 12px;
}
.footer strong { color: var(--navy); font-weight: 600; }
.sep { margin: 0 7px; color: var(--muted-lt); }

/* ───────────── 响应式 ───────────── */
@media (max-width: 1180px) {
  .kpi-grid, .kpi-grid.c4 { grid-template-columns: repeat(3, 1fr); }
  .grid-2, .grid-2-1, .risk-board, .grid-3 { grid-template-columns: 1fr; }
  .meta-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .topbar-inner { height: auto; padding: 12px 18px; flex-wrap: wrap; gap: 12px; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .topbar-meta { display: none; }
  .app { padding: 18px 16px 40px; }
  .kpi-grid, .kpi-grid.c4 { grid-template-columns: repeat(2, 1fr); }
  .detail-top { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .search-input { min-width: 0; width: 100%; }
}


/* ───────────── 甘特图 ───────────── */
.gantt-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.gantt-scroll { overflow-x: auto; }
.gantt { min-width: 1080px; }

.g-row { display: grid; grid-template-columns: 336px 1fr; }
.g-row + .g-row { border-top: 1px solid var(--line-soft); }
.g-row.head { background: #f7f9fc; border-top: none; }
.g-row.phase { background: #f2f6fa; }
.g-row.phase .g-name {
  font-weight: 600; color: var(--navy); font-size: 12.5px;
  letter-spacing: .2px;
}
.g-row:hover:not(.head):not(.phase) { background: #fbfdff; }

.g-name {
  padding: 7px 14px; border-right: 1px solid var(--line);
  font-size: 12.5px; display: flex; align-items: center; gap: 8px;
  min-height: 40px; position: relative;
}
.g-name .idx {
  color: var(--muted-lt); font-size: 11px; font-family: var(--mono);
  min-width: 16px;
}
.g-name .t { flex: 1; line-height: 1.35; }
.g-name .pct {
  font-variant-numeric: tabular-nums; font-size: 11.5px; font-weight: 600;
  color: var(--navy); min-width: 38px; text-align: right;
}
.g-name .pct.zero { color: var(--muted-lt); font-weight: 400; }

.g-years { display: grid; grid-template-columns: repeat(3, 1fr); }
.g-years div {
  text-align: center; font-size: 11.5px; color: var(--navy); font-weight: 600;
  padding: 5px 0 3px; border-bottom: 1px solid var(--line-soft);
  border-left: 1px solid var(--line);
}
.g-years div:first-child { border-left: none; }
.g-months { display: grid; grid-template-columns: repeat(36, 1fr); }
.g-months div {
  text-align: center; font-size: 9.5px; color: var(--muted-lt);
  padding: 3px 0 4px; font-variant-numeric: tabular-nums;
}
.g-months div.q { color: var(--navy); font-weight: 600; background: #f2f6fa; }

.g-track {
  position: relative; min-height: 40px;
  background-image:
    linear-gradient(to right, #eef3f8 1px, transparent 1px),
    linear-gradient(to right, #dce6f0 1px, transparent 1px);
  background-size: calc(100% / 36) 100%, calc(100% / 6) 100%;
  background-position: 0 0, 0 0;
}
.g-bar {
  position: absolute; top: 10px; height: 20px; border-radius: 4px;
  background: #dbe8f3; box-shadow: inset 0 0 0 1px rgba(31, 111, 168, .13);
  overflow: hidden; cursor: default;
  transition: box-shadow .15s;
}
.g-bar:hover { box-shadow: 0 0 0 1px rgba(31, 111, 168, .5); }
.g-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, #3b95cf, #1f6fa8);
  border-radius: 4px 0 0 4px;
}
.g-fill.done  { background: linear-gradient(90deg, #3f9c68, #2a7d4f); }
.g-fill.behind{ background: linear-gradient(90deg, #cc5a4d, #b23b32); }
.g-fill.ahead,
.g-fill.pre   { background: linear-gradient(90deg, #2c9a92, #0f7c76); }

.g-today {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: #e08a2c; z-index: 4; opacity: .85;
}
.g-today::after {
  content: "Today"; position: absolute; top: -1px; left: 3px;
  font-size: 9px; color: #b8721f; background: #fff; padding: 0 3px;
  border-radius: 2px; white-space: nowrap;
}
.g-start {
  position: absolute; top: 0; bottom: 0; width: 1px;
  background: #9fb3c8; border-left: 1px dashed #9fb3c8; z-index: 3;
}

.gantt-legend {
  display: flex; flex-wrap: wrap; gap: 18px; align-items: center;
  padding: 11px 16px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--muted); background: #fbfcfe;
}
.gantt-legend i {
  display: inline-block; width: 22px; height: 9px; border-radius: 2px;
  margin-right: 6px; vertical-align: middle;
}
.lg-plan  { background: #dbe8f3; box-shadow: inset 0 0 0 1px rgba(31,111,168,.15); }
.lg-doing { background: linear-gradient(90deg, #3b95cf, #1f6fa8); }
.lg-done  { background: linear-gradient(90deg, #3f9c68, #2a7d4f); }
.lg-ahead { background: linear-gradient(90deg, #2c9a92, #0f7c76); }
.lg-behind{ background: linear-gradient(90deg, #cc5a4d, #b23b32); }
.lg-today { background: #e08a2c; width: 2px !important; }

.banner {
  border-radius: var(--radius); padding: 12px 16px; font-size: 12.5px;
  line-height: 1.8; margin-bottom: 16px; border: 1px solid;
}
.banner.info { background: #f2f8fd; border-color: #cfe3f2; color: #1b5a86; }
.banner.warn { background: #fdf8ee; border-color: #f0e0c0; color: #8a5f14; }

.g-edit {
  border: 1px solid #cfd9e3; background: #fff; border-radius: 4px;
  width: 22px; height: 22px; line-height: 1; cursor: pointer;
  color: var(--muted); font-size: 11px; flex-shrink: 0;
}
.g-edit:hover { border-color: var(--blue); color: var(--blue); }

@media (max-width: 860px) {
  .g-row { grid-template-columns: 220px 1fr; }
  .g-name { font-size: 11.5px; }
}

/* ============================================================
   Mobile layout  (<= 700 px): bottom tab bar, card tables,
   sticky Gantt labels, touch-friendly controls, safe-area inset
   ============================================================ */

/* elements that only appear on phones */
.brand-short, .nav-ico, .nav-short, .mobile-hint, .mobile-sort { display: none; }

.quality-row.compact { grid-template-columns: 220px 1fr 96px; }

html { -webkit-text-size-adjust: 100%; }

@media (max-width: 700px) {
  body { padding-bottom: calc(62px + env(safe-area-inset-bottom, 0px)); }

  /* ── top bar ── */
  .topbar-inner {
    height: 54px; gap: 10px; flex-wrap: nowrap;
    padding-left: max(14px, env(safe-area-inset-left, 0px));
    padding-right: max(14px, env(safe-area-inset-right, 0px));
  }
  .brand { gap: 8px; min-width: 0; }
  .brand-mark { width: 30px; height: 30px; border-radius: 7px; }
  .brand-text { min-width: 0; }
  .brand-long { display: none; }
  .brand-short { display: block; font-size: 14px; white-space: nowrap; }
  .brand-text em { display: none; }
  .topbar-meta { display: none; }

  /* ── bottom navigation ── */
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 200;
    order: initial; width: auto; margin: 0; gap: 0; overflow: visible;
    display: flex; align-items: stretch;
    background: rgba(13, 35, 56, .97);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    border-top: 1px solid rgba(255, 255, 255, .12);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    box-shadow: 0 -4px 18px rgba(13, 35, 56, .2);
  }
  .nav a {
    flex: 1 1 0; min-width: 0; height: 58px; padding: 7px 2px 5px;
    border-radius: 0; font-size: 10px; line-height: 1.2;
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 3px; color: #9db9d0;
  }
  .nav a:hover { background: rgba(255, 255, 255, .06); }
  .nav a.active { background: rgba(95, 176, 224, .16); color: #fff; }
  .nav a.active::after {
    left: 22%; right: 22%; top: 0; bottom: auto;
    height: 3px; border-radius: 0 0 3px 3px;
  }
  .nav-ico { display: block; width: 20px; height: 20px; flex-shrink: 0; }
  .nav-full { display: none; }
  .nav-short { display: inline; }

  /* ── page frame ── */
  .app {
    padding: 16px 12px 30px; min-height: 50vh;
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
  }
  .page-head { margin-bottom: 16px; }
  .page-head h1 { font-size: 21px; }
  .page-head p { font-size: 12.5px; line-height: 1.65; }
  .section-title {
    flex-direction: column; align-items: flex-start; gap: 2px;
    margin: 22px 0 10px;
  }
  .section-title h2 { font-size: 15px; }
  .section-title span { font-size: 11.5px; }

  /* ── KPI ── */
  .kpi-grid, .kpi-grid.c4 {
    grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px;
  }
  .kpi { padding: 12px 13px 11px; }
  .kpi-label { font-size: 11.5px; }
  .kpi-value { font-size: 25px; margin-top: 4px; }
  .kpi-value small { font-size: 12px; }
  .kpi-sub { font-size: 10.5px; line-height: 1.45; }
  .kpi-grid > .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }

  /* ── panels & charts ── */
  .panel { padding: 13px 13px 14px; }
  .panel-head { flex-wrap: wrap; gap: 4px 10px; margin-bottom: 10px; }
  .panel-head h3 { font-size: 14px; }
  .grid-2, .grid-2-1, .grid-3, .risk-board { gap: 12px; }
  .chart-box { height: 250px; }
  .chart-box.tall { height: 370px; }
  .chart-box.short { height: 225px; }

  /* ── filters & forms ── */
  .filters {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px; padding: 12px; align-items: end;
  }
  .filters > .field { min-width: 0; }
  .filters > .field:nth-child(1) { grid-column: 1 / -1; }
  .filters input, .filters select { width: 100%; }
  .filters > .btn { width: 100%; }
  .filters > .btn:last-child { grid-column: 1 / -1; }
  .field label { font-size: 11px; }
  input[type="text"], input[type="number"], input[type="password"],
  select, textarea { font-size: 16px; width: 100%; }
  .btn { padding: 9px 13px; min-height: 40px; }
  .btn-sm { padding: 6px 10px; min-height: 34px; font-size: 12px; }
  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .form-actions { flex-wrap: wrap; }
  .form-actions .btn { flex: 1 1 auto; }
  .admin-tabs { overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .admin-tabs button { padding: 10px 12px; font-size: 13px; }
  .admin-gate { margin: 18px auto; padding: 20px 18px; }
  .upload-zone { padding: 24px 14px; }
  .upload-zone span { font-size: 11.5px; }

  /* ── quality bars ── */
  .quality-row, .quality-row.compact {
    grid-template-columns: 1fr 74px !important; gap: 5px 10px;
    padding: 10px 0;
  }
  .quality-label { grid-column: 1 / -1; font-size: 12.5px !important; }
  .quality-bar { grid-column: 1; }
  .quality-val { grid-column: 2; font-size: 12px !important; }

  /* ── tables become cards ── */
  .table-wrap {
    background: transparent; border: none; border-radius: 0;
    overflow: visible; max-height: none !important;
  }
  table.data, table.data tbody { display: block; width: 100%; }
  table.data thead { display: none; }
  table.data tr {
    display: block; background: var(--panel);
    border: 1px solid var(--line); border-radius: var(--radius);
    margin-bottom: 10px; padding: 2px 0;
    box-shadow: 0 1px 2px rgba(20, 49, 79, .04);
  }
  table.data tr.clickable:active { background: var(--blue-wash); }
  table.data td {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 12px; padding: 8px 12px; font-size: 12.5px;
    border-bottom: 1px dashed var(--line-soft); text-align: right;
    vertical-align: baseline; word-break: break-word;
  }
  table.data tr > td:last-child { border-bottom: none; }
  table.data td::before {
    content: attr(data-label); flex: 0 0 38%;
    color: var(--muted-lt); font-size: 10.5px; font-weight: 500;
    text-align: left; letter-spacing: .2px; text-transform: uppercase;
  }
  table.data td .cell-v {
    flex: 1 1 auto; min-width: 0; text-align: right;
    word-break: break-word; overflow-wrap: anywhere;
  }
  table.data tr > td:first-child {
    background: #f7f9fc; border-radius: var(--radius) var(--radius) 0 0;
  }
  table.data tr > td:first-child::before { display: none; }
  table.data tr > td:first-child .cell-v { text-align: left; font-weight: 600; }
  table.data td.m-full {
    display: block; padding: 0; border: none; text-align: center;
    background: transparent;
  }
  table.data td.m-full::before { display: none; }
  .nowrap { white-space: normal; }

  .mobile-sort {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    margin: 0 0 10px;
  }
  .mobile-sort > span {
    font-size: 11px; color: var(--muted); text-transform: uppercase;
    letter-spacing: .4px; margin-right: 2px;
  }
  .mobile-sort button {
    padding: 6px 11px; min-height: 34px;
    border: 1px solid #cfd9e3; background: #fff; color: var(--ink);
    border-radius: var(--radius-sm); font-family: var(--font); font-size: 11.5px;
    cursor: pointer;
  }
  .mobile-sort button:active { background: var(--blue-wash); border-color: var(--blue-lt); }

  /* ── detail page ── */
  .crumb { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .detail-top { gap: 12px; }
  .structure-card { min-height: 180px; padding: 10px; }
  .info-card { padding: 15px 15px 16px; }
  .info-card h1 { font-size: 19px; overflow-wrap: anywhere; }
  .info-sub { font-size: 12px; line-height: 1.8; }
  .meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .meta-item .v { font-size: 12.5px; overflow-wrap: anywhere; }

  /* ── risk board ── */
  .risk-note { font-size: 11.5px; padding: 10px 12px; }
  .risk-list { max-height: 340px; }
  .risk-item { padding: 10px 13px; }
  .risk-item .m { flex-wrap: wrap; gap: 0 10px; }
  .risk-col-head { padding: 11px 13px; }

  /* ── Gantt ── */
  .mobile-hint {
    display: block; margin: 0 0 10px; padding: 8px 12px;
    border: 1px solid #cfe3f2; border-radius: var(--radius-sm);
    background: #f2f8fd; color: #1b5a86; font-size: 11.5px;
  }
  .gantt-card { border-radius: var(--radius); }
  .gantt-scroll {
    -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
  }
  .gantt { min-width: 880px; }
  .g-row, .g-row:not(.head) { grid-template-columns: 156px 1fr; }
  .g-name {
    position: sticky; left: 0; z-index: 6;
    padding: 6px 8px; font-size: 11px; min-height: 44px;
    background: #fff; border-right: 1px solid var(--line);
    box-shadow: 2px 0 5px rgba(20, 49, 79, .07);
  }
  .g-row.head .g-name { background: #f7f9fc; z-index: 7; font-size: 11px; }
  .g-row.phase .g-name { background: #f2f6fa; }
  .g-name .idx { min-width: 13px; font-size: 10px; }
  .g-name .pct { min-width: 30px; font-size: 10.5px; }
  .g-name .t { font-size: 10.8px; }
  .g-edit { width: 28px; height: 28px; font-size: 13px; }
  .g-track { min-height: 44px; }
  .g-bar { top: 12px; }
  .gantt-legend { gap: 8px 14px; font-size: 11px; padding: 10px 12px; }
  .gantt-legend i { width: 18px; }
  .banner { font-size: 11.5px; padding: 10px 12px; }

  /* ── pager / logs / footer / toast ── */
  .pager { flex-wrap: wrap; gap: 8px; justify-content: center; font-size: 12px; }
  .pager-btns { flex-wrap: wrap; justify-content: center; }
  .pager-btns button { min-width: 36px; height: 36px; }
  .log-row { grid-template-columns: 1fr; gap: 2px; padding: 10px 0; }
  .log-row > div { overflow-wrap: anywhere; }
  .footer { padding: 14px 0; }
  .footer-inner {
    flex-direction: column; gap: 5px; padding: 0 14px;
    font-size: 11px; line-height: 1.6;
  }
  .footer-meta .sep { display: none; }
  .toast-wrap {
    left: 12px; right: 12px; bottom: calc(70px + env(safe-area-inset-bottom, 0px));
    align-items: stretch;
  }
  .toast { max-width: none; font-size: 12.5px; padding: 10px 14px; }
}

@media (max-width: 380px) {
  .nav a { font-size: 9.5px; gap: 2px; }
  .nav-ico { width: 18px; height: 18px; }
  .brand-short { font-size: 13px; }
  .kpi-value { font-size: 22px; }
  .kpi { padding: 10px 11px; }
  .chart-box.tall { height: 340px; }
  .g-row, .g-row:not(.head) { grid-template-columns: 138px 1fr; }
  .gantt { min-width: 820px; }
}

/* ============================================================
   Computed candidate space — measured / computed tabs, source notes
   ============================================================ */
.lib-tabs {
  display: flex; gap: 4px; margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.lib-tabs button {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; margin-bottom: -1px;
  border: none; border-bottom: 2px solid transparent;
  background: none; cursor: pointer; color: var(--muted);
  font-family: var(--font); font-size: 13.5px; white-space: nowrap;
}
.lib-tabs button:hover { color: var(--blue); }
.lib-tabs button.active {
  color: var(--blue); border-bottom-color: var(--blue); font-weight: 600;
}
.lib-tabs button span {
  background: #eef2f7; color: var(--muted); font-size: 11px;
  padding: 1px 7px; border-radius: 10px; font-variant-numeric: tabular-nums;
}
.lib-tabs button.active span { background: var(--blue-wash); color: var(--blue); }

.mini-head { margin: 0 0 6px; font-size: 14px; font-weight: 600; color: var(--navy); }
.muted { color: var(--muted-lt); font-size: 11.5px; }
.source-note { line-height: 1.85; }
.source-note b { color: #8a5f14; }
.structure-card img { max-height: 250px; }

@media (max-width: 700px) {
  .lib-tabs {
    overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 14px;
  }
  .lib-tabs button { padding: 9px 10px; font-size: 12px; }
  .source-note { font-size: 11.5px; }
  .banner { line-height: 1.75; }
  .mini-head { font-size: 13.5px; }
}

/* ============================================================
   Tiering method comparison
   ============================================================ */
.subtabs {
  display: flex; gap: 4px; margin: -8px 0 20px;
  border-bottom: 1px solid var(--line); overflow-x: auto;
}
.subtabs a {
  padding: 10px 16px; margin-bottom: -1px; white-space: nowrap;
  border-bottom: 2px solid transparent; color: var(--muted);
  font-size: 13.5px; text-decoration: none;
}
.subtabs a:hover { color: var(--blue); }
.subtabs a.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }

/* Shared small key label (tiering tables and virtual-library rows). */
.ep-key { font-size: 10.5px; color: var(--muted-lt); margin-top: 4px; }

.verdict {
  background: var(--blue-wash); border: 1px solid #c9dcF0; border-left: 4px solid var(--blue);
  border-radius: 9px; padding: 18px 22px; margin-bottom: 20px;
}
.verdict-tag {
  display: inline-block; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase;
  color: #fff; background: var(--blue); border-radius: 4px; padding: 3px 8px; margin-bottom: 10px;
}
.verdict h2 { font-size: 17px; color: var(--navy); margin: 0 0 10px; line-height: 1.5; }
.verdict p { font-size: 12.8px; line-height: 1.85; color: #3d536b; margin: 0 0 8px; }
.verdict p:last-child { margin-bottom: 0; }

.method-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.method-card {
  border: 1px solid var(--line); border-radius: 9px; background: #fff;
  padding: 16px 17px; display: flex; flex-direction: column;
}
.method-card.recommended { border-color: #9ec7b6; box-shadow: 0 0 0 2px #e7f4ee; }
.mc-head { display: flex; align-items: center; gap: 9px; margin-bottom: 11px; flex-wrap: wrap; }
.mc-letter {
  width: 26px; height: 26px; border-radius: 7px; background: #eef2f7; color: var(--navy);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex: none;
}
.recommended .mc-letter { background: var(--green); color: #fff; }
.mc-head h3 { font-size: 13.5px; margin: 0; color: var(--navy); line-height: 1.4; }
.mc-badge {
  font-size: 10px; padding: 2px 7px; border-radius: 10px;
  background: #e7f4ee; color: var(--green); font-weight: 600;
}
.mc-formula {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.2px;
  line-height: 1.7; background: #f7f9fc; border-radius: 6px;
  padding: 9px 11px; color: #41566d; margin-bottom: 11px;
}
.method-card ul { margin: 0 0 12px; padding-left: 17px; flex: 1; }
.method-card li { font-size: 11.8px; line-height: 1.75; color: #4b5d70; margin-bottom: 7px; }
.mc-foot {
  font-size: 11.5px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 9px;
}

.dist-panel { padding: 18px 20px; }
.dist-row { margin-bottom: 17px; }
.dist-label { font-size: 12.5px; font-weight: 600; color: var(--navy); margin-bottom: 7px; }
.dist-label span { font-weight: 400; color: var(--muted); margin-left: 9px; font-size: 11px; }
.dist-bar { display: flex; height: 17px; border-radius: 5px; overflow: hidden; background: #eef2f7; }
.dist-bar i { display: block; height: 100%; }
.dist-legend { display: flex; flex-wrap: wrap; gap: 13px; margin-top: 6px; }
.dist-legend span { font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.dist-legend span i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.dist-legend b { color: var(--navy); font-variant-numeric: tabular-nums; }
.dist-note { font-size: 11.8px; line-height: 1.8; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 11px; }

.tier-filters { align-items: end; }
.tier-table { font-size: 12px; }
.tier-table .ep-key { margin-top: 2px; }
.refs { padding: 6px 20px 14px; }
.refs p { font-size: 11.8px; line-height: 1.8; color: #4b5d70; margin: 11px 0; }
.refs a { color: var(--blue); }
.tier-caveat {
  margin-top: 18px; padding: 14px 17px; border-radius: 8px;
  background: #f7f9fc; border: 1px solid var(--line);
  font-size: 11.8px; line-height: 1.8; color: var(--muted);
}
.tier-caveat strong { color: var(--navy); }

@media (max-width: 1000px) {
  .method-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .subtabs { margin: -4px 0 15px; }
  .subtabs a { padding: 9px 11px; font-size: 12px; }
  .verdict { padding: 15px 16px; }
  .verdict h2 { font-size: 15px; }
  .verdict p { font-size: 12px; }
  .dist-panel { padding: 14px 13px; }
  .dist-legend { gap: 8px; }
  .dist-legend span { font-size: 10px; }
  .tier-caveat { font-size: 11px; }
}
