/* ===========================================================================
   PostPilot design system
   Dark-first, glass surfaces, soft depth. One system, applied everywhere.
   =========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:ital,wght@0,400..700;1,400..700&family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans+Arabic:wght@400;500;600&display=swap');

/* ------------------------------------------------------------------ tokens */
:root {
  /* Neutrals carry a faint blue bias so the greys read as chosen, not default. */
  --ink-0:  #06070A;   /* page ground, deepest */
  --ink-1:  #0A0C11;   /* app shell */
  --ink-2:  #101319;   /* raised surface */
  --ink-3:  #161A22;   /* input wells */

  /* Glass: translucent white over the ground, never a flat fill. */
  --glass:        rgba(255, 255, 255, 0.028);
  --glass-hover:  rgba(255, 255, 255, 0.045);
  --glass-active: rgba(255, 255, 255, 0.065);

  --line:        rgba(255, 255, 255, 0.075);
  --line-strong: rgba(255, 255, 255, 0.13);

  --text:   #EDF0F5;
  --text-2: #9BA5B7;   /* secondary */
  --text-3: #667085;   /* metadata */

  /* One accent, spent sparingly. Desaturated so it sits in the dark. */
  --accent:       #4F8FF7;
  --accent-soft:  rgba(79, 143, 247, 0.13);
  --accent-line:  rgba(79, 143, 247, 0.32);
  --accent-ink:   #04101F;

  /* Semantic colours are separate from the accent. */
  --ok:      #3DD68C;  --ok-soft:   rgba(61, 214, 140, 0.12);
  --warn:    #F5B544;  --warn-soft: rgba(245, 181, 68, 0.12);
  --danger:  #FF6B6B;  --danger-soft: rgba(255, 107, 107, 0.12);
  --info:    #6EA8FF;  --info-soft: rgba(110, 168, 255, 0.12);

  /* Depth: small and soft. Never a hard drop shadow. */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.34);
  --shadow-md: 0 4px 16px rgba(0,0,0,.34), 0 1px 2px rgba(0,0,0,.28);
  --shadow-lg: 0 18px 48px rgba(0,0,0,.50), 0 2px 8px rgba(0,0,0,.34);

  --r-sm: 8px;  --r-md: 12px;  --r-lg: 16px;  --r-full: 999px;

  --s-1: 4px;  --s-2: 8px;  --s-3: 12px;  --s-4: 16px;
  --s-5: 24px; --s-6: 32px; --s-7: 48px;  --s-8: 64px;

  --sidebar-w: 248px;
  --sidebar-w-collapsed: 68px;
  --topbar-h: 60px;
  --tap: 44px;

  --font: 'Instrument Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --font-arabic: 'IBM Plex Sans Arabic', 'Noto Naskh Arabic', 'Geeza Pro', Tahoma, sans-serif;

  --ease: cubic-bezier(.2, .7, .3, 1);
  --fast: 130ms;  --med: 200ms;
}

/* A deliberately single-theme product: one dark world, painted explicitly so
   it holds regardless of the host's theme. */
:root { color-scheme: dark; }

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--ink-0);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Ambient depth: two very soft pools of light, fixed behind everything. */
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(900px 500px at 12% -8%, rgba(79,143,247,.07), transparent 60%),
    radial-gradient(700px 460px at 92% 4%, rgba(61,214,140,.035), transparent 62%);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }

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

/* -------------------------------------------------------------- typography */
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.015em; text-wrap: balance; }
.page-title { font-size: 24px; line-height: 1.25; letter-spacing: -0.025em; }
.page-desc  { color: var(--text-2); font-size: 14px; margin-top: 2px; max-width: 68ch; }
.section-title { font-size: 15px; font-weight: 600; }

.eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: .09em;
  text-transform: uppercase; color: var(--text-3);
}
.meta  { font-size: 12.5px; color: var(--text-3); }
.muted { font-size: 13px; color: var(--text-2); }
.num   { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

[dir="rtl"], .rtl, [lang="ar"], [lang="ckb"] {
  font-family: var(--font-arabic);
  direction: rtl; text-align: right; line-height: 1.95;
}

/* ============================================================ app skeleton */
.app-shell { position: relative; z-index: 1; min-height: 100dvh; }

/* -------------------------------------------------------------- sidebar */
.sidebar {
  position: fixed; inset-block: 0; inset-inline-start: 0; width: var(--sidebar-w);
  display: flex; flex-direction: column; z-index: 60;
  background: linear-gradient(180deg, rgba(16,19,25,.92), rgba(10,12,17,.92));
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-inline-end: 1px solid var(--line);
  transition: width var(--med) var(--ease), transform var(--med) var(--ease);
}
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }

