/* ── Wheelhouse design system ─────────────────────────────────────── */
:root {
  --bg:        #0d1117;
  --bg-soft:   #10161f;
  --panel:     #151d28;
  --panel-2:   #1b2532;
  --panel-3:   #222e3e;
  --line:      #263140;
  --line-soft: #1e2836;
  --text:      #e6edf5;
  --text-dim:  #9aa8ba;
  --muted:     #6b7a8f;
  --accent:    #4a7dff;
  --accent-hi: #6a94ff;
  --accent-bg: rgba(74, 125, 255, .14);
  --green:     #34c98e;
  --green-bg:  rgba(52, 201, 142, .13);
  --red:       #ef6a6f;
  --red-bg:    rgba(239, 106, 111, .12);
  --amber:     #e6b45a;
  --amber-bg:  rgba(230, 180, 90, .13);
  --radius:    12px;
  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.5);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14.5px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-bg); }

/* ── layout ─────────────────────────────────────────────────────────── */
#layout { display: flex; min-height: 100vh; }
.modebar {
  text-align: center; font-size: 11px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; padding: 3px 8px; line-height: 1.4;
}
.modebar.normal { background: #2f6fd0; color: #eaf1fb; }
.modebar.debug  { background: #d9a514; color: #2a2004; }
#sidebar {
  width: 218px; flex-shrink: 0; display: flex; flex-direction: column; gap: 4px;
  padding: 18px 12px 14px; background: var(--bg-soft);
  border-right: 1px solid var(--line-soft); position: sticky; top: 0; height: 100vh;
}
#content { flex: 1; min-width: 0; }
main { max-width: 1080px; margin: 0 auto; padding: 30px 34px 60px; }

.brand {
  display: flex; align-items: center; gap: 9px; padding: 2px 8px 10px;
  font-weight: 650; font-size: 15px; letter-spacing: .01em; color: var(--text);
}
.logo { width: 20px; height: 20px; flex-shrink: 0; }

.acct-chip {
  padding: 5px 10px; border-radius: 8px;
  background: var(--panel); border: 1px solid var(--line-soft);
  font-family: var(--mono); font-size: 12px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* account identity block under the brand: avatar + number (or switcher) */
.acct {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  margin: 0 6px 14px;
}
.acct .acct-chip { margin: 0; max-width: 100%; }
.acct-switch { display: flex; gap: 5px; align-items: center; min-width: 0; }
.acct-switch select {
  flex: 1; min-width: 0; font-family: var(--mono); font-size: 11.5px;
  padding: 4px 6px; border-radius: 8px; background: var(--panel);
  color: var(--text-dim); border: 1px solid var(--line-soft); max-width: 148px;
}

nav#nav { display: flex; flex-direction: column; gap: 2px; }
nav#nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 9px; color: var(--text-dim); text-decoration: none;
  font-size: 14px; font-weight: 500; transition: background .12s, color .12s;
}
nav#nav a:hover { background: var(--panel); color: var(--text); }
nav#nav a.on { background: var(--accent-bg); color: var(--accent-hi); }
nav#nav a svg.ic, nav#nav a .ic { width: 17px; height: 17px; flex-shrink: 0; }
.ic { width: 17px; height: 17px; flex-shrink: 0; stroke: currentColor; }
svg.ic { display: block; }

.side-foot {
  margin-top: auto; padding: 10px 8px 0; color: var(--muted);
  font-size: 11px; line-height: 1.5; text-align: center;
}

@media (max-width: 860px) {
  #layout { flex-direction: column; }
  #sidebar { width: auto; height: auto; position: static; flex-direction: row;
    align-items: center; flex-wrap: wrap; gap: 6px; padding: 10px 12px;
    border-right: none; border-bottom: 1px solid var(--line-soft); }
  .brand { padding: 0 6px; }
  .acct { flex-direction: row; margin: 0 0 0 auto; }
  nav#nav { flex-direction: row; flex-wrap: wrap; width: 100%; }
  nav#nav a { padding: 6px 9px; }
  nav#nav span { display: none; }
  .side-foot { display: none; }
  main { padding: 18px 14px 48px; }
}

