/* ============================================================
   نبالي كارز — لوحة الإدارة
   Design tokens extracted verbatim from the approved prototype
   (15 admin screens, RTL desktop console).
   أحمر نبالي #C81E2A · قرمزي #8E1220 · أسود #0B0B0C
   Cairo + IBM Plex Sans Arabic + IBM Plex Mono
   ============================================================ */

@font-face { font-family: 'Cairo'; font-weight: 400; src: url('fonts/Cairo-400.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Cairo'; font-weight: 600; src: url('fonts/Cairo-600.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Cairo'; font-weight: 700; src: url('fonts/Cairo-700.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Cairo'; font-weight: 900; src: url('fonts/Cairo-900.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'IBM Plex Sans Arabic'; font-weight: 400; src: url('fonts/IBMPlexSansArabic-400.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'IBM Plex Sans Arabic'; font-weight: 600; src: url('fonts/IBMPlexSansArabic-600.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'IBM Plex Sans Arabic'; font-weight: 700; src: url('fonts/IBMPlexSansArabic-700.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 400; src: url('fonts/IBMPlexMono-400.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 600; src: url('fonts/IBMPlexMono-600.ttf') format('truetype'); font-display: swap; }

:root {
  /* Brand */
  --brand: #C81E2A;
  --brand-dark: #8E1220;
  --brand-deep: #6d0d18;
  --ink: #0B0B0C;

  /* Light surfaces */
  --canvas: #f6f4f4;            /* admin content area */
  --card: #ffffff;
  --surface-subtle: #fffafa;
  --row-divider: #f2eded;

  /* Dark surfaces (sidebar, login) */
  --dark-canvas: #0c0c0e;
  --dark-surface: #0b0b0c;
  --dark-card: #17171a;

  /* Borders */
  --hairline: #ece7e8;
  --border-card: #e8e3e4;
  --border-control: #e6e0e1;
  --border-dark: #232326;
  --border-dark-control: #2b2b2f;

  /* Text on light */
  --text: #17171a;
  --text-strong: #3b3839;
  --text-neutral: #4b4849;
  --text-secondary: #8b8688;
  --text-tertiary: #a5a0a2;

  /* Text on dark */
  --dark-text: #ffffff;
  --dark-text-secondary: #989395;
  --dark-text-muted: #b3aeb0;
  --dark-text-caption: #7e797b;

  /* Semantic badge pairs */
  --success-bg: #f0f5f1; --success-fg: #2f6b45;
  --warning-bg: #fdf3e7; --warning-fg: #8a5a1b;
  --danger-bg: #f7eff0;  --danger-fg: #8E1220;
  --danger-bright-bg: #fff2f3;
  --neutral-bg: #eef0ef; --neutral-fg: #4b4849;
  --brand-lite-bg: #f2e3e5;

  /* Type */
  --font-display: 'Cairo', sans-serif;
  --font-body: 'IBM Plex Sans Arabic', 'Cairo', sans-serif;
  --font-mono: 'IBM Plex Mono', 'IBM Plex Sans Arabic', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { direction: rtl; }

body {
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  color: var(--text);
  background: var(--canvas);
  min-height: 100vh;
}

/* ── Shell ─────────────────────────────────────────────── */
.admin-shell { display: flex; min-height: 100dvh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--dark-surface);
  color: var(--dark-text);
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100dvh;
}

.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 8px 20px;
  border-bottom: 1px solid var(--border-dark);
  margin-bottom: 14px;
}
.sidebar .brand img { width: 38px; height: 38px; object-fit: contain; }
.sidebar .brand .name { font-family: var(--font-display); font-weight: 700; font-size: 15px; }
.sidebar .brand .sub { font-size: 10px; color: var(--dark-text-caption); }

.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; scrollbar-width: thin; min-height: 0; }
.sidebar nav .section-label { margin-top: 10px; padding: 8px 12px 4px; font-size: 11px; font-weight: 700; color: var(--dark-text-caption); } /* no letter-spacing: it breaks Arabic joins */
.sidebar nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--dark-text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}
.sidebar nav a .icon { width: 18px; text-align: center; }
.sidebar nav a.active { background: var(--brand); color: #fff; }
.sidebar nav a:hover:not(.active) { background: var(--dark-card); color: var(--dark-text); }
.sidebar nav a .count {
  margin-inline-start: auto;
  background: var(--brand);
  color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
}
.sidebar nav a.active .count { background: rgba(255, 255, 255, 0.22); }

.sidebar .user {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 8px 0;
  border-top: 1px solid var(--border-dark);
}
.sidebar .user .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand);
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; color: #fff;
}
.sidebar .user .name { font-size: 12px; font-weight: 600; color: var(--dark-text); }
.sidebar .user .role { font-size: 10px; color: var(--dark-text-caption); }
.sidebar .user .me {
  display: flex; align-items: center; gap: 10px;
  flex: 1; min-width: 0;
  text-decoration: none;
  padding: 5px; margin: -5px;
  border-radius: 10px;
}
.sidebar .user .me:hover, .sidebar .user .me.active { background: var(--dark-card); }
.sidebar .user .who { min-width: 0; }
.sidebar .user .who .name, .sidebar .user .who .role { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .user .logout { flex-shrink: 0; }
.sidebar .user .logout button {
  width: 30px; height: 30px; border-radius: 8px;
  background: none; border: 1px solid var(--border-dark);
  color: var(--dark-text-muted); line-height: 0;
  display: grid; place-items: center;
  cursor: pointer;
}
.sidebar .user .logout button:hover { background: var(--brand); border-color: var(--brand); color: #fff; }

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

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border-card);
  padding: 0 26px;
  height: 62px;
  display: flex; align-items: center; gap: 14px;
}
.topbar h1 { font-family: var(--font-display); font-weight: 700; font-size: 17px; }
.topbar .meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); }
.topbar .actions { margin-inline-start: auto; display: flex; gap: 8px; }
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border: 1px solid var(--border-control); border-radius: 8px;
  font-size: 12px; font-weight: 600; color: var(--text-secondary); text-decoration: none;
}
.back-link:hover { color: var(--brand); border-color: var(--brand); }
.back-link svg { width: 15px; height: 15px; }
/* Phone numbers, e-mails, IBANs and date-times read left to right inside
   Arabic text: «+962…» kept its plus sign and «2026/09/30 14:05» its order. */