.brand {
  display: flex; align-items: center; gap: var(--s-3);
  height: var(--topbar-h); padding-inline: var(--s-4);
  border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
.brand-mark {
  width: 30px; height: 30px; flex: 0 0 auto; border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent), #2E6FD4);
  color: #fff; font-weight: 700; font-size: 14px;
  box-shadow: 0 2px 10px rgba(79,143,247,.36);
}
.brand-name { font-weight: 600; letter-spacing: -.02em; white-space: nowrap; }
.brand-sub  { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.sidebar.collapsed .brand-text { display: none; }

.nav { flex: 1 1 auto; overflow-y: auto; padding: var(--s-4) var(--s-3); }
.nav-group + .nav-group { margin-top: var(--s-5); }
.nav-group-label {
  font-size: 10.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-3); padding-inline: var(--s-3); margin-bottom: var(--s-2);
}
.sidebar.collapsed .nav-group-label { opacity: 0; height: 8px; overflow: hidden; }

.nav-item {
  position: relative; width: 100%;
  display: flex; align-items: center; gap: var(--s-3);
  min-height: var(--tap); padding: 0 var(--s-3);
  border: 0; border-radius: var(--r-md); background: transparent;
  color: var(--text-2); font: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer; text-align: start;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.nav-item:hover { background: var(--glass-hover); color: var(--text); }
/* Active state reads clearly without shouting: a soft tint plus an edge marker. */
.nav-item.active { background: var(--accent-soft); color: #DCE9FF; }
.nav-item.active::before {
  content: ''; position: absolute; inset-inline-start: calc(var(--s-3) * -1);
  inset-block: 22%; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-item .ico { width: 18px; height: 18px; flex: 0 0 auto; opacity: .92; }
.nav-item .label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar.collapsed .nav-item .label,
.sidebar.collapsed .nav-item .nav-badge { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 0; }

.nav-badge {
  margin-inline-start: auto; min-width: 20px; height: 20px; padding: 0 6px;
  display: grid; place-items: center; border-radius: var(--r-full);
  background: var(--accent); color: var(--accent-ink);
  font-size: 11px; font-weight: 700; font-family: var(--font-mono);
}
.nav-badge.dot {
  min-width: 7px; width: 7px; height: 7px; padding: 0;
  background: var(--ok); box-shadow: 0 0 0 3px rgba(61,214,140,.16);
}

/* Nested navigation */
.nav-sub { margin: 2px 0 2px 0; padding-inline-start: 30px; display: grid; gap: 2px; }
.nav-sub .nav-item { min-height: 34px; font-size: 13px; }
.sidebar.collapsed .nav-sub { display: none; }
.chev { margin-inline-start: auto; transition: transform var(--fast) var(--ease); opacity: .6; }
.chev.open { transform: rotate(90deg); }

.sidebar-foot { flex: 0 0 auto; border-top: 1px solid var(--line); padding: var(--s-3); }
.userbox {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2); border-radius: var(--r-md); cursor: pointer;
  transition: background var(--fast) var(--ease);
}
.userbox:hover { background: var(--glass-hover); }
.avatar {
  width: 32px; height: 32px; flex: 0 0 auto; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: linear-gradient(145deg, #2A3342, #1A2130);
  border: 1px solid var(--line-strong); color: var(--text);
}
.userbox .who { min-width: 0; }
.userbox .who .n { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar.collapsed .userbox .who { display: none; }
.sidebar.collapsed .userbox { justify-content: center; }

/* --------------------------------------------------------------- topbar */
.main {
  margin-inline-start: var(--sidebar-w);
  transition: margin var(--med) var(--ease);
  min-height: 100dvh; display: flex; flex-direction: column;
}
.main.wide { margin-inline-start: var(--sidebar-w-collapsed); }

.topbar {
  position: sticky; top: 0; z-index: 50; height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--s-3);
  padding-inline: var(--s-5);
  background: rgba(10,12,17,.72);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border-bottom: 1px solid var(--line);
}
.crumbs { display: flex; align-items: center; gap: var(--s-2); font-size: 13px; color: var(--text-3); min-width: 0; }
.crumbs .sep { opacity: .45; }
.crumbs .here { color: var(--text-2); font-weight: 500; }
.topbar .spacer { flex: 1 1 auto; }

.page { flex: 1 1 auto; padding: var(--s-6) var(--s-5) var(--s-8); max-width: 1180px; width: 100%; }
.page-head {
  display: flex; align-items: flex-start; gap: var(--s-4);
  flex-wrap: wrap; margin-bottom: var(--s-6);
}
.page-head .actions { margin-inline-start: auto; display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* ============================================================== surfaces */
.card {
  position: relative;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease),
              background var(--fast) var(--ease), transform var(--fast) var(--ease);
}
/* Only lift things that are actually interactive. */
.card.interactive:hover {
  background: var(--glass-hover); border-color: var(--line-strong);
  box-shadow: var(--shadow-md); transform: translateY(-1px);
}
.card-head {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line);
}
.card-head .spacer { flex: 1 1 auto; }
.card-body { padding: var(--s-5); }
.card-body.tight { padding: var(--s-4); }
.card-foot {
  padding: var(--s-3) var(--s-5); border-top: 1px solid var(--line);
  display: flex; gap: var(--s-2); align-items: center;
}

.grid { display: grid; gap: var(--s-4); }
.grid.k2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack  { display: grid; gap: var(--s-4); }
.row    { display: flex; gap: var(--s-3); flex-wrap: wrap; align-items: center; }

/* KPI tile: the number is the point, so it gets the mono face and the weight. */
.kpi { padding: var(--s-4) var(--s-5); }
.kpi .k-label { font-size: 12px; color: var(--text-3); font-weight: 500; }
.kpi .k-value {
  font-family: var(--font-mono); font-size: 27px; font-weight: 600;
  letter-spacing: -.03em; margin-top: 6px; line-height: 1.1;
}
.kpi .k-foot { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--text-3); }
.delta { font-family: var(--font-mono); font-weight: 600; font-size: 12px; }
.delta.up { color: var(--ok); } .delta.down { color: var(--danger); }

/* =============================================================== buttons */
.btn {
  --btn-bg: var(--glass); --btn-fg: var(--text); --btn-line: var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--tap); padding: 0 16px;
  border: 1px solid var(--btn-line); border-radius: var(--r-md);
  background: var(--btn-bg); color: var(--btn-fg);
  font: inherit; font-size: 14px; font-weight: 600; letter-spacing: -.005em;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease),
              transform var(--fast) var(--ease), opacity var(--fast) var(--ease);
}
.btn:hover { background: var(--glass-hover); border-color: var(--line-strong); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }

