/* MemoryPing Admin — "night ledger".
   A reminder system's console, not a generic dev dashboard: the palette is a
   ledger page at night, and monospace is reserved for the things an operator
   actually copies — ids, timestamps, payloads, money. */
:root {
  --bg: #0A0F18;          /* night ledger */
  --bg-2: #121A27;        /* raised panel */
  --bg-3: #18222F;
  --line: #223047;
  --line-2: #2C3D57;
  --text: #EAF0F7;
  --text-dim: #93A4BC;
  --text-faint: #6B7C94;
  --accent: #5B8CFF;      /* memory blue */
  --accent-2: #A78BFA;
  --ok: #38C793;          /* healthy mint */
  --warn: #E8B04B;
  --err: #FF6B6B;         /* alert coral */
  --info: #5B8CFF;
  --shadow: 0 1px 0 rgba(255,255,255,.04), 0 8px 24px rgba(0,0,0,.35);
  --radius: 10px;
  --radius-sm: 6px;
  /* Manrope/IBM Plex if the operator has them; otherwise a close system stack.
     Not webfonts: the CSP forbids third-party origins and self-hosting three
     families costs more page weight than the difference is worth here. */
  --mono: "IBM Plex Mono", ui-monospace, "JetBrains Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Manrope", "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: radial-gradient(ellipse at top left, #142033 0%, #0A0F18 60%);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.small { font-size: 12px; }
.dim { color: var(--text-dim); }
.muted { color: var(--text-dim); font-size: 12px; }
.center { text-align: center; }
.right { margin-left: auto; }
.h-sub { color: var(--text-dim); font-weight: 400; font-size: 16px; margin-left: 8px; }
.kbd {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--text-dim);
}

/* shell */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 18px 14px;
  gap: 14px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; font-weight: 700; color: #0b0d10;
}
.brand-mark.big { width: 56px; height: 56px; font-size: 20px; }
.brand-name { font-weight: 600; }
.brand-sub { font-size: 11px; color: var(--text-dim); }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 13.5px;
}
.nav-item:hover { background: var(--bg-3); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--bg-3); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.nav-item .ico { width: 18px; text-align: center; opacity: .9; font-size: 13px; }
.logout-form { margin-top: auto; }
.user-chip {
  display: flex; gap: 8px; align-items: center;
  padding: 6px 8px; border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 12.5px; color: var(--text-dim);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); display: inline-block; }
.dot.ok { background: var(--ok); box-shadow: 0 0 8px var(--ok); }

/* main */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 24px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(11,13,16,.85); backdrop-filter: blur(8px);
  z-index: 5;
}
.page-title { margin: 0; font-size: 20px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.global-search { position: relative; }
.global-search input {
  background: var(--bg-3); border: 1px solid var(--line);
  color: var(--text); padding: 6px 30px 6px 12px; border-radius: 8px; font-size: 13px;
  width: 280px; outline: none;
}
.global-search input:focus { border-color: var(--accent); }
.global-search .kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
.live-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--ok);
  background: rgba(63,185,80,.1); border: 1px solid rgba(63,185,80,.25);
  padding: 3px 8px; border-radius: 999px;
}
.pulse {
  width: 6px; height: 6px; border-radius: 50%; background: var(--ok);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(63,185,80,.6); }
  70% { box-shadow: 0 0 0 8px rgba(63,185,80,0); }
  100% { box-shadow: 0 0 0 0 rgba(63,185,80,0); }
}

.content { padding: 20px 24px 60px; display: flex; flex-direction: column; gap: 16px; }

/* cards */
.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px;
  box-shadow: var(--shadow);
}
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.card-head h2 { margin: 0; font-size: 13.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); }
.card-head h3, .sub-h { margin: 12px 0 6px; font-size: 12px; text-transform: uppercase; color: var(--text-dim); letter-spacing: .04em; }

/* grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-3 .span-2 { grid-column: span 2; }
.profile-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 1100px) {
  .grid-2, .grid-3, .profile-grid { grid-template-columns: 1fr; }
  .grid-3 .span-2 { grid-column: auto; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
}

/* KPI */
.kpi-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 12px; }
@media (max-width: 1400px) { .kpi-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 800px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi { display: contents; }
.kpi-cell {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow);
}
.kpi-label { color: var(--text-dim); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 26px; font-weight: 600; margin: 4px 0; }
.kpi-foot { color: var(--text-dim); font-size: 11.5px; }
.kpi-foot .ok { color: var(--ok); }
.kpi-foot .warn { color: var(--warn); }
.kpi-foot .err { color: var(--err); }

/* charts */
.chart-wrap { position: relative; height: 220px; }
.chart-wrap.tall { height: 280px; }

/* tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td {
  padding: 8px 10px; border-bottom: 1px solid var(--line);
  text-align: left; vertical-align: top;
}
table.data th { color: var(--text-dim); font-weight: 500; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
table.data tbody tr:hover { background: rgba(255,255,255,.02); }
table.data tr.done td { opacity: .6; }
table.data td.msg { max-width: 360px; word-break: break-word; }
table.data td.payload { max-width: 540px; word-break: break-word; white-space: pre-wrap; }
.link { color: var(--accent); }
.link:hover { text-decoration: underline; }

button.copy, .btn-ghost {
  background: var(--bg-3); border: 1px solid var(--line-2);
  color: var(--text-dim); padding: 1px 6px; border-radius: 4px;
  font-size: 10.5px; margin-left: 6px; cursor: pointer;
}
button.copy:hover, .btn-ghost:hover { color: var(--text); border-color: var(--accent); }
.btn {
  display: inline-block;
  background: var(--bg-3); border: 1px solid var(--line-2);
  color: var(--text); padding: 5px 10px; border-radius: 6px;
  font-size: 12.5px; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn-primary {
  background: linear-gradient(180deg, var(--accent), #5e7ce0);
  color: #0b0d10; border: 0; padding: 8px 14px; border-radius: 8px; font-weight: 600;
  cursor: pointer; font-size: 13.5px;
}
.btn-primary:hover { filter: brightness(1.1); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* badges */
.badge {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; background: var(--bg-3); border: 1px solid var(--line-2);
  color: var(--text-dim);
}
.badge.ok { background: rgba(63,185,80,.12); border-color: rgba(63,185,80,.35); color: var(--ok); }
.badge.warn { background: rgba(210,153,34,.12); border-color: rgba(210,153,34,.35); color: var(--warn); }
.badge.err { background: rgba(248,81,73,.12); border-color: rgba(248,81,73,.35); color: var(--err); }
.badge.wa { background: rgba(37,211,102,.12); border-color: rgba(37,211,102,.35); color: #25d366; }
.badge.tg { background: rgba(0,136,204,.12); border-color: rgba(0,136,204,.35); color: #58a6ff; }
.badge.active, .badge.confirmed { background: rgba(63,185,80,.12); border-color: rgba(63,185,80,.35); color: var(--ok); }
.badge.trialing, .badge.awaiting_confirmation, .badge.confirming {
  background: rgba(88,166,255,.12); border-color: rgba(88,166,255,.35); color: var(--info);
}
.badge.cancelled, .badge.failed, .badge.expired, .badge.discarded {
  background: rgba(248,81,73,.12); border-color: rgba(248,81,73,.35); color: var(--err);
}

/* profile kv */
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 4px 12px; margin: 0; }
.kv dt { color: var(--text-dim); font-size: 12px; }
.kv dd { margin: 0; font-size: 13px; word-break: break-word; }

/* tabs */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tab {
  background: transparent; border: 0; color: var(--text-dim);
  padding: 8px 12px; cursor: pointer; font-size: 13px;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-body { min-height: 120px; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; gap: 6px; align-items: center;
  padding: 4px 8px; border-radius: 999px;
  background: var(--bg-3); border: 1px solid var(--line-2);
  font-size: 12px; color: var(--text); text-decoration: none;
}
.chip:hover { border-color: var(--accent); }
.chip-name { color: var(--text-dim); }
.chip-n { font-weight: 600; }
/* tables excluded from the raw explorer: shown for row counts, not clickable */
.chip-locked { opacity: .55; cursor: not-allowed; border-style: dashed; }
.chip-locked:hover { border-color: var(--line-2); }

/* event list */
.event-list { list-style: none; margin: 0; padding: 0; }
.event-list li {
  display: flex; gap: 10px; align-items: center;
  padding: 6px 0; border-bottom: 1px dashed var(--line);
  font-size: 13px;
}
.event-list li:last-child { border-bottom: 0; }
.ev-type {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  background: var(--bg-3); border: 1px solid var(--line-2);
  font-size: 11px; color: var(--text-dim);
  min-width: 140px; text-align: center;
}

/* filter row */
.filter-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter-row select, .filter-row input {
  background: var(--bg-3); border: 1px solid var(--line);
  color: var(--text); padding: 6px 10px; border-radius: 8px; font-size: 13px;
  outline: none;
}
.filter-row select:focus, .filter-row input:focus { border-color: var(--accent); }
.filter-row input { flex: 1; min-width: 200px; }

/* search */
.card input[type="search"] {
  width: 100%;
  background: var(--bg-3); border: 1px solid var(--line);
  color: var(--text); padding: 10px 14px; border-radius: 8px; font-size: 14px;
  outline: none;
}
.card input[type="search"]:focus { border-color: var(--accent); }

/* toasts */
.toast-stack { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.toast {
  background: var(--bg-3); border: 1px solid var(--line-2);
  border-left: 3px solid var(--accent);
  padding: 10px 14px; border-radius: 8px;
  font-size: 13px; max-width: 360px; box-shadow: var(--shadow);
  animation: slideIn .2s ease-out;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
@keyframes slideIn { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* login */
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 360px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px;
  padding: 28px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 12px;
}
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-dim); }
.login-card input {
  background: var(--bg-3); border: 1px solid var(--line);
  color: var(--text); padding: 9px 12px; border-radius: 8px; font-size: 14px; outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.login-card .alert {
  background: rgba(248,81,73,.1); border: 1px solid rgba(248,81,73,.35);
  color: var(--err); padding: 8px 10px; border-radius: 6px; font-size: 13px;
}
.login-card .hint { font-size: 11.5px; color: var(--text-faint); margin: 4px 0 0; }
.brand.center { flex-direction: column; align-items: center; gap: 4px; margin-bottom: 10px; }

/* ══════════════════════════════════════════════════════════════════════
   ACTION LAYER
   Anything that writes. Visually distinct from the read surface on
   purpose: a control that changes state should never be mistaken for a
   control that only filters a table.
   ══════════════════════════════════════════════════════════════════════ */

.nav-sep {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-faint); padding: 14px 10px 4px; font-weight: 600;
}

.bot-status {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 9px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); margin-top: 8px;
}
.bot-status .dot.online { background: var(--ok); box-shadow: 0 0 6px rgba(63,185,80,.6); }
.bot-status .dot.offline { background: var(--err); box-shadow: 0 0 6px rgba(248,81,73,.5); }

/* action panel */
.action-panel {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 16px;
}
.action-panel > header {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(124,156,255,.06), transparent);
}
.action-panel > header h3 { margin: 0; font-size: 13.5px; font-weight: 600; }
.action-panel > header .tier {
  font-size: 10px; text-transform: uppercase; letter-spacing: .06em;
  padding: 2px 7px; border-radius: 20px; font-weight: 600;
  background: var(--bg-3); color: var(--text-dim); border: 1px solid var(--line-2);
}
.action-panel .body { padding: 14px; display: grid; gap: 12px; }

