/* codr console — base, layout, components, pages. Tokens live in tokens.css.
   Principles: quiet surfaces, generous whitespace, few words; numbers and actions carry the page. */

/* ================= base ================= */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 var(--fs-md)/1.6 var(--font-sans);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.3; }
h1 { font: 600 var(--fs-2xl)/1.25 var(--font-serif); letter-spacing: -.005em; }
h2 { font-size: 15px; }
h3 { font-size: var(--fs-md); }
p { margin: 0; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
code, kbd, .mono { font-family: var(--font-mono); font-size: .92em; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-sm); }
::selection { background: var(--harbor-100); color: #201e1a; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: var(--fs-xs); }
.nowrap { white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.stack.tight { gap: 10px; }
.spacer { flex: 1; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; } }

/* ================= icons ================= */
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.icon.sm { width: 16px; height: 16px; }
.icon.xs { width: 14px; height: 14px; vertical-align: -2px; }
.icon .fill { fill: currentColor; stroke: none; }

/* ================= app shell ================= */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--sb-bg); border-right: 1px solid var(--sb-border); z-index: 30; }
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 22px 20px 18px; }
.sb-brand a { display: flex; align-items: center; gap: 10px; color: var(--sb-strong); text-decoration: none; }
.sb-brand .wordmark { height: 16px; width: auto; color: var(--sb-strong); }
.sb-brand .env { margin-left: auto; font-size: 11px; color: var(--warning-text); background: var(--warning-bg); border-radius: var(--r-pill); padding: 0 8px; line-height: 20px; }
.sb-scroll { flex: 1; overflow-y: auto; padding: 0 12px 16px; scrollbar-width: thin; }
.nav-section { margin-top: 18px; }
.nav-section:first-child { margin-top: 2px; }
.nav-label { padding: 0 10px 6px; font-size: 12px; color: var(--sb-muted); }
.nav-item {
  display: flex; align-items: center; gap: 11px; height: 36px; padding: 0 10px; margin: 2px 0;
  border-radius: var(--r-md); color: var(--sb-text); text-decoration: none; font-size: var(--fs-md);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav-item .icon { color: var(--sb-muted); transition: color var(--t-fast) var(--ease); }
.nav-item:hover { background: var(--sb-hover); color: var(--sb-strong); text-decoration: none; }
.nav-item.active { background: var(--sb-active); color: var(--sb-strong); font-weight: 500; box-shadow: var(--shadow-1), 0 0 0 1px var(--sb-border); }
.nav-item.active .icon { color: var(--primary); }
.nav-item .count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); background: var(--warning-bg); color: var(--warning-text); font-size: 11.5px; font-weight: 600; line-height: 20px; text-align: center; }
.nav-item .count.info { background: var(--primary-soft-2); color: var(--primary-text); }
.sb-footer { padding: 12px; border-top: 1px solid var(--sb-border); }
.me-chip { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px; border: 0; border-radius: var(--r-md); background: transparent; color: var(--sb-strong); cursor: pointer; text-align: left; font: inherit; }
.me-chip:hover { background: var(--sb-hover); }
.me-chip .who { min-width: 0; flex: 1; line-height: 1.35; }
.me-chip .who b { display: block; font-weight: 500; font-size: var(--fs-sm); }
.me-chip .who span { font-size: 12px; color: var(--sb-muted); }
.me-chip .icon { color: var(--sb-muted); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar-mobile { display: none; }
.page { width: 100%; max-width: var(--page-max); margin: 0 auto; padding: 40px 48px 72px; }
.page-header { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.page-header .titles { min-width: 0; flex: 1; }
.page-header .eyebrow { font-size: var(--fs-sm); color: var(--muted); margin-bottom: 8px; display: flex; gap: 6px; align-items: center; }
.page-header .eyebrow a { color: var(--muted); }
.page-header .subtitle { color: var(--muted); margin-top: 8px; font-size: var(--fs-sm); display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; }
.page-header .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; overflow-y: hidden; padding-bottom: 1px; }
.tabs button { position: relative; padding: 10px 12px; color: var(--muted); font: 500 var(--fs-md) var(--font-sans); white-space: nowrap; background: none; border: 0; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); }
.tabs button.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--text); }
.tabs .badge { height: 18px; padding: 0 6px; font-size: 11px; }
.live { display: inline-flex; align-items: center; gap: 7px; }
.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--success-fill); }

/* ================= layout helpers ================= */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main-side { grid-template-columns: minmax(0, 1fr) 340px; }
.section { margin-top: 36px; }
.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.section-head h2 { flex: 1; }
.section-head .hint { color: var(--muted); font-size: var(--fs-sm); }

/* ================= cards ================= */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-1); min-width: 0; }
.card-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 18px 22px 0; min-height: 52px; }
.card-head h2 { flex: 1; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.card-head h2 .icon { color: var(--faint); }
.card-head .hint { color: var(--muted); font-size: var(--fs-xs); }
.card-body { padding: 16px 22px 22px; }
.card-body.flush { padding: 10px 0 6px; }
.card-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: center; }
.card.pad { padding: 22px; }

/* ================= KPI / stat tiles ================= */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px 20px; box-shadow: var(--shadow-1); min-width: 0; }
.kpi .label { color: var(--muted); font-size: var(--fs-sm); display: flex; align-items: center; gap: 6px; }
.kpi .label .icon { display: none; }
.kpi .value { margin-top: 10px; font-size: 30px; font-weight: 500; letter-spacing: -.02em; line-height: 1.1; white-space: nowrap; }
.kpi .value small { font-size: 14px; font-weight: 400; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.kpi .sub { margin-top: 8px; color: var(--muted); font-size: var(--fs-xs); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.kpi .spark { position: absolute; right: 18px; top: 18px; width: 76px; height: 26px; }
a.kpi { color: inherit; text-decoration: none; transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease); }
a.kpi:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); text-decoration: none; }
.kpi.alert .value { color: var(--warning-text); }
.kpi.alert::after { content: ""; position: absolute; top: 20px; right: 20px; width: 7px; height: 7px; border-radius: 50%; background: var(--warning-fill); }