.latin { direction: ltr; unicode-bidi: isolate; }

.content { padding: 22px 26px; display: flex; flex-direction: column; gap: 16px; }

.admin-footer {
  margin-top: auto;
  padding: 14px 26px;
  border-top: 1px solid var(--hairline);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 6px 16px;
  font-size: 11px; color: var(--text-secondary);
}
.admin-footer a { color: var(--brand); font-weight: 600; text-decoration: none; }
.admin-footer a:hover { color: var(--brand-dark); text-decoration: underline; }

/* ── Cards & stat tiles ────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  padding: 18px;
}
.card > h2 { font-family: var(--font-display); font-weight: 700; font-size: 15px; margin-bottom: 14px; }

.stat-row { display: grid; grid-template-columns: var(--cols, repeat(4, 1fr)); gap: 14px; }
.stat-tile { background: var(--card); border: 1px solid var(--border-card); border-radius: 16px; padding: 16px 18px; }
.stat-tile .label { font-size: 11px; color: var(--text-secondary); }
.stat-tile .value { font-family: var(--font-display); font-weight: 900; font-size: 24px; margin-top: 3px; }
.stat-tile .value small { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.stat-tile .delta { font-size: 11px; margin-top: 4px; }
.stat-tile .delta.up { color: var(--success-fg); }
.stat-tile .delta.down { color: var(--danger-fg); }
.stat-tile.inverse { background: var(--ink); border-color: var(--ink); color: #fff; }
.stat-tile.inverse .label { color: var(--dark-text-secondary); }

/* ── Tables (CSS grid, per the prototype) ──────────────── */
.table { display: flex; flex-direction: column; }
/* Column templates come from each view via --cols (style="--cols: ...") so
   media queries below can reflow tables — never set them as inline styles. */
.table .thead, .table .row { display: grid; grid-template-columns: var(--cols, 1fr); gap: 12px; align-items: center; padding: 12px 18px; }
.table .thead {
  background: #faf8f8;
  border-bottom: 1px solid var(--border-card);
  font-size: 11px; font-weight: 600; color: var(--text-secondary);
  border-radius: 12px 12px 0 0;
}
.table .row { border-bottom: 1px solid var(--row-divider); font-size: 12px; }
.table .row:last-child { border-bottom: none; }
.table .row .mono, .mono { font-family: var(--font-mono); font-size: 11px; }
.table .row .sub { font-size: 10px; color: var(--text-secondary); }
.table .thumb { width: 62px; height: 44px; border-radius: 8px; object-fit: cover; }

