/* appl console. Quiet surfaces, one accent, colour only where it carries meaning. */
:root {
  color-scheme: light;
  --bg: #f6f6f3; --surface: #ffffff; --surface-2: #fafaf7; --surface-3: #f1f1ed;
  --line: #e8e8e3; --line-strong: #d7d7d0;
  --ink: #1c1c1a; --ink-2: #55554f; --ink-3: #85857d;
  --accent: #2b5bd7; --accent-hover: #2450c2; --accent-soft: #edf2fe; --accent-ink: #ffffff;
  --good: #1a8050; --good-soft: #e7f5ee; --warn: #9a6408; --warn-soft: #fcf3df; --bad: #bf3429; --bad-soft: #fcebe9; --info: #4d5d7a; --info-soft: #eef1f6;
  --shadow-sm: 0 1px 2px rgba(28, 28, 26, .05); --shadow-lg: 0 12px 36px rgba(28, 28, 26, .16), 0 2px 6px rgba(28, 28, 26, .06);
  --radius: 12px; --radius-sm: 8px;
  --font: "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", -apple-system, "Segoe UI", system-ui, "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  color-scheme: dark;
  --bg: #131312; --surface: #1c1c1a; --surface-2: #20201e; --surface-3: #282825;
  --line: #2e2e2b; --line-strong: #3c3c38;
  --ink: #ececE8; --ink-2: #b1b1aa; --ink-3: #85857e;
  --accent: #7ba2ff; --accent-hover: #93b4ff; --accent-soft: #1d2740; --accent-ink: #0d1424;
  --good: #5ec28d; --good-soft: #15291f; --warn: #dfae5a; --warn-soft: #2d2413; --bad: #ef8177; --bad-soft: #321a18; --info: #9fb0cf; --info-soft: #1e2430;
  --shadow-sm: none; --shadow-lg: 0 16px 44px rgba(0, 0, 0, .55);
} }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131312; --surface: #1c1c1a; --surface-2: #20201e; --surface-3: #282825;
  --line: #2e2e2b; --line-strong: #3c3c38;
  --ink: #ececE8; --ink-2: #b1b1aa; --ink-3: #85857e;
  --accent: #7ba2ff; --accent-hover: #93b4ff; --accent-soft: #1d2740; --accent-ink: #0d1424;
  --good: #5ec28d; --good-soft: #15291f; --warn: #dfae5a; --warn-soft: #2d2413; --bad: #ef8177; --bad-soft: #321a18; --info: #9fb0cf; --info-soft: #1e2430;
  --shadow-sm: none; --shadow-lg: 0 16px 44px rgba(0, 0, 0, .55);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.6 var(--font); -webkit-font-smoothing: antialiased; font-feature-settings: "tnum"; }
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: .92em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* Shell */
.app { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; padding: 18px 12px 12px; border-right: 1px solid var(--line); background: var(--bg); }
.brand { display: flex; align-items: center; gap: 9px; padding: 2px 10px 14px; color: var(--ink); font-size: 15px; font-weight: 650; letter-spacing: .01em; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 700; }
.rail-search { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink-3); font: inherit; font-size: 13px; cursor: pointer; }
.rail-search:hover { border-color: var(--line-strong); color: var(--ink-2); }
.rail-search kbd { margin-left: auto; font: 11px var(--mono); color: var(--ink-3); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.nav a.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line); }
.nav-badge { margin-left: auto; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.conn { display: flex; align-items: center; gap: 8px; padding: 6px 10px; color: var(--ink-3); font-size: 12px; }
.conn .dot { background: var(--ink-3); }
.conn.is-live .dot { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.user-btn { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 10px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--ink-2); font: inherit; cursor: pointer; text-align: left; }
.user-btn:hover { background: var(--surface-3); color: var(--ink); }
.avatar { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-3); color: var(--ink-2); font-size: 11px; font-weight: 600; }
.content { min-width: 0; padding: 26px 32px 56px; }
.content-inner { max-width: 1180px; margin: 0 auto; }

