/* ============================================================
   WAGate.app — Design Tokens & Base
   Warm "Lexend" system, cream surfaces, green accent
   ============================================================ */

:root {
  /* Surfaces */
  --bg: #fbf7f0;
  --surface: #ffffff;
  --surface-2: #f6f1e7;
  --surface-3: #efe7d8;
  --inset: #faf6ee;

  /* Borders */
  --border: #ece4d6;
  --border-strong: #e0d7c6;
  --border-stronger: #cfc4b0;

  /* Text */
  --text: #17191d;
  --text-muted: #585d64;
  --text-faint: #9aa0a8;
  --text-on-accent: #ffffff;

  /* Accent — WAGate green */
  --accent: #12b76a;
  --accent-hover: #0fa861;
  --accent-press: #0e9f5d;
  --accent-tint: #e4f7ed;
  --accent-tint-2: #cdeedd;
  --accent-ring: rgba(18, 183, 106, 0.30);
  --accent-text: #0c8f55;

  /* Status */
  --green: #16a34a;
  --green-tint: #e7f6ec;
  --green-text: #15803d;
  --amber: #d97706;
  --amber-tint: #fbf0e0;
  --amber-text: #b45309;
  --red: #dc2626;
  --red-tint: #fbe9e9;
  --red-text: #b91c1c;
  --blue: #2563eb;
  --blue-tint: #e7eefc;
  --blue-text: #1d4ed8;
  --violet: #7c3aed;
  --violet-tint: #f0e9fd;

  /* WhatsApp chat */
  --wa-bg: #e4ddd4;
  --wa-bubble-in: #ffffff;
  --wa-bubble-out: #d9fdd3;
  --wa-header: #008069;
  --wa-tick: #34b7f1;

  /* Radii — rounder, friendlier */
  --r-xs: 7px;
  --r-sm: 10px;
  --r: 13px;
  --r-lg: 17px;
  --r-xl: 21px;
  --r-2xl: 26px;
  --r-full: 999px;

  /* Shadows — warm */
  --sh-xs: 0 1px 1.5px rgba(60, 48, 30, 0.04);
  --sh-sm: 0 1px 2px rgba(60, 48, 30, 0.05), 0 1px 1px rgba(60, 48, 30, 0.03);
  --sh: 0 2px 5px rgba(60, 48, 30, 0.05), 0 1px 2px rgba(60, 48, 30, 0.04);
  --sh-md: 0 6px 16px -4px rgba(60, 48, 30, 0.10), 0 2px 5px -2px rgba(60, 48, 30, 0.06);
  --sh-lg: 0 16px 40px -12px rgba(60, 48, 30, 0.18), 0 6px 14px -6px rgba(60, 48, 30, 0.09);
  --sh-pop: 0 12px 32px -8px rgba(40, 30, 18, 0.20), 0 3px 8px -3px rgba(40, 30, 18, 0.10);

  /* Typography — Lexend for Latin display; Rubik covers Hebrew glyphs (Lexend has
     none), so HE text falls through to Rubik rather than an ugly system font.
     JetBrains Mono is Latin-only; the mono stack also falls back to Rubik. */
  --font: "Lexend", "Rubik", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, "Rubik", monospace;

  /* Layout */
  --sidebar-w: 248px;
  --topbar-h: 56px;
  --maxw: 1180px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.006em;
}

#root { height: 100%; }

::selection { background: var(--accent-tint-2); }

h1, h2, h3, h4, h5, p { margin: 0; }

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

button { font-family: inherit; cursor: pointer; }

.mono { font-family: var(--mono); font-feature-settings: "zero" 1; }
/* Keep Latin codes / IDs / numbers left-to-right even inside RTL text */
.mono, code, .ltr, input.mono, .codeblock { direction: ltr; unicode-bidi: isolate; }
input.mono { text-align: start; }

/* Scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: #d9dce1;
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: #c4c8cf; background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ===================== App Shell ===================== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100%;
  overflow: hidden;
}

/* Sidebar — light surface, hairline border (warm Lexend chrome). */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sb-top {
  padding: 14px 14px 8px;
}
.brand {
  display: flex;
  align-items: center;
  justify-content: center;   /* center the WAGate wordmark in the sidebar */
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--r);
  cursor: pointer;
}
.brand:hover { background: var(--surface-2); }
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 78%, #fff), var(--accent));
  display: grid; place-items: center;
  box-shadow: var(--sh-sm), inset 0 1px 0 rgba(255,255,255,.25);
  flex-shrink: 0;
}
.brand-name { font-weight: 650; font-size: 14.5px; letter-spacing: -0.02em; }
.brand-sub { font-size: 11px; color: var(--text-faint); margin-top: -2px; letter-spacing: 0; }
/* WAGate.app wordmark — full-logo SVG, sized by height (keeps aspect ratio).
   Use WaGateLogoDark.svg on dark surfaces, WaGateLogoLight.svg on light ones. */
.brand-logo { display: block; width: auto; height: 26px; }

/* Tenant switcher */
.tenant {
  margin: 8px 14px 4px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  background: var(--surface);
  transition: background .12s, border-color .12s;
}
.tenant:hover { background: var(--surface-2); border-color: var(--border-strong); }
.tenant-logo {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--surface-3); color: var(--text-muted);
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
  flex-shrink: 0;
}
.tenant-name { font-weight: 600; font-size: 13px; line-height: 1.1; }
.tenant-plan { font-size: 11px; color: var(--text-faint); }

/* Nav */
.nav { padding: 10px 10px; flex: 1; overflow-y: auto; min-height: 0; }
.nav-label {
  font-size: 10.5px; font-weight: 650; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-faint);
  padding: 14px 8px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px; border-radius: var(--r-sm);
  color: var(--text-muted); font-weight: 530; font-size: 13.5px;
  cursor: pointer; user-select: none;
  transition: background .1s, color .1s;
  position: relative;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item.active { background: var(--accent-tint); color: var(--accent-text); font-weight: 600; }
.nav-item.active svg { color: var(--accent); }
.nav-item svg { width: 17px; height: 17px; color: var(--text-faint); flex-shrink: 0; }
.nav-item.active svg { color: var(--accent); }
.nav-item .nav-badge {
  margin-inline-start: auto; font-size: 11px; font-weight: 600;
  background: var(--surface-3); color: var(--text-muted);
  padding: 1px 7px; border-radius: var(--r-full);
}
.nav-item.active .nav-badge { background: var(--accent-tint-2); color: var(--accent-text); }

/* Sidebar footer */
.sb-foot { border-top: 1px solid var(--border); padding: 10px; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: var(--r-sm); cursor: pointer;
}
.user-chip:hover { background: var(--surface-2); }
.avatar {
  width: 28px; height: 28px; border-radius: var(--r-full);
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 70%, #fff), var(--accent-press));
  color: #fff; display: grid; place-items: center;
  font-weight: 650; font-size: 12px; flex-shrink: 0;
}

/* ===================== Main ===================== */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  background: rgba(251, 247, 240, 0.8);
  backdrop-filter: saturate(180%) blur(8px);
  display: flex; align-items: center; gap: 14px;
  padding: 0 22px; flex-shrink: 0;
}
/* Hamburger — only shown on narrow screens (see the mobile block below). */
.topbar-burger {
  display: none; width: 34px; height: 34px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); place-items: center; flex-shrink: 0;
}
.topbar-burger:hover { background: var(--surface-3); }
.topbar-burger svg { width: 18px; height: 18px; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.crumbs .c-muted { color: var(--text-faint); }
.crumbs .c-sep { color: var(--border-stronger); }
.crumbs .c-cur { font-weight: 600; }
.topbar-spacer { flex: 1; }

.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 6px 10px; width: 230px;
  color: var(--text-faint); font-size: 13px; cursor: text;
}
.search kbd {
  margin-inline-start: auto; font-family: var(--mono); font-size: 10.5px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 4px; padding: 1px 5px; color: var(--text-faint);
}

