/* 中控台视觉系统。Token 与理由见项目根 DESIGN.md。
   陛下 2026-09-26 定：电脑端走「值班简报」（B），手机端走「随身仪表」（C）——
   同一套设计语言，两端各自最优布局，不是把网页硬塞进手机。

   两条硬规矩：
   1. 电脑端不用卡片，只用细线和留白，靠字号字重拉层次。
   2. 状态永远「色点/色块 + 文字」成对，不单靠颜色表意。 */

/* ───────────────────────── Tokens ───────────────────────── */
:root {
  --bg:        oklch(1 0 0);
  --raise:     oklch(0.985 0.002 265);
  --sunk:      oklch(0.965 0.003 265);
  --rule:      oklch(0.885 0.005 265);   /* 主分栏线 */
  --hair:      oklch(0.935 0.003 265);   /* 行间细线 */
  --ink:       oklch(0.18 0.006 265);
  --ink-2:     oklch(0.44 0.006 265);
  --ink-3:     oklch(0.615 0.005 265);
  --on-ink:    oklch(0.99 0 0);

  --ok:    oklch(0.55 0.13 155);
  --warn:  oklch(0.64 0.14 72);
  --crit:  oklch(0.53 0.19 25);
  --idle:  oklch(0.72 0.012 265);
  --focus: oklch(0.55 0.16 250);

  /* 品牌绯红：只用于报头那一个点。红色在本产品里是「设备挂了」的语义，不挪作装饰 */
  --brand: oklch(0.591 0.172 24);

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Courier New", monospace;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 170ms;

  --z-sticky: 20; --z-backdrop: 30; --z-modal: 40; --z-toast: 50; --z-tooltip: 60;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:     oklch(0.165 0.006 265);
    --raise:  oklch(0.205 0.007 265);
    --sunk:   oklch(0.235 0.008 265);
    --rule:   oklch(0.325 0.009 265);
    --hair:   oklch(0.265 0.008 265);
    --ink:    oklch(0.955 0.003 265);
    --ink-2:  oklch(0.715 0.006 265);
    --ink-3:  oklch(0.565 0.006 265);
    --on-ink: oklch(0.17 0.006 265);
    --ok:    oklch(0.72 0.15 155);
    --warn:  oklch(0.78 0.15 80);
    --crit:  oklch(0.68 0.19 25);
    --idle:  oklch(0.40 0.010 265);
    --focus: oklch(0.70 0.16 250);
    --brand: oklch(0.68 0.17 24);
  }
}
:root[data-theme="dark"] {
  --bg:     oklch(0.165 0.006 265);
  --raise:  oklch(0.205 0.007 265);
  --sunk:   oklch(0.235 0.008 265);
  --rule:   oklch(0.325 0.009 265);
  --hair:   oklch(0.265 0.008 265);
  --ink:    oklch(0.955 0.003 265);
  --ink-2:  oklch(0.715 0.006 265);
  --ink-3:  oklch(0.565 0.006 265);
  --on-ink: oklch(0.17 0.006 265);
  --ok:    oklch(0.72 0.15 155);
  --warn:  oklch(0.78 0.15 80);
  --crit:  oklch(0.68 0.19 25);
  --idle:  oklch(0.40 0.010 265);
  --focus: oklch(0.70 0.16 250);
  --brand: oklch(0.68 0.17 24);
}

