:root {
  --bg: #0b0e14;
  --bg-glow: #131b2b;
  --surface: #131822;
  --surface-2: #1a212e;
  --surface-3: #212a39;
  --line: #242e3d;
  --line-soft: #1c242f;
  --fg: #e8eef6;
  --fg-dim: #96a3b6;
  --fg-mute: #5e6b7e;
  --accent: #7c9fff;
  --accent-dim: #4a6fd6;
  --ok: #3ddc84;
  --warn: #f0b429;
  --err: #ff5c5c;
  --hot: #ff5c5c;
  --radius: 14px;
  --radius-sm: 9px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --shadow: 0 10px 30px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }

/* The `hidden` attribute only works through the UA stylesheet, which any author
 * `display` rule outranks — and .gate/.panel/.drawer below all set `display`.
 * Without this, hiding the login gate or a panel silently does nothing.
 * Must stay above every rule that sets display. */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body {
  background-image:
    radial-gradient(900px 460px at 12% -8%, var(--bg-glow) 0%, transparent 62%),
    radial-gradient(760px 400px at 100% 0%, #16202f 0%, transparent 55%);
  background-attachment: fixed;
  min-height: 100dvh;
}

h1, h2 { margin: 0; font-weight: 640; letter-spacing: -.01em; }
h1 { font-size: 1.02rem; }
h2 { font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-dim); }
p { margin: 0; }
code { font-family: var(--mono); font-size: .84em; color: var(--accent); background: rgba(124,159,255,.1); padding: .08em .34em; border-radius: 4px; }
b { font-weight: 640; }
.muted { color: var(--fg-dim); }
.small { font-size: .8rem; }
.err { color: var(--err); font-size: .82rem; min-height: 1.15em; }
.danger-text { color: var(--err) !important; }
.row { display: flex; gap: .45rem; flex-wrap: wrap; align-items: center; }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- buttons ---------- */
button {
  font: inherit; font-size: .85rem; font-weight: 560;
  padding: .48rem .9rem; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: var(--surface-3); color: var(--fg);
  cursor: pointer; transition: background .15s, border-color .15s, color .15s, transform .06s;
}
button:hover { background: var(--line); }
button:active { transform: translateY(1px); }
button.primary { background: var(--accent); color: #08101f; border-color: var(--accent); }
button.primary:hover { background: #93b0ff; }
button.danger { background: var(--hot); color: #2b0808; border-color: var(--hot); }
button.danger:hover { background: #ff7676; }
button.ghost { background: transparent; color: var(--fg-dim); border-color: var(--line); }
button.ghost:hover { background: var(--surface-2); color: var(--fg); }
button.tiny { padding: .26rem .58rem; font-size: .76rem; }
button.block { width: 100%; padding: .62rem; }
button.icon {
  background: transparent; border-color: var(--line); color: var(--fg-dim);
  width: 34px; height: 34px; padding: 0; display: grid; place-items: center; font-size: .95rem;
}
button.icon:hover { color: var(--fg); background: var(--surface-2); }
button[disabled] { opacity: .45; cursor: not-allowed; }

/* ---------- inputs ---------- */
input, textarea, select {
  font: inherit; width: 100%;
  padding: .55rem .7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(0,0,0,.28); color: var(--fg);
  transition: border-color .15s, box-shadow .15s;
}
textarea { font-family: var(--mono); font-size: .78rem; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(124,159,255,.16);
}
input[type=number] { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- gate ---------- */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem; }
.gate-card {
  width: min(370px, 100%);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 2rem 1.7rem 1.5rem;
  display: grid; gap: .65rem; text-align: center;
  box-shadow: var(--shadow);
}
.gate-mark {
  font-size: 2rem; width: 62px; height: 62px; margin: 0 auto .3rem;
  display: grid; place-items: center; border-radius: 18px;
  background: linear-gradient(145deg, rgba(124,159,255,.22), rgba(124,159,255,.05));
  border: 1px solid rgba(124,159,255,.25);
}
.gate-card h1 { font-size: 1.3rem; }
.gate-card input { text-align: center; margin-top: .5rem; }
.sign { color: var(--fg-mute); font-size: .74rem; letter-spacing: .08em; margin-top: .2rem; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem clamp(.8rem, 3vw, 1.6rem);
  background: rgba(11,14,20,.82);
  backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.brand-text { min-width: 0; }
.brand-text h1 { font-size: 1rem; }
.brand-text p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: .4rem; flex: none; }
.dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--fg-mute); flex: none;
  box-shadow: 0 0 0 3px rgba(255,255,255,.04);
}
.dot.live { background: var(--ok); box-shadow: 0 0 0 3px rgba(61,220,132,.16); animation: pulse 2.4s ease-in-out infinite; }
.dot.stale { background: var(--warn); box-shadow: 0 0 0 3px rgba(240,180,41,.16); }
.dot.down { background: var(--err); box-shadow: 0 0 0 3px rgba(255,92,92,.16); }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .4 } }