.env-toggle {
  display: flex; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 2px; gap: 2px;
}
.env-toggle button {
  border: none; background: transparent; font-size: 12px; font-weight: 600;
  color: var(--text-muted); padding: 4px 11px; border-radius: 5px;
  display: flex; align-items: center; gap: 6px;
}
.env-toggle button.on { background: var(--surface); color: var(--text); box-shadow: var(--sh-xs); }
.env-toggle button.on.live .dot { background: var(--green); }
.env-toggle button.on.test .dot { background: var(--amber); }
.env-toggle .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); }

.icon-btn {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  border: 1px solid transparent; background: transparent;
  display: grid; place-items: center; color: var(--text-muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }

.content {
  flex: 1; overflow-y: auto; min-height: 0;
}
.content-inner { max-width: var(--maxw); margin: 0 auto; padding: 28px 28px 64px; }

/* Inbox runs full-bleed and full-height — no centering, no padding, own scroll */
.content--flush { overflow: hidden; }
.content-inner--flush { max-width: none; margin: 0; padding: 0; height: 100%; }

.page-head { margin-bottom: 22px; }
.page-title { font-size: 22px; font-weight: 680; letter-spacing: -0.025em; }
.page-desc { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

/* ===================== Primitives ===================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: var(--r-full); font-weight: 600; font-size: 13.5px;
  padding: 9px 16px; border: 1px solid transparent;
  transition: background .12s, border-color .12s, box-shadow .12s, color .12s;
  white-space: nowrap; line-height: 1;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--sh-sm), inset 0 1px 0 rgba(255,255,255,.16); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-press); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--sh-xs); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--border-stronger); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--surface); color: var(--red-text); border-color: #f0d4d4; }
.btn-danger:hover { background: var(--red-tint); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; gap: 5px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { padding: 11px 20px; font-size: 14.5px; }
.btn:disabled { opacity: .5; pointer-events: none; }

/* Card */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-sm);
}
.card-pad { padding: 18px; }
.card-head {
  padding: 15px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.card-title { font-weight: 640; font-size: 14.5px; letter-spacing: -0.01em; white-space: nowrap; }
.card-head > div:first-child { min-width: 0; }
.card-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

/* Badge */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600; padding: 2.5px 8px;
  border-radius: var(--r-full); line-height: 1.3;
  border: 1px solid transparent;
}
.badge .bdot { width: 6px; height: 6px; border-radius: 50%; }
.badge-green { background: var(--green-tint); color: var(--green-text); }
.badge-green .bdot { background: var(--green); }
.badge-amber { background: var(--amber-tint); color: var(--amber-text); }
.badge-amber .bdot { background: var(--amber); }
.badge-red { background: var(--red-tint); color: var(--red-text); }
.badge-red .bdot { background: var(--red); }
.badge-blue { background: var(--blue-tint); color: var(--blue-text); }
.badge-blue .bdot { background: var(--blue); }
.badge-violet { background: var(--violet-tint); color: var(--violet); }
.badge-violet .bdot { background: var(--violet); }
.badge-neutral { background: var(--surface-3); color: var(--text-muted); }
.badge-neutral .bdot { background: var(--text-faint); }
.badge-accent { background: var(--accent-tint); color: var(--accent-text); }
.badge-accent .bdot { background: var(--accent); }