/* ───────────────────────── Base ───────────────────────── */
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 14px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; text-wrap: balance; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
svg.ic { width: 16px; height: 16px; fill: none; stroke: currentColor;
         stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.skip { position: fixed; top: 8px; left: 8px; z-index: var(--z-tooltip);
        padding: 8px 12px; background: var(--ink); color: var(--on-ink);
        border-radius: 6px; transform: translateY(-200%); }
.skip:focus { transform: none; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ───────────────────────── 报头 ───────────────────────── */
.masthead {
  position: sticky; top: 0; z-index: var(--z-sticky);
  background: color-mix(in oklch, var(--bg) 92%, transparent);
  backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 2px solid var(--ink);
  padding: 0 var(--s7);
}
.mast-top { display: flex; align-items: center; justify-content: space-between;
            gap: var(--s5); padding: var(--s4) 0 var(--s3); }
.brand { display: flex; align-items: center; gap: var(--s2); }
.brand-mark { width: 9px; height: 9px; border-radius: 50%; background: var(--brand); flex: none; }
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -0.015em; }

.mast-right { display: flex; align-items: center; gap: var(--s3); }
.conn { display: flex; align-items: center; gap: 6px; font: 400 11px/1 var(--mono); color: var(--ink-3); }
.conn-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--idle); flex: none; }
.conn[data-state="live"] .conn-dot { background: var(--ok); animation: pulse 2.4s var(--ease) infinite; }
.conn[data-state="connecting"] .conn-dot { background: var(--warn); animation: pulse 1.2s var(--ease) infinite; }
.conn[data-state="down"] .conn-dot { background: var(--crit); }
@keyframes pulse { 50% { opacity: .3 } }
.stamp { font: 400 11px/1 var(--mono); color: var(--ink-3); }

/* 分栏导航：像报纸的版面条，不是侧边栏 */
.sections { display: flex; gap: var(--s5); overflow-x: auto; scrollbar-width: none; }
.sections::-webkit-scrollbar { display: none; }
.sec-link {
  position: relative; padding: 0 0 10px; white-space: nowrap;
  font-size: 13.5px; color: var(--ink-3);
  transition: color var(--dur) var(--ease);
}
.sec-link:hover { color: var(--ink); }
.sec-link[aria-current="page"] { color: var(--ink); font-weight: 500; }
.sec-link[aria-current="page"]::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px; background: var(--ink);
}
.sec-n { margin-left: 5px; font: 400 11px/1 var(--mono); color: var(--ink-3); }

/* ───────────────────────── 版面 ───────────────────────── */
.main { max-width: 1180px; margin: 0 auto; padding: 0 var(--s7); }
.view { padding: 0 0 var(--s8); }

/* 导语：整页第一句话，说结论 */
.lede { padding: var(--s7) 0 var(--s6); border-bottom: 1px solid var(--rule); }
.lede h1 { font: 600 40px/1.15 var(--sans); letter-spacing: -0.03em; max-width: 22ch; }
.lede h1 u { text-decoration: none; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.lede h1[data-t="crit"] u { color: var(--crit); }
.lede p { margin-top: var(--s3); color: var(--ink-2); max-width: 54ch; line-height: 1.7; }

.kicker { font: 500 11.5px/1 var(--sans); color: var(--ink-3); margin: 0 0 var(--s4); }

/* 两栏 */
.cols { display: grid; grid-template-columns: 1fr 296px; gap: var(--s8); padding-top: var(--s6); }

/* 编号清单：无卡片，只有细线 */
.item {
  display: grid; grid-template-columns: 32px 1fr auto; gap: var(--s4);
  align-items: baseline; padding: var(--s4) 0; border-bottom: 1px solid var(--hair);
  width: 100%; text-align: left; background: none; border-left: 0; border-right: 0; border-top: 0;
  cursor: default; transition: background var(--dur) var(--ease);
}
.item:first-of-type { border-top: 1px solid var(--rule); }
.item[data-act="1"] { cursor: pointer; }
.item[data-act="1"]:hover { background: var(--raise); }
.item .no { font: 400 12px/1 var(--mono); color: var(--ink-3); }
.item h3 { font: 500 16px/1.35 var(--sans); }
.item .src { font: 400 12px/1.4 var(--mono); color: var(--ink-3); margin-top: 2px; }
.item .v { font: 600 22px/1 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.item[data-t="crit"] .v { color: var(--crit); }
.item[data-t="zero"] .v { color: var(--ink-3); font-weight: 400; }
.item[data-t="na"] .v { font: 400 11.5px/1 var(--sans); color: var(--ink-3); }
.item[data-t="na"] h3 { color: var(--ink-2); }

/* 全队状态条：150 台压成一排，颜色就是信息 */
.fleet h4 { font-size: 13px; }
.fleet > p { margin: 4px 0 var(--s3); font-size: 12.5px; color: var(--ink-3); line-height: 1.5; }
.bars { display: flex; flex-wrap: wrap; gap: 2px; }
.bars i { width: 10px; height: 22px; border-radius: 1px; display: block;
          background: var(--ok); opacity: .72; transition: opacity var(--dur) var(--ease); }
.bars i[data-s="warn"] { background: var(--warn); opacity: 1; }
.bars i[data-s="crit"] { background: var(--crit); opacity: 1; }
.bars i[data-s="idle"] { background: var(--idle); opacity: 1; }
.bars .none { width: auto; height: auto; background: none; opacity: 1;
              font-size: 12.5px; color: var(--ink-3); }
.tally { margin-top: var(--s4); border-top: 1px solid var(--rule); }
.tally div { display: flex; align-items: baseline; justify-content: space-between;
             padding: 9px 0; border-bottom: 1px solid var(--hair); font-size: 13px; }
.tally div span { display: flex; align-items: center; gap: var(--s2); color: var(--ink-2); }
.tally div span u { width: 8px; height: 8px; border-radius: 2px; text-decoration: none; display: block; }
.tally div b { font: 500 15px/1 var(--mono); font-variant-numeric: tabular-nums; }

/* 产能：四个绝对数，靠字号对比拉层次 */
.block { margin-top: var(--s7); padding-top: var(--s5); border-top: 2px solid var(--ink); }
.figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
        gap: var(--s5); margin-top: var(--s4); }
.fig b { display: block; font: 600 30px/1 var(--mono); letter-spacing: -0.03em;
         font-variant-numeric: tabular-nums; }
.fig b[data-na] { font: 400 13px/1.6 var(--sans); color: var(--ink-3); letter-spacing: 0; }
.fig small { display: block; margin-top: var(--s2); color: var(--ink-2); font-size: 12.5px; }
.fig em { display: block; margin-top: 2px; color: var(--ink-3); font-size: 11.5px; font-style: normal; }

/* ───────────────────────── 状态 ───────────────────────── */
.st { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.st-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--idle); }
.st[data-s="ok"]   .st-dot { background: var(--ok); }
.st[data-s="warn"] .st-dot { background: var(--warn); }
.st[data-s="crit"] .st-dot { background: var(--crit); }
.st-txt { font-size: 13px; }