main {
  padding: clamp(.8rem, 2.5vw, 1.6rem);
  display: grid; gap: .9rem;
  max-width: 1120px; margin: 0 auto;
}

/* ---------- hero ---------- */
.hero {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: 1.05rem 1.2rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  position: relative; overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--fg-mute);
  transition: background .3s;
}
.hero.is-open::before { background: var(--ok); }
.hero.is-armed::before { background: var(--hot); }
.hero.is-dry::before { background: var(--warn); }
.hero.is-won::before { background: var(--ok); }
.hero.is-open { box-shadow: inset 0 0 60px rgba(61,220,132,.09); }
.hero.is-armed { box-shadow: inset 0 0 60px rgba(255,92,92,.08); }
.hero-main { min-width: 0; }
.hero-state { font-size: 1.32rem; font-weight: 650; letter-spacing: -.02em; line-height: 1.25; }
.hero-sub { color: var(--fg-dim); font-size: .84rem; margin-top: .15rem; }
.hero-actions { display: flex; gap: .45rem; flex: none; flex-wrap: wrap; }

/* ---------- metrics ---------- */
.metrics { display: grid; gap: .55rem; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); }
.metric {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm); padding: .6rem .75rem;
  display: grid; gap: .12rem;
}
.metric .k { font-size: .7rem; color: var(--fg-mute); letter-spacing: .03em; }
.metric .v { font-size: 1rem; font-weight: 620; font-variant-numeric: tabular-nums; }
.metric .v.ok { color: var(--ok); }
.metric .v.warn { color: var(--warn); }
.metric .v.err { color: var(--err); }

/* ---------- admin overview ---------- */
.overview-panel {
  gap: .9rem;
  background: linear-gradient(145deg, rgba(124,159,255,.055), var(--surface) 42%);
}
.overview-head { align-items: flex-start; }
.overview-head > div:first-child { display: grid; gap: .18rem; }
.overview-caption { color: var(--fg-mute); font-size: .76rem; }
.overview-health {
  display: inline-flex; align-items: center; gap: .42rem;
  color: var(--fg-dim); font-size: .78rem;
  padding: .28rem .62rem; border: 1px solid var(--line); border-radius: 999px;
  background: rgba(0,0,0,.14);
}
.overview-health-dot, .overview-user-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--fg-mute); flex: none;
}
.overview-health.ok { color: var(--ok); border-color: rgba(61,220,132,.25); }
.overview-health.warn { color: var(--warn); border-color: rgba(240,180,41,.28); }
.overview-health.err { color: var(--err); border-color: rgba(255,92,92,.28); }
.overview-health.ok .overview-health-dot, .overview-user-dot.ok { background: var(--ok); }
.overview-health.warn .overview-health-dot, .overview-user-dot.warn { background: var(--warn); }
.overview-health.err .overview-health-dot, .overview-user-dot.err,
.overview-user-dot.hot { background: var(--hot); }