.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }

.action-card {
  background: var(--bg-3); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px;
  display: flex; flex-direction: column; gap: 9px;
}
.action-card h4 { margin: 0; font-size: 12.5px; font-weight: 600; }
.action-card .desc { font-size: 11.5px; color: var(--text-dim); line-height: 1.4; }
.action-card.danger { border-color: rgba(248,81,73,.3); background: rgba(248,81,73,.04); }
.action-card.danger h4 { color: var(--err); }

/* form controls */
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11px; color: var(--text-dim); font-weight: 500; }
.field input, .field select, .field textarea {
  background: var(--bg); border: 1px solid var(--line-2); color: var(--text);
  padding: 7px 10px; border-radius: var(--radius-sm); font-size: 13px;
  outline: none; font-family: inherit; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 68px; line-height: 1.45; }
.field-row { display: flex; gap: 8px; }
.field-row .field { flex: 1; }

/* the reason field is required on anything that changes state, so it
   reads as part of the action rather than an optional extra */
.field.reason label::after { content: " · required"; color: var(--warn); font-size: 10px; }

.btn {
  background: var(--accent); color: #0b0d10; border: none;
  padding: 8px 14px; border-radius: var(--radius-sm);
  font-size: 12.5px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: filter .12s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.1); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.danger { background: var(--err); color: #fff; }
.btn.subtle { background: var(--bg); color: var(--text); border: 1px solid var(--line-2); }
.btn.subtle:hover:not(:disabled) { border-color: var(--accent); }
.btn.sm { padding: 5px 10px; font-size: 11.5px; }

/* offline gating: Tier 2 controls disable themselves when the bot is
   down, so a button is never live when pressing it can only fail */
.needs-bot[data-bot-offline="1"] { opacity: .45; pointer-events: none; }
.needs-bot[data-bot-offline="1"]::after {
  content: "Bot offline"; display: block; margin-top: 6px;
  font-size: 10.5px; color: var(--err);
}

/* channel availability */
.channel-state { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.chan {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; padding: 3px 9px; border-radius: 20px;
  border: 1px solid var(--line-2); background: var(--bg);
}
.chan.open { border-color: rgba(63,185,80,.4); color: var(--ok); }
.chan.limited { border-color: rgba(210,153,34,.4); color: var(--warn); }
.chan.closed { border-color: rgba(248,81,73,.35); color: var(--err); }

/* confirm modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.65);
  display: grid; place-items: center; z-index: 200; padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--bg-2); border: 1px solid var(--line-2);
  border-radius: 12px; padding: 20px; width: 100%; max-width: 440px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
  display: flex; flex-direction: column; gap: 12px;
}
.modal h3 { margin: 0; font-size: 15px; }
.modal .warn-box {
  background: rgba(248,81,73,.08); border: 1px solid rgba(248,81,73,.3);
  color: #ffb3ae; padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 12.5px; line-height: 1.5;
}
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }

/* audit log */
.audit-row td { vertical-align: top; }
.audit-action {
  font-family: var(--mono); font-size: 11.5px; font-weight: 600;
  padding: 2px 7px; border-radius: 4px;
  background: var(--bg-3); border: 1px solid var(--line-2);
}
.audit-row.failed .audit-action { color: var(--err); border-color: rgba(248,81,73,.35); }
.audit-row.failed { background: rgba(248,81,73,.03); }
.audit-diff {
  font-family: var(--mono); font-size: 11px; color: var(--text-dim);
  max-width: 340px; overflow-x: auto; white-space: pre-wrap;
  word-break: break-word; margin: 0;
}
.audit-reason { font-size: 12px; font-style: italic; color: var(--text-dim); }

details.diff-toggle summary {
  cursor: pointer; font-size: 11px; color: var(--accent); user-select: none;
}
details.diff-toggle[open] summary { margin-bottom: 5px; }

/* result flash inside a panel */
.action-result {
  font-size: 12px; padding: 8px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--bg);
}
.action-result.ok { border-color: rgba(63,185,80,.4); color: var(--ok); }
.action-result.err { border-color: rgba(248,81,73,.4); color: var(--err); }
.action-result:empty { display: none; }

/* Control center: a capability index shaped around MemoryPing's product
   domains. The signal rail is the one deliberate visual signature. */
.control-hero {
  display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(310px, .75fr);
  gap: 24px; align-items: stretch; padding: 24px;
  border: 1px solid var(--line); border-radius: 14px;
  background: linear-gradient(125deg, rgba(124,156,255,.12), rgba(18,26,39,.3) 45%, var(--bg-2));
  box-shadow: var(--shadow);
}
.control-hero h2 { margin: 4px 0 8px; font-size: clamp(24px, 3vw, 38px); line-height: 1.08; max-width: 720px; }
.control-hero p { max-width: 760px; }
.eyebrow { margin: 0; color: var(--accent); font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; }
.signal-rail { display: grid; align-content: center; gap: 0; border-left: 1px solid var(--line-2); padding-left: 22px; }
.signal-rail > div { display: grid; grid-template-columns: 10px 78px 1fr; gap: 9px; align-items: center; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 12px; }
.signal-rail > div:last-child { border: 0; }
.signal { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.signal.ok { background: var(--ok); box-shadow: 0 0 9px rgba(63,185,80,.7); }
.signal.warn { background: var(--warn); box-shadow: 0 0 9px rgba(210,153,34,.6); }
.signal.err { background: var(--err); box-shadow: 0 0 9px rgba(248,81,73,.6); }
.capability-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.capability-card { display: grid; grid-template-columns: 42px 1fr; gap: 12px; padding: 16px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); min-height: 180px; }
.capability-mark { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line-2); border-radius: 50%; color: var(--accent); font-size: 18px; }
.capability-copy { display: flex; flex-direction: column; min-width: 0; }
.capability-title { display: flex; align-items: center; gap: 8px; }
.capability-title h3 { margin: 0; font-size: 14px; }
.capability-copy p { color: var(--text-dim); font-size: 12px; margin: 9px 0; }
.capability-copy .actions { margin-top: auto; }