/* Pill tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 9px 13px; font-size: 13.5px; font-weight: 560; color: var(--text-muted);
  border: none; background: transparent; border-bottom: 2px solid transparent;
  margin-bottom: -1px; display: flex; align-items: center; gap: 7px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 620; }
.tab .tcount { font-size: 11px; background: var(--surface-3); color: var(--text-muted); padding: 0 6px; border-radius: 999px; font-weight: 600; }

/* Input */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--text); }
.field-hint { font-size: 12px; color: var(--text-faint); }
.input, .select, .textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); padding: 8px 11px; font-size: 13.5px; color: var(--text);
  font-family: inherit; transition: border-color .12s, box-shadow .12s;
  box-shadow: var(--sh-xs);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring);
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input.mono, .textarea.mono { font-family: var(--mono); font-size: 12.5px; }
.textarea { resize: vertical; min-height: 80px; line-height: 1.55; }
.input-group { display: flex; }
.input-group .input { border-top-right-radius: 0; border-bottom-right-radius: 0; border-right: none; }
.input-group .ig-btn {
  border: 1px solid var(--border-strong); border-left: 1px solid var(--border);
  background: var(--surface-2); border-top-right-radius: var(--r-sm); border-bottom-right-radius: var(--r-sm);
  padding: 0 11px; color: var(--text-muted); display: grid; place-items: center;
}
.input-group .ig-btn:hover { background: var(--surface-3); color: var(--text); }