.btn.primary {
  --btn-bg: var(--accent); --btn-fg: var(--accent-ink); --btn-line: transparent;
  box-shadow: 0 1px 3px rgba(0,0,0,.4);
}
.btn.primary:hover { --btn-bg: #63A0FF; }

.btn.outline { --btn-bg: transparent; --btn-line: var(--line-strong); }
.btn.ghost   { --btn-bg: transparent; --btn-line: transparent; --btn-fg: var(--text-2); }
.btn.ghost:hover { --btn-fg: var(--text); background: var(--glass-hover); }

.btn.destructive { --btn-bg: var(--danger-soft); --btn-fg: var(--danger); --btn-line: rgba(255,107,107,.28); }
.btn.destructive:hover { --btn-bg: rgba(255,107,107,.19); }

.btn.icon { width: var(--tap); padding: 0; }
.btn.sm { min-height: 34px; padding: 0 11px; font-size: 13px; }
.btn.lg { min-height: 52px; padding: 0 22px; font-size: 15px; }
.btn.block { width: 100%; }
.btn.loading { pointer-events: none; opacity: .8; }

.spin {
  width: 14px; height: 14px; flex: 0 0 auto;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-inline-start: -1px; }
.btn-group .btn:first-child { border-start-start-radius: var(--r-md); border-end-start-radius: var(--r-md); margin: 0; }
.btn-group .btn:last-child  { border-start-end-radius: var(--r-md); border-end-end-radius: var(--r-md); }

/* ================================================================= forms */
.field { display: grid; gap: 6px; }
.field + .field { margin-top: var(--s-4); }
.field > label { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.req { color: var(--danger); font-weight: 700; }
.field .desc { font-size: 12.5px; color: var(--text-3); }
.field .err  { font-size: 12.5px; color: var(--danger); display: flex; align-items: center; gap: 5px; }
.field .okmsg { font-size: 12.5px; color: var(--ok); }

.input, .select, textarea.input {
  width: 100%; min-height: var(--tap);
  background: var(--ink-3); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 10px 13px; font: inherit; font-size: 14px;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease), background var(--fast) var(--ease);
}
.input::placeholder { color: var(--text-3); }
.input:hover { border-color: var(--line-strong); }
.input:focus {
  outline: none; border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft); background: var(--ink-2);
}
.input[disabled] { opacity: .5; cursor: not-allowed; }
.input.invalid { border-color: rgba(255,107,107,.45); }
.input.invalid:focus { box-shadow: 0 0 0 3px var(--danger-soft); }
.input.valid { border-color: rgba(61,214,140,.4); }
textarea.input { min-height: 96px; resize: vertical; line-height: 1.6; }
textarea.input[lang="ar"], textarea.input[lang="ckb"] { font-family: var(--font-arabic); font-size: 15.5px; }