/* Account workspace and reminder command surface. */
.workspace-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, .75fr); gap: 14px; margin-bottom: 14px; }
.workspace-main, .workspace-side { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; background: rgba(255,255,255,.012); }
.workspace-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.workspace-heading h3 { margin: 3px 0 0; font-size: 15px; }
.workspace-kv { margin: 0; display: grid; gap: 0; }
.workspace-kv > div { display: flex; justify-content: space-between; gap: 14px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.workspace-kv > div:last-child { border: 0; }
.workspace-kv dt { color: var(--text-dim); font-size: 12px; }
.workspace-kv dd { margin: 0; font-family: var(--mono); font-size: 12px; }
.workspace-records { border-top: 1px solid var(--line); padding: 10px 0; }
.workspace-records > summary, .reminder-create > summary, .row-editor > summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 12px; }
.preset-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin-top: 12px; }
.preset-card { padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg-3); }
.preset-card h4 { margin: 0; font-size: 13px; }
.preset-card > p { color: var(--text-dim); font-size: 12px; min-height: 34px; }
.compact-stack { display: grid; gap: 7px; margin-top: 10px; }
.reminder-create { border: 1px solid rgba(124,156,255,.35); border-radius: var(--radius); padding: 13px; margin-bottom: 14px; background: rgba(124,156,255,.035); }
.reminder-editor { display: grid; grid-template-columns: minmax(240px, 2fr) repeat(4, minmax(120px, .7fr)); gap: 9px; align-items: end; margin-top: 12px; }
.reminder-notes, .reminder-reason { grid-column: span 2; }
.reminder-editor .action-result { grid-column: 1 / -1; }
.reminder-editor > .btn { justify-self: start; }
.row-actions { display: flex; flex-wrap: wrap; gap: 5px; align-items: flex-start; min-width: 240px; }
.row-actions form { margin: 0; }
.row-editor { position: relative; }
.compact-editor { position: absolute; right: 0; top: 26px; z-index: 20; width: 330px; padding: 12px; display: grid; gap: 8px; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: 0 18px 45px rgba(0,0,0,.6); }
.data-toolbar .card-head { align-items: flex-start; }
.data-toolbar .card-head p { margin: 4px 0 0; }
.data-toolbar .filter-row { align-items: end; }
.data-table-picker { min-width: 240px; }
.data-search { flex: 1; min-width: 220px; }
.data-limit { width: 90px; }
.data-browser-table { max-height: calc(100vh - 270px); }
.data-browser-table thead { position: sticky; top: 0; background: var(--bg-2); z-index: 2; }
.data-cell { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 11px; }

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 1180px) {
  .capability-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .reminder-editor { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .control-hero, .workspace-grid { grid-template-columns: 1fr; }
  .signal-rail { border-left: 0; border-top: 1px solid var(--line-2); padding: 14px 0 0; }
  .capability-grid { grid-template-columns: 1fr; }
  .reminder-editor { grid-template-columns: 1fr; }
  .reminder-notes, .reminder-reason { grid-column: auto; }
  .compact-editor { position: fixed; inset: 12px; width: auto; overflow: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ==========================================================================
   Accessibility baseline
   ========================================================================== */

/* Screen-reader-only text: used for chart data, heatmap cell values and
   table captions, so every visual signal has a text equivalent. */
.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;
}
.sr-only:focus, .skip-link:focus {
  position: static; width: auto; height: auto;
  clip: auto; margin: 0; padding: 8px 12px; white-space: normal;
}
.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  background: var(--accent); color: #06101f; border-radius: var(--radius-sm);
  font-weight: 600; transition: top .15s;
}
.skip-link:focus { top: 8px; }

/* A visible focus ring everywhere. The default outline was being removed by
   `outline: none` on inputs with nothing put back, so keyboard users had no
   idea where they were. */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Honour a reduced-motion preference: the live pulse and every transition
   become still rather than merely faster. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .pulse { animation: none; }
}