/* ── Badges ────────────────────────────────────────────── */
.badge {
  display: inline-block;
  border-radius: 999px;
  font-size: 10px; font-weight: 700;
  padding: 4px 8px;
  justify-self: start;
  white-space: nowrap;
}
.badge.success { background: var(--success-bg); color: var(--success-fg); }
.badge.warning { background: var(--warning-bg); color: var(--warning-fg); }
.badge.danger { background: var(--danger-bg); color: var(--danger-fg); }
.badge.danger-bright { background: var(--danger-bright-bg); color: var(--danger-fg); }
.badge.neutral { background: var(--neutral-bg); color: var(--neutral-fg); }
.badge.brand-lite { background: var(--brand-lite-bg); color: var(--brand-dark); }
.badge.accent { background: var(--brand); color: #fff; }
.badge.ink { background: var(--ink); color: #fff; }

/* ── Buttons & controls ────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-body);
  font-size: 13px; font-weight: 700;
  border: none; cursor: pointer; text-decoration: none;
  border-radius: 12px;
  padding: 9px 16px;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.secondary { background: var(--card); color: var(--text-strong); border: 1px solid var(--border-control); }
.btn.ink { background: var(--ink); color: #fff; }
.btn.ink:hover { background: #000; }
.btn.sm { font-size: 11px; padding: 6px 11px; border-radius: 999px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12px; font-weight: 600;
  background: var(--card); color: var(--text-strong);
  border: 1px solid var(--border-control);
  text-decoration: none; cursor: pointer;
}
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .n { font-size: 10px; color: inherit; opacity: 0.7; }

/* صور السيارة — شبكة بطاقات، الرئيسية بإطار. */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.photo { position: relative; border: 1px solid var(--border-card); border-radius: 10px; overflow: hidden; background: var(--neutral-bg); }
.photo.primary { border: 2px solid var(--brand); }
.photo img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.photo-badge { position: absolute; top: 8px; inset-inline-start: 8px; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; }
.photo-actions form { display: inline; }
.danger-text { color: var(--danger-fg, #b42318); }
.car-flags { display: inline-flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.star-btn { background: none; border: none; cursor: pointer; font-size: 16px; line-height: 1; color: var(--text-secondary); padding: 2px 4px; }
.star-btn.on { color: #d4a017; }

/* صف «عنوان: قيمة» — كان مكرراً داخل أربع صفحات. */
.kv { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--hairline); font-size: 12px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--text-secondary); font-size: 11px; }
.kv .v { font-weight: 600; text-align: end; }

/* قيد ملغى — يبقى ظاهراً ولا يُحتسب. */
.row.voided { opacity: .6; }
.row.voided .amount { text-decoration: line-through; }

/* الماركات والموديلات */
.brand-row { border-bottom: 1px solid var(--row-divider); }
.brand-row:last-child { border-bottom: none; }
.brand-row > summary { display: flex; align-items: center; gap: 10px; padding: 14px 18px; cursor: pointer; list-style: none; }
.brand-row > summary::-webkit-details-marker { display: none; }
.brand-row[open] > summary { background: var(--neutral-bg); }
.brand-body { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; padding: 14px 18px 18px; }
.model-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--row-divider); }
.inline-form { display: flex; gap: 6px; align-items: center; }
.inline-form input { max-width: 240px; }
@media (max-width: 760px) { .brand-body { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 11px; color: var(--text-secondary); }
.field input, .field select, .field textarea {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border-control);
  border-radius: 12px;
  padding: 11px 13px;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); }

.search {
  display: flex; align-items: center; gap: 9px;
  background: var(--card);
  border: 1px solid var(--border-control);
  border-radius: 12px;
  padding: 9px 13px;
  color: var(--text-tertiary);
  min-width: 260px;
}
.search input { border: none; outline: none; flex: 1; font-family: var(--font-body); font-size: 12px; }

/* ── Progress & misc ───────────────────────────────────── */
.progress { height: 8px; border-radius: 999px; background: var(--hairline); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--brand); }

