/*
 * Legal OS — design system.
 *
 * Written entirely in CSS logical properties (margin-inline-start, not margin-left).
 * RTL is a property of the `dir` attribute, not a second stylesheet: an Arabic
 * interface that drifts from the French one is the failure this construction avoids.
 *
 * Palette sampled directly from the brand mark: navy #052349, gold #b59150.
 * No CDN, no icon font, no external font file — inline SVG icons and the system
 * font stack, in keeping with Blueprint §3.3.
 *
 * Ing. Mohamed Lemine Khlil — Matter IT Mauritanie
 */

:root {
  /* ---- Brand: sampled from the Legal OS mark ---- */
  --navy-950: #02121f;
  --navy-900: #052349;   /* exact brand navy */
  --navy-800: #0b2f57;
  --navy-700: #123c69;
  --navy-600: #1a4c82;
  --navy-500: #275f9c;
  --navy-100: #e9eff7;
  --navy-50:  #f4f7fb;

  --gold-800: #6e5527;
  --gold-700: #8a6b32;   /* AA-safe gold-on-white for text */
  --gold-600: #a17c3f;
  --gold-500: #b59150;   /* exact brand gold */
  --gold-300: #d4bb8c;
  --gold-100: #f6efe0;
  --gold-50:  #fbf7ef;

  /* ---- Neutrals ---- */
  --ink:        #13161d;
  --ink-soft:   #565c68;
  --ink-faint:  #8992a1;
  --line:       #dde2ea;
  --line-soft:  #eceff4;
  --bg:         #f5f6f9;
  --surface:    #ffffff;
  --overlay:    rgba(9, 17, 33, .48);

  /* ---- Semantic: red reserved for FATAL/danger, per brief §7 & §16 ---- */
  --accent:      var(--navy-800);
  --accent-soft: var(--navy-100);
  --danger:      #a8271f;
  --danger-soft: #fdeceb;
  --warn:        #92600a;
  --warn-soft:   #fdf2df;
  --ok:          #1a6b47;
  --ok-soft:     #e7f5ee;
  --fatal:       #7a1712;
  --fatal-soft:  #f8dedc;

  /* ---- Scale ---- */
  --radius-sm: 5px;
  --radius: 8px;
  --radius-lg: 12px;
  --gap: 16px;
  --shadow-sm: 0 1px 2px rgba(5, 20, 45, .06);
  --shadow: 0 2px 10px rgba(5, 20, 45, .07), 0 0 0 1px rgba(5, 20, 45, .03);
  --shadow-lg: 0 16px 40px rgba(5, 20, 45, .16), 0 0 0 1px rgba(5, 20, 45, .04);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-ar: "Segoe UI", Tahoma, "Geeza Pro", "Arabic Typesetting", sans-serif;
  --font-serif: Georgia, "Iowan Old Style", "Times New Roman", serif; /* brand wordmark + page titles, LTR only */

  --sidebar-w: 236px;
  --topbar-h: 56px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

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

[dir="rtl"] body, body[dir="rtl"] { font-family: var(--font-ar); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--gold-600);
  outline-offset: 2px;
  border-radius: 3px;
}

h1, h2, h3, h4 { margin: 0 0 8px; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 21px; }
h2 { font-size: 16.5px; }
h3 { font-size: 14.5px; }
p { margin: 0 0 10px; }

/* ---- Skip link ---- */
.skip {
  position: absolute; inset-inline-start: -9999px; top: 0; z-index: 200;
  background: var(--navy-900); color: #fff; padding: 10px 16px; border-radius: 0 0 6px 6px;
}
.skip:focus { inset-inline-start: 0; }

/* ==================================================================
   Shell, topbar, sidebar
   ================================================================== */
.shell { display: flex; min-height: 100vh; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  height: var(--topbar-h);
  padding-inline: 18px;
  background: var(--surface);
  border-block-end: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
  flex-wrap: wrap;
}

.brand {
  display: flex; align-items: center; gap: 9px;
  color: var(--navy-900); white-space: nowrap; flex: 0 0 auto;
}
.brand img { display: block; height: 26px; width: auto; }
.brand .word {
  font-family: var(--font-serif); direction: ltr; unicode-bidi: isolate;
  font-size: 16.5px; letter-spacing: .05em; font-weight: 600; color: var(--navy-900);
}
.brand .word .os { color: var(--gold-600); }

