/* ============================================================
   DistriSync Dashboard — UI theme
   Layout: fixed dark sidebar + light content canvas.
   Status colors are reserved for state and always paired with
   a text label; data values are set in ink, never accent color.
   ============================================================ */

:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --brand: #f59e0b;
  --brand-strong: #d97706;
  --brand-ink: #1c1305;
  --accent: #0e7490;
  --accent-strong: #155e75;

  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --ok-ink: #166534;
  --info: #0284c7;
  --info-bg: #e0f2fe;
  --info-ink: #075985;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --danger-ink: #991b1b;
  --warn: #d97706;
  --warn-bg: #fef3c7;
  --warn-ink: #92400e;

  --sidebar-bg: #0b1220;
  --sidebar-ink: #cbd5e1;
  --sidebar-muted: #7c8aa0;
  --sidebar-active: #f8fafc;
  --sidebar-border: rgba(148, 163, 184, 0.14);
  --sidebar-hover: rgba(148, 163, 184, 0.10);

  --radius-s: 8px;
  --radius: 12px;
  --radius-l: 16px;
  --shadow-1: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-2: 0 8px 24px -12px rgba(15, 23, 42, 0.18);

  --sidebar-w: 252px;
  --content-max: 1240px;
  --gutter: 28px;

  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 22px; line-height: 1.25; }
h2 { font-size: 15px; line-height: 1.3; }
p { margin: 4px 0 0; color: var(--muted); }

.mono, pre, code { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.text-danger { color: var(--danger); font-weight: 600; }

/* ---------- App shell ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  width: var(--sidebar-w);
  overflow-y: auto;
}

.sidebar-brand {
  align-items: center;
  display: flex;
  gap: 10px;
  padding: 20px 20px 16px;
}

.brand-mark {
  align-items: center;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
  border-radius: 9px;
  color: var(--brand-ink);
  display: inline-flex;
  flex-shrink: 0;
  font-size: 15px;
  font-weight: 800;
  height: 30px;
  justify-content: center;
  width: 30px;
}

.brand-name {
  color: var(--sidebar-active);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-sub {
  color: var(--sidebar-muted);
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.sidebar-nav { display: flex; flex-direction: column; flex-grow: 1; gap: 2px; padding: 6px 12px 12px; }

.nav-group-label {
  color: var(--sidebar-muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  margin: 14px 10px 6px;
  text-transform: uppercase;
}

.nav-link {
  align-items: center;
  border-radius: var(--radius-s);
  color: var(--sidebar-ink);
  display: flex;
  font-size: 13.5px;
  font-weight: 500;
  gap: 10px;
  padding: 8px 10px;
  position: relative;
}

.nav-link:hover { background: var(--sidebar-hover); color: var(--sidebar-active); }

.nav-link.active {
  background: rgba(245, 158, 11, 0.12);
  color: var(--sidebar-active);
  font-weight: 600;
}

.nav-link.active::before {
  background: var(--brand);
  border-radius: 3px;
  content: "";
  height: 16px;
  left: 0;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
}

.nav-icon {
  align-items: center;
  display: inline-flex;
  flex-shrink: 0;
  height: 17px;
  justify-content: center;
  width: 17px;
}

.nav-icon svg { display: block; height: 16px; width: 16px; }

.sidebar-user {
  border-top: 1px solid var(--sidebar-border);
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding: 14px 16px 16px;
}

.sidebar-user-info { display: grid; gap: 1px; min-width: 0; }

.sidebar-user-name {
  color: var(--sidebar-active);
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-mail {
  color: var(--sidebar-muted);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-chip {
  background: rgba(148, 163, 184, 0.14);
  border-radius: 999px;
  color: var(--sidebar-ink);
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  justify-self: start;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  text-transform: uppercase;
}

.sidebar-user-actions { display: flex; gap: 8px; }

.sidebar-user-actions form { display: contents; }

.sidebar-btn {
  align-items: center;
  background: transparent;
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius-s);
  color: var(--sidebar-ink);
  cursor: pointer;
  display: inline-flex;
  flex: 1 1 0;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  height: 32px;
  justify-content: center;
  padding: 0 10px;
}

.sidebar-btn:hover { background: var(--sidebar-hover); color: var(--sidebar-active); }

.main { display: flex; flex-direction: column; flex-grow: 1; min-width: 0; }

.content {
  margin: 0 auto;
  max-width: var(--content-max);
  padding: 28px var(--gutter) 56px;
  width: 100%;
}

.content > * + * { margin-top: 20px; }

/* ---------- Page header ---------- */

.page-head {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: space-between;
}

.page-head .head-actions { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; }

.head-actions form { margin: 0; }

.page-head .kicker {
  color: var(--faint);
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.count-chip {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--ink-2);
  display: inline-flex;
  font-size: 12.5px;
  font-weight: 600;
  gap: 6px;
  padding: 6px 12px;
}

.count-chip strong { font-weight: 700; }

/* ---------- Buttons ---------- */

.button,
button.button {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  color: var(--ink-2);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  gap: 7px;
  height: 36px;
  justify-content: center;
  padding: 0 14px;
  transition: background 120ms ease, border-color 120ms ease;
  white-space: nowrap;
}

.button:hover, button.button:hover { background: var(--surface-3); }

.button.primary, button.button.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
}