/* ==========================================================================
   Work queue
   ========================================================================== */

.queue-card { border-left: 3px solid var(--line-2); }
.queue-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.queue-item { border-radius: var(--radius-sm); }
.queue-link {
  display: grid; grid-template-columns: 72px 1fr auto;
  align-items: center; gap: 12px;
  padding: 8px 10px; color: var(--text); text-decoration: none;
  border-left: 3px solid transparent; border-radius: var(--radius-sm);
}
.queue-link:hover { background: var(--bg-3); text-decoration: none; }
.queue-count { font-size: 18px; font-weight: 600; text-align: right; }
.queue-sev { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); }
.sev-critical .queue-link { border-left-color: var(--err); }
.sev-critical .queue-count { color: var(--err); }
.sev-warning  .queue-link { border-left-color: var(--warn); }
.sev-warning  .queue-count { color: var(--warn); }
.sev-info     .queue-link { border-left-color: var(--accent); }
.queue-clear { color: var(--ok); margin: 4px 0; }
.queue-foot { margin: 10px 0 0; font-size: 12px; }
.badge.sev-critical { background: rgba(255,107,107,.14); color: var(--err); border-color: rgba(255,107,107,.3); }
.badge.sev-warning  { background: rgba(232,176,75,.14); color: var(--warn); border-color: rgba(232,176,75,.3); }
.badge.sev-ok       { background: rgba(56,199,147,.14); color: var(--ok); border-color: rgba(56,199,147,.3); }

