/* Wembee admin. Structure follows the Regina console: sidebar with groups,
   page head with an icon, toolbar, tables in cards, KPI tiles. */
:root {
  --ink: #1d1716; --ink-soft: #3b3230; --surface: #f5f2ef; --card: #fff; --line: #e6dfda; --muted: #6f6560;
  --accent: #7a1f2b; --accent-deep: #5e1520; --accent-wash: #f6e6e8;
  --gold: #a8730c; --gold-wash: #f8eed9;
  --signal: #2f7a4a; --signal-wash: #e3f2e8;
  --info: #2a56d6; --info-wash: #e5ecfd;
  --danger: #b42335; --danger-wash: #fbe8ea;
  --radius: 14px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --ink: #f2ebe7; --ink-soft: #d8cdc8; --surface: #141010; --card: #1d1817; --line: #33292a; --muted: #a69a95;
  --accent: #e0707e; --accent-deep: #f08c98; --accent-wash: #3a1c21;
  --gold: #e8b04a; --gold-wash: #3a2c14;
  --signal: #7cc796; --signal-wash: #17301f;
  --info: #8aa8ff; --info-wash: #1c2645;
  --danger: #ff8a96; --danger-wash: #3d1a1f;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #f2ebe7; --ink-soft: #d8cdc8; --surface: #141010; --card: #1d1817; --line: #33292a; --muted: #a69a95;
    --accent: #e0707e; --accent-deep: #f08c98; --accent-wash: #3a1c21;
    --gold: #e8b04a; --gold-wash: #3a2c14;
    --signal: #7cc796; --signal-wash: #17301f;
    --info: #8aa8ff; --info-wash: #1c2645;
    --danger: #ff8a96; --danger-wash: #3d1a1f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--surface); color: var(--ink); font: 14px/1.5 Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; }
h1 { font-size: 24px; line-height: 1.2; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 18px 0 6px; }
p { margin: 0 0 10px; }
.i { flex: none; vertical-align: middle; }
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.clip { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
button:not(:disabled), a[href], select, summary, label[for] { cursor: pointer; }

/* ------------------------------------------------------------------ shell */
.shell { display: flex; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; width: 232px; flex: none; display: flex; flex-direction: column; padding: 16px 12px; background: var(--card); border-right: 1px solid var(--line); overflow-y: auto; transition: width .2s ease-out; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 8px; border-radius: 10px; color: var(--ink); text-decoration: none; min-width: 0; }
.logo:hover { background: var(--surface); }
.logo-mark { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 9px; background: var(--accent-wash); color: var(--accent); }
.logo-text { line-height: 1.15; min-width: 0; }
.wordmark { font-weight: 800; font-size: 16px; letter-spacing: -0.02em; color: var(--gold); }
.wordmark i { font-style: normal; color: var(--ink); }
.logo-sub { display: block; font-size: 10.5px; color: var(--muted); }
.icon-btn { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border: 0; border-radius: 9px; background: none; color: var(--muted); padding: 0; }
.icon-btn:hover { background: var(--accent-wash); color: var(--accent); }
.side-open { display: none; width: 100%; margin-top: 12px; }

.nav { margin-top: 18px; display: flex; flex-direction: column; gap: 2px; }
.nav + .nav { margin-top: 16px; }
.nav-title { padding: 0 12px 4px; font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 9px; color: var(--muted); text-decoration: none; font-size: 13.5px; }
.nav a:hover { background: var(--surface); color: var(--ink); }
.nav a[aria-current] { background: var(--accent-wash); color: var(--accent); font-weight: 600; }
.nav a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.nav .count { flex: none; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--card); font-size: 11px; font-weight: 700; text-align: center; line-height: 18px; }

.side-foot { margin-top: auto; padding-top: 12px; }
.theme { display: flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 9px; margin-bottom: 10px; }
.theme button { flex: 1; display: grid; place-items: center; height: 28px; border: 0; border-radius: 7px; background: none; color: var(--muted); padding: 0; }
.theme button[aria-pressed="true"] { background: var(--accent-wash); color: var(--accent); }
.me { display: flex; align-items: center; gap: 10px; padding: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--accent-wash); color: var(--accent); font-weight: 700; font-size: 13px; }
.me-text { min-width: 0; line-height: 1.2; flex: 1; }
.me-name, .me-role { display: block; }
.me-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-role { font-size: 11px; color: var(--muted); }
.logout { margin: 0; }
.logout .icon-btn:hover { background: var(--danger-wash); color: var(--danger); }