/* ───────────────────────── 设备表（电脑） ───────────────────────── */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl thead th {
  text-align: left; font: 500 11.5px/1 var(--sans); color: var(--ink-3);
  padding: 0 var(--s4) 10px 0; border-bottom: 1px solid var(--rule); white-space: nowrap;
}
.tbl thead th:last-child { padding-right: 0; text-align: right; }
.tbl tbody td { height: 46px; padding: 0 var(--s4) 0 0; border-bottom: 1px solid var(--hair);
                font-size: 13px; white-space: nowrap; }
.tbl tbody td:last-child { padding-right: 0; text-align: right; }
.tbl tbody tr { transition: background var(--dur) var(--ease); cursor: pointer; }
.tbl tbody tr:hover { background: var(--raise); }
.td-sn { font-family: var(--mono); font-weight: 500; }
.td-dim { color: var(--ink-2); }

/* ───────────────────────── 设备卡（手机） ───────────────────────── */
.dcards { display: none; }

/* ───────────────────────── 空状态 ───────────────────────── */
.empty { padding: var(--s7) var(--s5); text-align: center;
         display: flex; flex-direction: column; gap: var(--s2); align-items: center;
         border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.empty-t { font-weight: 500; font-size: 15px; }
.empty-d { font-size: 13px; color: var(--ink-2); max-width: 50ch; line-height: 1.7; }
.empty-tag { font: 400 11px/1 var(--mono); color: var(--ink-3);
             border: 1px solid var(--rule); padding: 4px 9px; border-radius: 999px; }

.sk { background: var(--sunk); border-radius: 3px; animation: sk 1.3s var(--ease) infinite; }
@keyframes sk { 50% { opacity: .5 } }
.sk-row { height: 46px; border-bottom: 1px solid var(--hair);
          display: flex; align-items: center; gap: var(--s5); }
.sk-b { height: 9px; border-radius: 999px; }

/* ───────────────────────── 按钮 ───────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
       min-height: 32px; padding: 0 12px; white-space: nowrap;
       border: 1px solid var(--rule); border-radius: 6px;
       background: var(--bg); color: var(--ink); cursor: pointer;
       transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.btn:hover { background: var(--raise); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-sm { min-height: 30px; font-size: 13px; }
.btn-icon { width: 32px; padding: 0; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-3); }
.btn-ghost:hover { background: var(--raise); color: var(--ink); }
.btn-danger { color: var(--crit); border-color: color-mix(in oklch, var(--crit) 35%, var(--rule)); }
.btn-danger:hover { background: color-mix(in oklch, var(--crit) 8%, var(--bg)); }

/* ───────────────────────── 抽屉 / 确认 / 提示 ───────────────────────── */
.drawer-root { position: fixed; inset: 0; z-index: var(--z-modal); }
.drawer-backdrop { position: absolute; inset: 0; background: oklch(0.2 0.01 265 / .38);
                   z-index: var(--z-backdrop); animation: fade var(--dur) var(--ease); }
@keyframes fade { from { opacity: 0 } }
.drawer { position: absolute; right: 0; top: 0; height: 100dvh; width: min(520px, 100%);
          display: flex; flex-direction: column; background: var(--bg);
          border-left: 1px solid var(--rule); z-index: var(--z-modal);
          animation: slide 230ms var(--ease); }
@keyframes slide { from { transform: translateX(14px); opacity: 0 } }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between;
               gap: var(--s3); padding: var(--s5); border-bottom: 2px solid var(--ink); }