.pipeline { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; align-items: start; }
.pipeline .col { background: #faf8f8; border: 1px solid var(--border-card); border-radius: 14px; padding: 12px; }
.pipeline .col > h3 { font-size: 12px; font-weight: 700; display: flex; justify-content: space-between; margin-bottom: 10px; }
.pipeline .lead { background: var(--card); border: 1px solid var(--hairline); border-radius: 11px; padding: 10px 12px; margin-bottom: 8px; }
.pipeline .lead .who { font-size: 12px; font-weight: 700; }
.pipeline .lead .what { font-size: 10px; color: var(--text-secondary); margin-top: 2px; }
.pipeline .lead .when { font-family: var(--font-mono); font-size: 10px; color: var(--text-tertiary); margin-top: 5px; }

.bars { display: flex; align-items: flex-end; gap: 10px; height: 160px; }
.bars .group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bars .pair { display: flex; gap: 4px; align-items: flex-end; height: 130px; }
.bars .bar { width: 14px; border-radius: 5px 5px 0 0; background: var(--brand); }
.bars .bar.alt { background: var(--ink); opacity: 0.85; }
.bars .m { font-size: 10px; color: var(--text-secondary); }

.two-col { display: grid; grid-template-columns: var(--cols, 1.55fr 1fr); gap: 16px; align-items: start; }
.three-col { display: grid; grid-template-columns: var(--cols, repeat(3, 1fr)); gap: 14px; }
/* Grid items default to min-width:auto, which lets a nested table's
   min-content blow the track wider than the viewport — allow shrinking so
   the .table scroll container can engage instead. */
.two-col > *, .three-col > *, .stat-row > * { min-width: 0; }

.notice {
  background: #fff5f6;
  border: 1px solid #f3dde0;
  color: #6b5a5c;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 12px;
}

.empty { text-align: center; color: var(--text-tertiary); padding: 34px 0; font-size: 12px; }

/* ── Login (screen 36) ─────────────────────────────────── */
body.login-page {
  background: var(--dark-canvas);
  display: grid; place-items: center;
}
.login-card {
  width: min(420px, calc(100vw - 32px));
  background: var(--dark-card);
  border: 1px solid var(--border-dark-control);
  border-radius: 16px;
  padding: 30px;
  color: var(--dark-text);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
}
.login-card h1 { font-family: var(--font-display); font-weight: 900; font-size: 22px; }
.login-card .sub { color: var(--dark-text-secondary); font-size: 12px; margin: 6px 0 22px; line-height: 1.8; }
.login-card .field label { color: var(--dark-text-secondary); }
.login-card .field input {
  background: var(--dark-surface);
  border-color: var(--border-dark-control);
  color: var(--dark-text);
}
.login-card .fine { color: #6f6b6d; font-size: 10px; margin-top: 16px; text-align: center; }

/* ── Shared helpers (promoted from per-view inline styles) ── */
.btn.block { width: 100%; justify-content: center; }

/* Flush card: table sits edge-to-edge; thead radius matches the card
   (only when the table actually starts the card). */
.card.flush { padding: 0; }
.card.flush > .table:first-child .thead, .card.flush > form:first-child > .table .thead { border-radius: 16px 16px 0 0; }

/* Small bare controls used outside .field (e.g. inline table forms) */
select.sm, input.sm {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border-control);
  border-radius: 10px;
  padding: 7px 10px;
  outline: none;
}
select.sm:focus, input.sm:focus { border-color: var(--brand); }

/* Inline payment popover (collections) — opens as a floating panel instead
   of expanding inside a narrow grid track. */
.pay-inline { position: relative; }
.pay-inline > summary { list-style: none; cursor: pointer; }
.pay-inline > summary::-webkit-details-marker { display: none; }
.pay-inline form {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-end: 0;
  z-index: 40;
  width: 300px;
  max-width: 90vw;
  max-height: 70vh;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border-card);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.14);
}
.pay-inline form select, .pay-inline form input, .pay-inline form textarea { min-width: 0; }
.pay-inline form .field { width: 100%; }

/* Mobile nav controls (hidden on desktop) */
.nav-toggle {
  display: none;
  align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border: 1px solid var(--border-control);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
  flex-shrink: 0;
}
.nav-overlay { display: none; }

/* Pager inside a flush card needs its own inset (the card has no padding). */
.card.flush .pager { padding: 0 18px 14px; }

/* ============================================================
   Responsive layer — الشاشات الصغيرة
   Tables reflow via --cols/--tmin custom properties set per view.
   ============================================================ */
@media (max-width: 1280px) {
  .pipeline { display: flex; overflow-x: auto; padding-bottom: 8px; -webkit-overflow-scrolling: touch; }
  .pipeline .col { flex: 0 0 236px; min-width: 236px; }
}

@media (max-width: 1150px) {
  /* Wide data tables scroll horizontally while the sidebar is still docked;
     headers stay aligned with rows (equal min-width on both). */
  .table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table .thead, .table .row { min-width: var(--tmin, 640px); }

  /* Once tables scroll, an absolutely-positioned popover would be clipped
     by the scroll container — switch .pay-inline to a fixed bottom sheet.
     z-index sits above the nav overlay (50) but below the open drawer (60). */
  .pay-inline form {
    position: fixed;
    top: auto;
    inset-inline: 12px;
    bottom: 12px;
    width: auto;
    max-width: none;
    max-height: 60dvh;
    z-index: 55;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.25);
  }
}