.overview-stats {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  background: rgba(0,0,0,.12); overflow: hidden;
}
.overview-stat {
  min-width: 0; padding: .6rem .72rem;
  display: grid; gap: .08rem; border-right: 1px solid var(--line-soft);
}
.overview-stat:last-child { border-right: none; }
.overview-stat-action {
  border-width: 0 1px 0 0; border-color: var(--line-soft); border-radius: 0;
  background: transparent; color: inherit; text-align: left; font-weight: inherit;
  transform: none;
}
.overview-stat-action:hover { background: rgba(124,159,255,.08); }
.overview-stat-action:active { transform: none; }
.overview-stat-action:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.overview-stat-action[aria-pressed="true"] { background: rgba(124,159,255,.12); }
.overview-stat-label { color: var(--fg-mute); font-size: .68rem; white-space: nowrap; }
.overview-stat-value {
  color: var(--fg); font-size: 1.02rem; line-height: 1.3;
  font-variant-numeric: tabular-nums; font-weight: 660;
}
.overview-stat-value.ok, .overview-user-facts b.ok { color: var(--ok); }
.overview-stat-value.warn, .overview-user-facts b.warn { color: var(--warn); }
.overview-stat-value.err, .overview-user-facts b.err { color: var(--err); }
.overview-stat-value.hot { color: var(--hot); }