.drawer-title { font: 600 17px/1.2 var(--mono); letter-spacing: -0.01em; }
.drawer-sub { font-size: 13px; color: var(--ink-2); margin-top: 3px; }
.drawer-body { padding: var(--s5); overflow-y: auto; display: flex; flex-direction: column; gap: var(--s6); }
.dgroup h4 { font-size: 13px; }
.dgroup > .note { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.kv { display: grid; grid-template-columns: minmax(80px, auto) 1fr; gap: 9px var(--s4);
      font-size: 13px; margin-top: var(--s3); padding-top: var(--s3); border-top: 1px solid var(--rule); }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; }
.tl { display: flex; flex-direction: column; gap: var(--s3); margin-top: var(--s3);
      padding-top: var(--s3); border-top: 1px solid var(--rule); }
.tl-i { display: grid; grid-template-columns: 7px 1fr; gap: var(--s3); font-size: 13px; }
.tl-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--rule); margin-top: 7px; }
.tl-when { font: 400 11.5px/1.5 var(--mono); color: var(--ink-3); }

.confirm-root .confirm { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(400px, calc(100% - 32px)); z-index: var(--z-modal); background: var(--bg);
  border: 1px solid var(--rule); border-radius: 12px; padding: var(--s5);
  display: flex; flex-direction: column; gap: var(--s3); animation: pop 190ms var(--ease); }
@keyframes pop { from { transform: translate(-50%, -47%); opacity: 0 } }
.confirm-title { font-size: 16px; }
.confirm-body { font-size: 13.5px; color: var(--ink-2); line-height: 1.7; }
.confirm-acts { display: flex; justify-content: flex-end; gap: var(--s2); margin-top: var(--s2); }

.toasts { position: fixed; right: var(--s4); bottom: var(--s4); z-index: var(--z-toast);
          display: flex; flex-direction: column; gap: var(--s2); pointer-events: none; }
.toast { pointer-events: auto; padding: 11px var(--s4); border-radius: 8px;
         background: var(--ink); color: var(--on-ink); font-size: 13px;
         animation: toast 200ms var(--ease); }
.toast[data-s="bad"] { background: var(--crit); color: oklch(0.99 0 0); }
@keyframes toast { from { transform: translateY(6px); opacity: 0 } }

.tabbar { display: none; }

/* ───────────────────────── 中屏 ───────────────────────── */
@media (max-width: 1080px) {
  .masthead, .main { padding-left: var(--s5); padding-right: var(--s5); }
  .cols { grid-template-columns: 1fr; gap: var(--s7); }
  .lede h1 { font-size: 34px; }
}

/* ───────────────────────── 手机：C 随身仪表 ─────────────────────────
   不是把电脑版缩小，是换一套形态：结论卡 + 大触控分组行 + 底部导航。 */