.omnibar { flex: 1 1 260px; min-width: 160px; max-width: 480px; position: relative; }
.omnibar input {
  width: 100%; padding: 8px 12px 8px 34px; font-size: 13.5px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg); color: inherit; font-family: inherit;
  transition: background-color .12s, border-color .12s;
}
[dir="rtl"] .omnibar input { padding: 8px 34px 8px 12px; }
.omnibar::before {
  content: ""; position: absolute; inset-inline-start: 11px; top: 50%;
  width: 14px; height: 14px; margin-block-start: -7px; pointer-events: none;
  background: no-repeat center / contain;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238992a1' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
}
.omnibar input:focus { outline: 2px solid var(--gold-600); outline-offset: 1px; background: var(--surface); }

.topbar-actions { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; flex: 0 0 auto; }

.layout { display: flex; flex: 1; align-items: flex-start; }

.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  padding: 14px 10px 24px;
  border-inline-end: 1px solid var(--line);
  background: var(--surface);
  min-height: calc(100vh - var(--topbar-h));
  position: sticky; top: var(--topbar-h);
  align-self: flex-start;
  overflow-y: auto; max-height: calc(100vh - var(--topbar-h));
}
.sidebar nav { display: flex; flex-direction: column; gap: 1px; }
.sidebar a {
  padding: 7px 11px; border-radius: var(--radius-sm);
  color: var(--ink-soft); font-size: 13.5px; font-weight: 500;
  display: flex; align-items: center; gap: 10px;
}
.sidebar a svg { flex: 0 0 auto; width: 17px; height: 17px; opacity: .78; }
.sidebar a:hover { background: var(--bg); text-decoration: none; color: var(--ink); }
.sidebar a.active {
  background: var(--accent-soft); color: var(--accent); font-weight: 650;
  box-shadow: inset 2px 0 0 var(--accent);
}
[dir="rtl"] .sidebar a.active { box-shadow: inset -2px 0 0 var(--accent); }
.sidebar a.active svg { opacity: 1; }
.sidebar .group {
  margin-block-start: 16px; margin-block-end: 3px; font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em; color: var(--ink-faint); padding-inline: 11px;
}
.sidebar .group:first-child { margin-block-start: 4px; }