.cluster-nodes { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .5rem; }
.cluster-node {
  display: flex; align-items: center; gap: .55rem; min-width: 0;
  padding: .52rem .65rem; border: 1px solid var(--line-soft); border-radius: 10px;
  background: rgba(0,0,0,.1);
}
.cluster-node-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--fg-mute); }
.cluster-node.online .cluster-node-dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(61,220,132,.1); }
.cluster-node.offline .cluster-node-dot { background: var(--err); }
.cluster-node-main { min-width: 0; display: grid; gap: .08rem; }
.cluster-node-main b { color: var(--fg); font-size: .78rem; }
.cluster-node-main small { color: var(--fg-mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cluster-node-load { margin-left: auto; display: grid; text-align: right; }
.cluster-node-load small { color: var(--fg-mute); font-size: .62rem; }
.cluster-node-load strong { color: var(--fg-dim); font-family: var(--mono); font-size: .82rem; }


/* ---------- panels ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .95rem 1.1rem 1.1rem;
  display: grid; gap: .8rem;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: .7rem; flex-wrap: wrap; }
.pill {
  font-size: .74rem; padding: .18rem .58rem; border-radius: 999px;
  background: var(--surface-3); color: var(--fg-dim); font-variant-numeric: tabular-nums;
}
.pill.hot { background: rgba(61,220,132,.16); color: var(--ok); }
.empty { color: var(--fg-mute); font-size: .82rem; text-align: center; padding: .6rem 0; }
.legend { display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; color: var(--fg-mute); }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.open { background: rgba(61,220,132,.5); }
.sw.full { background: rgba(255,255,255,.07); }
.sw.tgt { background: transparent; box-shadow: inset 0 0 0 1.5px var(--accent); }
.sw.watched { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }

/* ---------- target slots ---------- */
.targets { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
.slot {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .6rem .7rem; background: var(--surface-2);
  display: grid; gap: .1rem; position: relative; overflow: hidden;
  transition: border-color .2s, background .2s;
}
.slot .d { font-family: var(--mono); font-size: .74rem; color: var(--fg-mute); }
.slot .t { font-size: 1.12rem; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.slot .s { font-size: .73rem; color: var(--fg-mute); }
.slot.open {
  border-color: rgba(61,220,132,.45);
  background: linear-gradient(150deg, rgba(61,220,132,.14), var(--surface-2));
  animation: breathe 2s ease-in-out infinite;
}
.slot.open .s { color: var(--ok); font-weight: 620; }
.slot.open .t { color: var(--ok); }
@keyframes breathe { 0%,100% { box-shadow: 0 0 0 0 rgba(61,220,132,0) } 50% { box-shadow: 0 0 18px 0 rgba(61,220,132,.18) } }
.slot.past, .slot.stale { opacity: .38; }

/* ---------- matrix ---------- */
.edit-bar {
  display: flex; align-items: center; justify-content: space-between; gap: .7rem; flex-wrap: wrap;
  padding: .5rem .7rem; border-radius: var(--radius-sm);
  background: rgba(124,159,255,.1); border: 1px solid rgba(124,159,255,.28);
}
.matrix-wrap { overflow-x: auto; margin: 0 -.35rem; padding: 0 .35rem; }
.matrix { border-collapse: separate; border-spacing: 0 2px; font-size: .78rem; width: 100%; min-width: 400px; }
.matrix th { color: var(--fg-mute); font-weight: 500; font-family: var(--mono); font-size: .72rem; padding: 0 .2rem .3rem; text-align: center; }
.matrix td { padding: 0 .12rem; }
.matrix td.date {
  text-align: left; font-family: var(--mono); font-size: .74rem;
  color: var(--fg-dim); white-space: nowrap; padding-right: .5rem; width: 1%;
}
.matrix tr.is-target td.date { color: var(--accent); font-weight: 620; }
.matrix tr.is-past td.date { opacity: .4; }
.matrix .cell {
  display: block; border-radius: 5px; padding: .26rem 0; text-align: center;
  font-family: var(--mono); font-size: .72rem; user-select: none;
  background: rgba(255,255,255,.045); color: var(--fg-mute);
  transition: background .15s, box-shadow .15s, color .15s;
}
.matrix .cell.open { background: rgba(61,220,132,.26); color: #7ff0af; font-weight: 700; }
.matrix .cell.unknown { background: rgba(255,255,255,.02); color: #363f4d; }
.matrix .cell.target { box-shadow: inset 0 0 0 1.5px var(--accent); }
.matrix tr.is-past .cell { opacity: .38; }
.matrix.editing .cell { cursor: pointer; }
.matrix.editing .cell:hover { background: rgba(124,159,255,.24); color: var(--fg); }
.matrix.editing .cell.target { box-shadow: inset 0 0 0 2px var(--accent); background: rgba(124,159,255,.2); color: #cfdcff; }
.matrix.editing tr.is-past .cell { cursor: not-allowed; }

/* ---------- attempts ---------- */
.attempts { border-collapse: collapse; width: 100%; font-size: .78rem; min-width: 520px; }
.attempts th, .attempts td { padding: .38rem .55rem; border-bottom: 1px solid var(--line-soft); text-align: left; white-space: nowrap; }
.attempts th { color: var(--fg-mute); font-weight: 500; font-size: .72rem; }
.attempts td { font-family: var(--mono); font-size: .74rem; color: var(--fg-dim); }
.attempts tr.ok td { color: var(--ok); }

/* ---------- success ---------- */
.success-panel { border-color: rgba(61,220,132,.4); background: linear-gradient(150deg, rgba(61,220,132,.09), var(--surface)); }
.success-body { display: grid; gap: .35rem; }
.success-body .kv { display: flex; justify-content: space-between; gap: 1rem; font-size: .84rem; padding: .3rem 0; border-bottom: 1px solid var(--line-soft); }
.success-body .kv:last-child { border-bottom: none; }
.success-body .kv span:first-child { color: var(--fg-mute); }
.success-body .kv span:last-child { font-family: var(--mono); font-size: .8rem; }

/* ---------- log ---------- */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { border: none; border-radius: 0; background: transparent; color: var(--fg-mute); padding: .22rem .62rem; font-size: .74rem; }
.seg button.on { background: var(--surface-3); color: var(--fg); }
.log-filters { display: flex; justify-content: flex-end; gap: .45rem; flex-wrap: wrap; }
.log { max-height: 320px; overflow-y: auto; display: grid; gap: 1px; font-family: var(--mono); font-size: .74rem; align-content: start; }
.log .line { display: grid; grid-template-columns: 58px 60px 1fr; gap: .5rem; padding: .22rem .3rem; border-radius: 4px; }
.log .line.has-node { grid-template-columns: 58px 72px 60px 1fr; }
.log .line:hover { background: rgba(255,255,255,.035); }
.log .ts, .log .kind { color: var(--fg-mute); }
.log-node { color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log .msg { color: var(--fg-dim); word-break: break-word; }
.log .repeat {
  margin-left: .45rem; padding: 0 .4rem; border-radius: 999px;
  background: rgba(240,180,41,.14); color: var(--warn); font-size: .68rem; font-weight: 640;
}
.log-day {
  display: flex; align-items: center; gap: .6rem; padding: .5rem .3rem .25rem;
  color: var(--fg-mute); font-size: .68rem; letter-spacing: .06em;
}
.log-day::before, .log-day::after { content: ''; flex: 1; border-top: 1px solid var(--line-soft); }
.log .line.warn .msg { color: var(--warn); }
.log .line.error .msg { color: var(--err); }
.log .line.success .msg { color: var(--ok); font-weight: 620; }

.foot { display: flex; justify-content: center; gap: .5rem; padding: 1rem 0 .3rem; color: var(--fg-mute); font-size: .75rem; letter-spacing: .03em; }
.foot .sep { opacity: .45; }

/* ---------- drawer ---------- */
.drawer-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(2px); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: min(460px, 100%);
  background: var(--surface); border-left: 1px solid var(--line);
  display: grid; grid-template-rows: auto auto 1fr auto;
  box-shadow: -20px 0 50px rgba(0,0,0,.5);
  animation: slidein .22s ease-out;
}
@keyframes slidein { from { transform: translateX(24px); opacity: .4 } to { transform: none; opacity: 1 } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: .9rem 1.1rem; border-bottom: 1px solid var(--line-soft); }
.drawer-head h2 { font-size: .95rem; text-transform: none; letter-spacing: 0; color: var(--fg); }
.tabs { display: flex; gap: .25rem; padding: .6rem 1.1rem 0; border-bottom: 1px solid var(--line-soft); overflow-x: auto; }
.tabs button {
  background: transparent; border: none; border-radius: 0; color: var(--fg-mute);
  padding: .4rem .55rem .55rem; font-size: .83rem; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button.on { color: var(--fg); border-bottom-color: var(--accent); }
.drawer-body { overflow-y: auto; padding: 1.1rem; }
.tabpane { display: none; gap: .85rem; }
.tabpane.on { display: grid; }
.drawer-foot { display: flex; align-items: center; justify-content: space-between; gap: .7rem; padding: .8rem 1.1rem; border-top: 1px solid var(--line-soft); background: var(--surface-2); }

.note { background: rgba(124,159,255,.07); border: 1px solid rgba(124,159,255,.18); border-radius: var(--radius-sm); padding: .7rem .85rem; font-size: .8rem; color: var(--fg-dim); display: grid; gap: .4rem; }
.note ol { margin: 0; padding-left: 1.1rem; display: grid; gap: .22rem; }
.session-box { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .7rem .85rem; font-size: .84rem; display: grid; gap: .3rem; }
.session-box .kv { display: flex; justify-content: space-between; gap: 1rem; }
.session-box .kv span:first-child { color: var(--fg-mute); font-size: .78rem; }
.session-box .kv span:last-child { font-family: var(--mono); font-size: .78rem; }

.credential-login-box, .credential-inline {
  border: 1px solid rgba(124,159,255,.25); border-radius: var(--radius-sm);
  background: rgba(124,159,255,.065); padding: .75rem .82rem; display: grid; gap: .65rem;
}
.credential-login-head, .credential-inline-head { display: flex; justify-content: space-between; gap: .7rem; align-items: flex-start; }
.credential-login-head b, .credential-inline-head b { color: var(--fg); font-size: .85rem; }
.credential-login-head p { color: var(--fg-mute); font-size: .74rem; margin: .15rem 0 0; }
.secure-chip, .vip-badge, .node-badge {
  flex: none; border-radius: 999px; padding: .12rem .42rem; font-size: .62rem; font-weight: 650;
}
.secure-chip { color: var(--ok); border: 1px solid rgba(61,220,132,.25); background: rgba(61,220,132,.08); }
.vip-badge { color: #ffd66b; border: 1px solid rgba(255,214,107,.3); background: rgba(255,214,107,.1); }
.node-badge { color: var(--accent); border: 1px solid rgba(124,159,255,.25); background: rgba(124,159,255,.08); }
.credential-inline-fields { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) auto; gap: .45rem; }
.credential-inline-fields input { min-width: 0; }
.manual-login { border-top: 1px solid var(--line-soft); padding-top: .5rem; }
.manual-login summary { cursor: pointer; color: var(--fg-mute); font-size: .76rem; user-select: none; }
.manual-login[open] summary { margin-bottom: .75rem; color: var(--fg-dim); }
.manual-login > *:not(summary) + * { margin-top: .65rem; }

.otp-dialog {
  width: min(390px, calc(100vw - 2rem)); border: 1px solid var(--line); border-radius: 16px;
  padding: 0; color: var(--fg); background: var(--surface); box-shadow: 0 24px 80px rgba(0,0,0,.65);
}
.otp-dialog::backdrop { background: rgba(3,5,10,.72); backdrop-filter: blur(4px); }
.otp-dialog form { padding: 1.35rem; display: grid; gap: .8rem; text-align: center; }
.otp-dialog h2 { font-size: 1.05rem; text-transform: none; letter-spacing: 0; }
.otp-dialog p { color: var(--fg-mute); font-size: .8rem; margin: 0; }
.otp-dialog .err { color: var(--err); min-height: 1.1em; }
.otp-dialog input { text-align: center; font: 650 1.2rem var(--mono); letter-spacing: .24em; }
.otp-icon { width: 42px; height: 42px; margin: 0 auto; border-radius: 13px; display: grid; place-items: center; background: rgba(124,159,255,.12); color: var(--accent); font-size: 1.2rem; }
.otp-secondary { justify-content: center; }

.field { display: grid; gap: .3rem; }
.flabel { font-size: .82rem; color: var(--fg-dim); }
.fhint { font-size: .73rem; color: var(--fg-mute); }
.field-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .8rem; }
.suffix { display: flex; align-items: center; gap: .4rem; }
.suffix .unit { color: var(--fg-mute); font-size: .78rem; flex: none; }
.group { display: grid; gap: .8rem; padding-bottom: .3rem; }
.group > .gtitle { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-mute); border-bottom: 1px solid var(--line-soft); padding-bottom: .35rem; }

/* toggle */
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 1rem; cursor: pointer; }
.toggle .tt { display: grid; gap: .1rem; }
.switch { width: 42px; height: 24px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--line); position: relative; flex: none; transition: background .18s, border-color .18s; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--fg-mute); transition: transform .18s, background .18s; }
input[type=checkbox] { position: absolute; opacity: 0; width: 0; height: 0; }
input[type=checkbox]:checked + .switch { background: rgba(124,159,255,.3); border-color: var(--accent-dim); }
input[type=checkbox]:checked + .switch::after { transform: translateX(18px); background: var(--accent); }
input[type=checkbox]:focus-visible + .switch { box-shadow: 0 0 0 3px rgba(124,159,255,.2); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 1.3rem; transform: translateX(-50%);
  background: var(--surface-3); border: 1px solid var(--line);
  padding: .6rem 1.1rem; border-radius: 999px; font-size: .84rem;
  box-shadow: var(--shadow); z-index: 100; max-width: calc(100vw - 2rem); text-align: center;
  animation: rise .2s ease-out;
}
@keyframes rise { from { transform: translate(-50%, 8px); opacity: 0 } to { transform: translate(-50%, 0); opacity: 1 } }
.toast.err { border-color: var(--err); color: var(--err); }
.toast.ok { border-color: var(--ok); color: var(--ok); }

/* ---------- multi-user ---------- */
/* h2 is uppercased; a person's name must not be. */
.h2-name { text-transform: none; color: var(--fg-mute); font-weight: 500; letter-spacing: 0; }
.role {
  align-self: center; flex: none;
  font-size: .68rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--accent); background: rgba(124,159,255,.12);
  border: 1px solid rgba(124,159,255,.28); border-radius: 999px; padding: .16rem .5rem;
}

/* ---------- the one user list ----------
 * Stats, view switching, per-user status and actions all live in this single
 * panel: the same sixteen people must never be painted three times. */
.overview-toolbar { display: flex; gap: .45rem; align-items: center; flex-wrap: wrap; }
.toolbar-spring { flex: 1; }

.user-list { display: grid; border-top: 1px solid var(--line-soft); }
.user-row { border-bottom: 1px solid var(--line-soft); }
.user-row:last-child { border-bottom: none; }
.user-row.sel { background: rgba(124,159,255,.06); box-shadow: inset 3px 0 0 var(--accent); }
.user-row-line { display: flex; align-items: center; gap: .5rem; padding: .18rem .35rem .18rem 0; }
.user-row-main {
  flex: 1; display: flex; align-items: center; gap: .6rem; min-width: 0;
  background: none; border: none; border-radius: 0; text-align: left;
  padding: .5rem .2rem .5rem .6rem; font-size: .8rem; color: var(--fg-dim);
}
.user-row-main:hover { background: rgba(255,255,255,.025); }
.user-row-main:active { transform: none; }
/* Fixed columns for name and status so sixteen rows read as a table. */
.user-row-name { color: var(--fg); font-size: .85rem; flex: 0 0 6.5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row-off { color: var(--fg-mute); font-size: .68rem; flex: none; }
.user-chip {
  flex: none; min-width: 4.6em; text-align: center;
  font-size: .7rem; font-weight: 620; border-radius: 999px; padding: .12rem .5rem;
  color: var(--fg-mute); background: rgba(255,255,255,.05);
}
.user-chip.ok { color: var(--ok); background: rgba(61,220,132,.1); }
.user-chip.warn { color: var(--warn); background: rgba(240,180,41,.1); }
.user-chip.err, .user-chip.hot { color: var(--hot); background: rgba(255,92,92,.1); }
.user-fact { display: inline-flex; align-items: baseline; gap: .3rem; min-width: 0; white-space: nowrap; }
.user-fact[data-login-fact] { flex: 0 1 15em; }
.user-fact small { color: var(--fg-mute); font-size: .66rem; }
.user-fact b { font-size: .76rem; font-weight: 560; overflow: hidden; text-overflow: ellipsis; max-width: 15em; }
.user-fact .ok { color: var(--ok); }
.user-fact .warn { color: var(--warn); }
.user-fact .hot { color: var(--hot); }
.user-fact .mute { color: var(--fg-mute); }
.user-row-actions { position: relative; display: flex; gap: .3rem; flex: none; }
.user-row-actions .login-toggle.on, .user-row-actions .menu-toggle.on { color: var(--accent); border-color: var(--accent-dim); }

/* Low-frequency actions live behind "⋯" so no screen width ever hides them. */
.user-menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 30;
  min-width: 130px; display: grid; padding: .3rem;
  background: var(--surface-3); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow);
}
.user-menu button {
  background: none; border: none; border-radius: 7px; text-align: left;
  padding: .45rem .6rem; font-size: .78rem; color: var(--fg-dim); white-space: nowrap;
}
.user-menu button:hover { background: rgba(124,159,255,.12); color: var(--fg); }
.user-menu button.danger-text:hover { background: rgba(255,92,92,.12); }

.user-rename-form { flex: 1; display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; padding: .35rem 0 .35rem .6rem; min-width: 0; }
.user-rename-form input { width: 138px; min-width: 110px; padding: .34rem .48rem; font-size: .8rem; }
.user-rename-feedback { flex-basis: 100%; min-height: 1em; font-size: .7rem; white-space: normal; }

.add-user { display: flex; gap: .45rem; align-items: center; flex-wrap: wrap; }
.add-user input { flex: 1; min-width: 160px; }

.user-login-editor { padding: .85rem .95rem 1rem; display: grid; gap: .72rem; background: rgba(124,159,255,.035); border-top: 1px solid var(--line-soft); }
.user-login-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.user-login-head b { color: var(--fg); font-size: .88rem; }
.user-login-head p { margin: .18rem 0 0; color: var(--fg-mute); font-size: .75rem; }
.session-badge { flex: none; border: 1px solid var(--line); border-radius: 999px; padding: .18rem .55rem; color: var(--fg-mute); font-size: .72rem; }
.session-badge.ok { border-color: rgba(67,207,139,.35); color: var(--ok); }
.session-badge.hot { border-color: rgba(255,94,122,.35); color: var(--hot); }
.user-login-meta { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)); gap: .4rem .7rem; }
.user-login-meta .kv { display: flex; justify-content: space-between; gap: .6rem; padding: .42rem .55rem; border: 1px solid var(--line-soft); border-radius: 8px; background: var(--surface); }
.user-login-meta .kv span:first-child { color: var(--fg-mute); font-size: .72rem; }
.user-login-meta .kv span:last-child { color: var(--fg-dim); font-family: var(--mono); font-size: .72rem; text-align: right; }
.user-login-editor textarea { width: 100%; min-height: 82px; resize: vertical; font-family: var(--mono); font-size: .75rem; }
.user-login-editor .small { margin: -.35rem 0 0; }
.user-login-feedback { min-height: 1em; margin: -.35rem 0 0; }
.user-login-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