@media (max-width: 720px) {
  body { background: oklch(0.965 0.003 265); }
  :root:not([data-theme="light"]) body { background: var(--bg); }
  @media (prefers-color-scheme: dark) { body { background: var(--bg); } }

  .masthead { padding: 0 var(--s4); border-bottom: 1px solid var(--rule);
              background: color-mix(in oklch, var(--bg) 94%, transparent); }
  .mast-top { padding: var(--s3) 0; }
  .sections { display: none; }
  .stamp { display: none; }
  .conn-text { display: none; }

  .main { padding: 0 var(--s4); }
  .view { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }

  /* 导语收进一张结论卡 */
  .lede { padding: var(--s4) var(--s4) var(--s5); border: 1px solid var(--rule);
          border-radius: 16px; background: var(--bg); margin-top: var(--s4); }
  .lede h1 { font-size: 27px; max-width: none; }
  .lede p { font-size: 13.5px; }
  .kicker { margin-bottom: var(--s2); }

  .cols { padding-top: var(--s5); gap: var(--s5); }

  /* 清单变成分组圆角大行 */
  .item { grid-template-columns: 34px 1fr auto; gap: var(--s3);
          align-items: center; min-height: 64px; padding: var(--s3) var(--s4);
          background: var(--bg); border: 1px solid var(--rule); border-bottom: 0; }
  .item:first-of-type { border-top: 1px solid var(--rule); border-radius: 14px 14px 0 0; }
  .item:last-of-type { border-bottom: 1px solid var(--rule); border-radius: 0 0 14px 14px; }
  .item .no { width: 30px; height: 30px; border-radius: 9px; background: var(--sunk);
              display: grid; place-items: center; font-size: 11px; }
  .item[data-t="crit"] .no { background: color-mix(in oklch, var(--crit) 14%, var(--bg)); color: var(--crit); }
  .item h3 { font-size: 15px; }
  .item .v { font-size: 19px; }

  .block { margin-top: var(--s5); padding-top: var(--s4); border-top-width: 1px; border-top-color: var(--rule); }
  .figs { grid-template-columns: repeat(2, 1fr); gap: var(--s4);
          background: var(--bg); border: 1px solid var(--rule); border-radius: 14px; padding: var(--s4); }
  .fig b { font-size: 24px; }

  .fleet { background: var(--bg); border: 1px solid var(--rule); border-radius: 14px; padding: var(--s4); }
  .bars i { width: 8px; height: 18px; }

  /* 设备：表格换卡片，横滚窄表在手机上不可用 */
  .tbl-wrap { display: none; }
  .dcards { display: block; }
  .dcard { display: grid; grid-template-columns: 1fr auto; gap: 4px var(--s3);
           align-items: center; width: 100%; text-align: left; min-height: 68px;
           padding: var(--s3) var(--s4); background: var(--bg);
           border: 1px solid var(--rule); border-bottom: 0; cursor: pointer; }
  .dcard:first-child { border-radius: 14px 14px 0 0; }
  .dcard:last-child { border-bottom: 1px solid var(--rule); border-radius: 0 0 14px 14px; }
  .dcard:active { background: var(--raise); }
  .dcard-sn { font-family: var(--mono); font-weight: 600; font-size: 15px; }
  .dcard-meta { grid-column: 1 / -1; font: 400 12px/1.5 var(--mono); color: var(--ink-3); }

  .empty { border: 1px solid var(--rule); border-radius: 14px; background: var(--bg); }

  .drawer { width: 100%; border-left: 0; }
  .toasts { left: var(--s4); right: var(--s4); bottom: calc(76px + env(safe-area-inset-bottom)); }

  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-sticky);
    display: grid; grid-template-columns: repeat(4, 1fr);
    background: color-mix(in oklch, var(--bg) 95%, transparent);
    backdrop-filter: saturate(150%) blur(12px);
    border-top: 1px solid var(--rule); padding-bottom: env(safe-area-inset-bottom);
  }
  .tab { display: flex; flex-direction: column; align-items: center; justify-content: center;
         gap: 4px; min-height: 58px; font-size: 11px; color: var(--ink-3);
         transition: color var(--dur) var(--ease); }
  .tab[aria-current="page"] { color: var(--ink); font-weight: 500; }
  .tab .ic { width: 20px; height: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