/* ================= buttons ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 15px;
  border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface); color: var(--text);
  font: 500 var(--fs-md)/1 var(--font-sans); cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn[disabled], .btn.loading { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { color: var(--danger-text); border-color: var(--border-strong); }
.btn.danger:hover { background: var(--danger-bg); border-color: var(--danger-border); }
.btn.danger.solid { background: var(--danger-fill); border-color: var(--danger-fill); color: #fff; }
.btn.danger.solid:hover { filter: brightness(.95); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.sm { height: 30px; padding: 0 11px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn.lg { height: 44px; padding: 0 22px; font-size: 15px; }
.btn.block { width: 100%; }
.btn.icon-only { width: 36px; padding: 0; }
.btn.sm.icon-only { width: 30px; }
.btn .spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ================= forms ================= */
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--text); font: 400 var(--fs-md)/1.4 var(--font-sans);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }
.input[disabled], .select[disabled] { background: var(--surface-2); color: var(--muted); }
.input.mono { font-family: var(--font-mono); font-size: 13px; }
.input.sm, .select.sm { height: 32px; font-size: var(--fs-sm); padding: 0 10px; }
.select { appearance: none; padding-right: 32px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.select.sm { padding-right: 30px; }
.textarea { height: auto; min-height: 104px; padding: 10px 12px; resize: vertical; line-height: 1.6; }
.textarea.code { font-family: var(--font-mono); font-size: 12.5px; min-height: 420px; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > label, .field-label { font-size: var(--fs-sm); font-weight: 500; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.field .req { color: var(--danger-text); }
.field .hint { font-size: var(--fs-xs); color: var(--muted); }
.field .error { font-size: var(--fs-xs); color: var(--danger-text); }
.field .error:empty { display: none; }
.form { display: flex; flex-direction: column; gap: 18px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group > .icon { position: absolute; left: 12px; color: var(--faint); pointer-events: none; }
.input-group > .input { padding-left: 36px; }
.input-group > .addon { position: absolute; right: 5px; }
.input-suffix { display: flex; align-items: stretch; }
.input-suffix .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-suffix .suffix { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--border-strong); border-left: 0; border-radius: 0 var(--r-md) var(--r-md) 0; background: var(--surface-2); color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; color: var(--text-2); }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); cursor: pointer; }
.check.disabled { opacity: .5; cursor: not-allowed; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; color: var(--text-2); font-size: var(--fs-sm); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 32px; height: 18px; border-radius: var(--r-pill); background: var(--border-strong); position: relative; transition: background var(--t-fast) var(--ease); flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform var(--t-fast) var(--ease); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { box-shadow: var(--focus-ring); }
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border-radius: var(--r-md); }
.segmented button { height: 28px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font: 500 var(--fs-sm)/1 var(--font-sans); cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.segmented button:hover { color: var(--text); }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .input-group { width: 240px; }
.toolbar .select { width: auto; min-width: 120px; }
.toolbar .count { color: var(--muted); font-size: var(--fs-sm); }
.toolbar .count b { color: var(--text); font-weight: 600; }
.tag-input { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 38px; padding: 5px 7px; border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface); cursor: text; }
.tag-input:focus-within { border-color: var(--primary); box-shadow: var(--focus-ring); }
.tag-input input { flex: 1; min-width: 120px; border: 0; outline: none; background: transparent; color: var(--text); font: 400 var(--fs-md) var(--font-sans); height: 26px; }
.tag-input.mono input, .tag-input.mono .tag { font-family: var(--font-mono); font-size: 12.5px; }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 4px 0 9px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--border); font-size: var(--fs-sm); max-width: 100%; }
.tag.invalid { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }
.tag button { display: inline-flex; border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px; border-radius: 4px; }
.tag button:hover { color: var(--text); background: var(--surface-3); }