/* ==========================================================================
   Heatmap — a real day x hour grid
   ========================================================================== */

.heatmap-scroll { overflow-x: auto; }
table.heatmap { border-collapse: collapse; width: 100%; }
.heatmap th { font-weight: 500; color: var(--text-dim); font-size: 10.5px; padding: 2px 3px; }
.hm-day { text-align: right; padding-right: 8px !important; white-space: nowrap; }
.hm-cell {
  width: 3.6%; height: 18px; padding: 0;
  border: 1px solid var(--bg-2); border-radius: 3px;
  background: var(--bg-3);
}
/* Five discrete steps rather than a continuous ramp, so the levels stay
   distinguishable without fine colour discrimination. */
.hm-0 { background: var(--bg-3); }
.hm-1 { background: rgba(91,140,255,.20); }
.hm-2 { background: rgba(91,140,255,.38); }
.hm-3 { background: rgba(91,140,255,.56); }
.hm-4 { background: rgba(91,140,255,.76); }
.hm-5 { background: rgba(91,140,255,.95); }
.hm-legend { display: flex; align-items: center; gap: 6px; font-size: 11.5px; margin: 10px 0 0; }
.hm-swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }

/* ==========================================================================
   Pager
   ========================================================================== */

.pager {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-top: 12px; flex-wrap: wrap;
}
.pager-count { margin: 0; color: var(--text-dim); font-size: 12.5px; }
.pager-controls { display: flex; gap: 8px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.is-disabled { opacity: .4; cursor: not-allowed; }

/* ==========================================================================
   Event drawer
   ========================================================================== */

.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(5,8,14,.6);
  display: grid; justify-items: end; z-index: 50;
}
.drawer {
  background: var(--bg-2); border-left: 1px solid var(--line);
  width: min(720px, 100%); height: 100%; overflow-y: auto;
  padding: 20px; box-shadow: -8px 0 32px rgba(0,0,0,.4);
}
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.drawer-title { margin: 0; font-family: var(--display); font-size: 18px; }
.drawer-sub { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); margin: 18px 0 6px; }
.drawer-correlate { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 0 0; }
.payload {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px;
  overflow-x: auto; max-height: 50vh; font-size: 12px; margin: 0;
}
.tiny { font-size: 11px; }