/* collapsed rail */
.collapsed .side { width: 68px; padding-inline: 10px; }
.collapsed .logo-text, .collapsed .nav-title, .collapsed .nav a span, .collapsed .nav .count, .collapsed .me-text, .collapsed .theme, .collapsed .side-close { display: none; }
.collapsed .side-head, .collapsed .logo { justify-content: center; padding-inline: 0; }
.collapsed .side-open { display: grid; }
.collapsed .nav a { justify-content: center; padding-inline: 0; }
.collapsed .me { flex-direction: column; padding-inline: 0; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mobile-top { display: none; }
main { width: 100%; max-width: 1440px; padding: 20px 28px 48px; }

@media (max-width: 1023px) {
  .side { display: none; }
  .mobile-top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); overflow-x: auto; }
  .mobile-top nav { display: flex; gap: 4px; }
  .mobile-top nav a { padding: 6px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; white-space: nowrap; font-size: 13px; }
  .mobile-top nav a[aria-current] { background: var(--accent-wash); color: var(--accent); }
  main { padding: 16px; }
}

/* ------------------------------------------------------------------- page */
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: 13px; margin-bottom: 10px; }
.back:hover { color: var(--accent); }
.page-head { margin-bottom: 18px; }
.page-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-title > .i { color: var(--accent); }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 80ch; }
.head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

.flash { display: flex; align-items: center; gap: 8px; background: var(--signal-wash); color: var(--signal); padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 500; }
.error { background: var(--danger-wash); color: var(--danger); padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; }
.warn { background: var(--gold-wash); color: var(--gold); padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; }