/* Page head */
.page-head { margin-bottom: 20px; }
.back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 8px; color: var(--ink-3); font-size: 13px; }
.back:hover { color: var(--ink); text-decoration: none; }
.page-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-title h1 { font-size: 22px; font-weight: 650; line-height: 1.35; letter-spacing: -.005em; }
.page-title p { margin-top: 3px; color: var(--ink-2); }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 6px 13px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: inherit; font-weight: 500; white-space: nowrap; cursor: pointer; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); text-decoration: none; }
.btn:active { background: var(--surface-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn[aria-busy="true"] { opacity: .65; cursor: progress; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--surface); border-color: var(--bad); color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn-ghost { background: none; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--ink); }
.btn-sm { min-height: 28px; padding: 3px 10px; font-size: 13px; }
.btn-xs { min-height: 22px; padding: 2px 5px; }
.btn-icon { padding: 6px 8px; }
.btn-link { padding: 0; min-height: 0; border: 0; background: none; color: var(--accent); font-weight: 500; }
.btn-link:hover { background: none; text-decoration: underline; }

/* Status vocabulary */
.dot { display: inline-block; flex: none; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); white-space: nowrap; }
.status-good { color: var(--good); } .status-warn, .status-warning { color: var(--warn); } .status-bad, .status-critical { color: var(--bad); } .status-off { color: var(--ink-3); } .status-info { color: var(--info); }
.status-live .dot { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.status-live { color: var(--ink); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 0 7px; border-radius: 6px; background: var(--surface-3); color: var(--ink-2); font-size: 12px; line-height: 20px; white-space: nowrap; }
.chip-good { background: var(--good-soft); color: var(--good); } .chip-warn { background: var(--warn-soft); color: var(--warn); } .chip-bad { background: var(--bad-soft); color: var(--bad); } .chip-accent { background: var(--accent-soft); color: var(--accent); }
.muted { color: var(--ink-3); } .sub { display: block; color: var(--ink-3); font-size: 12.5px; }
.strong { font-weight: 600; } .num { font-variant-numeric: tabular-nums; } .nowrap { white-space: nowrap; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Banners and notes */
.banner { display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.banner + .banner { margin-top: 8px; }
.banner > .icon { margin-top: 3px; }
.banner-text { flex: 1; min-width: 0; }
.banner-text strong { display: block; font-weight: 600; }
.banner-text span { color: var(--ink-2); font-size: 13px; }
.banner-actions { display: flex; gap: 6px; align-self: center; flex: none; }
.banner-critical, .banner-bad { background: var(--bad-soft); border-color: transparent; } .banner-critical > .icon, .banner-bad > .icon { color: var(--bad); }
.banner-warning, .banner-warn { background: var(--warn-soft); border-color: transparent; } .banner-warning > .icon, .banner-warn > .icon { color: var(--warn); }
.banner-info { background: var(--info-soft); border-color: transparent; } .banner-info > .icon { color: var(--info); }
.banners { margin-bottom: 18px; }
.note { padding: 9px 12px; border-radius: var(--radius-sm); background: var(--surface-3); color: var(--ink-2); font-size: 13px; }
.note-warn { background: var(--warn-soft); color: var(--warn); } .note-bad { background: var(--bad-soft); color: var(--bad); } .note-good { background: var(--good-soft); color: var(--good); }

/* Cards */
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 16px 0; }
.card-head h3 { font-size: 14.5px; font-weight: 600; }
.card-sub { margin-top: 1px; color: var(--ink-3); font-size: 13px; }
.card-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.card-body { padding: 12px 16px 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; align-items: start; }
.grid-2 > .card + .card, .stack-0 > .card + .card { margin-top: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack > .card + .card { margin-top: 0; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px 18px; margin: 0; }
.kv dt { color: var(--ink-3); font-size: 12.5px; }
.kv dd { margin: 1px 0 0; font-weight: 500; overflow-wrap: anywhere; }
.setting { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 13px 16px; border-top: 1px solid var(--line); }
.setting:first-child { border-top: 0; }
.card-head + .setting, .card-head + div > .setting:first-child { border-top: 0; }
.setting-text { min-width: 0; }
.setting-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 550; }
.setting-desc { margin-top: 1px; color: var(--ink-3); font-size: 13px; }
.setting-ctl { display: flex; align-items: center; gap: 10px; flex: none; }
.setting-note { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; margin-top: 5px; font-size: 13px; }
.setting-note.is-applying { color: var(--accent); } .setting-note.is-failed { color: var(--bad); } .setting-note.is-drifted { color: var(--warn); } .setting-note.is-offline { color: var(--ink-3); }

/* Switch */
.switch { position: relative; flex: none; width: 38px; height: 22px; padding: 0; border: 0; border-radius: 11px; background: var(--line-strong); cursor: pointer; transition: background .16s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch-knob { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .16s; }
.switch[aria-checked="true"] .switch-knob { transform: translateX(16px); }
.switch:disabled { cursor: not-allowed; opacity: .55; }
.switch.is-busy { opacity: 1; background-image: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .4) 50%, transparent 70%); background-size: 200% 100%; animation: shimmer 1.1s linear infinite; }
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }
.segmented { display: inline-flex; padding: 2px; border-radius: var(--radius-sm); background: var(--surface-3); }
.segmented button { padding: 3px 11px; border: 0; border-radius: 6px; background: none; color: var(--ink-2); font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
.segmented button.is-on { background: var(--surface); color: var(--ink); font-weight: 550; box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }
.segmented button:disabled { cursor: not-allowed; }
.segmented.is-busy { opacity: .7; }

/* Tabs */
.tabs { position: sticky; top: 0; z-index: 3; display: flex; gap: 2px; margin: 0 -8px 18px; padding: 0 8px; border-bottom: 1px solid var(--line); background: var(--bg); overflow-x: auto; scrollbar-width: none; }
.tabs a { display: inline-flex; align-items: center; gap: 6px; padding: 10px 11px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--ink-2); font-weight: 500; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.is-active { border-bottom-color: var(--ink); color: var(--ink); font-weight: 600; }
.tab-badge { padding: 0 6px; border-radius: 8px; background: var(--surface-3); color: var(--ink-2); font-size: 11.5px; font-weight: 500; line-height: 17px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 9px 16px; border-bottom: 1px solid var(--line); color: var(--ink-3); font-size: 12.5px; font-weight: 500; text-align: left; white-space: nowrap; }
td { padding: 10px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.t-right, th.t-right { text-align: right; }
td.t-actions { text-align: right; white-space: nowrap; }
td.t-actions .btn + .btn { margin-left: 4px; }
.row-title { font-weight: 550; overflow-wrap: anywhere; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 13px; }
.pager-buttons { display: flex; gap: 6px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 12px 16px; }
.key-selection-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.key-selection-summary { color: var(--ink-2); font-size: 12.5px; }
.key-bulk-toolbar { padding-top: 0; border-bottom: 1px solid var(--line); }
.key-member-check { width: 48px; }
.key-member-select { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--surface); color: var(--accent); cursor: pointer; }
.key-member-select[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.key-order-editor { margin-top: 12px; }
.key-order-list { max-height: min(52vh, 540px); overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.key-order-row { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-bottom: 1px solid var(--line); background: var(--surface); }
.key-order-row:last-child { border-bottom: 0; }
.key-order-row.is-dragging { opacity: .55; }
.key-order-row.is-drag-over { box-shadow: inset 0 3px 0 var(--accent); background: var(--accent-soft); }
.key-order-grip { display: flex; padding: 6px 2px; border: 0; color: var(--ink-3); background: none; cursor: grab; touch-action: none; }
.key-order-number { min-width: 22px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.key-order-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.key-order-controls { display: flex; gap: 3px; flex: none; }
.key-order-reload { margin-top: 10px; }
@media (max-width: 600px) { .key-order-row { flex-wrap: wrap; } .key-order-controls { margin-left: auto; } .key-selection-summary { width: 100%; } }
.empty { padding: 36px 20px; color: var(--ink-3); text-align: center; }
.empty strong { display: block; color: var(--ink-2); font-size: 14.5px; font-weight: 600; }
.empty p { margin: 3px auto 12px; max-width: 460px; font-size: 13px; }

/* Forms */
.field { display: block; }
.field + .field, .step-fields > * + * { margin-top: 12px; }
.field-label { display: block; margin-bottom: 4px; color: var(--ink-2); font-size: 13px; font-weight: 500; }
.field-hint { display: block; margin-top: 4px; color: var(--ink-3); font-size: 12.5px; }
.input { width: 100%; min-height: 36px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: inherit; }
.input:hover { border-color: var(--ink-3); }
.input:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); outline-offset: 0; }
textarea.input { resize: vertical; line-height: 1.5; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row .field + .field { margin-top: 0; }
.field + .form-row, .form-row + .field, .form-row + .form-row { margin-top: 12px; }
.check { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; }
.check input { margin-top: 4px; }
.search-input { display: flex; align-items: center; gap: 8px; min-width: 260px; flex: 0 1 340px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink-3); }
.search-input input { flex: 1; min-width: 0; min-height: 34px; border: 0; outline: 0; background: none; color: var(--ink); font: inherit; }
.search-input:focus-within { border-color: var(--accent); }

/* Dialog */
.dialog { width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 0; border-radius: 14px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); overflow: hidden; }
.dialog[open] { display: flex; animation: rise .16s ease-out; }
.dialog-wide { width: min(780px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(20, 20, 18, .38); animation: fade .16s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade { from { opacity: 0; } }
.dialog form { display: flex; flex-direction: column; width: 100%; min-height: 0; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 18px 10px; }
.dialog-head h2 { font-size: 16px; font-weight: 650; }
.dialog-head p { margin-top: 2px; color: var(--ink-3); font-size: 13px; }
.dialog-body { flex: 1; min-height: 0; padding: 4px 18px 16px; overflow-y: auto; }
.dialog-error { margin-top: 12px; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--bad-soft); color: var(--bad); font-size: 13px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2); }
.prose p + p { margin-top: 8px; }
.prose { color: var(--ink-2); }
.staged-preview:not(:empty) { margin-top: 14px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.staged-preview h4 { margin-bottom: 4px; font-size: 13.5px; font-weight: 600; }
pre.block { margin: 8px 0 0; padding: 10px 12px; max-height: 280px; overflow: auto; border-radius: var(--radius-sm); background: var(--surface-3); font: 12.5px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }

/* Menu */
.menu-pop { position: fixed; z-index: 1000; min-width: 170px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-lg); }
.menu-pop button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: 0; border-radius: 6px; background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.menu-pop button:hover, .menu-pop button:focus-visible { background: var(--surface-3); outline: 0; }
.menu-pop button:disabled { opacity: .45; cursor: not-allowed; }
.menu-pop .is-danger { color: var(--bad); }

/* Toast */
.toasts { position: fixed; bottom: 20px; left: 50%; z-index: 1100; display: flex; flex-direction: column; align-items: center; gap: 8px; transform: translateX(-50%); pointer-events: none; }
.toast { max-width: 560px; padding: 9px 15px; border-radius: 10px; background: var(--ink); color: var(--bg); font-size: 13.5px; box-shadow: var(--shadow-lg); animation: rise .18s ease-out; }
.toast-bad { background: var(--bad); color: #fff; }
.toast.is-leaving { opacity: 0; transition: opacity .2s; }

/* Fleet */
.summary { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-bottom: 16px; color: var(--ink-2); }
.summary b { color: var(--ink); font-size: 15px; font-weight: 650; }
.device-list { display: flex; flex-direction: column; }
.device-row { display: grid; grid-template-columns: minmax(200px, 1.5fr) minmax(0, 2.2fr) 112px 18px; align-items: center; gap: 16px; padding: 13px 16px; border-top: 1px solid var(--line); color: inherit; }
.device-row:first-child { border-top: 0; }
.device-row:hover { background: var(--surface-2); text-decoration: none; }
.device-name { font-weight: 600; overflow-wrap: anywhere; }
.device-main { display: flex; gap: 11px; align-items: flex-start; min-width: 0; }
.device-main .dot { margin-top: 8px; }
.device-main.is-online .dot { color: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.device-main.is-offline .dot { color: var(--ink-3); }
.device-facts { display: flex; flex-wrap: wrap; gap: 4px 6px; min-width: 0; }
.device-seen { color: var(--ink-3); font-size: 13px; text-align: right; white-space: nowrap; }
.device-row > .icon { color: var(--ink-3); }

/* Device page */
.device-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.device-title h1 { font-size: 22px; font-weight: 650; }
.title-edit { color: var(--ink-3); }
.device-meta { display: flex; align-items: center; gap: 4px 14px; flex-wrap: wrap; margin-top: 4px; color: var(--ink-2); font-size: 13.5px; }
.state-card { display: flex; flex-direction: column; }
.state-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; align-items: stretch; }
.state-grid > .card + .card { margin-top: 0; }
.health-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.is-stale { opacity: .72; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; padding: 8px 16px; border-top: 1px solid var(--line); }
.timeline li:first-child { border-top: 0; }
.timeline .dot { margin-top: 8px; color: var(--line-strong); }
.timeline .lv-warning .dot, .timeline .lv-warning.dot { color: var(--warn); }
.timeline .lv-critical.dot { color: var(--bad); }
.tl-title { min-width: 0; overflow-wrap: anywhere; }
.tl-sub { display: block; color: var(--ink-3); font-size: 12.5px; }
.tl-time { color: var(--ink-3); font-size: 12.5px; white-space: nowrap; }
.task-row { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--line); }
.task-row:first-child { border-top: 0; }
.task-spin { color: var(--accent); }

/* Steps editor */
.editor-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.editor-grid > .card + .card { margin-top: 0; }
.step-list { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px 16px; }
.step { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.step[open] { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.step.is-drag-over { border-color: var(--accent); }
.step > summary { display: grid; grid-template-columns: 22px 26px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 9px 10px; list-style: none; cursor: pointer; }
.step > summary::-webkit-details-marker { display: none; }
.step-grip { color: var(--ink-3); cursor: grab; }
.step-no { color: var(--ink-3); font: 12.5px var(--mono); }
.step-name { font-weight: 550; }
.step-summary { display: block; color: var(--ink-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-body { padding: 4px 12px 14px 12px; border-top: 1px solid var(--line); }
.step-tools { display: flex; gap: 2px; }
.savebar { position: sticky; bottom: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-lg); }
.review-steps { margin: 8px 0 0; padding-left: 22px; }
.review-steps li { padding: 3px 0; }
.review-steps small { display: block; color: var(--ink-3); }
.plan-card { display: block; padding: 14px 16px; color: inherit; }
.plan-card:hover { background: var(--surface-2); text-decoration: none; }
.plan-card h3 { font-size: 15px; font-weight: 600; }
.plan-card p { margin-top: 2px; color: var(--ink-2); font-size: 13px; }
.version-row { border-top: 1px solid var(--line); }
.version-row:first-child { border-top: 0; }
.version-row > summary { display: flex; align-items: center; gap: 10px; padding: 11px 16px; cursor: pointer; list-style: none; }
.version-row > summary::-webkit-details-marker { display: none; }
.version-row .review-steps { padding: 0 16px 12px 38px; }

/* Palette */
.palette-input { width: 100%; padding: 13px 16px; border: 0; border-bottom: 1px solid var(--line); outline: 0; background: none; color: var(--ink); font: inherit; font-size: 15px; }
.palette-list { max-height: 340px; padding: 4px; overflow-y: auto; }
.palette-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; border-radius: 8px; background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.palette-item.is-on, .palette-item:hover { background: var(--surface-3); }
.palette-item small { margin-left: auto; color: var(--ink-3); }

/* Auth */
.auth { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.auth-card { width: min(380px, 100%); }
.auth-card.is-wide { width: min(480px, 100%); }
.auth-card .brand { padding: 0 0 22px; font-size: 16px; }
.auth-card h1 { font-size: 21px; font-weight: 650; }
.auth-card > p { margin: 3px 0 20px; color: var(--ink-2); }
.auth-card .btn { width: 100%; margin-top: 16px; }

/* Loading */
.sk { border-radius: var(--radius); background: var(--surface-3); animation: pulse 1.3s ease-in-out infinite; }
.sk-title { width: 220px; height: 30px; margin-bottom: 20px; }
.sk-card { height: 120px; margin-bottom: 14px; }
@keyframes pulse { 50% { opacity: .55; } }
.page-failure { padding: 60px 20px; text-align: center; }
.page-failure h2 { font-size: 16px; }
.page-failure p { margin: 6px 0 14px; color: var(--ink-2); }

/* Small helpers */
.field + .note, .note + .field, .field + .btn, .note + .note { margin-top: 12px; }
.grow { flex: 1; }
.field-gap { height: 12px; }
.narrow { max-width: 420px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.block-title { margin: 16px 0 0; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.task-message { margin-top: 12px; padding: 9px 12px; border-radius: var(--radius-sm); background: var(--surface-3); color: var(--ink-2); }
.run-note { padding: 0 16px 10px 42px; color: var(--ink-2); font-size: 13px; }
.plain-details > summary { color: var(--ink-2); cursor: pointer; font-size: 13px; }
.plain-details[open] > summary { margin-bottom: 4px; }
.version-row[open] > summary > .icon:first-child { transform: rotate(90deg); }
.version-row > summary > .icon:first-child { color: var(--ink-3); transition: transform .12s; }
.plan-list > .plan-card { border-top: 1px solid var(--line); }
.plan-list > .plan-card:first-child { border-top: 0; }
.filter-row { display: flex; flex-wrap: wrap; gap: 4px; }
.filter { padding: 3px 11px; border: 0; border-radius: 15px; background: none; color: var(--ink-2); font: inherit; font-size: 13px; cursor: pointer; }
.filter:hover { background: var(--surface-3); }
.filter.is-on { background: var(--ink); color: var(--bg); font-weight: 550; }
.timeline.is-plain { margin-top: 6px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.timeline.is-plain li { padding: 7px 12px; }
.palette-dialog { top: 14vh; margin-top: 0; }
.palette-dialog[open] { display: block; }
.palette { display: flex; flex-direction: column; }
.savebar .dialog-error { margin: 0; }
.task-row .setting-text .btn-link { display: inline; text-align: left; white-space: normal; }

/* Small screens */
.rail-toggle { display: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .rail { position: sticky; z-index: 5; height: auto; flex-direction: row; align-items: center; gap: 2px; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
  .brand { padding: 0 8px 0 2px; } .brand span:last-child { display: none; }
  .rail-search { width: auto; margin: 0; padding: 7px; } .rail-search span, .rail-search kbd { display: none; }
  .nav { flex-direction: row; } .nav a { padding: 7px 9px; white-space: nowrap; } .nav a span { display: none; } .nav a.is-active span { display: inline; }
  .rail-foot { flex-direction: row; margin: 0 0 0 auto; } .conn span, .user-btn span:last-child { display: none; }
  .content { padding: 18px 16px 48px; }
  .tabs { top: 0; margin: 0 -16px 16px; padding: 0 16px; }
  .grid-2, .state-grid { grid-template-columns: minmax(0, 1fr); }
  .device-row { grid-template-columns: minmax(0, 1fr) 16px; gap: 6px 10px; }
  .device-facts { grid-column: 1; grid-row: 2; } .device-seen { grid-column: 1; grid-row: 3; text-align: left; } .device-row > .icon { grid-column: 2; grid-row: 1 / span 3; align-self: center; }
  .editor-grid { grid-template-columns: minmax(0, 1fr); }
  .form-row { grid-template-columns: minmax(0, 1fr); } .form-row .field + .field { margin-top: 12px; }
  .search-input { min-width: 0; flex: 1 1 100%; }
  .setting { gap: 12px; }
  table.is-compact th { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
/* V20 device admission and operations workspace. Tokens also work in dark mode. */
.fleet-work { display: grid; gap: 20px; }
.fleet-work .page-head, .fleet-work .banners { margin: 0; }
.fleet-metrics { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; }
.fleet-metric { --metric-ink: var(--accent); --metric-soft: var(--accent-soft); padding: 15px 17px 13px; display: grid; gap: 3px; min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); text-align: left; font: inherit; cursor: pointer; box-shadow: var(--shadow-sm); }
.fleet-metric[data-tone=pending] { --metric-ink: var(--warn); --metric-soft: var(--warn-soft); }
.fleet-metric[data-tone=managed] { --metric-ink: var(--good); --metric-soft: var(--good-soft); }
.fleet-metric[data-tone=revoked] { --metric-ink: var(--ink-2); --metric-soft: var(--surface-3); }
.fleet-metric:hover, .fleet-metric[aria-pressed=true] { border-color: var(--metric-ink); }
.fleet-metric[aria-pressed=true] { box-shadow: inset 0 0 0 1px var(--metric-ink); }
.fleet-metric:focus-visible, .fleet-name:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.metric-line, .metric-detail { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.metric-line { font-weight: 600; } .metric-line .icon { width: 28px; height: 28px; padding: 5px; color: var(--metric-ink); background: var(--metric-soft); border-radius: 8px; }
.fleet-metric b { font-size: 30px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.15; letter-spacing: -.03em; }
.metric-detail { font-size: 12px; color: var(--ink-2); margin-top: 5px; } .metric-detail .icon { width: 13px; height: 13px; color: var(--metric-ink); }
.fleet-table { min-width: 0; } .fleet-table .card-head { padding: 18px 18px 0; } .fleet-table .card-head h3 { font-size: 17px; }
.fleet-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 18px; }
.fleet-toolbar .search-input { width: min(100%,290px); } .fleet-filter-label { font-size: 13px; margin-left: 4px; color: var(--ink-2); }
.fleet-name { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; } .fleet-name strong { font-size: 14px; } .fleet-name small { display: block; color: var(--ink-2); font-size: 11px; }
.unit-icon, .device-ticket > .icon { display: inline-grid; place-items: center; width: 34px; height: 38px; flex: none; color: var(--accent); background: var(--accent-soft); border-radius: 9px; }
.fleet-links, .row-actions, .device-quick, .journey-meta, .journey-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fleet-links { column-gap: 12px; row-gap: 4px; }
.device-ticket { padding: 12px; margin-bottom: 15px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); display: flex; gap: 10px; align-items: center; }
.device-ticket > .icon { padding: 6px; }
.journey-panel { margin: 0 0 18px; padding: 18px 20px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); border-top: 3px solid var(--accent); }
.journey-panel[data-stage=guarding] { border-top-color: var(--good); } .journey-panel[data-stage=pending],.journey-panel[data-stage=attention] { border-top-color: var(--warn); }
.journey-copy { flex: 1 1 265px; min-width: 0; }
.overline { color: var(--ink-2); font-size: 12px; font-weight: 600; letter-spacing: .04em; }
.journey-copy h2 { margin: 3px 0; font-size: 21px; } .journey-copy p { margin: 3px 0 8px; color: var(--ink-2); }
.journey-progress { flex: 0 1 180px; min-width: 130px; font-size: 12px; } .journey-progress > * { display: block; } .journey-progress progress { appearance: auto; accent-color: var(--accent); width: 100%; height: 9px; margin: 5px 0; }
.journey-actions { justify-content: flex-end; }
.device-quick { margin: 0 0 12px; padding: 12px 15px; gap: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.device-quick strong { margin-right: 5px; }
@media (max-width: 960px) { .fleet-metrics { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media (max-width: 610px) {
  .fleet-work { gap: 14px; } .fleet-metrics { gap: 8px; } .fleet-metric { padding: 11px 12px; }
  .fleet-metric b { font-size: 26px; } .metric-detail .icon { display: none; } .fleet-toolbar .search-input { width: 100%; }
  .fleet-table .table-wrap { overflow: visible; } .fleet-table table, .fleet-table tbody, .fleet-table tr, .fleet-table td { display: block; width: auto; }
  .fleet-table thead { display: none; } .fleet-table tr { margin: 0 15px; padding: 8px 0; border-top: 1px solid var(--line); }
  .fleet-table td { border: 0; white-space: normal; padding: 4px 0; display: flex; align-items: baseline; flex-wrap: wrap; gap: 5px; }
  .fleet-table td:not(:first-child)::before { content: attr(data-label); width: 66px; color: var(--ink-3); font-size: 12px; flex: none; }
  .fleet-table td:first-child { padding: 4px 0 7px; } .journey-panel { padding: 14px; }
}
.journey-checks { display: grid; grid-template-columns: repeat(2,auto); align-items: center; gap: 5px 14px; }
.journey-checks small { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); } .journey-checks .icon { width: 13px; height: 13px; }
.ops-filterbar, .ops-filters, .ops-actions, .ops-picks, .ops-entry, .ops-create { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.ops-filterbar { justify-content:space-between; padding:0 18px 12px; align-items:flex-end; }
.ops-filters > .field { margin:0; min-width:118px; }
.ops-filters .input { min-height:32px; max-width:210px; }
.ops-actions { gap:5px; }
.ops-picks { padding:8px 18px; border-top:1px solid var(--line); color:var(--ink-2); font-size:12px; }
.ops-picks label { display:inline-flex; align-items:center; gap:6px; }
.ops-check { accent-color:var(--accent); width:16px; height:16px; margin:0; vertical-align:middle; }
.ops-pick-cell { width:44px; }
.ops-placement { color:var(--ink); background:transparent; border:0; cursor:pointer; text-align:left; font:inherit; padding:3px; border-radius:4px; }
.ops-placement:hover { background:var(--accent-soft); }
.ops-placement small, .ops-entry small { display:block; font-size:12px; color:var(--ink-2); }
.ops-placement small .icon { width:13px; height:13px; margin-right:3px; }
.ops-create { align-items:flex-end; margin:12px 0; }
.ops-create .field { flex:1; margin:0; min-width:100px; }
.ops-directory { max-height:46vh; overflow-y:auto; }
.ops-entry { border-bottom:1px solid var(--line); padding:9px 0; }
.ops-entry > span { flex:1; min-width:0; overflow-wrap:anywhere; }
@media(max-width:610px) {
  .ops-filters, .ops-actions { width:100%; }
  .ops-filters > .field { flex:1; min-width:95px; }
  .ops-filters .input { max-width:100%; }
  .fleet-table td.ops-pick-cell { padding:8px 0 0; }
  .fleet-table td.ops-pick-cell::after { content:"选择设备"; color:var(--ink-3); font-size:12px; }
  .fleet-table td:nth-child(2)::before { display:none; }
}
.ops-placement strong > .icon { opacity:.6; width:12px; height:12px; }