/* ==========================================================================
   Metric list + operation states
   ========================================================================== */

.metric-list { display: flex; flex-direction: column; gap: 2px; margin: 14px 0 0; }
.metric-list > div { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--line); }
.metric-list dt { color: var(--text-dim); font-size: 12.5px; margin: 0; }
.metric-list dd { margin: 0; font-family: var(--mono); font-size: 12.5px; }
.badge.state-succeeded { background: rgba(56,199,147,.14); color: var(--ok); }
.badge.state-failed { background: rgba(255,107,107,.14); color: var(--err); }
.badge.state-running { background: rgba(232,176,75,.14); color: var(--warn); }

/* ==========================================================================
   Temporal signal spine — the one distinctive element.
   A thin vertical timeline tying an account's reminders, deliveries and
   operator actions to one another in time. Domain-specific to a reminder
   product, and more useful than decoration.
   ========================================================================== */

.spine { position: relative; margin: 8px 0 0; padding-left: 18px; list-style: none; }
.spine::before {
  content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px;
  width: 2px; background: linear-gradient(var(--accent), transparent);
  border-radius: 2px;
}
.spine-item { position: relative; padding: 6px 0 6px 4px; }
.spine-item::before {
  content: ""; position: absolute; left: -17px; top: 12px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--bg-2); border: 2px solid var(--accent);
}
.spine-item.is-missed::before { border-color: var(--err); background: var(--err); }
.spine-item.is-done::before { border-color: var(--ok); background: var(--ok); }
.spine-item.is-admin::before { border-color: var(--accent-2); }
.spine-when { color: var(--text-dim); font-family: var(--mono); font-size: 11.5px; }

/* ==========================================================================
   Mobile navigation
   ========================================================================== */

.nav-toggle { display: none; }
@media (max-width: 1100px) {
  .nav-toggle {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--bg-3); border: 1px solid var(--line);
    color: var(--text); padding: 6px 10px; border-radius: var(--radius-sm);
  }
  .sidebar .nav { display: none; }
  .sidebar.is-open .nav { display: flex; }
  .global-search input { width: 100%; }
  .topbar { flex-wrap: wrap; gap: 8px; }
}

/* ==========================================================================
   WhatsApp template reconciliation
   ========================================================================== */

.tpl-summary { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .tpl-summary { grid-template-columns: repeat(2, 1fr); } }
.kpi-value.bad { color: var(--err); }

.banner {
  border-radius: var(--radius); padding: 10px 14px;
  border: 1px solid var(--line-2); background: var(--bg-2); font-size: 13px;
}
.banner.warn { border-color: rgba(232,176,75,.35); background: rgba(232,176,75,.08); }

/* A row's left edge carries its severity, so the eye finds the broken ones
   before reading a word. */
tr.sev-row-critical td:first-child { box-shadow: inset 3px 0 0 var(--err); }
tr.sev-row-warning  td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
tr.sev-row-info     td:first-child { box-shadow: inset 3px 0 0 var(--line-2); }
tr.sev-row-ok       td:first-child { box-shadow: inset 3px 0 0 var(--ok); }