.select {
  appearance: none; padding-inline-end: 34px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
                    linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 17px) 51%, calc(100% - 12px) 51%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}

.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .lead {
  position: absolute; inset-inline-start: 12px; color: var(--text-3);
  pointer-events: none; display: flex;
}
.input-wrap .lead ~ .input { padding-inline-start: 38px; }

/* Toggle */
.toggle { display: inline-flex; align-items: center; gap: var(--s-3); cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .track {
  width: 42px; height: 24px; border-radius: var(--r-full); flex: 0 0 auto;
  background: var(--ink-3); border: 1px solid var(--line); position: relative;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.toggle .track::after {
  content: ''; position: absolute; top: 2px; inset-inline-start: 2px;
  width: 18px; height: 18px; border-radius: 50%; background: var(--text-2);
  transition: transform var(--fast) var(--ease), background var(--fast) var(--ease);
}
.toggle input:checked + .track { background: var(--accent); border-color: transparent; }
.toggle input:checked + .track::after { transform: translateX(18px); background: #fff; }
.toggle input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-soft); }

/* Checkbox / radio */
.check { display: inline-flex; align-items: center; gap: var(--s-2); cursor: pointer; font-size: 14px; }
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check .box {
  width: 18px; height: 18px; flex: 0 0 auto; border-radius: 5px;
  border: 1.5px solid var(--line-strong); background: var(--ink-3);
  display: grid; place-items: center;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.check.radio .box { border-radius: 50%; }
.check input:checked + .box { background: var(--accent); border-color: var(--accent); }
.check input:checked + .box::after {
  content: ''; width: 9px; height: 5px; border: 2px solid #fff;
  border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px);
}
.check.radio input:checked + .box::after {
  content: ''; width: 7px; height: 7px; border: 0; border-radius: 50%;
  background: #fff; transform: none;
}
.check input:focus-visible + .box { box-shadow: 0 0 0 3px var(--accent-soft); }

/* File upload */
.dropzone {
  display: grid; place-items: center; gap: 6px; text-align: center;
  padding: var(--s-6) var(--s-4); cursor: pointer;
  border: 1.5px dashed var(--line-strong); border-radius: var(--r-md);
  background: var(--glass); color: var(--text-2);
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.dropzone:hover, .dropzone.hot { border-color: var(--accent-line); background: var(--accent-soft); color: var(--text); }

/* =============================================================== badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px; border-radius: var(--r-full);
  font-size: 11.5px; font-weight: 600; letter-spacing: .01em;
  border: 1px solid var(--line); background: var(--glass); color: var(--text-2);
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok      { color: var(--ok);     background: var(--ok-soft);     border-color: rgba(61,214,140,.26); }
.badge.warn    { color: var(--warn);   background: var(--warn-soft);   border-color: rgba(245,181,68,.26); }
.badge.danger  { color: var(--danger); background: var(--danger-soft); border-color: rgba(255,107,107,.26); }
.badge.info    { color: var(--info);   background: var(--info-soft);   border-color: rgba(110,168,255,.26); }
.badge.accent  { color: #B9D3FF;       background: var(--accent-soft); border-color: var(--accent-line); }

/* =============================================================== tables */
.table-wrap {
  overflow-x: auto; border-radius: var(--r-lg);
  border: 1px solid var(--line); background: var(--glass);
}
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; min-width: 640px; }
table.data thead th {
  position: sticky; top: 0; z-index: 2;
  background: rgba(16,19,25,.94);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  text-align: start; font-size: 11.5px; font-weight: 600;
  letter-spacing: .07em; text-transform: uppercase; color: var(--text-3);
  padding: 11px var(--s-4); border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data thead th.sortable { cursor: pointer; user-select: none; }
table.data thead th.sortable:hover { color: var(--text-2); }
table.data thead th .arrow { opacity: .5; font-size: 9px; margin-inline-start: 4px; }
table.data thead th .arrow.on { opacity: 1; color: var(--accent); }
table.data tbody td { padding: 12px var(--s-4); border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr { transition: background var(--fast) var(--ease); }
table.data tbody tr:hover { background: var(--glass-hover); }
table.data tbody tr.selected { background: var(--accent-soft); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: end; }
table.data td.shrink { width: 1%; white-space: nowrap; }

.toolbar {
  display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line);
}
.toolbar .spacer { flex: 1 1 auto; }
.bulkbar {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); background: var(--accent-soft);
  border-bottom: 1px solid var(--accent-line); font-size: 13px;
}
.pagination {
  display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  padding: var(--s-3) var(--s-4); border-top: 1px solid var(--line);
  font-size: 13px; color: var(--text-3);
}
.pagination .spacer { flex: 1 1 auto; }

/* Below the breakpoint a table becomes a stack of labelled cards. */
@media (max-width: 720px) {
  table.data.responsive { min-width: 0; }
  table.data.responsive thead { display: none; }
  table.data.responsive tbody tr {
    display: grid; gap: 6px; padding: var(--s-4);
    border-bottom: 1px solid var(--line);
  }
  table.data.responsive tbody td { border: 0; padding: 0; display: flex; gap: var(--s-3); align-items: baseline; }
  table.data.responsive tbody td::before {
    content: attr(data-label); flex: 0 0 96px;
    font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3);
  }
  table.data.responsive td.num { text-align: start; }
}