.main { flex: 1; padding: 22px 26px 64px; min-width: 0; }
.page-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-block-end: 18px; }
.page-head h1 { margin: 0; font-family: var(--font-serif); }
[dir="rtl"] .page-head h1 { font-family: var(--font-ar); }
.page-head .actions { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.subtitle { color: var(--ink-soft); font-size: 13.5px; margin: 3px 0 0; }

/* ==================================================================
   Icons — inline SVG, no icon font. Directional glyphs mirror in RTL
   via [dir="rtl"] .icon-dir; symmetric ones (search, gear, check…)
   never do.
   ================================================================== */
.icon { display: inline-block; width: 16px; height: 16px; vertical-align: -3px; flex: 0 0 auto; }
[dir="rtl"] .icon-dir { transform: scaleX(-1); }
/* An icon directly preceding text needs breathing room; flex containers (buttons,
   badges) already set their own gap, so this only targets plain headings/labels. */
h1 > .icon:first-child, h2 > .icon:first-child, h3 > .icon:first-child,
label > .icon:first-child, .empty h3 > .icon:first-child {
  margin-inline-end: 7px;
}

/* ==================================================================
   Cards
   ================================================================== */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 18px; margin-block-end: var(--gap);
  box-shadow: var(--shadow-sm);
}
.card > h2, .card > h3 { margin-block-start: 0; }
.card-head { display: flex; align-items: center; gap: 10px; margin-block-end: 14px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .actions { margin-inline-start: auto; display: flex; gap: 8px; }

.grid { display: grid; gap: var(--gap); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* ==================================================================
   Tables — Stripe-inspired: tabular numerals, quiet borders, strict
   end-alignment for amounts.
   ================================================================== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td {
  padding: 10px 11px; text-align: start;
  border-block-end: 1px solid var(--line-soft); vertical-align: middle;
}
table.data th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .045em;
  color: var(--ink-faint); font-weight: 650; white-space: nowrap;
  border-block-end: 1px solid var(--line);
}
table.data tbody tr { transition: background-color .1s; }
table.data tbody tr:hover { background: var(--navy-50); }
table.data td.num, table.data th.num {
  text-align: end; white-space: nowrap;
  font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1;
}
table.data td.tight { white-space: nowrap; }
table.data tr.row-link { cursor: pointer; }

/* ==================================================================
   Badges — every status carries an icon or shape cue, never colour
   alone (WCAG 1.4.1). Tone classes shared across badges/flashes/banners.
   ================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 650; white-space: nowrap;
  background: var(--line-soft); color: var(--ink-soft);
  border: 1px solid transparent;
}
.badge .icon { width: 11px; height: 11px; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.gold { background: var(--gold-100); color: var(--gold-800); }
.badge.fatal {
  background: var(--fatal); color: #fff;
  box-shadow: 0 0 0 3px var(--fatal-soft);
}

/* ==================================================================
   Buttons
   ================================================================== */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 8px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 13.5px; font-family: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: background-color .12s, border-color .12s, box-shadow .12s, transform .05s;
}
.btn:hover { background: var(--bg); text-decoration: none; border-color: #cdd3dd; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(.9); }
.btn.gold {
  background: var(--gold-500); border-color: var(--gold-500); color: #26190a;
}
.btn.gold:hover { background: var(--gold-600); border-color: var(--gold-600); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { background: #8e211a; border-color: #8e211a; }
.btn.small { padding: 4px 10px; font-size: 12.5px; border-radius: 6px; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 2px 4px; font-weight: 600; }
.btn.link:hover { background: none; text-decoration: underline; }
.btn.icon-only { padding: 7px; width: 32px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .icon { width: 15px; height: 15px; }

/* ==================================================================
   Forms
   ================================================================== */
.field { margin-block-end: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 650; margin-block-end: 5px; color: var(--ink-soft); }
.field .hint { font-size: 12px; color: var(--ink-faint); margin-block-start: 4px; }
.field .err { font-size: 12px; color: var(--danger); margin-block-start: 4px; font-weight: 600; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="number"], input[type="search"], input[type="tel"], select, textarea {
  width: 100%; padding: 9px 11px; font-size: 13.5px; font-family: inherit;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: inherit;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
input[aria-invalid="true"]:focus, textarea[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--danger-soft); }
textarea { min-height: 84px; resize: vertical; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > .field { flex: 1 1 220px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.check input { width: auto; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px; margin-block-end: 14px; }
legend { font-size: 12.5px; font-weight: 650; padding-inline: 6px; color: var(--ink-soft); }

/*
 * Codes, references and identifiers stay LTR whatever the interface direction
 * (ADR-024, brief §24-25). This is the screen-side counterpart of Text::isolateLtr().
 */
.ltr, code, .ref, input.ltr, .mono {
  direction: ltr; unicode-bidi: isolate; text-align: start;
  font-variant-numeric: tabular-nums;
}
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* ==================================================================
   Flash, banners, callouts
   ================================================================== */
.flash {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 11px 14px; border-radius: var(--radius); margin-block-end: 12px; font-size: 13.5px;
  border-inline-start: 3px solid;
}
.flash .icon { flex: 0 0 auto; margin-block-start: 1px; }
.flash.success { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.flash.error { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.flash.info { background: var(--navy-50); border-color: var(--navy-700); color: var(--navy-800); }
.flash.warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }

.banner {
  padding: 8px 18px; font-size: 12.5px; text-align: center; font-weight: 600;
  background: var(--warn-soft); color: var(--warn); border-block-end: 1px solid #f0dcb4;
}
.banner.danger { background: var(--danger-soft); color: var(--danger); border-block-end-color: #f3cbc8; }

.note {
  font-size: 12.5px; color: var(--ink-soft); background: var(--navy-50);
  border: 1px solid var(--navy-100); border-radius: var(--radius); padding: 10px 12px;
}

/* ==================================================================
   Critical banner — Ma Journée top zone (brief §11, §55). Escapes when
   there is nothing critical: it is never a permanent fixture.
   ================================================================== */
.critical-zone {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--fatal); color: #fff;
  border-radius: var(--radius-lg); padding: 13px 18px; margin-block-end: var(--gap);
  box-shadow: var(--shadow);
}
.critical-zone .icon { width: 20px; height: 20px; }
.critical-zone strong { font-size: 14.5px; }
.critical-zone .btn { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.3); color: #fff; }
.critical-zone .btn:hover { background: rgba(255,255,255,.24); }

/* ==================================================================
   Empty states — no module ever shows a bare "no data" (brief §21, §118)
   ================================================================== */
.empty { text-align: center; padding: 38px 20px; color: var(--ink-soft); }
.empty .icon-lg {
  display: block; width: 46px; height: 46px; margin-inline: auto; margin-block-end: 12px;
  color: var(--gold-500); opacity: .55;
}
.empty h3 { color: var(--ink); margin-block-end: 4px; }
.empty p { margin-block-end: 14px; max-width: 40ch; margin-inline: auto; }

/* ==================================================================
   Ma Journée — stat tiles, row items
   ================================================================== */
.stack { display: flex; flex-direction: column; gap: 8px; }
.row-item {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface);
  border-inline-start-width: 3px;
  transition: box-shadow .12s, border-color .12s;
}
a.row-item:hover { box-shadow: var(--shadow-sm); text-decoration: none; border-color: #cdd3dd; }
.row-item .body { flex: 1; min-width: 0; }
.row-item .title { font-weight: 650; font-size: 13.5px; color: var(--ink); }
.row-item .meta { font-size: 12px; color: var(--ink-soft); margin-block-start: 3px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.row-item .side { text-align: end; white-space: nowrap; font-size: 12px; flex: 0 0 auto; }
.row-item.crit-FATAL { border-inline-start-color: var(--fatal); }
.row-item.crit-CRITICAL { border-inline-start-color: var(--danger); }
.row-item.crit-HIGH { border-inline-start-color: var(--warn); }
.row-item.crit-NORMAL { border-inline-start-color: var(--line); }
.row-item.late { background: var(--danger-soft); border-color: #f3cbc8; }

.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.stat .value {
  font-size: 23px; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--navy-900); font-family: var(--font-serif);
}
[dir="rtl"] .stat .value { font-family: var(--font-ar); }
.stat .label { font-size: 12px; color: var(--ink-soft); margin-block-start: 2px; }

.timer-bar {
  display: flex; align-items: center; gap: 11px; flex-wrap: wrap;
  background: var(--navy-900); color: #fff;
  border-radius: var(--radius-lg); padding: 11px 16px; margin-block-end: var(--gap);
  box-shadow: var(--shadow);
}
.timer-bar .badge.accent { background: var(--gold-500); color: #26190a; }
.timer-bar input, .timer-bar select {
  background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.24); color: #fff;
}
.timer-bar input::placeholder { color: rgba(255,255,255,.6); }
.timer-bar .btn { border-color: rgba(255,255,255,.3); }
.timer-bar .btn:not(.primary) { background: rgba(255,255,255,.1); color: #fff; }

/* ==================================================================
   Conflict check — three-tier risk system (brief §14, §78): exact =
   danger, probable = warning, none = reassuring. Colour is never the
   only signal — each tier also carries a label and an icon.
   ================================================================== */
.hit {
  border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 13px 15px;
  margin-block-end: 10px; background: var(--surface); box-shadow: var(--shadow-sm);
}
.hit.tier-EXACT { border-inline-start: 4px solid var(--danger); background: linear-gradient(to var(--start-side, right), var(--danger-soft) 0%, var(--surface) 140px); }
.hit.tier-STRONG { border-inline-start: 4px solid var(--warn); }
.hit.tier-POSSIBLE { border-inline-start: 4px solid var(--line); }
.hit .reasons { font-size: 12.5px; color: var(--ink-soft); margin-block-start: 7px; padding-inline-start: 18px; }
.hit .reasons li { margin-block-end: 3px; }
.verdicts { display: flex; gap: 15px; flex-wrap: wrap; margin-block-start: 9px; font-size: 12.5px; }
.verdicts label { display: inline-flex; align-items: center; gap: 5px; }
.verdicts input { width: auto; }

.conflict-clear {
  display: flex; align-items: center; gap: 10px;
  background: var(--ok-soft); color: var(--ok); border-radius: var(--radius-lg);
  padding: 13px 16px; font-weight: 600; font-size: 13.5px;
}
.conflict-clear .icon { width: 20px; height: 20px; }

/* ==================================================================
   Definition lists
   ================================================================== */
.definition { display: grid; grid-template-columns: minmax(150px, auto) 1fr; gap: 7px 14px; font-size: 13.5px; }
.definition dt { color: var(--ink-soft); font-size: 12px; font-weight: 600; }
.definition dd { margin: 0; }

/* ==================================================================
   Unified timeline (brief §15, §72) — matter/engagement activity feed
   combining notes, documents, tasks, obligations, time, invoices.
   ================================================================== */
.timeline { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.timeline li {
  padding: 9px 0; border-block-end: 1px solid var(--line-soft);
  display: flex; gap: 11px; align-items: flex-start;
}
.timeline li:last-child { border-block-end: 0; }
.timeline .dot {
  flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%;
  background: var(--navy-500); margin-block-start: 5px;
}
.timeline .dot.ev-document { background: var(--gold-500); }
.timeline .dot.ev-invoice, .timeline .dot.ev-payment { background: var(--ok); }
.timeline .dot.ev-obligation { background: var(--danger); }
.timeline .body { flex: 1; min-width: 0; }
.timeline time { color: var(--ink-faint); font-size: 11.5px; white-space: nowrap; direction: ltr; unicode-bidi: isolate; }

/* ==================================================================
   Drawers — slide-in panel for non-blocking creation/edit (brief §20).
   Pure CSS + tiny JS toggle (data-island="drawer"); degrades to an
   anchored in-page section if JS is unavailable, since it is a normal
   element in the document flow, never display:none by default markup.
   ================================================================== */
.drawer-backdrop {
  position: fixed; inset: 0; background: var(--overlay); z-index: 90;
  opacity: 0; pointer-events: none; transition: opacity .16s;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; inset-block: 0; inset-inline-end: 0; width: min(420px, 100vw);
  background: var(--surface); z-index: 91; box-shadow: var(--shadow-lg);
  transform: translateX(var(--drawer-closed-x, 100%)); transition: transform .18s ease-out;
  display: flex; flex-direction: column;
}
[dir="rtl"] .drawer { --drawer-closed-x: -100%; }
.drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex; align-items: center; gap: 10px; padding: 16px 18px;
  border-block-end: 1px solid var(--line); flex: 0 0 auto;
}
.drawer-head h2 { margin: 0; flex: 1; font-size: 15.5px; }
.drawer-body { padding: 18px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 14px 18px; border-block-start: 1px solid var(--line); display: flex; gap: 8px; flex: 0 0 auto; }

/* ==================================================================
   Toasts — non-blocking feedback (brief §22, §122)
   ================================================================== */
.toast-stack {
  position: fixed; bottom: 18px; inset-inline-end: 18px; z-index: 120;
  display: flex; flex-direction: column; gap: 8px; max-width: min(360px, calc(100vw - 24px));
}
.toast {
  display: flex; align-items: flex-start; gap: 9px;
  background: var(--navy-950); color: #fff; padding: 11px 14px; border-radius: var(--radius);
  font-size: 13px; box-shadow: var(--shadow-lg); animation: toast-in .18s ease-out;
}
.toast.ok { background: var(--ok); } .toast.error { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ==================================================================
   Skeletons — perceived performance (brief §29, §139)
   ================================================================== */
.skeleton { position: relative; overflow: hidden; background: var(--line-soft); border-radius: var(--radius-sm); }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.6), transparent);
  animation: skeleton-sweep 1.3s infinite;
}
[dir="rtl"] .skeleton::after { animation-direction: reverse; }
@keyframes skeleton-sweep { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.skeleton-line { height: 12px; margin-block-end: 8px; }
.skeleton-line.w60 { width: 60%; } .skeleton-line.w40 { width: 40%; }

/* ==================================================================
   Login
   ================================================================== */
.centered { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(circle at 30% 20%, var(--navy-50), var(--bg) 60%); }
.panel {
  width: 100%; max-width: 408px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 32px 30px 28px;
  box-shadow: var(--shadow-lg);
}
.panel .brand-lockup { display: flex; flex-direction: column; align-items: center; margin-block-end: 20px; }
.panel .brand-lockup img { height: 64px; width: auto; margin-block-end: 10px; }
.panel .brand-lockup .word {
  font-family: var(--font-serif); direction: ltr; unicode-bidi: isolate;
  font-size: 22px; letter-spacing: .09em; font-weight: 650; color: var(--navy-900);
}
.panel .brand-lockup .word .os { color: var(--gold-600); }
.panel .brand-lockup .tagline { font-size: 11.5px; color: var(--ink-faint); margin-block-start: 3px; letter-spacing: .02em; }
.panel h1 { display: none; } /* the lockup replaces the literal H1 on the login screen */

/* ==================================================================
   Utilities
   ================================================================== */
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; }
.strong { font-weight: 650; }
.end { text-align: end; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mt { margin-block-start: 12px; }
.mb { margin-block-end: 12px; }
.inline-form { display: inline; }
.flex { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.divider { border: 0; border-block-start: 1px solid var(--line-soft); margin: 15px 0; }
.plain-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.plain-list a { display: block; padding: 6px 2px; }
.help-article { max-width: 74ch; line-height: 1.65; }
.help-article p { margin: 0 0 12px; }
.help-article ul { margin: 0 0 12px; padding-inline-start: 22px; }
[dir="rtl"] .help-article ul { padding-inline-start: 22px; }
.help-article li { margin-block-end: 4px; }
.help-hint {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line);
  color: var(--ink-soft); font-size: 12px; margin-inline-start: 6px; vertical-align: middle;
  text-decoration: none;
}
.help-hint:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.onboarding-checklist { margin-block-end: 18px; }
.onboarding-step { display: flex; align-items: center; gap: 8px; }
.onboarding-step .icon { color: var(--ink-faint); }
.onboarding-step.done .icon { color: var(--ok); }
.onboarding-step.done a { color: var(--ink-soft); text-decoration: line-through; }

.app-footer {
  margin-block-start: 32px; padding-block-start: 14px; padding-block-end: 4px;
  border-block-start: 1px solid var(--line-soft);
  text-align: center; font-size: 11px; color: var(--ink-faint);
}
.login-footer {
  text-align: center; font-size: 11px; color: var(--ink-faint); margin-block-start: 18px;
}

/* ==================================================================
   Accent swatches (admin › apparence) — a small, pre-vetted palette,
   never a free colour picker (night-shift §15).
   ================================================================== */
.accent-swatches { display: flex; flex-wrap: wrap; gap: 10px; margin-block-start: 4px; }
.accent-swatch {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.accent-swatch:has(input:checked) { border-color: var(--accent); background: var(--line-soft); }
.accent-swatch input { margin: 0; }
.swatch-dot {
  width: 18px; height: 18px; border-radius: 50%; flex: none;
  border: 1px solid rgba(0,0,0,.12); display: inline-block;
}
.swatch-label { font-size: 13px; }

/* ==================================================================
   Responsive
   ================================================================== */
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; min-height: 0; position: static; max-height: none;
    border-inline-end: 0; border-block-end: 1px solid var(--line);
    padding: 8px;
  }
  .sidebar nav { flex-direction: row; overflow-x: auto; gap: 4px; }
  .sidebar a { white-space: nowrap; }
  .sidebar .group { display: none; }
  .main { padding: 16px 14px 90px; }
  .definition { grid-template-columns: 1fr; gap: 2px 0; }
  .definition dd { margin-block-end: 8px; }
  .page-head .actions { width: 100%; }
  .drawer { width: 100%; }
  table.data.stack-mobile, table.data.stack-mobile thead { display: none; }
  table.data.stack-mobile tbody, table.data.stack-mobile tr, table.data.stack-mobile td { display: block; width: 100%; }
  table.data.stack-mobile tr {
    border: 1px solid var(--line); border-radius: var(--radius); margin-block-end: 10px; padding: 8px 12px;
  }
  table.data.stack-mobile td { border: 0; padding: 4px 0; }
}

@media print {
  .topbar, .sidebar, .actions, .banner, .skip, .toast-stack { display: none !important; }
  .main { padding: 0; }
  .card { border: 0; padding: 0; box-shadow: none; }
  body { background: #fff; }
}