.button.primary:hover, button.button.primary:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
}

.button.danger, button.button.danger {
  background: var(--surface);
  border-color: #fca5a5;
  color: var(--danger);
}

.button.danger:hover, button.button.danger:hover { background: var(--danger-bg); }

.button.small, button.button.small { font-size: 12.5px; height: 30px; padding: 0 10px; }

/* ---------- Cards / panels ---------- */

.card, .panel, .empty {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 20px;
}

.panel > h2 { margin-bottom: 12px; }
.panel > h2:not(:first-child) { margin-top: 24px; }

.card-head {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-head h2 { margin: 0; }
.card-head p { font-size: 13px; }

.empty { color: var(--muted); padding: 40px 24px; text-align: center; }
.empty h2 { color: var(--ink); margin-bottom: 4px; }

/* ---------- Stat tiles ---------- */

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

.stat-grid.wide { grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); }

.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  display: grid;
  gap: 6px;
  padding: 14px 16px;
}

.metric span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.metric strong {
  color: var(--ink);
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.metric strong a { border-bottom: 1px dotted var(--border-strong); }
.metric strong .status { font-size: 12px; }

/* ---------- Tables ---------- */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  overflow: auto;
}

.panel .table-wrap, .card .table-wrap { border-radius: var(--radius-s); box-shadow: none; }

table { border-collapse: collapse; min-width: 100%; }

th, td {
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

tbody tr { transition: background 100ms ease; }
tbody tr:hover { background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }

td { font-size: 13.5px; }

.dense th, .dense td { font-size: 13px; padding: 8px 12px; white-space: nowrap; }

.table-link { color: var(--accent-strong); font-weight: 650; }
.table-link:hover { text-decoration: underline; }

td a:not(.button):not(.table-link):hover { text-decoration: underline; }

.cell-sub { color: var(--muted); display: block; font-size: 12px; }

/* ---------- Status pills ----------
   Class names come from server helpers (paymentClass/jobStatusClass):
   status-paid | status-open | status-overdue | status-unknown        */

.status {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 650;
  gap: 6px;
  line-height: 1;
  padding: 5px 10px;
  white-space: nowrap;
}

.status::before { border-radius: 50%; content: ""; height: 6px; width: 6px; }

.status-paid { background: var(--ok-bg); color: var(--ok-ink); }
.status-paid::before { background: var(--ok); }

.status-open { background: var(--info-bg); color: var(--info-ink); }
.status-open::before { background: var(--info); }

.status-overdue { background: var(--danger-bg); color: var(--danger-ink); }
.status-overdue::before { background: var(--danger); }

.status-unknown { background: var(--surface-3); color: var(--ink-2); }
.status-unknown::before { background: var(--faint); }

/* ---------- Filters / toolbars ---------- */

.toolbar {
  align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 16px;
}

.toolbar form { margin: 0; }
.toolbar label { display: grid; gap: 5px; }
.toolbar .grow { flex-grow: 1; }

.filter-actions { align-items: center; display: flex; gap: 8px; }

.inline-form { align-items: flex-end; display: flex; flex-wrap: wrap; gap: 10px; }
.inline-form label { display: grid; gap: 5px; }

label > span,
.field > span {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ---------- Inputs ---------- */

input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  height: 36px;
  min-width: 200px;
  padding: 0 11px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
  outline: none;
}

input::placeholder { color: var(--faint); }

textarea { min-height: 96px; padding: 10px 11px; resize: vertical; }

/* ---------- Forms ---------- */

.form-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  display: grid;
  gap: 16px;
  max-width: 720px;
  padding: 22px;
}