/* Code block */
.codeblock {
  background: #15171c; border-radius: var(--r); padding: 14px 16px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.7;
  color: #d6d9e0; overflow-x: auto; position: relative;
}
.codeblock .c-key { color: #a5b4fc; }
.codeblock .c-str { color: #86efac; }
.codeblock .c-num { color: #fcd34d; }
.codeblock .c-punc { color: #8b909c; }
.codeblock .c-comment { color: #6b7280; }

/* Table */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl thead th {
  text-align: left; font-weight: 600; font-size: 11.5px; letter-spacing: 0.02em;
  text-transform: uppercase; color: var(--text-faint);
  padding: 9px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.tbl tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr.clickable { cursor: pointer; }

/* Stat */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 16px 17px; box-shadow: var(--sh-sm);
}
.stat-label { font-size: 12.5px; color: var(--text-muted); font-weight: 560; display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 27px; font-weight: 680; letter-spacing: -0.03em; margin-top: 8px; line-height: 1; }
.stat-delta { font-size: 12px; font-weight: 600; margin-top: 8px; display: inline-flex; align-items: center; gap: 4px; }
.stat-delta.up { color: var(--green-text); }
.stat-delta.down { color: var(--red-text); }
.stat-delta.flat { color: var(--text-faint); }

/* Toast */
.toast-wrap {
  position: fixed; bottom: 22px; right: 22px; z-index: 9000;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
}
.toast {
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r); box-shadow: var(--sh-lg);
  padding: 12px 14px; display: flex; align-items: flex-start; gap: 11px;
  width: 340px; animation: toast-in .28s cubic-bezier(.16,1,.3,1);
}
.toast.leaving { animation: toast-out .2s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }
.toast-ic { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; margin-top: 1px; }
.toast-ic svg { width: 13px; height: 13px; color: #fff; }
.toast-ic.success { background: var(--green); }
.toast-ic.error { background: var(--red); }
.toast-ic.warning { background: var(--amber); }
.toast-ic.info { background: var(--accent); }
.toast-title { font-weight: 620; font-size: 13.5px; }
.toast-msg { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; line-height: 1.45; }
.toast-x { margin-inline-start: auto; color: var(--text-faint); background: none; border: none; padding: 2px; }
.toast-x:hover { color: var(--text); }

/* Modal / overlay */
.overlay {
  position: fixed; inset: 0; z-index: 8000;
  background: rgba(20,22,30,0.42);
  backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 24px;
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--sh-lg); width: 100%; max-width: 460px;
  animation: modal-in .26s cubic-bezier(.16,1,.3,1); overflow: hidden;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }

/* Misc */
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.row { display: flex; align-items: center; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.kbd-key {
  font-family: var(--mono); font-size: 11px; background: var(--surface-2);
  border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: 5px; padding: 1px 6px; color: var(--text-muted);
}
.copy-flash { color: var(--green-text) !important; }
/* Entrance that is SAFE if the animation never runs (throttled iframe):
   resting opacity is 1, and the keyframe floor never fully hides content. */
.fade-in { animation: riseIn .42s cubic-bezier(.16,1,.3,1); }
@keyframes riseIn { from { opacity: .9; transform: translateY(7px); } to { opacity: 1; transform: none; } }
.tooltip-wrap { position: relative; }

.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px; text-align: center; color: var(--text-muted);
}

/* ===================== RTL (Hebrew) ===================== */
/* Code-bearing groups always render LTR so keys/URLs read correctly */
.input-group { direction: ltr; }
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }
[dir="rtl"] .flip-rtl-icon svg { transform: scaleX(-1); }
.ltr { direction: ltr; unicode-bidi: isolate; }
[dir="rtl"] .sidebar { border-right: none; border-left: 1px solid var(--border); }
[dir="rtl"] .tbl thead th { text-align: right; }
[dir="rtl"] .tbl tbody td { text-align: right; }
[dir="rtl"] .c-sep svg { transform: scaleX(-1); }
[dir="rtl"] .toast-wrap { right: auto; left: 22px; align-items: flex-start; }
[dir="rtl"] .toast { animation: toast-in-rtl .28s cubic-bezier(.16,1,.3,1); }
@keyframes toast-in-rtl { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
/* Hebrew WhatsApp preview reads RTL; Latin tokens stay isolated */
[dir="rtl"] .wa-body, [dir="rtl"] .wa-btext, [dir="rtl"] .wa-footer { direction: rtl; text-align: right; }
[dir="rtl"] .wa-bubble { border-radius: 9px 9px 2px 9px; }
[dir="rtl"] .wa-header > svg:first-child { transform: scaleX(-1); }
/* Onboarding exit button to the opposite corner */
[dir="rtl"] .ob-exit { right: auto; left: 24px; }
/* Digits inside Hebrew sentences stay readable */
[dir="rtl"] .stat-value, [dir="rtl"] .ob-done-num { direction: ltr; text-align: right; }

/* ===================== Mobile / responsive ===================== */
/* Scrim sits behind the drawer on mobile; never visible on desktop. */
.sb-scrim { display: none; }

@media (max-width: 860px) {
  /* Single column — the sidebar becomes an off-canvas drawer. */
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0;
    width: var(--sidebar-w); max-width: 82vw; z-index: 220;
    transform: translateX(-100%);
    transition: transform .26s cubic-bezier(.16,1,.3,1);
    box-shadow: var(--sh-lg);
  }
  [dir="rtl"] .sidebar {
    /* base inset-inline-start:0 already pins the drawer to the RIGHT in RTL
       (inline-start = right). Only flip the hide direction: push off-screen right. */
    transform: translateX(100%);
    border-right: none; border-left: 1px solid var(--border);
  }
  .app.nav-open .sidebar { transform: none; }
  .sb-scrim {
    display: block; position: fixed; inset: 0; z-index: 210;
    background: rgba(8,10,16,0.5); animation: fade .2s ease;
  }

  .topbar-burger { display: grid; }
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar .search { display: none; }      /* command palette (⌘K / burger) still reachable */

  .content-inner { padding: 20px 16px 56px; }
  .content-inner--flush { padding: 0; }
  .page-title { font-size: 19px; }
  .page-head.spread { flex-wrap: wrap; }

  .stat-grid { grid-template-columns: 1fr 1fr; }

  /* Wide tables scroll horizontally instead of overflowing the viewport. */
  .tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tbl-wrap .tbl { min-width: 600px; }

  /* Toasts span the width on small screens. */
  .toast { width: auto; max-width: calc(100vw - 32px); }
  .toast-wrap { left: 16px; right: 16px; align-items: stretch; }
  [dir="rtl"] .toast-wrap { left: 16px; right: 16px; }
}

@media (max-width: 560px) {
  .stat-grid { grid-template-columns: 1fr; }
  .topbar .env-toggle { display: none; }  /* Live/Test still in the command palette */
  .crumbs .c-muted, .crumbs .c-sep { display: none; }  /* keep only the current page */
  .content-inner { padding: 16px 12px 48px; }
}