/* toolbar */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.search-box { position: relative; flex: 1; min-width: 220px; max-width: 520px; margin: 0; }
.search-box .i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-box input { padding-left: 34px; height: 38px; }
.seg { display: inline-flex; flex-wrap: wrap; padding: 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.seg a { padding: 6px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: 13px; }
.seg a:hover { color: var(--ink); }
.seg a[aria-current] { background: var(--accent-wash); color: var(--accent); }
.total { color: var(--muted); font-size: 13px; }

/* tables */
.table-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface) 55%, transparent); }
td a.strong, .strong { color: var(--ink); font-weight: 600; text-decoration: none; }
td a.strong:hover { color: var(--accent); }
.sub { display: block; color: var(--muted); font-size: 12.5px; }
.num-col { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.empty-box { padding: 36px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.pager { display: flex; justify-content: flex-end; gap: 6px; margin-top: 10px; }

/* action chips (journal) */
.act { display: inline-flex; align-items: center; gap: 8px; }
.act-ico { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; flex: none; }
.tone-accent { background: var(--accent-wash); color: var(--accent); }
.tone-signal { background: var(--signal-wash); color: var(--signal); }
.tone-gold { background: var(--gold-wash); color: var(--gold); }
.tone-info { background: var(--info-wash); color: var(--info); }
.tone-danger { background: var(--danger-wash); color: var(--danger); }
.tone-muted { background: var(--surface); color: var(--muted); }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface); color: var(--muted); white-space: nowrap; vertical-align: middle; }
.badge.new, .badge.open, .badge.scheduled, .badge.warn { background: var(--gold-wash); color: var(--gold); }
.badge.in_progress, .badge.draft, .badge.info { background: var(--info-wash); color: var(--info); }
.badge.converted, .badge.resolved, .badge.active, .badge.ok, .badge.live { background: var(--signal-wash); color: var(--signal); }
.badge.rejected, .badge.suspended, .badge.blocked, .badge.bad, .badge.retired { background: var(--danger-wash); color: var(--danger); }
.badge.official { background: var(--accent-wash); color: var(--accent); }
.badge.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* KPI tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; color: var(--ink); text-decoration: none; }
a.tile:hover { border-color: var(--accent); }
.tile-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tile-label { font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.tile-ico { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; }
.tile-value { margin-top: 8px; font-size: 26px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.tile-sub { margin-top: 6px; font-size: 12px; color: var(--muted); }

/* charts */
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; margin-bottom: 20px; }
.chart { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.chart h2 { display: flex; justify-content: space-between; gap: 8px; }
.chart h2 .muted { font-weight: 500; font-size: 13px; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; margin-top: 8px; }
.bar { flex: 1; min-width: 4px; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.bar span { display: block; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.bar:hover span { opacity: 1; }
.bars-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 6px; }
.funnel { display: grid; gap: 8px; margin-top: 8px; }
.funnel-row { display: grid; grid-template-columns: 120px 1fr 48px; gap: 10px; align-items: center; font-size: 13px; }
.funnel-track { height: 10px; border-radius: 999px; background: var(--surface); overflow: hidden; }
.funnel-track span { display: block; height: 100%; background: var(--gold); border-radius: 999px; }

/* detail pages */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .detail { grid-template-columns: 1fr; } }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.panel > h2:first-child { display: flex; align-items: center; gap: 8px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.note { border-top: 1px solid var(--line); padding: 10px 0; }
.note:first-of-type { border-top: 0; }
.note p { margin: 4px 0 0; }
.history { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.history li { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; }
.history .when { display: block; color: var(--muted); font-size: 12px; }
.steps { padding-left: 20px; }

/* forms */
form.stack { display: grid; gap: 12px; }
form.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: end; }
form.inline { display: inline; margin: 0; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 500; }
label small { font-size: 12px; font-weight: 400; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--ink); }
fieldset { border: 0; padding: 0; margin: 0; }
input, textarea, select { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; width: 100%; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn, button[type=submit]:not(.icon-btn):not(.link) { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; border: 1px solid transparent; border-radius: 9px; padding: 8px 15px; background: var(--accent); color: #fff; text-decoration: none; }
.btn:hover, button[type=submit]:not(.icon-btn):not(.link):hover { background: var(--accent-deep); }
:root[data-theme="dark"] .btn, :root[data-theme="dark"] button[type=submit]:not(.icon-btn):not(.link) { color: #1d1716; }
button.secondary, .btn.secondary { background: var(--card) !important; color: var(--ink) !important; border-color: var(--line) !important; }
button.secondary:hover, .btn.secondary:hover { border-color: var(--accent) !important; color: var(--accent) !important; }
button.danger { background: var(--card) !important; color: var(--danger) !important; border-color: var(--danger-wash) !important; }
button.danger:hover { background: var(--danger-wash) !important; }
button.small, .btn.small { padding: 4px 10px !important; font-size: 12.5px; }
button.link { background: none; border: 0; color: inherit; padding: 0; font-weight: 400; text-decoration: underline; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.wide { grid-column: 1 / -1; }

/* auth pages */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 28px; }
.auth-card .logo { padding: 0; margin-bottom: 20px; }
.auth-card h1 { font-size: 20px; margin-bottom: 14px; }
.qr { display: block; margin: 16px 0; width: 232px; height: 232px; image-rendering: pixelated; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.secret code { font-size: 14px; letter-spacing: .05em; }
.hint { margin-top: 14px; }

/* server-drawn SVG charts */
.barchart { display: block; width: 100%; height: 150px; margin-top: 8px; }
.barchart .axis { stroke: var(--line); stroke-width: 1; }
.barchart .hit { fill: transparent; }
.barchart .bar-r { fill: var(--accent); opacity: .85; }
.barchart g:hover .bar-r { opacity: 1; fill: var(--accent-deep); }
.chart.gold .bar-r { fill: var(--gold); }
.chart.info .bar-r { fill: var(--info); }
.chart.signal .bar-r { fill: var(--signal); }
.meter { display: block; width: 100%; height: 8px; }
.meter-bg { fill: var(--surface); }
.meter-fg { fill: var(--gold); }
.share { display: grid; grid-template-columns: 130px 1fr 44px; gap: 10px; align-items: center; font-size: 13px; margin-top: 10px; }
.share .num-col { text-align: right; }
.live-list { display: grid; gap: 8px; }
.live-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.live-item .grow { flex: 1; min-width: 0; }
.cols-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.chat-body { max-width: 520px; overflow-wrap: anywhere; }
.deleted { opacity: .55; text-decoration: line-through; }
.link-box { display: block; padding: 10px 12px; background: var(--surface); border-radius: 9px; overflow-wrap: anywhere; user-select: all; }
textarea.code { font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
details.panel > summary { font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel[open] > summary { margin-bottom: 12px; }