.issue { font-size: 12px; color: var(--text-dim); margin: 2px 0; }
.issue.sev-critical { color: var(--err); }
.issue.sev-warning { color: var(--warn); }
.issue-list { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-direction: column; gap: 6px; }
.issue-list .issue strong { text-transform: uppercase; font-size: 10.5px; letter-spacing: .05em; }

/* A button that reads as a link: keyboard-operable and announced correctly,
   unlike an <a href="#"> with a click handler. */
.link-button {
  background: none; border: 0; padding: 0;
  color: var(--accent); cursor: pointer;
  font: inherit; text-align: left;
}
.link-button:hover { text-decoration: underline; }

.badge.ok { background: rgba(56,199,147,.14); color: var(--ok); border-color: rgba(56,199,147,.3); }
.err { color: var(--err); }

/* ========================================================================== 
   Bulk access — a high-impact control with its own visual boundary.
   ========================================================================== */

.page-actions { display: flex; justify-content: flex-end; margin: 0 0 12px; }
.bulk-access-intro {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 24px;
  margin: 0 0 18px; padding: 20px 22px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background:
    radial-gradient(circle at 92% 10%, rgba(124,156,255,.16), transparent 32%),
    var(--bg-2);
}
.bulk-access-intro h2 { margin: 5px 0 7px; font-size: 22px; letter-spacing: -.02em; }
.bulk-access-intro p:last-child { max-width: 720px; margin-bottom: 0; line-height: 1.55; }
.bulk-access-kpis { grid-template-columns: repeat(4, 1fr); margin-bottom: 16px; }
.bulk-access-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.bulk-access-card {
  position: relative; overflow: hidden; padding: 18px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2);
}
.bulk-access-card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--accent);
}
.bulk-access-card.premium-card::before { background: var(--warn); }
.bulk-access-card-head { display: flex; align-items: center; gap: 12px; }
.bulk-access-card-head h3 { margin: 3px 0 0; font-size: 16px; }
.bulk-access-icon {
  display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 36px;
  border: 1px solid rgba(124,156,255,.45); border-radius: 50%;
  color: var(--accent); background: rgba(124,156,255,.08);
  font: 600 14px var(--mono);
}
.premium-card .bulk-access-icon {
  border-color: rgba(232,176,75,.45); color: var(--warn); background: rgba(232,176,75,.08);
}
.bulk-access-card > .desc { min-height: 52px; margin: 14px 0; color: var(--text-dim); line-height: 1.5; }
.impact-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px; overflow: hidden;
  margin-bottom: 16px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--line);
}
.impact-row > div { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; background: var(--bg-3); }
.impact-row strong { font: 600 19px var(--mono); }
.impact-row span { color: var(--text-dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; }
.bulk-access-card form { display: flex; flex-direction: column; gap: 10px; }
.bulk-access-card form > .btn { align-self: flex-start; margin-top: 2px; }
.bulk-safety-note {
  padding: 8px 10px; border-left: 2px solid var(--warn);
  background: rgba(232,176,75,.06); color: var(--text-dim); font-size: 11px; line-height: 1.45;
}
.bulk-notify-choice {
  display: flex; align-items: flex-start; gap: 9px; padding: 9px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg-3);
  cursor: pointer;
}
.bulk-notify-choice input { margin-top: 2px; accent-color: var(--accent); }
.bulk-notify-choice span { display: flex; flex-direction: column; gap: 2px; font-size: 11.5px; }
.bulk-notify-choice small { color: var(--text-dim); font-size: 10.5px; }
.guardrail-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.guardrail-grid > div { display: flex; flex-direction: column; gap: 4px; }
.guardrail-grid strong { font-size: 12px; }
.guardrail-grid span { color: var(--text-dim); font-size: 11px; line-height: 1.45; }

@media (max-width: 900px) {
  .bulk-access-grid { grid-template-columns: 1fr; }
  .guardrail-grid { grid-template-columns: repeat(2, 1fr); }
  .bulk-access-intro { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 560px) {
  .bulk-access-kpis, .guardrail-grid { grid-template-columns: 1fr 1fr; }
  .field-row, .impact-row { grid-template-columns: 1fr; display: grid; }
}