/* ================= badges ================= */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: var(--r-pill); font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--surface-2); color: var(--text-2); line-height: 1; }
.badge .icon { width: 13px; height: 13px; vertical-align: 0; }
.badge.primary { background: var(--primary-soft); color: var(--primary-text); }
.badge.success { background: var(--success-bg); color: var(--success-text); }
.badge.warning { background: var(--warning-bg); color: var(--warning-text); }
.badge.danger { background: var(--danger-bg); color: var(--danger-text); }
.badge.ink { background: var(--surface-3); color: var(--text); }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.role { display: inline-flex; align-items: center; gap: 7px; font-size: var(--fs-sm); color: var(--text-2); white-space: nowrap; }
.role i { width: 7px; height: 7px; border-radius: 2px; background: var(--border-strong); }
.role.admin i { background: var(--ad-ink); }
.score { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.score .bar { width: 40px; height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; position: relative; }
.score .bar i { position: absolute; inset: 0 auto 0 0; border-radius: 2px; background: var(--faint); }
.score.good .bar i { background: var(--success-fill); }
.score.warn .bar i { background: var(--warning-fill); }
.score.bad .bar i { background: var(--danger-fill); }
.score.bad { color: var(--danger-text); }
.score .tag-low { font-size: 11px; font-weight: 500; color: var(--danger-text); }
.models { white-space: normal; }
.models .m { white-space: nowrap; }
.models .n { margin-left: 3px; color: var(--muted); font-variant-numeric: tabular-nums; }
.models .sep { margin: 0 6px; color: var(--faint); }
.reasons { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.reasons span { font-size: 12px; color: var(--muted); }
.reasons span + span::before { content: "· "; color: var(--faint); }
.yes { color: var(--text-2); display: inline-flex; align-items: center; gap: 5px; }
.yes .icon { color: var(--success-text); }
.no { color: var(--faint); }

/* ================= avatar / person ================= */
.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex: none; font-size: 12px; font-weight: 500; color: #fff; background: var(--harbor-600); user-select: none; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.lg { width: 52px; height: 52px; font-size: 18px; }
.avatar.c1 { background: #3f7f86; } .avatar.c2 { background: #5c6f8f; } .avatar.c3 { background: #7a6f95; }
.avatar.c4 { background: #5e8466; } .avatar.c5 { background: #93774a; } .avatar.c6 { background: #6d6a63; }
.person { display: flex; align-items: center; gap: 11px; min-width: 0; color: inherit; }
a.person:hover { text-decoration: none; }
.person .who { min-width: 0; line-height: 1.35; }
.person .who b { display: block; font-weight: 500; color: var(--text); }
.person .who span { font-size: 12px; color: var(--muted); }

/* ================= tables ================= */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-1); }
.card .table-wrap { border: 0; border-radius: 0; box-shadow: none; background: transparent; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th, .table td { padding: 13px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td.wrap { white-space: normal; }
.table th { color: var(--muted); font-size: 12.5px; font-weight: 500; white-space: nowrap; padding-top: 14px; padding-bottom: 12px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--t-fast) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.dim td { color: var(--faint); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.mono { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-2); }
.table td.actions { text-align: right; white-space: nowrap; color: var(--faint); }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover, .table th.sorted { color: var(--text); }
.table th .sort { display: inline-block; width: 10px; margin-left: 4px; color: var(--primary); }
.table.compact th, .table.compact td { padding: 11px 16px; }
.card .table th:first-child, .card .table td:first-child { padding-left: 22px; }
.card .table th:last-child, .card .table td:last-child { padding-right: 22px; }
.table .empty-row td { padding: 0; }
.table .empty-row:hover { background: none; }
.table .sub { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.table .sub.text-warn { color: var(--warning-text); }
.table .sub.text-bad { color: var(--danger-text); }
/* 冷却 / 错误 with the administrators' 刷新状态 next to it (codr v1.10) */
.state-refresh { display: flex; align-items: center; gap: 4px; }
.state-refresh .btn.icon-only { opacity: .55; }
tr:hover .state-refresh .btn.icon-only, .state-refresh .btn.icon-only:focus-visible { opacity: 1; }
.cell-bar { display: flex; align-items: center; gap: 12px; justify-content: flex-end; }
.cell-bar .track { width: 64px; height: 4px; border-radius: 2px; background: var(--surface-3); position: relative; overflow: hidden; flex: none; }
.cell-bar .track i { position: absolute; inset: 0 auto 0 0; background: var(--series-1); border-radius: 2px; }
.table-foot { display: flex; align-items: center; gap: 10px; padding: 12px 16px; color: var(--muted); font-size: var(--fs-sm); border-top: 1px solid var(--border); }
.table td.reasons-col { white-space: normal; min-width: 180px; max-width: 280px; }

/* ================= meters ================= */
.meter { position: relative; height: 8px; border-radius: var(--r-pill); background: var(--meter-track); }
.meter .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: var(--r-pill); background: var(--primary); max-width: 100%; transition: width var(--t-med) var(--ease); }
.meter.warn .fill { background: var(--warning-fill); }
.meter.bad .fill { background: var(--danger-fill); }
.meter .mark { position: absolute; top: -4px; bottom: -4px; width: 2px; border-radius: 1px; background: var(--text-2); opacity: .55; }
.meter-legend { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; font-size: var(--fs-xs); color: var(--muted); }
.quota .top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.quota .top .big { font-size: 30px; font-weight: 500; letter-spacing: -.02em; }
.quota .top .of { color: var(--muted); }
.quota .top .state { margin-left: auto; }

/* ================= callouts ================= */
.callout { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-md); border: 1px solid var(--info-border); background: var(--info-bg); color: var(--text); font-size: var(--fs-sm); }
.callout > .icon { color: var(--info-text); margin-top: 1px; }
.callout .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.callout .body b { font-weight: 600; }
.callout .body p { color: var(--text-2); }
.callout.warning { border-color: var(--warning-border); background: var(--warning-bg); }
.callout.warning > .icon { color: var(--warning-text); }
.callout.danger { border-color: var(--danger-border); background: var(--danger-bg); }
.callout.danger > .icon { color: var(--danger-text); }
.callout.success { border-color: var(--success-border); background: var(--success-bg); }
.callout.success > .icon { color: var(--success-text); }
.callout.neutral { border-color: var(--border); background: var(--surface-2); }
.callout.neutral > .icon { color: var(--muted); }
.callout .actions { display: flex; gap: 8px; align-items: center; align-self: center; }
.attn { display: flex; flex-direction: column; }
.attn a { display: flex; align-items: center; gap: 12px; padding: 12px 0; color: inherit; text-decoration: none; border-bottom: 1px solid var(--border); }
.attn a:first-child { padding-top: 2px; }
.attn a:last-child { border-bottom: 0; padding-bottom: 0; }
.attn a:hover .t b { color: var(--primary-text); }
.attn .dotc { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.attn .dotc.danger { background: var(--danger-fill); }
.attn .dotc.warning { background: var(--warning-fill); }
.attn .t { flex: 1; min-width: 0; }
.attn .t b { display: block; font-weight: 500; }
.attn .t span { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attn .icon { color: var(--faint); }

/* ================= empty & loading ================= */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; padding: 48px 20px; color: var(--muted); }
.empty .art { width: 64px; height: 64px; margin-bottom: 8px; }
.empty b { color: var(--text); font-weight: 500; }
.empty p { max-width: 380px; font-size: var(--fs-sm); }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 96px 20px; color: var(--muted); }
.loading .spin { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
.refreshing { opacity: .55; transition: opacity var(--t-med) var(--ease); }

/* ================= code & secrets ================= */
.code { position: relative; display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px; border-radius: var(--r-md); background: #1b1d1f; color: #e4e2dc; font-family: var(--font-mono); font-size: 12.8px; line-height: 1.7; }
.code pre { margin: 0; flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-all; font: inherit; }
.code .prompt { color: #69c3d4; user-select: none; }
.code .cmt { color: #8e8b84; }
.code .copy { flex: none; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.05); color: #d7d4cd; border-radius: var(--r-sm); height: 26px; padding: 0 9px; font: 500 12px var(--font-sans); cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.code .copy:hover { background: rgba(255,255,255,.1); color: #fff; }
.secret { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-radius: var(--r-md); border: 1px dashed var(--border-strong); background: var(--surface-2); font-family: var(--font-mono); font-size: 20px; letter-spacing: .08em; font-weight: 600; }
.secret span { flex: 1; user-select: all; word-break: break-all; }
.secret.sm { font-size: 14px; letter-spacing: .02em; font-weight: 500; }
.kv { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ================= modal & drawer ================= */
.overlay { position: fixed; inset: 0; z-index: 60; background: var(--scrim); display: flex; align-items: flex-start; justify-content: center; padding: 10vh 16px 16px; animation: fade var(--t-med) var(--ease); overflow-y: auto; backdrop-filter: blur(2px); }
.overlay.drawer-host { padding: 0; justify-content: flex-end; align-items: stretch; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px) scale(.995); } }
@keyframes slide { from { transform: translateX(20px); opacity: .5; } }
.modal { width: min(520px, 100%); background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-3); border: 1px solid var(--border); animation: rise var(--t-med) var(--ease); display: flex; flex-direction: column; max-height: 82vh; }
.modal.wide { width: min(680px, 100%); }
.modal-head { display: flex; align-items: flex-start; gap: 14px; padding: 24px 24px 6px; }
.modal-head .icon-badge { display: none; }
.modal-head .t { flex: 1; min-width: 0; }
.modal-head h2 { font: 600 20px/1.35 var(--font-serif); }
.modal-head p { color: var(--muted); font-size: var(--fs-sm); margin-top: 6px; }
.modal-body { padding: 14px 24px 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 18px 24px 22px; }
.modal-foot .left { margin-right: auto; color: var(--muted); font-size: var(--fs-xs); align-self: center; }
.close-x { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 6px; border-radius: var(--r-sm); display: inline-flex; }
.close-x:hover { background: var(--surface-3); color: var(--text); }
.drawer { width: min(520px, 100vw); height: 100%; background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-3); display: flex; flex-direction: column; animation: slide var(--t-med) var(--ease); }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 26px 26px 18px; }
.drawer-head .t { flex: 1; min-width: 0; }
.drawer-head h2 { font: 600 20px/1.35 var(--font-serif); }
.drawer-head p { color: var(--muted); font-size: var(--fs-sm); margin-top: 6px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 4px 26px 26px; display: flex; flex-direction: column; gap: 26px; }
.drawer-body h3 { font-size: var(--fs-sm); color: var(--muted); font-weight: 500; margin-bottom: 10px; }
.drawer-foot { padding: 16px 26px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ================= menu & toast ================= */
.menu { position: fixed; z-index: 70; min-width: 200px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-3); animation: rise var(--t-fast) var(--ease); }
.menu button, .menu a { width: 100%; display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border: 0; border-radius: var(--r-sm); background: none; color: var(--text); font: 400 var(--fs-md) var(--font-sans); cursor: pointer; text-align: left; text-decoration: none; }
.menu button .icon, .menu a .icon { color: var(--muted); }
.menu button:hover, .menu a:hover { background: var(--surface-2); text-decoration: none; }
.menu button.danger, .menu button.danger .icon { color: var(--danger-text); }
.menu .sep { height: 1px; background: var(--border); margin: 6px 4px; }
.menu .menu-head { padding: 8px 10px 4px; color: var(--muted); font-size: var(--fs-xs); }
.menu button .check-mark { margin-left: auto; color: var(--primary); }
.toasts { position: fixed; z-index: 90; left: 50%; bottom: 28px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 440px; padding: 11px 16px; border-radius: var(--r-pill); background: #262522; color: #f3f1ec; box-shadow: var(--shadow-3); font-size: var(--fs-sm); animation: rise var(--t-med) var(--ease); }
.toast .icon { color: #69c3d4; }
.toast.error .icon { color: #f19a92; }

/* ================= charts ================= */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: var(--fs-xs); color: var(--muted); align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-family: var(--font-sans); font-variant-numeric: tabular-nums; }
.chart .tick.today { fill: var(--text); font-weight: 600; }
.chart .s1 { fill: var(--series-1); }
.chart .s2 { fill: var(--series-2); }
.chart .col .hit { fill: transparent; }
.chart .col:hover .hit, .chart .col:focus .hit { fill: var(--series-1-soft); }
.chart .col:focus { outline: none; }
.chart .val { fill: var(--text-2); font-size: 11px; font-weight: 500; font-variant-numeric: tabular-nums; }
.chart-tip { position: absolute; z-index: 5; pointer-events: none; min-width: 168px; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-2); font-size: var(--fs-xs); color: var(--muted); }
.chart-tip .d { color: var(--text-2); font-weight: 500; margin-bottom: 6px; }
.chart-tip .r { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.chart-tip .r i { width: 12px; height: 3px; border-radius: 2px; }
.chart-tip .r b { color: var(--text); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; margin-left: auto; padding-left: 12px; }
.chart-tip .tot { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 6px; }
.spark path.line { fill: none; stroke: var(--series-1); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.spark path.area { fill: var(--series-1-soft); }
.spark circle { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }

/* ================= steps / timeline ================= */
.steps { display: flex; flex-direction: column; counter-reset: step; }
.step { position: relative; display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 18px; padding-bottom: 34px; }
.step:last-child { padding-bottom: 0; }
.step::before { counter-increment: step; content: counter(step); width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--surface); color: var(--text); font: 600 var(--fs-sm) var(--font-serif); border: 1px solid var(--border-strong); z-index: 1; }
.step::after { content: ""; position: absolute; left: 15px; top: 34px; bottom: 4px; width: 1px; background: var(--border); }
.step:last-child::after { display: none; }
.step .c { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; min-width: 0; }
.step .c h3 { font-size: 15px; font-weight: 600; }
.step .c p { color: var(--muted); }
.step-ic { width: 32px; height: 32px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--primary-soft); color: var(--primary-text); flex: none; }
.timeline { display: flex; flex-direction: column; }
.tl-item { position: relative; display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 12px; padding-bottom: 18px; }
.tl-item::before { content: ""; width: 7px; height: 7px; margin: 7px 5px 0; border-radius: 50%; background: var(--border-strong); z-index: 1; }
.tl-item::after { content: ""; position: absolute; left: 8px; top: 18px; bottom: 0; width: 1px; background: var(--border); }
.tl-item:last-child { padding-bottom: 0; }
.tl-item:last-child::after { display: none; }
.tl-item.on::before { background: var(--primary); }
.tl-item.warn::before { background: var(--warning-fill); }
.tl-item .meta { color: var(--muted); font-size: var(--fs-xs); margin-top: 2px; }
.quote { border-left: 2px solid var(--border-strong); padding: 4px 0 4px 14px; color: var(--text-2); white-space: pre-wrap; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.facts div { padding: 12px 14px; background: var(--surface); }
.facts b { display: block; font-size: 17px; font-weight: 500; font-variant-numeric: tabular-nums; }
.facts span { font-size: var(--fs-xs); color: var(--muted); }

/* ================= sign-in ================= */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(420px, .9fr); background: var(--bg); }
.auth-brand { position: relative; overflow: hidden; display: flex; flex-direction: column; padding: 40px 56px; background: linear-gradient(160deg, #e9f3f3 0%, #f3f4f0 46%, var(--bg) 100%); border-right: 1px solid var(--border); }
.auth-brand .logo { height: 26px; width: auto; align-self: flex-start; color: var(--text); }
.auth-brand .pitch { margin: auto 0; max-width: 520px; }
.auth-brand h1 { font: 600 40px/1.32 var(--font-serif); letter-spacing: -.01em; color: var(--text); }
.auth-brand .lede { margin-top: 16px; color: var(--muted); font-size: 15px; }
.auth-brand .diagram { margin-top: 44px; width: 100%; max-width: 480px; }
.auth-brand .foot { color: var(--faint); font-size: var(--fs-xs); display: flex; gap: 16px; flex-wrap: wrap; }
.diagram text { font-family: var(--font-sans); }
.diagram .dg-box { fill: var(--surface); stroke: var(--border); }
.diagram .dg-title { fill: var(--text); font-size: 14px; font-weight: 600; }
.diagram .dg-sub { fill: var(--muted); font-size: 12px; }
.diagram .dg-link { fill: var(--text-2); font-size: 12px; }
.diagram .dg-line { stroke: var(--harbor-400); stroke-width: 1.5; }
.diagram .dg-disc { fill: var(--mark-disc); }
.diagram .dg-bracket { fill: none; stroke: var(--text); stroke-width: 9; stroke-linecap: round; }
.diagram .dg-lock { fill: var(--surface); stroke: var(--harbor-400); stroke-width: 1.5; }
.diagram .dg-lock-ic { fill: none; stroke: var(--primary); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.diagram .dg-pulse { fill: var(--harbor-500); animation: dg-move 2.8s var(--ease) infinite; }
@keyframes dg-move { 0% { transform: translateX(0); opacity: 0; } 12% { opacity: 1; } 88% { opacity: 1; } 100% { transform: translateX(118px); opacity: 0; } }
.auth-form { display: flex; flex-direction: column; justify-content: center; padding: 48px clamp(28px, 6vw, 96px); }
.auth-form .box { width: 100%; max-width: 360px; margin: 0 auto; }
.auth-form h2 { font: 600 30px/1.3 var(--font-serif); }
.auth-form .sub { color: var(--muted); margin: 10px 0 32px; }
.auth-form .form { gap: 18px; }
.auth-form .links { margin-top: 28px; display: flex; gap: 18px; font-size: var(--fs-sm); }
.auth-form .links a { color: var(--muted); }
.auth-form .links a:hover { color: var(--text); }
.auth-form .mobile-logo { display: none; margin-bottom: 36px; }
.auth-form .mobile-logo .wordmark { height: 18px; color: var(--text); }
.pw-toggle { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 6px; border-radius: var(--r-sm); display: inline-flex; }
.pw-toggle:hover { color: var(--text); background: var(--surface-3); }
:root[data-theme="dark"] .auth-brand { background: linear-gradient(160deg, #18292b 0%, #191917 50%, var(--bg) 100%); }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .auth-brand { background: linear-gradient(160deg, #18292b 0%, #191917 50%, var(--bg) 100%); } }

/* ================= portal & help ================= */
.hello h1 { font-size: 30px; }
.score-hero { display: flex; align-items: flex-end; gap: 10px; }
.score-hero .num { font-size: var(--fs-hero); font-weight: 500; letter-spacing: -.03em; line-height: 1; }
.score-hero .num.good { color: var(--success-text); }
.score-hero .num.warn { color: var(--warning-text); }
.score-hero .num.bad { color: var(--danger-text); }
.score-hero .of { color: var(--muted); padding-bottom: 6px; }
/* score split bar: no text inside, each part grows by its points (flex-grow set inline); the rules
   under it are the legend, keyed by the same colors */
.composition { display: flex; height: 8px; border-radius: var(--r-pill); overflow: hidden; gap: 3px; }
.composition i { flex: 1 1 0; min-width: 2px; }
.composition .p1, .rule .key.p1 { background: var(--harbor-600); }
.composition .p2, .rule .key.p2 { background: var(--harbor-500); }
.composition .p3, .rule .key.p3 { background: var(--harbor-400); }
.rule .key { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 8px; vertical-align: 1px; }
.rule-list { display: grid; gap: 0; }
.rule { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 16px; align-items: baseline; padding: 18px 0; border-bottom: 1px solid var(--border); }
.rule:last-child { border-bottom: 0; }
.rule .n { font: 600 26px/1 var(--font-serif); color: var(--primary-text); }
.rule b { display: block; font-weight: 600; }
.rule span { color: var(--muted); font-size: var(--fs-sm); }
.prose { max-width: 720px; color: var(--text-2); line-height: 1.9; font-size: 15px; }
.prose h1 { font: 600 24px/1.4 var(--font-serif); color: var(--text); margin: 0 0 18px; }
.prose h2 { font-size: var(--fs-lg); color: var(--text); margin: 26px 0 8px; }
.prose p { margin: 12px 0; }
.prose ol, .prose ul { padding-left: 22px; margin: 12px 0; }
.prose li { margin: 10px 0; padding-left: 6px; }
.prose li::marker { color: var(--faint); }
.prose strong { color: var(--text); }
.prose code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
/* usage policy: reading, confirming, and the administrators' editor */
.policy-doc { padding: 8px 12px; }
.policy-toolbar { margin-bottom: 14px; }
.textarea.policy-input { min-height: 460px; font-family: var(--font-mono); font-size: 13px; line-height: 1.75; }
.policy-preview { min-height: 460px; border: 1px solid var(--border); border-radius: var(--r-md); padding: 18px 22px; }
.policy-editor .card-foot { align-items: flex-start; }
.ack-count b { font: 600 26px/1 var(--font-serif); color: var(--text); }
.text-warn { color: var(--warning-text); }
.text-bad { color: var(--danger-text); }
.faq details { border-bottom: 1px solid var(--border); padding: 16px 0; }
.faq details:last-child { border-bottom: 0; }
.faq summary { cursor: pointer; font-weight: 500; list-style: none; display: flex; align-items: center; gap: 10px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary .icon { color: var(--faint); transition: transform var(--t-fast) var(--ease); }
.faq details[open] summary .icon { transform: rotate(90deg); }
.faq details p { margin: 10px 0 0 28px; color: var(--text-2); }

/* ================= policy editor ================= */
.pg-list { display: flex; flex-direction: column; gap: 4px; }
.pg-item { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px solid transparent; border-radius: var(--r-md); background: transparent; cursor: pointer; text-align: left; font: inherit; color: inherit; transition: background var(--t-fast) var(--ease); }
.pg-item:hover { background: var(--surface-2); }
.pg-item.on { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow-1); }
.pg-item .nm { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.pg-item .nm .badge { margin-left: auto; }
.pg-item .meta { color: var(--muted); font-size: var(--fs-xs); }
.pg-item.new { flex-direction: row; align-items: center; gap: 8px; color: var(--muted); }
.pg-item.new:hover { color: var(--primary-text); }
.editor-section { padding: 26px 28px; border-bottom: 1px solid var(--border); }
.editor-section:last-of-type { border-bottom: 0; }
.editor-section > header { margin-bottom: 18px; }
.editor-section > header h3 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.editor-section > header p { color: var(--muted); font-size: var(--fs-sm); margin-top: 4px; }
.opt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.opt { display: flex; align-items: flex-start; gap: 10px; padding: 11px 13px; border: 1px solid var(--border); border-radius: var(--r-md); cursor: pointer; background: var(--surface); }
.opt:hover { border-color: var(--border-strong); }
.opt.on { border-color: var(--primary); background: var(--primary-soft); }
.opt.locked { cursor: not-allowed; background: var(--surface-2); opacity: .7; }
.opt.risky.on { border-color: var(--danger-fill); background: var(--danger-bg); }
.opt input { margin-top: 3px; accent-color: var(--primary); }
.opt b { display: block; font-weight: 500; font-family: var(--font-mono); font-size: 13px; }
.opt span { display: block; color: var(--muted); font-size: var(--fs-xs); margin-top: 2px; }
.save-bar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: var(--surface); border-top: 1px solid var(--border); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.save-bar .input { max-width: 360px; }
.dirty-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warning-fill); display: inline-block; }

/* ================= user detail & devices ================= */
.flow { display: flex; flex-direction: column; gap: 14px; padding: 18px; border-radius: var(--r-md); background: var(--surface-2); }
.flow ol { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 14px; color: var(--text-2); }
.status-line { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--text-2); }
.status-line .spin { width: 14px; height: 14px; border: 2px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
.device { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.device:first-child { padding-top: 0; }
.device:last-child { border-bottom: 0; padding-bottom: 0; }
.device .ic { width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; color: var(--muted); }
.device b { font-weight: 500; }
.device .meta { color: var(--muted); font-size: var(--fs-xs); display: flex; flex-wrap: wrap; gap: 2px 10px; margin-top: 2px; }
.device.revoked { opacity: .55; }

/* ================= account pool ================= */
.loan-now { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 16px; align-items: center; }
.loan-now.compact { grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; }
.loan-ic { width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); color: var(--muted); display: flex; align-items: center; justify-content: center; }
.loan-now.compact .loan-ic { width: 36px; height: 36px; border-radius: 10px; }
.loan-ic.on { background: var(--primary-soft); color: var(--primary-text); }
.loan-now .t { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.loan-now .t .eyebrow { font-size: var(--fs-xs); color: var(--muted); }
.loan-now .t b { font-size: var(--fs-lg); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loan-now.compact .t b { font-size: var(--fs-md); }
.loan-now .meta { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: var(--fs-sm); color: var(--muted); }
.loan-now .actions { display: flex; gap: 8px; align-items: center; }
.sess { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); }
.sess > .icon { color: var(--muted); margin-top: 2px; }
.sess .t { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: var(--fs-sm); }
.sess .t b { font-weight: 500; }
.sess .t span { color: var(--muted); font-size: var(--fs-xs); }
.link-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 6px 0; border: 0; border-top: 1px solid var(--border); background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.link-row:hover > span:first-child, .link-row:focus-visible > span:first-child { color: var(--primary-text); }
@media (max-width: 640px) {
  .loan-now, .loan-now.compact { grid-template-columns: 36px minmax(0, 1fr); }
  .loan-now .actions { grid-column: 1 / -1; }
}

/* ================= responsive ================= */
@media (max-width: 1180px) {
  .grid-main-side { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; transform: translateX(-100%); transition: transform var(--t-med) var(--ease); box-shadow: var(--shadow-3); }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open::after { content: ""; position: fixed; inset: 0; background: var(--scrim); z-index: 20; }
  .topbar-mobile { display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 14px; background: var(--bg); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 15; }
  .topbar-mobile .wordmark { height: 15px; color: var(--text); }
  .topbar-mobile button { border: 0; background: none; color: var(--text-2); padding: 8px; border-radius: var(--r-sm); display: inline-flex; cursor: pointer; }
  .page { padding: 24px 18px 56px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-brand { display: none; }
  .auth-form .mobile-logo { display: flex; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar .input-group { width: 100%; }
  .chart { overflow-x: auto; }
  .chart svg { min-width: 620px; }
}
@media print {
  .sidebar, .topbar-mobile, .page-header .actions, .toolbar { display: none !important; }
  .app { display: block; }
  .card, .kpi, .table-wrap { box-shadow: none; }
}
.dotc { width: 6px; height: 6px; border-radius: 50%; background: var(--warning-fill); flex: none; }

/* ================= notifications ================= */
.notes { display: flex; flex-direction: column; }
.note { display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 14px 2px; border: 0; border-bottom: 1px solid var(--border); background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.note:first-child { padding-top: 4px; }
.note:last-child { border-bottom: 0; padding-bottom: 4px; }
.note .dotc { width: 8px; height: 8px; margin-top: 7px; border-radius: 50%; flex: none; background: transparent; }
.note.unread .dotc { background: var(--primary); }
.note.unread .dotc.warning { background: var(--warning-fill); }
.note.unread .dotc.danger { background: var(--danger-fill); }
.note .t { flex: 1; min-width: 0; }
.note .t b { display: block; font-weight: 400; color: var(--text-2); }
.note.unread .t b { font-weight: 500; color: var(--text); }
.note .t span { display: block; margin-top: 3px; font-size: 12.5px; color: var(--muted); }
.note time { flex: none; margin-top: 2px; font-size: 12px; color: var(--faint); white-space: nowrap; }
.note:hover .t b, .note:focus-visible .t b { color: var(--primary-text); }
.week-nav { display: inline-flex; align-items: center; gap: 4px; }
.week-nav .label { min-width: 148px; text-align: center; font-size: var(--fs-sm); color: var(--text-2); }
.mcp-list { display: flex; flex-direction: column; gap: 8px; }
.mcp-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.mcp-row > .input:first-child { flex: 1 1 110px; min-width: 0; }
.mcp-row > .select { flex: 0 0 112px; }
.mcp-row > .input:nth-child(3) { flex: 3 1 180px; min-width: 0; }
.install-tabs { margin-bottom: 12px; }

/* ---- remote-browser login (js/ui/remote-browser.js): full-screen, the remote screen on a quiet stage ---- */
body.rb-open { overflow: hidden; }
.rb { position: fixed; inset: 0; z-index: 58; display: flex; flex-direction: column; background: var(--bg); animation: fade var(--t-med) var(--ease); }
.rb-bar { position: relative; display: flex; align-items: center; gap: 14px; height: 56px; flex: none; padding: 0 14px 0 22px; border-bottom: 1px solid var(--border); background: var(--surface); }
.rb-title { display: flex; align-items: baseline; gap: 12px; min-width: 0; flex: 1; }
.rb-title h2 { font: 600 17px/1.3 var(--font-serif); white-space: nowrap; }
.rb-meta { min-width: 0; color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rb-status { display: inline-flex; align-items: center; gap: 7px; font-size: var(--fs-sm); color: var(--text-2); white-space: nowrap; }
.rb-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.rb-status.live::before, .rb-status.ok::before { background: var(--success-fill); }
.rb-status.wait::before { background: var(--warning-fill); animation: rb-pulse 1.2s ease-in-out infinite; }
.rb-status.off::before { background: var(--danger-fill); }
@keyframes rb-pulse { 50% { opacity: .3; } }
.rb-actions { display: flex; align-items: center; gap: 4px; }
.rb-clip { display: flex; align-items: center; gap: 4px; padding-left: 12px; border-radius: var(--r-pill); background: var(--primary-soft); color: var(--text-2); font-size: var(--fs-sm); white-space: nowrap; }
.rb-stage { position: relative; flex: 1; min-height: 0; margin: 14px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface-2); box-shadow: var(--shadow-2); }
.rb-screen { position: absolute; inset: 0; }
.rb-cover { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--surface-2); }
.rb-card { display: flex; flex-direction: column; align-items: center; gap: 10px; width: min(440px, 100%); text-align: center; color: var(--text-2); font-size: var(--fs-sm); }
.rb-card > b { font: 600 19px/1.4 var(--font-serif); color: var(--text); }
.rb-card > .spin { width: 22px; height: 22px; margin-bottom: 4px; border: 2px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
.rb-card > .icon { width: 30px; height: 30px; color: var(--success-fill); }
.rb-card > .callout { width: 100%; text-align: left; }
.rb-card > .row { justify-content: center; margin-top: 6px; }
.rb-paste { position: absolute; top: 52px; right: 14px; z-index: 2; display: flex; flex-direction: column; gap: 10px; width: min(360px, calc(100vw - 28px)); padding: 12px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-3); animation: rise var(--t-fast) var(--ease); }
.rb-paste .textarea { width: 100%; resize: vertical; }
.rb-paste .row { justify-content: flex-end; }
@media (max-width: 760px) { .rb-meta, .rb-note { display: none; } .rb-stage { margin: 8px; } .rb-actions .btn:not(:last-child) { display: none; } .rb-fill { border-right: 0; } }

/* ---- account import, bulk actions and sign-in details (codr v1.7) ---- */
.table th.sel, .table td.sel { width: 1%; padding-right: 2px; }
.table .sel input { width: 16px; height: 16px; margin: 0; vertical-align: middle; accent-color: var(--primary); cursor: pointer; }
.import-files { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 6px 8px 6px 14px; border: 1px dashed var(--border-strong); border-radius: var(--r-md); background: var(--surface-2); color: var(--muted); font-size: var(--fs-sm); transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease); }
.import-files.over { border-color: var(--primary); background: var(--primary-soft); }
.import-files .names { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-sum { display: flex; gap: 28px; flex-wrap: wrap; }
.import-sum div { display: flex; flex-direction: column; gap: 2px; }
.import-sum b { font: 600 24px/1.2 var(--font-sans); }
.import-sum span { color: var(--muted); font-size: var(--fs-sm); }
.import-sum .bad b { color: var(--danger-text); }
.import-list { max-height: 300px; overflow: auto; }
.import-list .table-wrap { box-shadow: none; }
.import-list td .ellipsis { display: inline-block; max-width: 200px; vertical-align: bottom; }
.signin { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.signin .t { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.signin .t > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rb-fill { display: flex; align-items: center; gap: 2px; padding-right: 10px; border-right: 1px solid var(--border); }
.rb-note { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-xs); color: var(--warning-text); }
/* automatic sign-in (codr v1.8): the queue's line over the account table */
.auto-run { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -4px 0 16px; padding: 8px 10px 8px 14px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); font-size: var(--fs-sm); }
.auto-run.paused { border-color: var(--warning-border); background: var(--warning-bg); }
.auto-run .line { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--text-2); }
.auto-run .line b { font-weight: 500; color: var(--text); white-space: nowrap; }
.auto-run .line > .icon { flex: none; color: var(--muted); }
.auto-run.paused .line > .icon { color: var(--warning-text); }
.auto-run .spin { width: 14px; height: 14px; flex: none; border: 2px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
/* 系统设置 (codr v1.13): one setting per row, what it does on the left, its switch on the right */
.settings-list { display: flex; flex-direction: column; }
.setting { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding: 16px 0; }
.setting + .setting { border-top: 1px solid var(--border); }
.setting:first-child { padding-top: 4px; }
.setting:last-child { padding-bottom: 4px; }
.setting-text { min-width: 0; max-width: 640px; }
.setting-title { font-weight: 500; color: var(--text); margin-bottom: 4px; }
.setting-text p { margin: 0; font-size: var(--fs-sm); line-height: 1.6; }
.setting-note { margin-top: 6px !important; }
.setting-note.warn { color: var(--warning-text); }
.setting .switch { margin-top: 2px; }

/* ================= account quota (codr v1.5: what an account has left, Sub2API-style rows) ================= */
.quota { display: flex; flex-direction: column; gap: 5px; }
.quota .q, .quota-inline .q { display: inline-grid; grid-template-columns: 24px 40px 32px auto; align-items: center; gap: 6px; font-size: 12px; line-height: 1; white-space: nowrap; font-variant-numeric: tabular-nums; }
.quota .k, .quota-inline .k { height: 17px; display: inline-flex; align-items: center; justify-content: center; border-radius: 5px; background: var(--surface-2); color: var(--text-2); font-size: 11px; font-weight: 500; }
.quota .bar, .quota-inline .bar { position: relative; height: 4px; border-radius: 2px; background: var(--meter-track); overflow: hidden; }
.quota .bar i, .quota-inline .bar i { position: absolute; inset: 0 auto 0 0; border-radius: 2px; background: var(--primary); }
.quota .q.warn .bar i, .quota-inline .q.warn .bar i { background: var(--warning-fill); }
.quota .q.bad .bar i, .quota-inline .q.bad .bar i { background: var(--danger-fill); }
.quota .pct { text-align: right; color: var(--text); }
.quota .q.warn .pct, .quota-inline .q.warn { color: var(--warning-text); }
.quota .q.bad .pct, .quota-inline .q.bad { color: var(--danger-text); }
.quota .when { color: var(--faint); }
.quota .stale { font-size: 11px; color: var(--faint); }
.quota-inline { display: inline-flex; gap: 12px; }
.quota-inline .q { grid-template-columns: 24px 32px auto; }
.name-plan { display: inline-flex; align-items: center; gap: 8px; }
.name-plan .badge { height: 19px; padding: 0 7px; font-size: 11px; }
/* 子账号 (codr v1.14): indented under its top-level account, joined to it by a hairline corner */
.sub-account { padding-left: 18px; position: relative; }
.sub-mark { position: absolute; left: 4px; top: 1px; width: 9px; height: 10px; border-left: 1px solid var(--border-strong); border-bottom: 1px solid var(--border-strong); border-bottom-left-radius: 3px; }
.ws-tag { font-size: 11px; color: var(--muted); padding: 0 6px; height: 19px; display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: var(--r-pill); max-width: 14em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quota-card .quota-rows { display: flex; flex-direction: column; gap: 12px; }
.quota-card .qrow { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 4px 12px; align-items: center; font-size: var(--fs-sm); }
.quota-card .qrow .k { color: var(--text-2); }
.quota-card .qrow .meter { height: 6px; }
.quota-card .qrow .v { grid-column: 2; display: flex; justify-content: space-between; gap: 8px; font-size: var(--fs-xs); }
.quota-card .qrow .v b { font-weight: 500; font-variant-numeric: tabular-nums; }
.quota-card .qrow.warn .v b { color: var(--warning-text); }
.quota-card .qrow.bad .v b { color: var(--danger-text); }
.quota-card .quota-credits { display: flex; flex-direction: column; gap: 10px; padding-top: 12px; border-top: 1px solid var(--border); }

/* ================= group chat 群聊 (codr v1.13): one room, the list fills the window ================= */
.page.chat-page { display: flex; flex-direction: column; height: 100vh; height: 100dvh; padding-bottom: 28px; }
.chat-page .page-header { margin-bottom: 18px; }
.chat-status { display: inline-flex; align-items: center; gap: 6px; }
.chat-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--success-fill); }
.chat-status.off { color: var(--warning-text); }
.chat-status.off i { background: var(--warning-fill); }
.card.chat { flex: 1; min-height: 340px; display: flex; flex-direction: column; overflow: hidden; }
.chat-view { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-list { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 0 12px; scrollbar-width: thin; outline: none; }
.chat-list .empty { min-height: 100%; }
.chat-more { display: flex; justify-content: center; padding: 2px 0 6px; }
.chat-day { display: flex; align-items: center; gap: 12px; margin: 12px 22px 4px; font-size: 12px; color: var(--faint); }
.chat-day::before, .chat-day::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.chat-msg { position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 0 12px; padding: 7px 52px 3px 22px; }
.chat-msg.cont { padding-top: 1px; }
.chat-msg:hover { background: var(--surface-2); }
.chat-main { min-width: 0; }
.chat-meta { display: flex; align-items: baseline; gap: 8px; min-width: 0; line-height: 1.4; }
.chat-meta b { font-weight: 600; font-size: var(--fs-sm); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-msg.mine .chat-meta b { color: var(--primary-text); }
.chat-meta time, .chat-gutter time { font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.chat-admin { font-size: 11px; line-height: 18px; padding: 0 7px; border-radius: var(--r-pill); background: var(--primary-soft); color: var(--primary-text); white-space: nowrap; }
.chat-gutter { display: flex; justify-content: flex-end; padding-top: 3px; }
.chat-gutter time { visibility: hidden; font-size: 10.5px; }
.chat-msg.cont:hover .chat-gutter time { visibility: visible; }
.chat-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; font-size: var(--fs-md); color: var(--text); }
.chat-text a { color: var(--link); }
.chat-act { position: absolute; top: 3px; right: 16px; width: 28px; height: 28px; display: none; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); color: var(--muted); cursor: pointer; }
.chat-act:hover { color: var(--text); background: var(--surface-3); }
.chat-msg:hover .chat-act, .chat-act:focus-visible { display: inline-flex; }
@media (hover: none) { .chat-act { display: inline-flex; border-color: transparent; background: transparent; } }
.chat-new { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 14px; border: 0; border-radius: var(--r-pill); background: var(--primary); color: var(--on-primary); font: 500 var(--fs-sm) var(--font-sans); box-shadow: var(--shadow-2); cursor: pointer; }
.chat-new[hidden] { display: none; }
.chat-compose { border-top: 1px solid var(--border); padding: 12px 16px 14px; }
.chat-box { display: flex; align-items: flex-end; gap: 10px; }
.textarea.chat-input { flex: 1; height: 40px; min-height: 40px; max-height: 200px; padding: 8px 12px; resize: none; overflow-y: hidden; line-height: 1.55; }
.chat-box .btn { height: 40px; }
.chat-count { display: block; text-align: right; font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.chat-count:empty { display: none; }
.chat-count.over { color: var(--danger-text); }
.chat-muted { display: flex; align-items: center; gap: 8px; min-height: 40px; font-size: var(--fs-sm); color: var(--muted); }
.chat-quote { margin: 0 0 14px; padding: 10px 12px; border-left: 3px solid var(--border-strong); border-radius: 0 var(--r-sm) var(--r-sm) 0; background: var(--surface-2); font-size: var(--fs-sm); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 160px; overflow: hidden; }
.chat-quote b { display: block; font-weight: 500; margin-bottom: 2px; }
.chat-mutes { display: flex; flex-direction: column; }
.chat-mute { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.chat-mute:last-child { border-bottom: 0; }
@media (max-width: 960px) {
  .page.chat-page { height: calc(100vh - 56px); height: calc(100dvh - 56px); padding-bottom: 14px; }
  .chat-msg { padding-left: 14px; padding-right: 44px; }
  .chat-day { margin-left: 14px; margin-right: 14px; }
  .chat-compose { padding: 10px 12px 12px; }
}