/* ============================================================== dropdown */
.menu-wrap { position: relative; display: inline-flex; }
.menu {
  position: absolute; top: calc(100% + 6px); inset-inline-end: 0; z-index: 70;
  min-width: 190px; padding: 5px;
  background: rgba(18,21,28,.97); border: 1px solid var(--line-strong);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  animation: menuIn var(--fast) var(--ease);
}
@keyframes menuIn { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.menu-item {
  display: flex; align-items: center; gap: var(--s-3); width: 100%;
  padding: 9px 11px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text-2);
  font: inherit; font-size: 13.5px; text-align: start; cursor: pointer;
}
.menu-item:hover { background: var(--glass-hover); color: var(--text); }
.menu-item.danger { color: var(--danger); }
.menu-sep { height: 1px; background: var(--line); margin: 5px 0; }

/* ================================================= modals & side drawers */
dialog.modal {
  padding: 0; border: 0; background: transparent; color: var(--text);
  max-width: min(620px, calc(100vw - 32px)); width: 100%;
}
dialog.modal::backdrop {
  background: rgba(3,4,7,.72);
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
}
dialog.modal .sheet {
  background: rgba(18,21,28,.97);
  border: 1px solid var(--line-strong); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); overflow: hidden;
  animation: modalIn var(--med) var(--ease);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.985); } }
.modal-head { padding: var(--s-5) var(--s-5) var(--s-3); }
.modal-body { padding: 0 var(--s-5) var(--s-4); max-height: 62dvh; overflow-y: auto; }
.modal-foot {
  padding: var(--s-4) var(--s-5); border-top: 1px solid var(--line);
  display: flex; gap: var(--s-2); justify-content: flex-end; flex-wrap: wrap;
}
.modal-icon {
  width: 40px; height: 40px; border-radius: var(--r-md);
  display: grid; place-items: center; margin-bottom: var(--s-3);
}
.modal-icon.danger { background: var(--danger-soft); color: var(--danger); }
.modal-icon.warn   { background: var(--warn-soft);   color: var(--warn); }
.modal-icon.ok     { background: var(--ok-soft);     color: var(--ok); }

.drawer {
  position: fixed; inset-block: 0; inset-inline-end: 0; z-index: 80;
  width: min(440px, 100vw); display: flex; flex-direction: column;
  background: rgba(14,17,23,.98); border-inline-start: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg); animation: drawerIn var(--med) var(--ease);
}
@keyframes drawerIn { from { transform: translateX(100%); } }
.scrim {
  position: fixed; inset: 0; z-index: 75; background: rgba(3,4,7,.6);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fade var(--fast) var(--ease);
}
@keyframes fade { from { opacity: 0; } }