/* Someone else in the group wants this slot — admin view only. */
.matrix .cell.watched { box-shadow: inset 0 0 0 1px var(--line); }

@media (max-width: 620px) {
  .hero { padding: .9rem 1rem; }
  .hero-state { font-size: 1.14rem; }
  .hero-actions { width: 100%; }
  .hero-actions button { flex: 1; }
  .metrics { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
  .overview-head { display: grid; }
  .overview-health { justify-self: start; }
  .overview-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .overview-stat:nth-child(3n) { border-right: none; }
  .overview-stat:nth-child(-n+3) { border-bottom: 1px solid var(--line-soft); }
  /* Rows wrap to two lines: identity + status on top, facts underneath. */
  .user-row-main { flex-wrap: wrap; row-gap: .12rem; padding: .5rem .2rem .55rem .6rem; }
  .user-row-name { flex: 0 1 auto; max-width: 40vw; }
  .user-fact[data-login-fact] { flex: none; }
  .user-fact { flex: none; }
  .user-fact[data-login-fact] b { max-width: 9em; }
  .panel { padding: .85rem .9rem 1rem; }
  .drawer { width: 100%; }
  .log-filters { width: 100%; justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto; padding-bottom: .15rem; }
  .log-filters .seg { flex: none; }
  .log .line { grid-template-columns: 52px 1fr; }
  .log .kind { display: none; }
  .user-login-meta { grid-template-columns: 1fr; }
  .user-login-head { align-items: center; }
  .credential-inline-fields { grid-template-columns: 1fr; }
  .log .line.has-node { grid-template-columns: 52px 64px 1fr; }
}
