/* Control Center: the workspace design system (same tokens, light and dark), self-contained for the admin origin. */
:root {
  color-scheme: light;
  --bg-root: #f6f7f9; --bg-sidebar: #fcfcfd; --bg-panel: #ffffff; --bg-elevated: #f1f3f5; --bg-hover: #eceff2; --surface-subtle: #fafbfc;
  --border: #e4e7eb; --border-light: #d4d9df; --text-main: #242b34; --text-muted: #697380; --text-dim: #8a94a1;
  --accent: #c44e2d; --accent-hover: #aa4023; --accent-soft: #fbede7; --accent-text: #a94227; --focus-ring: #c44e2d;
  --positive: #22734e; --positive-bg: #edf6f0; --positive-border: #c2dfce;
  --negative: #b23946; --negative-bg: #fbedef; --negative-border: #edc6cb;
  --warn: #946515; --warn-bg: #fbf3e4; --warn-border: #ead6b0; --blue: #3769a0;
  --radius-panel: 12px; --radius-control: 7px;
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg-root: #101319; --bg-sidebar: #14181f; --bg-panel: #1a1f28; --bg-elevated: #242b36; --bg-hover: #2c3542; --surface-subtle: #1e2530;
  --border: #303a48; --border-light: #414e60; --text-main: #edf1f7; --text-muted: #b1bccb; --text-dim: #8999ac;
  --accent: #c44e2d; --accent-hover: #b44729; --accent-soft: #3a2825; --accent-text: #ffb694; --focus-ring: #ffac84;
  --positive: #72d5a3; --positive-bg: #19352c; --positive-border: #35684f;
  --negative: #ff929d; --negative-bg: #39232c; --negative-border: #764452;
  --warn: #e8bd72; --warn-bg: #322b1e; --warn-border: #6b5635; --blue: #8bbfff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg-root); color: var(--text-main); font: 13px/1.5 -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'Segoe UI', sans-serif; letter-spacing: -.01em; }
button, input, select, textarea { font: inherit; letter-spacing: inherit; color: inherit; }
::selection { background: #f5d8cb; color: #242b34; }
:root[data-theme='dark'] ::selection { background: #614438; color: #fff; }
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-thumb { background: var(--border-light); border: 2px solid transparent; background-clip: padding-box; border-radius: 10px; }
.mono { font-family: 'SFMono-Regular', Consolas, monospace; font-variant-numeric: tabular-nums; font-size: .92em; }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.pos { color: var(--positive); }
.neg { color: var(--negative); }
[hidden] { display: none !important; }
svg.icon { width: 15px; height: 15px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---- shell ---- */
.shell { display: flex; height: 100dvh; }
.sidebar { width: 236px; flex: none; display: flex; flex-direction: column; gap: 18px; padding: 22px 14px 14px; background: var(--bg-sidebar); border-right: 1px solid var(--border); overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand-mark { width: 32px; height: 32px; flex: none; border-radius: 9px; display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 800; font-size: 13px; letter-spacing: -.5px; }
.brand strong { display: block; font-size: 14px; font-weight: 700; letter-spacing: -.3px; }
.brand small { display: block; font-size: 11px; color: var(--text-muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: 14px 10px 6px; font-size: 10px; letter-spacing: .075em; text-transform: uppercase; color: var(--text-dim); font-weight: 600; }
.nav-label:first-child { padding-top: 0; }
.nav a { display: flex; align-items: center; gap: 11px; min-height: 36px; padding: 8px 10px; border-radius: 6px; color: var(--text-muted); text-decoration: none; font-size: 12px; font-weight: 500; }
.nav a:hover { background: var(--bg-elevated); color: var(--text-main); }
.nav a[aria-current='page'] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav .count { margin-left: auto; font-size: 10px; min-width: 20px; text-align: center; padding: 1px 6px; border-radius: 5px; background: var(--bg-elevated); color: var(--text-muted); }
.nav .count.warn { background: var(--warn-bg); color: var(--warn); }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.who { display: flex; align-items: center; gap: 9px; padding: 4px 6px; font-size: 11px; color: var(--text-muted); }
.who .avatar { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); font-weight: 700; font-size: 10px; }
.foot-actions { display: flex; gap: 6px; }
.foot-actions .btn { flex: 1; }
.main { flex: 1; min-width: 0; overflow-y: auto; }
.page { max-width: 1240px; margin: 0 auto; padding: 30px max(24px, env(safe-area-inset-right, 0px)) 60px max(24px, env(safe-area-inset-left, 0px)); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.eyebrow { margin: 0 0 6px; font-size: 10px; letter-spacing: .09em; text-transform: uppercase; color: var(--text-dim); font-weight: 600; }
.eyebrow a { color: inherit; text-decoration: none; }
.eyebrow a:hover { color: var(--text-main); }
h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -.5px; text-wrap: balance; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-head p.sub { margin: 6px 0 0; color: var(--text-muted); font-size: 12px; max-width: 70ch; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.updated { font-size: 10px; color: var(--text-dim); }

/* ---- controls ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 34px; padding: 0 13px; border-radius: var(--radius-control); border: 1px solid var(--border-light); background: var(--bg-panel); color: var(--text-muted); font-size: 12px; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--bg-elevated); color: var(--text-main); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.input:disabled, .input-unit:has(input:disabled) { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--negative); border-color: var(--negative-border); background: var(--negative-bg); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--bg-elevated); }
.btn.small { min-height: 28px; padding: 0 10px; font-size: 11px; }
.btn.armed { background: var(--negative); border-color: var(--negative); color: #fff; }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; font-size: 11px; font-weight: 600; color: var(--text-main); }
.field small { font-weight: 400; color: var(--text-muted); font-size: 10px; line-height: 1.6; }
.input, select.input, textarea.input { width: 100%; min-height: 38px; padding: 8px 11px; border: 1px solid var(--border-light); border-radius: var(--radius-control); background: var(--bg-panel); color: var(--text-main); font-size: 12px; font-weight: 400; outline: none; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent); }
textarea.input { resize: vertical; min-height: 76px; }
.input-unit { position: relative; display: block; }
.input-unit .input { padding-right: 46px; }
.input-unit span { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); font-size: 10px; color: var(--text-dim); pointer-events: none; }
.check { display: flex; align-items: center; gap: 9px; font-size: 12px; font-weight: 500; color: var(--text-main); cursor: pointer; }
input[type='checkbox'] { accent-color: var(--accent); width: 14px; height: 14px; margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

/* ---- surfaces ---- */
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.panel { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius-panel); min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 13px; font-weight: 650; }
.panel-head p { margin: 3px 0 0; font-size: 11px; color: var(--text-muted); }
.panel-body { padding: 18px 20px; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 22px; }
.metric { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius-panel); padding: 17px 19px; min-width: 0; }
.metric-label { font-size: 11px; color: var(--text-muted); margin-bottom: 12px; display: flex; justify-content: space-between; gap: 8px; }
.metric-value { font-size: 24px; font-weight: 600; letter-spacing: -.8px; line-height: 1.15; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric-value small { font-size: 12px; font-weight: 400; color: var(--text-muted); letter-spacing: 0; margin-left: 3px; }
.metric-caption { margin-top: 8px; font-size: 10px; color: var(--text-muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 9px 18px; margin: 0; font-size: 12px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 4px 9px; border-radius: 6px; background: var(--bg-elevated); font-size: 11px; color: var(--text-muted); }
.chip b { color: var(--text-main); font-weight: 600; font-variant-numeric: tabular-nums; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 5px; border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text-muted); font-size: 10px; font-weight: 600; white-space: nowrap; letter-spacing: 0; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill.good { background: var(--positive-bg); border-color: var(--positive-border); color: var(--positive); }
.pill.warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn); }
.pill.bad { background: var(--negative-bg); border-color: var(--negative-border); color: var(--negative); }
.pill.plain::before { display: none; }
.empty { padding: 30px 20px; text-align: center; color: var(--text-muted); font-size: 12px; }
.callout { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border-radius: 10px; border: 1px solid var(--warn-border); background: var(--warn-bg); color: var(--text-main); font-size: 12px; margin-bottom: 16px; }
.callout svg { color: var(--warn); margin-top: 2px; }
.callout.info { border-color: var(--border); background: var(--surface-subtle); }
.callout.info svg { color: var(--blue); }
.callout p { margin: 0; }
.callout .btn { margin-left: auto; }
.attention { display: flex; flex-direction: column; }
.attention .item { display: flex; align-items: center; gap: 11px; padding: 12px 20px; border-bottom: 1px solid var(--border); font-size: 12px; }
.attention .item:last-child { border-bottom: 0; }
.attention .item svg { color: var(--warn); }
.attention .item.ok svg { color: var(--positive); }
.attention .item a { margin-left: auto; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { text-align: left; padding: 11px 14px; background: var(--surface-subtle); color: var(--text-muted); font-size: 9px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text-muted); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th:first-child, td:first-child { padding-left: 20px; }
th:last-child, td:last-child { padding-right: 20px; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover td, tbody tr:hover td { background: var(--surface-subtle); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td .name { color: var(--text-main); font-weight: 600; }
td .meta { font-size: 10px; color: var(--text-dim); margin-top: 2px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.bar-track { height: 6px; border-radius: 3px; background: var(--bg-elevated); overflow: hidden; min-width: 80px; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 3px; }
.bar-row { display: grid; grid-template-columns: minmax(80px, 140px) 1fr 40px; gap: 10px; align-items: center; font-size: 11px; }

/* ---- key assignment rows ---- */
.keys { display: flex; flex-direction: column; }
.key-row { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 14px; align-items: center; padding: 10px 20px; border-bottom: 1px solid var(--border); }
.key-row:last-child { border-bottom: 0; }
.key-row > span { font-size: 12px; color: var(--text-main); font-weight: 500; }

/* ---- sheet (forms) ---- */
.sheet-backdrop { position: fixed; inset: 0; background: #0006; z-index: 20; }
.sheet { position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100vw); background: var(--bg-panel); border-left: 1px solid var(--border); z-index: 21; display: flex; flex-direction: column; box-shadow: -12px 0 40px #0003; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: max(20px, env(safe-area-inset-top, 0px)) max(22px, env(safe-area-inset-right, 0px)) 16px 22px; border-bottom: 1px solid var(--border); }
.sheet-head h2 { margin: 0; font-size: 15px; }
.sheet-head p { margin: 4px 0 0; font-size: 11px; color: var(--text-muted); }
.sheet-body { padding: 20px max(22px, env(safe-area-inset-right, 0px)) 30px 22px; overflow-y: auto; flex: 1; }

/* ---- notices ---- */
.toast { position: fixed; bottom: max(20px, env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); z-index: 30; max-width: min(560px, calc(100vw - 32px)); padding: 11px 16px; border-radius: 9px; background: var(--text-main); color: var(--bg-panel); font-size: 12px; box-shadow: 0 8px 30px #0004; }
.toast.error { background: var(--negative); color: #fff; }

/* ---- sign-in ---- */
.signin { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.signin-card { width: min(400px, 100%); background: var(--bg-panel); border: 1px solid var(--border); border-radius: 16px; padding: 30px 28px; }
.signin-card .brand { padding: 0; margin-bottom: 22px; }
.signin-card h1 { font-size: 18px; margin-bottom: 6px; }
.signin-card p { margin: 0 0 20px; color: var(--text-muted); font-size: 12px; }
.wallets { display: flex; flex-direction: column; gap: 8px; }
.wallets .btn { min-height: 40px; justify-content: flex-start; }
.signin-status { min-height: 18px; margin: 14px 0 0; font-size: 11px; color: var(--text-muted); }
.signin-form { display: flex; flex-direction: column; gap: 12px; }
.signin-form p { margin: 0; }
.signin-form .btn.primary { min-height: 40px; justify-content: center; margin-top: 4px; }
.signin-form .input.code { font-family: var(--font-mono, ui-monospace, monospace); font-size: 16px; letter-spacing: .25em; text-align: center; }
.qr { width: max-content; margin: 4px auto; padding: 10px; border-radius: 10px; background: #fff; }
.qr svg { display: block; width: 180px; height: 180px; }
.secret { padding: 8px 10px; border-radius: 8px; background: var(--surface-subtle); color: var(--text-main) !important; font-size: 11px !important; word-break: break-all; text-align: center; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin: 0; padding: 12px; border-radius: 8px; background: var(--surface-subtle); list-style: none; font-size: 12px; }
.assign-row .input { min-width: 12rem; }
.search-row { display: flex; gap: 8px; align-items: center; }
.search-row .input { max-width: 22rem; }
.result-log { margin-top: 12px; padding: 12px; border-radius: 8px; background: var(--surface-subtle); white-space: pre-wrap; word-break: break-all; font-size: 10px; }

@media (max-width: 1180px) {
  .cols-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
}
@media (max-width: 980px) {
  .cols-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { flex-direction: column; height: auto; min-height: 100dvh; }
  .sidebar { width: 100%; border-right: 0; border-bottom: 1px solid var(--border); padding: 14px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)); gap: 10px; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; }
  .nav-label { display: none; }
  .nav a { flex: none; }
  .sidebar-foot { flex-direction: row; align-items: center; justify-content: space-between; margin-top: 0; padding-top: 8px; }
  .main { overflow: visible; }
  .page { padding: 20px max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px)); }
  .form-grid { grid-template-columns: 1fr; }
  .key-row { grid-template-columns: 1fr; gap: 6px; }
}