/* =============================================================== toasts */
.toasts {
  position: fixed; z-index: 100; inset-block-end: var(--s-5); inset-inline-end: var(--s-5);
  display: grid; gap: var(--s-2); width: min(380px, calc(100vw - 32px));
}
.toast {
  display: flex; gap: var(--s-3); padding: var(--s-3) var(--s-4);
  background: rgba(20,24,31,.97); border: 1px solid var(--line-strong);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  animation: toastIn var(--med) var(--ease);
}
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }
.toast .bar { width: 3px; border-radius: 3px; flex: 0 0 auto; background: var(--text-3); }
.toast.ok .bar { background: var(--ok); } .toast.error .bar { background: var(--danger); }
.toast.warn .bar { background: var(--warn); } .toast.info .bar { background: var(--info); }
.toast .t { font-size: 13.5px; font-weight: 600; }
.toast .d { font-size: 12.5px; color: var(--text-2); margin-top: 1px; }

/* ================================================== states & skeletons */
.empty {
  display: grid; place-items: center; gap: var(--s-3);
  text-align: center; padding: var(--s-8) var(--s-5); color: var(--text-2);
}
.empty .glyph {
  width: 46px; height: 46px; border-radius: var(--r-md);
  display: grid; place-items: center;
  background: var(--glass); border: 1px solid var(--line); color: var(--text-3);
}
.empty h3 { font-size: 15px; color: var(--text); }
.empty p { font-size: 13.5px; max-width: 42ch; margin: 0; }

.skel {
  background: linear-gradient(90deg, var(--glass) 25%, var(--glass-active) 37%, var(--glass) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s ease-in-out infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }
.skel.line { height: 11px; }
.skel.title { height: 17px; width: 42%; }

/* ================================================================ charts */
.chart { width: 100%; display: block; overflow: visible; }
.chart text { font-family: var(--font-mono); font-size: 10px; fill: var(--text-3); }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.legend { display: flex; gap: var(--s-4); flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 9px; height: 9px; border-radius: 3px; }

/* ================================================================= misc */
pre.code {
  background: var(--ink-3); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: var(--s-4); font-family: var(--font-mono); font-size: 12px; line-height: 1.6;
  overflow-x: auto; max-height: 380px; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
}
.kv { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 10px var(--s-4); margin: 0; font-size: 13.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; word-break: break-word; }
.divider { height: 1px; background: var(--line); margin: var(--s-4) 0; }

.banner {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--glass); font-size: 13.5px;
}
.banner.warn   { border-color: rgba(245,181,68,.28);  background: var(--warn-soft); }
.banner.danger { border-color: rgba(255,107,107,.28); background: var(--danger-soft); }
.banner.info   { border-color: var(--accent-line);    background: var(--accent-soft); }

.steps { display: flex; gap: 6px; flex-wrap: wrap; }
.step {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px; border-radius: var(--r-full);
  font-size: 11px; font-weight: 600; letter-spacing: .05em;
  background: var(--glass); border: 1px solid var(--line); color: var(--text-3);
}
.step.active { background: var(--accent-soft); border-color: var(--accent-line); color: #CFE0FF; }
.step.done   { color: var(--ok); border-color: rgba(61,214,140,.28); }
.step.error  { color: var(--danger); border-color: rgba(255,107,107,.3); background: var(--danger-soft); }

.preview-img {
  width: 100%; aspect-ratio: 1200 / 627; object-fit: cover;
  border-radius: var(--r-md); border: 1px solid var(--line); display: block; background: var(--ink-3);
}

[hidden] { display: none !important; }
.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* =========================================================== responsive */
.mobile-only { display: none; }

@media (max-width: 1080px) {
  .grid.k4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.k3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .mobile-only { display: inline-flex; }
  /* The sidebar becomes an off-canvas drawer rather than a squeezed column. */
  .sidebar {
    transform: translateX(-100%); width: min(280px, 84vw);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar.collapsed { width: min(280px, 84vw); }
  .sidebar.collapsed .brand-text,
  .sidebar.collapsed .nav-item .label,
  .sidebar.collapsed .userbox .who { display: revert; }
  .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 0 var(--s-3); }

  .main, .main.wide { margin-inline-start: 0; }
  .page { padding: var(--s-5) var(--s-4) var(--s-8); }
  .topbar { padding-inline: var(--s-4); }
  .grid.k2, .grid.k3, .grid.k4 { grid-template-columns: 1fr; }
  .page-head .actions { margin-inline-start: 0; width: 100%; }
  .page-head .actions .btn { flex: 1 1 auto; }
  .toasts { inset-inline: var(--s-4); width: auto; inset-block-end: var(--s-4); }
}

@media (max-width: 520px) {
  .page-title { font-size: 20px; }
  .kpi .k-value { font-size: 23px; }
}