.form-panel label { display: grid; gap: 6px; }
.form-panel input, .form-panel select, .form-panel textarea { width: 100%; }
.form-panel.embedded { border: 0; box-shadow: none; max-width: none; padding: 0; }
.form-panel > .button { justify-self: start; }

.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }

.form-actions { display: flex; gap: 8px; justify-content: flex-end; }

.row-actions { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; }
.row-actions form { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.row-actions input { height: 32px; min-width: 170px; }
.row-actions .button { font-size: 12.5px; height: 32px; padding: 0 10px; }

.actions { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.actions form { margin: 0; }
.actions.left { justify-content: flex-start; }

/* ---------- Alerts / notices ---------- */

.notice {
  background: var(--ok-bg);
  border: 1px solid rgba(22, 163, 74, 0.3);
  border-left: 4px solid var(--ok);
  border-radius: var(--radius-s);
  color: var(--ok-ink);
  font-size: 13.5px;
  padding: 12px 14px;
}

.notice strong { display: block; margin-bottom: 2px; }
.notice div { color: inherit; }

.notice-error {
  background: var(--danger-bg);
  border-color: rgba(220, 38, 38, 0.3);
  border-left-color: var(--danger);
  color: var(--danger-ink);
}

.notice-warning {
  background: var(--warn-bg);
  border-color: rgba(217, 119, 6, 0.3);
  border-left-color: var(--warn);
  color: var(--warn-ink);
}

.form-panel > .notice { margin: 0; }

.notice pre {
  background: #0b1220;
  border-radius: var(--radius-s);
  color: #e2e8f0;
  margin: 10px 0 0;
  max-height: 420px;
  overflow: auto;
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- Quota meter ---------- */

.quota-head {
  align-items: flex-end;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.quota-title {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.quota-value { font-size: 24px; font-weight: 650; letter-spacing: -0.01em; line-height: 1.1; }
.quota-value small { color: var(--muted); font-size: 14px; font-weight: 500; }

.quota-pct {
  background: var(--surface-3);
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 700;
  padding: 6px 12px;
}

.quota-pct.warn { background: var(--warn-bg); color: var(--warn-ink); }
.quota-pct.over { background: var(--danger-bg); color: var(--danger-ink); }

.meter {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  height: 14px;
  overflow: hidden;
  padding: 2px;
  width: 100%;
}

.meter-fill {
  background: linear-gradient(90deg, #fbbf24, var(--brand));
  border-radius: 999px;
  display: block;
  height: 100%;
  min-width: 8px;
  transition: width 200ms ease;
}

.meter-fill.warn { background: linear-gradient(90deg, #fbbf24, var(--warn)); }
.meter-fill.over { background: linear-gradient(90deg, #f87171, var(--danger)); }

.quota-scale {
  color: var(--faint);
  display: flex;
  font-size: 12px;
  font-weight: 600;
  justify-content: space-between;
  margin-top: 6px;
}

.panel > .notice { margin-top: 14px; }

/* ---------- Key/value grids ---------- */

.key-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

.key-grid > div {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  display: grid;
  gap: 4px;
  padding: 10px 12px;
}

.key-grid span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.key-grid strong { font-weight: 600; overflow-wrap: anywhere; }

/* ---------- Payload panels / details ---------- */

.payload-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }

.payload-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}

.payload-panel > summary {
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 650;
  padding: 12px 16px;
}

.payload-panel > summary:hover { background: var(--surface-2); }

.payload-panel pre, .timeline-card pre {
  background: #0b1220;
  border-radius: var(--radius-s);
  color: #e2e8f0;
  font-size: 12.5px;
  margin: 0 14px 14px;
  max-height: 520px;
  overflow: auto;
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- Timeline ---------- */

.timeline { display: grid; gap: 0; position: relative; }

.timeline-event {
  display: grid;
  gap: 16px;
  grid-template-columns: 26px minmax(0, 1fr);
  padding-bottom: 14px;
  position: relative;
}

.timeline-event::before {
  background: var(--border);
  bottom: 0;
  content: "";
  left: 12px;
  position: absolute;
  top: 26px;
  width: 2px;
}

.timeline-event:last-child::before { display: none; }

.timeline-marker {
  background: var(--surface);
  border: 2.5px solid var(--accent);
  border-radius: 50%;
  height: 13px;
  margin-left: 6px;
  margin-top: 14px;
  width: 13px;
  z-index: 1;
}

.timeline-error .timeline-marker { border-color: var(--danger); }

.timeline-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  min-width: 0;
  padding: 14px 16px;
}

.timeline-error .timeline-card { border-color: #fca5a5; }

.timeline-head { align-items: flex-start; display: flex; gap: 16px; justify-content: space-between; }
.timeline-head > div { display: grid; gap: 3px; min-width: 0; }
.timeline-head strong { font-size: 13.5px; overflow-wrap: anywhere; }
.timeline-head time { color: var(--faint); flex-shrink: 0; font-size: 12px; }

.event-kind {
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.timeline-meta { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.timeline-card details { border-top: 1px solid var(--border); margin-top: 10px; }

.timeline-card summary {
  color: var(--ink-2);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  padding: 9px 0;
}

.timeline-card details pre { margin: 0 0 10px; }

/* ---------- Pagination ---------- */

.pagination {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.pagination span { color: var(--muted); font-size: 13px; font-weight: 600; }

/* ---------- Traffic table ---------- */

.traffic-number {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 650;
  text-align: right;
}

.traffic-login-row td { background: var(--surface-2); }

/* ---------- Secret / API key reveal ---------- */

.secret-panel { display: grid; gap: 14px; max-width: 860px; }

.secret-value {
  background: #0b1220;
  border-radius: var(--radius-s);
  color: #f8fafc;
  display: block;
  font-size: 14.5px;
  line-height: 1.6;
  overflow-wrap: anywhere;
  padding: 16px;
  user-select: all;
}

/* ---------- Auth (login) ---------- */

.auth-body {
  background:
    radial-gradient(1000px 500px at 85% -10%, rgba(245, 158, 11, 0.14), transparent 60%),
    radial-gradient(800px 500px at -10% 110%, rgba(14, 116, 144, 0.12), transparent 55%),
    var(--sidebar-bg);
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-2);
  display: grid;
  gap: 18px;
  padding: 30px 28px;
  width: min(420px, 100%);
}

.auth-brand { align-items: center; display: flex; gap: 10px; }
.auth-card h1 { font-size: 19px; }
.auth-card label { display: grid; gap: 6px; }
.auth-card input { min-width: 0; width: 100%; }
.auth-card .button { height: 40px; width: 100%; }

.auth-frame, .auth-frame-inner, .auth-main { display: contents; }

.auth-body .error-box { background: var(--surface); border-radius: var(--radius-l); margin: 0; }

/* ---------- Error page ---------- */

.error-box { margin: 48px auto 0; max-width: 640px; }

.error-box pre {
  background: #0b1220;
  border-radius: var(--radius-s);
  color: #e2e8f0;
  margin: 14px 0;
  overflow: auto;
  padding: 12px;
  text-align: left;
}

.error-box .button { margin-top: 8px; }

/* ---------- UC summary (legacy invoices) ---------- */

.uc-panel { align-items: flex-start; display: flex; flex-wrap: wrap; gap: 18px; justify-content: space-between; }
.uc-panel form { margin: 0; }
.uc-summary { display: grid; gap: 3px; }
.uc-summary strong, .uc-summary span { overflow-wrap: anywhere; }
.uc-summary span { color: var(--muted); font-size: 13px; }

/* ---------- Responsive ---------- */

@media (max-width: 980px) {
  :root { --gutter: 18px; }

  .shell { flex-direction: column; }

  .sidebar {
    height: auto;
    position: static;
    width: 100%;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px 12px 12px;
  }

  .nav-group-label { display: none; }
  .nav-link.active::before { display: none; }

  .sidebar-user {
    align-items: center;
    border-top: 1px solid var(--sidebar-border);
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .role-chip { display: none; }

  .content { padding-top: 20px; }

  .form-grid, .payload-grid { grid-template-columns: 1fr; }

  input, select, textarea { min-width: 0; }

  .toolbar label { flex: 1 1 180px; }
  .toolbar input, .toolbar select { width: 100%; }
}

@media (max-width: 640px) {
  .page-head, .card-head { align-items: stretch; flex-direction: column; }
  .page-head .head-actions { justify-content: flex-start; }
  .pagination { justify-content: center; }
  .row-actions form { width: 100%; }
  .row-actions input { flex-grow: 1; }
}

/* Documentation page */
.docs-toc h2 { font-size: 14px; margin-bottom: 8px; }
.docs-toc ul {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.docs-toc a { border-bottom: 1px dotted var(--border-strong); color: var(--accent-strong); font-size: 13.5px; font-weight: 600; }
.docs-toc a:hover { text-decoration: none; border-bottom-style: solid; }

.docs-section { scroll-margin-top: 20px; }
.docs-section h3 { font-size: 15px; margin: 20px 0 8px; }
.docs-section p { margin: 8px 0; max-width: 85ch; }
.docs-section p + .table-wrap, .docs-section p + .code-block { margin-top: 10px; }
.docs-section .table-wrap { margin: 10px 0; }
.docs-section .notice { margin: 12px 0; }

.docs-list { margin: 8px 0; padding-left: 20px; }
.docs-list li { margin: 5px 0; max-width: 85ch; }

.docs-steps { margin: 8px 0; padding-left: 20px; }
.docs-steps li { margin: 8px 0; max-width: 85ch; }

.code-block {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  font-size: 12.5px;
  line-height: 1.55;
  margin: 10px 0;
  overflow-x: auto;
  padding: 12px 14px;
}
.code-block code { background: none; padding: 0; }

.docs-section code, .docs-toc code {
  background: var(--surface-3);
  border-radius: 4px;
  font-size: 0.92em;
  padding: 1px 5px;
}
.docs-section pre code, .docs-section table code { background: none; padding: 0; }
.docs-section table code { background: var(--surface-3); padding: 1px 5px; }

.code-tabs { margin: 12px 0; }
.code-tabs > input[type="radio"] {
  opacity: 0;
  pointer-events: none;
  position: absolute;
}
.code-tabs .tab-labels { display: flex; gap: 4px; }
.code-tabs .tab-labels label {
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-s) var(--radius-s) 0 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
}
.code-tabs .tab-labels label:hover { color: var(--ink); }
.code-tabs .tab-panel { display: none; }
.code-tabs .tab-panel .code-block { border-top-left-radius: 0; margin: 0; }
#lang-python:checked ~ .tab-panel-python,
#lang-js:checked ~ .tab-panel-js,
#lang-ts:checked ~ .tab-panel-ts { display: block; }
#lang-python:checked ~ .tab-labels label[for="lang-python"],
#lang-js:checked ~ .tab-labels label[for="lang-js"],
#lang-ts:checked ~ .tab-labels label[for="lang-ts"] {
  background: var(--surface-2);
  color: var(--ink);
  position: relative;
  top: 1px;
}
#lang-python:focus-visible ~ .tab-labels label[for="lang-python"],
#lang-js:focus-visible ~ .tab-labels label[for="lang-js"],
#lang-ts:focus-visible ~ .tab-labels label[for="lang-ts"] { outline: 2px solid var(--accent); outline-offset: -2px; }