@media (max-width: 1100px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .two-col, .three-col { grid-template-columns: 1fr; }
  .bars { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

@media (max-width: 920px) {
  /* Off-canvas sidebar drawer (RTL: slides in from the right) */
  .sidebar {
    position: fixed;
    top: 0; bottom: 0;
    inset-inline-start: 0;
    height: 100dvh;
    width: min(78vw, 300px);
    z-index: 60;
    transform: translateX(100%);
    visibility: hidden; /* keep closed drawer out of tab order / readers */
    transition: transform 0.25s ease, visibility 0.25s;
  }
  body.nav-open .sidebar {
    transform: translateX(0);
    visibility: visible;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.35);
  }
  body.nav-open { overflow: hidden; } /* lock page scroll behind the drawer */
  .nav-toggle { display: inline-flex; }
  .nav-overlay {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s;
    z-index: 50;
  }
  body.nav-open .nav-overlay { opacity: 1; pointer-events: auto; }

  .topbar {
    flex-wrap: wrap;
    height: auto;
    min-height: 62px;
    padding: 10px 16px;
    row-gap: 8px;
  }
  .topbar h1 { font-size: 15px; }
  .topbar .actions { flex-wrap: wrap; row-gap: 8px; }
  .search { min-width: 0; flex: 1 1 200px; }

  .content { padding: 14px; gap: 13px; }
}

@media (max-width: 560px) {
  .content { padding: 12px 10px; }
  .card { padding: 14px; border-radius: 14px; }
  .card.flush { padding: 0; }
  .card.flush > .table:first-child .thead { border-radius: 14px 14px 0 0; }
  .stat-row { gap: 10px; }
  .stat-tile { padding: 13px 14px; }
  .stat-tile .value { font-size: 20px; }
  .three-col { gap: 10px; }
  .topbar .meta { display: none; }
  .login-card { padding: 24px 20px; }
  .admin-footer { justify-content: center; text-align: center; padding: 12px 10px; }
}

/* ── Print: drop the nav chrome and credit footer (PDF exports use pdf._layout) ── */
@media print {
  .sidebar, .admin-footer, .nav-toggle, .nav-overlay, .topbar .actions { display: none !important; }
  .admin-shell { display: block; }
  .content { padding: 0; }
}

/* ── Result messages (partials/flash) ─────────────────────────────────────
   One place for every screen: success, warning and failure no longer look
   the same. */
.flash-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.flash-stack:empty { display: none; }
.notice.ok { background: #effaf3; border-color: #cdebd8; color: #1f6b3a; }
.notice.warn { background: #fff8eb; border-color: #f4dfb3; color: #7a5a12; }
.notice.error { background: #fdf0f1; border-color: #e7b9be; color: var(--danger-fg, #a3202c); }
details:target, details.card:target { outline: none; }

/* ── Sidebar groups (App\Support\AdminNav) ─────────────────────────────── */
.sidebar nav details.nav-group { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav details.nav-group > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
  border-radius: 8px;
}
.sidebar nav details.nav-group > summary::-webkit-details-marker { display: none; }
.sidebar nav details.nav-group > summary::after { content: '‹'; font-size: 13px; transition: transform .15s; }
.sidebar nav details.nav-group[open] > summary::after { transform: rotate(-90deg); }
.sidebar nav details.nav-group > summary:hover { color: var(--dark-text); }
.sidebar nav details.nav-group > a { margin-inline-start: 2px; }
.sidebar nav a .icon { display: inline-flex; align-items: center; justify-content: center; }
.sidebar nav a .icon svg { display: block; }
/* RED = waiting for your action; AMBER = a deadline counter. */
.sidebar nav a .count.amber { background: #b7791f; color: #fff; }

/* ── A group heading's count: the same pill as a link's. It had no rule of
   its own, so the red/amber class on the heading did nothing. ─────────── */
.sidebar nav details.nav-group > summary .count {
  margin-inline-start: auto; margin-inline-end: 6px;
  background: var(--brand); color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 999px;
}
.sidebar nav details.nav-group > summary .count.amber { background: #b7791f; }

/* An identifier (partials <x-id>) keeps the size of the heading it sits in. */
h1 .mono, h2 .mono, h3 .mono { font-size: inherit; }

/* ── The search box on every screen (admin.search) ─────────────────────── */
.topbar-search { min-width: 0; flex: 0 1 250px; padding: 7px 11px; }
.topbar-search svg { flex-shrink: 0; width: 15px; height: 15px; }
.topbar-search input { width: 100%; min-width: 0; background: none; }
@media (max-width: 920px) {
  .topbar-search { flex: 1 1 100%; order: 10; }
}