/* ── typography ─────────────────────────────────────────────────────── */
h1 { font-size: 21px; font-weight: 650; margin: 2px 0 18px; letter-spacing: -.01em; }
h2 {
  font-size: 11.5px; font-weight: 650; margin: 2px 0 12px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .09em;
}
h1 + .grid, h1 + .cards { margin-top: -6px; }
a { color: var(--accent-hi); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 8px 0; }
code {
  background: var(--panel-2); border: 1px solid var(--line-soft);
  padding: 1px 6px; border-radius: 6px; font: 12.5px var(--mono); color: var(--text-dim);
}
.muted  { color: var(--muted); }
.small  { font-size: 12px; }
.mono   { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.wrap   { word-break: break-all; }
.right  { text-align: right; }
.quote-card { border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; margin: 2px 0 12px; background: var(--bg-soft); }
.quote-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.quote-head .quote-bar { width: 3px; height: 16px; border-radius: 2px; background: var(--accent); flex-shrink: 0; }
.quote-head .muted { margin-left: auto; }
.quote-body { color: var(--text-dim); font-size: 13px; margin: 4px 0 2px 11px; }
.rowbtns { display: flex; gap: 5px; justify-content: flex-end; align-items: center; white-space: nowrap; }
.rowbtns form.inline { margin: 0; }
.device {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 2px; border-bottom: 1px solid var(--line-soft);
}
.device:last-of-type { border-bottom: none; }
.center { text-align: center; }
.avatar-row { display: flex; gap: 14px; align-items: center; margin-bottom: 6px; }
.avatar.lg { border-radius: 50%; object-fit: cover; background: var(--panel-3);
  border: 1px solid var(--line); display: inline-block; }
.note {
  margin-top: 12px; padding: 9px 12px; border-radius: 9px; font-size: 13px;
  background: var(--amber-bg); border: 1px solid rgba(230,180,90,.3); color: #e9c886;
}

/* ── cards & grids ──────────────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 16px; }
.card {
  background: linear-gradient(180deg, var(--panel) 0%, #141b26 100%);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card.warn { border-color: #55441f; background: linear-gradient(180deg, #211b10, #1a150c); }
.card.info { border-color: rgba(74,125,255,.35); background: linear-gradient(180deg, #131f33, #101826); }
.card.info h2 { color: var(--accent-hi); }
.card.info p { margin: 0; }
.card.err  { border-color: #58262a; }
.card ul { margin: 6px 0 0; padding-left: 20px; }

.cards.metrics { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.stat {
  flex: 1 1 148px; text-align: center; padding: 16px 10px 13px;
  background: linear-gradient(180deg, var(--panel), #141b26);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: var(--line);
}
.stat.in::after  { background: var(--accent); }
.stat.out::after { background: var(--green); }
.stat b { display: block; font-size: 27px; font-weight: 650; letter-spacing: -.02em; }
.stat b.dat { font-size: 18px; letter-spacing: 0; font-weight: 600; }
.stat span { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; }
.stat.in b { color: var(--accent-hi); }
.stat.out b { color: var(--green); }

/* ── tables ─────────────────────────────────────────────────────────── */
table { border-collapse: collapse; width: 100%; }
table.list td, table.list th, table.kv td { overflow-wrap: anywhere; }
table.list.fixed { table-layout: fixed; }
table.list.fixed td, table.list.fixed th { overflow-wrap: anywhere; }
table.list th {
  text-align: left; color: var(--muted); font-size: 10.5px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .08em; padding: 6px 10px;
  border-bottom: 1px solid var(--line);
}
table.list td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.list tbody tr:last-child td, table.list tr:last-child td { border-bottom: none; }
table.list tr { transition: background .1s; }
table.list tr:hover td { background: rgba(255,255,255,.017); }
table.kv td { padding: 5px 10px 5px 0; vertical-align: top; }
table.kv td:first-child { color: var(--muted); white-space: nowrap; }

/* ── badges ─────────────────────────────────────────────────────────── */
.pill {
  display: inline-block; padding: 1px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 550; background: var(--panel-2);
  border: 1px solid var(--line); color: var(--text-dim); white-space: nowrap;
}
.pill.ok   { color: var(--green); background: var(--green-bg); border-color: rgba(52,201,142,.35); }
.pill.err  { color: var(--red);   background: var(--red-bg);   border-color: rgba(239,106,111,.35); }
.pill.warn { color: var(--amber); background: var(--amber-bg); border-color: rgba(230,180,90,.35); }

/* ── buttons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-block; background: var(--panel-3); color: var(--text);
  cursor: pointer; border: 1px solid var(--line); border-radius: 9px;
  padding: 7px 13px; font: inherit; font-size: 13.5px; text-decoration: none !important;
  transition: border-color .12s, background .12s, transform .05s; box-shadow: 0 1px 0 rgba(0,0,0,.3);
}
.btn:hover  { border-color: #38506e; background: #26344a; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  border-color: transparent; color: #fff; font-weight: 550;
}
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { background: var(--red-bg); border-color: rgba(239,106,111,.4); color: #f5adaf; }
.btn.danger:hover { background: rgba(239,106,111,.22); }
.btn.sm { padding: 3px 9px; font-size: 12px; border-radius: 7px; }

/* ── forms ──────────────────────────────────────────────────────────── */
form { margin: 0 0 12px; }
form.inline { display: inline; margin: 0 2px; }
.form label { display: block; margin: 9px 0; color: var(--text-dim); font-size: 12.5px; }
.form label input, .form label select, .form label textarea {
  display: block; width: 100%; margin-top: 4px; }
.form .row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.form .row label, .form .row > input, .form .row > select { display: inline-block; width: auto; }
input, select, textarea, button { font: inherit; color-scheme: dark; }
input[type=text], input:not([type]), input[type=number], input[type=file], textarea, select {
  background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 9px; padding: 7px 10px;
}
input[type=file] { padding: 6px; font-size: 13px; }
textarea { width: 100%; resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
select[multiple] { padding: 4px; }
select[multiple] option { padding: 3px 7px; border-radius: 5px; }
label.check, .check { display: flex; gap: 8px; align-items: center; color: var(--text); cursor: pointer; }
input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; }

/* ── flash messages ─────────────────────────────────────────────────── */
.flash {
  display: flex; align-items: center; gap: 10px; padding: 11px 15px;
  border-radius: var(--radius); margin-bottom: 18px; font-size: 14px; box-shadow: var(--shadow);
}
.flash svg { width: 17px; height: 17px; flex-shrink: 0; }
.flash.ok  { background: var(--green-bg); border: 1px solid rgba(52,201,142,.3); color: #9fe5c6; }
.flash.err { background: var(--red-bg);   border: 1px solid rgba(239,106,111,.3); color: #f5b7ba; }

/* ── inbox ──────────────────────────────────────────────────────────── */
.scrollbox {
  max-height: 72vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
table.msgs { table-layout: fixed; width: 100%; }
table.msgs td { padding: 7px 10px; overflow-wrap: anywhere; }
table.msgs tr.dir-in  td:first-child { border-left: 2px solid var(--accent); }
table.msgs tr.dir-out td:first-child { border-left: 2px solid var(--green); }
table.msgs thead th { position: sticky; top: 0; background: var(--panel); z-index: 1; }
.att {
  margin-left: 6px; text-decoration: none !important; background: var(--panel-2);
  border: 1px solid var(--line); padding: 0 7px; border-radius: 6px;
  font-size: 12px; white-space: nowrap; display: inline-block;
}

/* ── avatars ────────────────────────────────────────────────────────── */
.avatar {
  width: 30px; height: 30px; border-radius: 50%; object-fit: cover;
  vertical-align: middle; display: inline-block; margin-right: 8px;
  background: var(--panel-3); border: 1px solid var(--line);
  flex-shrink: 0;
}
img.avatar { max-width: 30px; }
span.avatar { background: linear-gradient(135deg, var(--accent), #7a5cff); border: none; }
.avatar.init {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; background: linear-gradient(135deg, #3d5f9e, #7a5cff);
  color: #fff; font-weight: 650; font-size: 12px; letter-spacing: .02em;
  vertical-align: middle; margin-right: 8px; text-transform: uppercase;
  user-select: none; line-height: 1;
}
.avatar.sm { margin-right: 6px; }

/* ── dropdown-in-table (verify…) ────────────────────────────────────── */
.drop { display: inline-block; position: relative; }
.drop summary { list-style: none; cursor: pointer; display: inline-block; }
.drop[open] { z-index: 6; }
.drop form {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; position: absolute; right: 0; top: 110%; width: 360px;
  max-width: 82vw; box-shadow: var(--shadow);
}

/* ── chart ──────────────────────────────────────────────────────────── */
.chart svg { max-width: 100%; height: auto; display: block; }
.metric-controls { display: flex; align-items: center; gap: 12px; margin: 4px 0 14px; }
.metric-controls select { min-width: 150px; }
.chart { padding: 4px 0 2px; }
.legend { font-size: 12px; }
.legend i.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.sw.in  { background: var(--accent); }
.sw.out { background: var(--green); }

/* ── QR page ────────────────────────────────────────────────────────── */
.qr {
  display: inline-block; padding: 14px; background: #fff;
  border-radius: 14px; margin: 8px auto; box-shadow: var(--shadow);
}
.qr svg { width: 250px; height: 250px; display: block; }

/* ── privacy mask ───────────────────────────────────────────────────── */
.secret {
  background: #2b3648; color: transparent; border-radius: 5px;
  padding: 0 3px; cursor: pointer; user-select: none;
  -webkit-user-select: none; text-shadow: none; transition: background .12s, color .12s;
}
.secret:hover { outline: 1px solid var(--line); outline-offset: 1px; }
.secret.shown, body.revealed .secret {
  background: transparent; color: inherit; cursor: auto; user-select: auto;
  -webkit-user-select: auto;
}
#reveal-toggle { font-size: 12.5px; }

/* ── scrollbars ─────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--panel-3); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

tr.newrow td { animation: newrow-fade 3s ease-out 1; }
@keyframes newrow-fade { 0% { background: rgba(58,122,254,.30); } 100% { background: transparent; } }

.login-wrap { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 340px; }
.login-brand { display: flex; align-items: center; gap: 10px; }
.login-brand h1 { margin: 0; }
.center { text-align: center; }
button.wide { width: 100%; }

.topuser {
  position: fixed; top: 10px; right: 14px; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 6px 4px 12px;
}
.topuser .tu-name { color: var(--muted); font-size: 12.5px; text-decoration: none; }
.topuser .tu-name:hover { color: var(--fg, #d7e0ea); text-decoration: underline; }

input:disabled, select:disabled { opacity: .55; background: var(--bg-soft); cursor: not-allowed; }

.sso-sep { display: flex; align-items: center; gap: .6em; margin: .9em 0; color: var(--muted); font-size: .8rem; }
.sso-sep::before, .sso-sep::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.login-card .btn.wide + .sso-sep { margin-top: 1.1em; }

/* ── sidebar account avatar ── (two-class selectors placed last so they beat
   the generic .avatar / img.avatar sizing above) ── */
.avatar.acct-avatar { margin-right: 0; width: 132px; height: 132px; font-size: 48px; }
img.avatar.acct-avatar { max-width: 132px; }
@media (max-width: 860px) {
  .avatar.acct-avatar { margin-right: 0; width: 26px; height: 26px; font-size: 11px; }
  img.avatar.acct-avatar { max-width: 26px; }
}

.subtabs { display: flex; gap: 6px; margin: -14px 0 18px; }
.subtabs a { padding: 4px 12px; border-radius: 8px; font-size: 13px; text-decoration: none;
  color: var(--text-dim); border: 1px solid var(--line-soft); background: var(--panel); }
.subtabs a:hover { color: var(--text); }
.subtabs a.on { background: var(--accent-bg); color: var(--accent-hi); border-color: transparent; }
