/* RuleFirm — office app design system (December 2026)
   A law-office look on the bordered admin layout: a deep navy side menu, a pale slate page,
   white cards with a 1px frame, one primary colour, and gold for the few marks that carry rank.
   Colours live only in the token blocks at the top; every rule below uses var(--…).
   Primary colours: navy (default), teal, blue, violet, rose, amber — each light and dark.
   Exceptions (paper previews and the Jordan flag) sit between rf:allow-colour and rf:end markers. */

/* ============================== 1. Tokens ============================== */
:root {
  color-scheme: light;
  /* neutrals */
  --bg: #F5F7FA; --surface: #FFFFFF; --surface-2: #F8FAFC; --surface-3: #EEF2F7; --input-bg: #FFFFFF;
  --ink: #0F1B33; --ink-2: #44526A; --muted: #66748C;
  --line: #DFE5EE; --line-2: #EBEFF5; --line-strong: #C5CEDB;
  --secondary: #5B6B84; --dark: #0C1730; --on-dark: #FFFFFF;
  /* primary */
  --accent: #1E3A8A; --accent-hover: #172F73; --on-accent: #FFFFFF;
  --accent-ink: var(--accent);
  --accent-soft: color-mix(in srgb, var(--accent) 10%, var(--surface));
  --bright: color-mix(in srgb, var(--accent) 70%, var(--surface));
  --hl-soft: var(--accent-soft); --hl-ink: var(--accent);
  /* side menu: dark in the light mode too (semi-dark) */
  --side: #0C1730; --side-ink: #D6DDEC; --side-muted: #8492B0; --side-hover: #17264A; --side-line: #1E2E55;
  --side-on: color-mix(in srgb, var(--accent) 84%, #FFFFFF);
  /* gold: rank marks only (open page, page title rule, main action on navy) */
  --gold: #C8A04E; --gold-ink: #8A5F0C; --gold-soft: color-mix(in srgb, var(--gold) 16%, var(--surface)); --on-gold: #1A1305;
  --hero: linear-gradient(120deg, var(--dark), var(--accent));
  /* text and fills on a primary-coloured panel */
  --menu-1: var(--dark); --menu-2: color-mix(in srgb, var(--dark) 55%, var(--accent)); --menu-3: var(--accent);
  --menu-ink: rgba(255, 255, 255, .88); --menu-muted: rgba(255, 255, 255, .7); --menu-hover: rgba(255, 255, 255, .14); --menu-on: rgba(255, 255, 255, .24);
  --menu-line: rgba(255, 255, 255, .22); --menu-ring: rgba(255, 255, 255, .03); --menu-white: #FFFFFF;
  /* status */
  --green: #15803D; --red: #DC2626; --red-hover: #B91C1C; --amber: #B45309; --blue: #0369A1; --teal: #0F766E;
  --green-soft: color-mix(in srgb, var(--green) 11%, var(--surface));
  --red-soft: color-mix(in srgb, var(--red) 11%, var(--surface));
  --amber-soft: color-mix(in srgb, var(--amber) 11%, var(--surface));
  --blue-soft: color-mix(in srgb, var(--blue) 11%, var(--surface));
  --teal-soft: color-mix(in srgb, var(--teal) 11%, var(--surface));
  --gray-soft: color-mix(in srgb, var(--secondary) 12%, var(--surface)); --gray-ink: var(--secondary);
  /* paper (print previews stay white) */
  --paper: #FFFFFF; --paper-ink: #1A1A1A; --paper-desk: #EEF2F7;
  /* depth: cards carry a 1px frame; shadows are for things that float or lift */
  --shadow-card: 0 0 0 1px var(--line);
  --shadow-soft: 0 1px 3px 0 rgba(15, 27, 51, .1), 0 1px 2px -1px rgba(15, 27, 51, .08);
  --shadow-menu: 0 2px 10px 0 rgba(6, 12, 28, .24);
  --shadow-lift: 0 0 0 1px var(--line-strong), 0 10px 24px -8px rgba(15, 27, 51, .18);
  --shadow-pop: 0 0 0 1px var(--line), 0 6px 20px 0 rgba(15, 27, 51, .14);
  --shadow-side: 0 6px 20px 0 rgba(15, 27, 51, .18);
  --shadow-accent: 0 2px 6px 0 rgba(15, 27, 51, .14);
  --shadow-red: 0 2px 6px 0 rgba(15, 27, 51, .14);
  --scrim: rgba(15, 27, 51, .5);
  --ring: inset 0 0 0 1px var(--accent);
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2344526A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  /* names kept from older screens */
  --brand: var(--accent); --brand-2: var(--accent-ink); --brand-soft: var(--accent-soft);
  --sub: var(--muted); --head-bg: var(--surface-3); --row-hover: var(--surface-2);
  /* shape, rhythm, motion */
  --radius: 6px; --radius-sm: 4px; --radius-lg: 8px; --radius-card: 10px; --pill: var(--radius); --round: 50rem;
  --ctl-h: 38px; --ctl-h-sm: 30px;
  --side-w: 260px; --side-mini: 70px; --nav-pad: 12px; --gutter: 24px;
  --font: 'Cairo', 'IBM Plex Sans Arabic', 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --spring: cubic-bezier(.22, 1.08, .36, 1);
}
:root[data-mode=dark] {
  color-scheme: dark;
  --bg: #0B1324; --surface: #111B30; --surface-2: #16223B; --surface-3: #1C2A47; --input-bg: #0E1729;
  --ink: #E8EDF6; --ink-2: #B5C0D4; --muted: #8795B0;
  --line: #24324E; --line-2: #1C2942; --line-strong: #3A4B6C;
  --dark: #0A1222; --on-dark: #E8EDF6;
  --accent: #4468D6; --accent-hover: #5578E0;
  --side: #080F1E; --side-hover: #121E38; --side-line: #18243F;
  --gold: #D6B36A; --gold-ink: #E2C587; --on-gold: #1A1305;
  --green: #22C55E; --red: #EF4444; --red-hover: #F26060; --amber: #F59E0B; --blue: #38A5E4; --teal: #14B8A6; --secondary: #8795B0;
  --accent-ink: color-mix(in srgb, var(--accent) 55%, var(--ink));
  --paper-desk: #080F1E;
  --shadow-soft: 0 2px 6px 0 rgba(2, 6, 16, .2);
  --shadow-lift: 0 0 0 1px var(--line), 0 8px 22px -4px rgba(2, 6, 16, .34);
  --shadow-pop: 0 0 0 1px var(--line), 0 6px 20px 0 rgba(2, 6, 16, .3);
  --shadow-side: 0 6px 20px 0 rgba(2, 6, 16, .28);
  --shadow-accent: 0 2px 6px 0 rgba(2, 6, 16, .2);
  --shadow-red: 0 2px 6px 0 rgba(2, 6, 16, .2);
  --scrim: rgba(2, 6, 16, .6);
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23B5C0D4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* --- primary colours --- */
:root[data-accent=teal] { --accent: #0F6E6E; --accent-hover: #0B5A5A; }
:root[data-mode=dark][data-accent=teal] { --accent: #14928F; --accent-hover: #18A5A1; }
:root[data-accent=amber] { --accent: #9A5B0A; --accent-hover: #7F4A07; }
:root[data-mode=dark][data-accent=amber] { --accent: #B9770F; --accent-hover: #C98514; }
:root[data-accent=rose] { --accent: #9F1D3F; --accent-hover: #861634; }
:root[data-mode=dark][data-accent=rose] { --accent: #C93A5E; --accent-hover: #D44C6E; }
:root[data-accent=blue] { --accent: #1D6FB8; --accent-hover: #175D9C; }
:root[data-mode=dark][data-accent=blue] { --accent: #2F86D2; --accent-hover: #4094DB; }
:root[data-accent=violet] { --accent: #4F46B8; --accent-hover: #423A9E; }
:root[data-mode=dark][data-accent=violet] { --accent: #6A62D9; --accent-hover: #7A73E0; }

/* ============================== 2. Base ============================== */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink-2); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { color: var(--accent-hover); }
h1, h2, h3, h4 { margin: 0; line-height: 1.4; color: var(--ink); font-weight: 600; }
h1 { font-size: 24px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 18px; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 15px; }
b, strong { font-weight: 600; }
code { background: var(--gray-soft); padding: 1px 6px; border-radius: var(--radius-sm); direction: ltr; display: inline-block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.muted { color: var(--muted); }
.pad { padding: 10px 4px; margin: 0; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.text-red { color: var(--red); }
.text-green { color: var(--green); }
.spacer { flex: 1; }
.ic { flex-shrink: 0; vertical-align: middle; }
.sm { font-size: 13px; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.center { text-align: center; }

/* ============================== 3. Layout ============================== */
#app { display: flex; min-height: 100vh; }

/* Side menu: dark panel; the open page is a solid primary pill */

.sidebar { --thumb: color-mix(in srgb, var(--side-ink) 32%, transparent); width: var(--side-w); position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 40; display: flex; flex-direction: column;
  background: var(--side); color: var(--side-ink); box-shadow: var(--shadow-menu); }

.brand { flex: none; display: flex; align-items: center; gap: 10px; height: 64px; padding: 0 22px; color: var(--side-ink); text-decoration: none !important; overflow: hidden; white-space: nowrap; }

.brand:hover { color: var(--side-ink); }

.brand-mark { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; padding: 0; background: radial-gradient(circle, var(--paper) 0 73%, transparent 74%); }

.brand-mark img { width: 100%; height: 100%; display: block; object-fit: contain; }
.brand b { display: block; font-size: 20px; line-height: 1.2; font-weight: 600; letter-spacing: .15px; }

.brand small { display: block; font-size: 11.5px; line-height: 1.3; color: var(--side-muted); }

.brand-text { transition: opacity .2s; min-width: 0; }
/* The office name: up to two lines, then cut. */
.brand-text > b { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; white-space: normal; font-size: 15px; line-height: 1.25; letter-spacing: 0; }
.sidebar nav { padding: 2px var(--nav-pad) 16px; display: flex; flex-direction: column; flex: 1; overflow-y: auto; overflow-x: hidden; }
.nav-group { display: flex; flex-direction: column; gap: 4px; }
.nav-label { display: flex; align-items: center; gap: 10px; margin: 20px 0 6px; font-size: 13px; line-height: 18px; font-weight: 400; letter-spacing: .4px; color: var(--side-muted); white-space: nowrap; overflow: hidden; }

.nav-label::before, .nav-label::after { content: ''; height: 1px; background: var(--side-line); }
.nav-label::before { flex: none; width: 12px; }
.nav-label::after { flex: 1; }

.nav-group:first-child .nav-label { margin-top: 6px; }
.sidebar nav a { position: relative; display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 12px; border-radius: var(--radius-lg);
  color: var(--side-ink); font-weight: 400; text-decoration: none; overflow: hidden; white-space: nowrap; transition: background .2s, color .2s, padding .25s var(--ease), box-shadow .2s; }

.sidebar nav a .ic { color: currentColor; width: 22px; height: 22px; transition: transform .25s var(--spring); }

.sidebar nav a:hover { background: var(--side-hover); color: var(--side-ink); padding-inline-start: 16px; }
.sidebar nav a:hover .ic { transform: scale(1.08); }

.sidebar nav a.on { background: var(--side-on); color: var(--on-accent); font-weight: 500; box-shadow: var(--shadow-accent); padding-inline-start: 12px; }
.sidebar nav a.on::before { content: ''; position: absolute; inset-block: 9px; inset-inline-start: 0; width: 3px; border-radius: 3px; background: var(--gold); }

.nav-count { margin-inline-start: auto; height: 24px; line-height: 24px; min-width: 24px; padding: 0 7px; border-radius: var(--round); text-align: center;
  font-style: normal; font-size: 13px; font-weight: 500; background: var(--accent); color: var(--on-accent); }

.nav-count:empty { display: none; }
.nav-count.red { background: var(--red); color: var(--on-accent); }

.nav-count.amber { background: var(--amber); color: var(--on-accent); }

.sidebar nav a.on .nav-count { background: var(--menu-on); color: var(--menu-white); }
.sidebar-foot { flex: none; padding: 12px 22px; border-top: 1px solid var(--side-line); color: var(--side-muted); white-space: nowrap; overflow: hidden; }


/* Scroll bars: a thin rail that shows only while the pointer is on the scroll area */
@property --sb { syntax: '<color>'; inherits: true; initial-value: transparent; }
:root { --thumb: color-mix(in srgb, var(--ink) 30%, transparent); }
:where(*) { --sb: transparent; transition: --sb .3s; }
:where(*):hover, :where(*):focus-within { --sb: var(--thumb); }
::-webkit-scrollbar { width: 6px; height: 6px; background: transparent; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--sb); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover, ::-webkit-scrollbar-thumb:active { background: color-mix(in srgb, var(--thumb) 55%, var(--ink)); }
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-width: thin; scrollbar-color: var(--sb) transparent; }
}

/* Menu pin: the round button keeps the side menu open or folds it to icons; the folded menu opens under the pointer */
.side-pin { display: none; }
@media (min-width: 1200px) {
  .side-pin { display: grid; place-items: center; position: absolute; top: 14px; inset-inline-end: 12px; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; z-index: 2;
    background: transparent; color: var(--side-ink); cursor: pointer; transition: background .15s, opacity .2s, transform .3s var(--spring); }
  .side-pin:hover { background: var(--side-hover); }
  .side-pin:active { transform: scale(.9); }
  .side-pin svg { width: 20px; height: 20px; }
  .side-pin .pin-dot { transform-origin: center; transition: transform .3s var(--spring), opacity .2s; }
  .brand { padding-inline-end: 56px; }
  .sidebar { transition: width .3s var(--ease), box-shadow .3s; }
  .sidebar nav a span, .nav-count, .sidebar-foot small { transition: opacity .2s; }
  .brand, .nav-label { transition: padding .3s var(--ease), gap .3s var(--ease), font-size .2s; }
  .main { transition: margin .3s var(--ease); }
  [data-menu=mini] .main { margin-inline-start: var(--side-mini); }
  [data-menu=mini] .side-pin .pin-dot { transform: scale(0); opacity: 0; }
  [data-menu=mini] .sidebar:hover, [data-menu=mini] .sidebar:focus-within { box-shadow: var(--shadow-side); }
  [data-menu=mini] .sidebar:not(:hover, :focus-within) { width: var(--side-mini); }
  [data-menu=mini] .sidebar:not(:hover, :focus-within) .brand { padding-inline: 17px; }
  [data-menu=mini] .sidebar:not(:hover, :focus-within) :is(.brand-text, nav a span, .nav-count, .sidebar-foot small) { opacity: 0; }
  [data-menu=mini] .sidebar:not(:hover, :focus-within) .side-pin { opacity: 0; pointer-events: none; }
  [data-menu=mini] .sidebar:not(:hover, :focus-within) .nav-label { font-size: 0; gap: 0; }
  [data-menu=mini] .sidebar:not(:hover, :focus-within) nav a { padding-inline: 12px; }
  [data-menu=mini] .sidebar:not(:hover, :focus-within) nav { overflow: hidden; }
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; margin-inline-start: var(--side-w); }

/* Top bar: a framed bar with round lower corners; the page scrolls under it */

.topbar { position: sticky; top: 0; z-index: 30; flex: none; height: 64px; display: flex; align-items: center; gap: 12px;
  width: calc(100% - 2 * var(--gutter)); max-width: 1392px; margin: 0 auto; padding: 0 16px; box-shadow: var(--shadow-card);
  background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(7.5px); -webkit-backdrop-filter: blur(7.5px);
  border-radius: 0 0 var(--radius-card) var(--radius-card); }

.top-end { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }

.top-end .quick-add { margin: 0; }
.ai-top { color: var(--ink); }


#view { position: relative; width: 100%; max-width: 1440px; margin: 0 auto; padding: 12px var(--gutter) var(--gutter); }


.global-search { position: relative; flex: 1 1 auto; min-width: 0; height: 38px; display: flex; align-items: center; gap: 12px; color: var(--ink); }

.global-search kbd { font: inherit; font-size: 12px; color: var(--muted); white-space: nowrap; }
.global-search input { border: 0; min-width: 0; outline: 0; background: transparent; flex: 0 1 300px; padding: 0; height: 100%; font: inherit; color: var(--ink); box-shadow: none !important; }
.gs-results { position: absolute; top: calc(100% + 14px); inset-inline-start: -8px; width: min(520px, calc(100vw - 48px)); background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-pop); max-height: 420px; overflow: auto; padding: 8px; animation: pop .2s var(--ease); }
.gs-results a { display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.gs-results a.on, .gs-results a:hover { background: var(--accent-soft); color: var(--accent); }
.gs-results a b { display: block; font-weight: 500; color: inherit; }
.gs-results a small { color: var(--muted); }
.quick-add { position: relative; }
.qa-menu { position: absolute; top: calc(100% + 10px); left: 0; z-index: 40; min-width: 230px; display: flex; flex-direction: column; padding: 8px 0; overflow: hidden;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-pop); animation: pop .16s var(--ease); transform-origin: top left; }
.qa-menu[hidden] { display: none; }
.qa-menu button { display: flex; gap: 10px; align-items: center; background: none; border: 0; padding: 8px 16px; font: inherit; color: var(--ink); text-align: right; cursor: pointer; transition: background .15s, color .15s, padding .2s var(--ease); }

.qa-menu button:hover { background: var(--surface-3); color: var(--accent); padding-inline-start: 20px; }


.user-menu { position: relative; }
.user-chip { display: flex; align-items: center; gap: 10px; background: transparent; border: 0; border-radius: var(--round); padding: 0; cursor: pointer; font: inherit; color: var(--ink); }
.avatar { position: relative; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 500; font-size: 15px; background: var(--accent-soft); color: var(--accent); }

.user-chip .avatar::after { content: ''; position: absolute; bottom: 0; inset-inline-end: 0; width: 11px; height: 11px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 2px var(--surface); }
.um-text { display: flex; flex-direction: column; line-height: 1.3; text-align: right; }
@media (max-width: 1440px) { .um-text { display: none; } }
.um-text b { font-size: 14px; font-weight: 500; }
.um-text small { font-size: 12.5px; color: var(--muted); }
.um-menu { left: 0; min-width: 250px; }
.um-menu button { white-space: nowrap; }
.um-tag { margin-inline-start: auto; font-size: 12px; color: var(--secondary); background: var(--gray-soft); border-radius: var(--radius-sm); padding: 1px 8px; white-space: nowrap; }
.um-tag.on { color: var(--green); background: var(--green-soft); }

/* Menu button and the slide-in side menu (up to 1199px) */
.menu-btn, .nav-close, .nav-scrim { display: none; }
@media (max-width: 1199px) {
  .main { margin-inline-start: 0; }
  .menu-btn { display: inline-grid; place-items: center; flex: none; width: 38px; height: 38px; margin-inline-start: -8px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
    color: var(--ink); background: transparent; transition: background .15s; }
  .menu-btn:hover { background: var(--surface-3); }
  .sidebar { z-index: 50; transform: translateX(105%); transition: transform .3s ease-in-out; box-shadow: none; }
  [dir=ltr] .sidebar { transform: translateX(-105%); }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-side); }
  .brand { padding-inline-end: 56px; }
  .nav-close { display: grid; place-items: center; position: absolute; top: 16px; inset-inline-end: 12px; width: 36px; height: 36px; border-radius: 50%; z-index: 2;
    border: 0; background: transparent; color: var(--side-ink); cursor: pointer; transition: background .15s; }
  .nav-close:hover { background: var(--side-hover); }
  .nav-scrim { display: block; position: fixed; inset: 0; z-index: 45; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity .3s; }
  body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }
}
@media (max-width: 900px) {
  :root { --gutter: 16px; }
  .global-search kbd { display: none; }
  .topbar { gap: 8px; }
}

/* ============================== 4. Controls ============================== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 20px; border-radius: var(--radius);
  border: 1px solid transparent; background: var(--gray-soft); color: var(--ink-2); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
  text-decoration: none !important; transition: background .2s ease-in-out, border-color .2s ease-in-out, color .2s ease-in-out, box-shadow .2s ease-in-out, transform .15s var(--ease); }
.btn:hover { background: color-mix(in srgb, var(--secondary) 24%, var(--surface)); color: var(--ink); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); box-shadow: var(--shadow-soft); }

.btn.dark { background: var(--dark); border-color: var(--dark); color: var(--on-dark); }
.btn.dark:hover { background: color-mix(in srgb, var(--dark) 88%, var(--surface)); color: var(--on-dark); }
.btn.danger { background: var(--red); border-color: var(--red); color: var(--on-accent); }

.btn.danger:hover { background: var(--red-hover); border-color: var(--red-hover); color: var(--on-accent); box-shadow: var(--shadow-soft); }

.btn.danger-ghost { background: var(--red-soft); color: var(--red); }
.btn.danger-ghost:hover { background: color-mix(in srgb, var(--red) 24%, var(--surface)); color: var(--red); }
.btn.ghost { background: transparent; color: var(--accent-ink); }
.btn.ghost:hover { background: var(--accent-soft); color: var(--accent-ink); }
.btn.sm { height: 30px; padding: 0 14px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: default; transform: none; box-shadow: none; }
.btn.ai-btn { background: var(--hl-soft); color: var(--hl-ink); gap: 6px; }
.btn.ai-btn:hover { background: color-mix(in srgb, var(--accent) 24%, var(--surface)); color: var(--hl-ink); }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; border: 0; background: transparent; color: var(--ink-2); cursor: pointer;
  transition: background .15s, color .15s; }
.icon-btn:hover, .ai-top:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); }
.icon-btn:disabled { opacity: .3; cursor: default; }
a.icon-btn { text-decoration: none !important; }

input, select, textarea { font: inherit; color: var(--ink); background: var(--input-bg); border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 7px 15px; outline: none; width: 100%; transition: border-color .15s, box-shadow .15s; }
input:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: var(--ring); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .75; }
textarea { resize: vertical; line-height: 1.7; padding: 9px 15px; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
input[type=date], input[type=time], input[type=number], input[type=tel], input[type=email] { direction: rtl; }
label { font-weight: 400; color: var(--ink); }
:where(input:not([type=checkbox], [type=radio], [type=file], [type=range], [type=color], [type=hidden], [type=image], [type=submit], [type=button])) { height: var(--ctl-h); }
select:where(:not([multiple], [size])) {
  -webkit-appearance: none; appearance: none; height: var(--ctl-h); line-height: normal; padding-block: 0; padding-inline: 15px 38px;
  background-color: var(--input-bg); background-image: var(--chev); background-repeat: no-repeat; background-size: 16px; background-position: left 12px center;
  cursor: pointer; text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
}
[dir=ltr] select:where(:not([multiple], [size])), select[dir=ltr]:where(:not([multiple], [size])) { background-position: right 12px center; }
select:where(:not([multiple], [size])):hover { border-color: var(--muted); }
select:disabled, input:disabled { background-color: var(--surface-3); color: var(--muted); cursor: not-allowed; }
select option { color: var(--ink); background: var(--surface); }
@supports (appearance: base-select) {
  select:where(:not([multiple], [size])), ::picker(select) { appearance: base-select; }
  select:where(:not([multiple], [size])) { display: inline-flex; align-items: center; }
  select::picker-icon { display: none; }
  ::picker(select) { border: 0; border-radius: var(--radius); background: var(--surface); color: var(--ink); padding: 8px; margin-block: 6px;
    max-height: min(340px, 60vh); overflow-y: auto; box-shadow: var(--shadow-pop);
    opacity: 0; translate: 0 -4px; transition: opacity .12s, translate .12s, overlay .12s allow-discrete, display .12s allow-discrete; }
  select:open::picker(select) { opacity: 1; translate: 0 0; }
  @starting-style { select:open::picker(select) { opacity: 0; translate: 0 -4px; } }
  select:open { border-color: var(--accent); box-shadow: var(--ring); }
  select option { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 14px; border-radius: var(--radius); background: transparent; color: var(--ink); cursor: pointer; white-space: nowrap; outline: none; }
  select option:hover, select option:focus-visible { background: var(--surface-3); }
  select option:checked { background: var(--accent-soft); color: var(--accent-ink); font-weight: 500; }
  select option::checkmark { order: 1; margin-inline-start: auto; color: var(--accent); content: "✓"; }
  select option:disabled { opacity: .5; cursor: default; }
  select optgroup { font-weight: 500; color: var(--muted); font-size: 13px; padding: 6px 8px 2px; }
}
select.sm, input.sm, .ai-case select { height: var(--ctl-h-sm); min-height: 0; font-size: 13px; }
.cv-bar select, .stage-select { height: 38px; min-height: 0; }
select.sm, .cv-bar select, .ai-case select, .stage-select { padding-block: 0; padding-inline: 12px 32px; background-position: left 10px center; background-size: 14px; }
input.sm { padding-block: 0; }
.stage-select { width: auto; }

/* combo: text input with suggestions, same look as the select */
.combo, .pick { position: relative; }
.pick { flex: 1 1 220px; min-width: 0; }
.combo > input[data-combo], .pick > .pick-text { width: 100%; padding-inline-end: 38px; background-color: var(--input-bg); background-image: var(--chev); background-repeat: no-repeat;
  background-size: 16px; background-position: left 12px center; }
[dir=ltr] .combo > input[data-combo], [dir=ltr] .pick > .pick-text { background-position: right 12px center; }
.combo > input.combo-open, .pick > .pick-text.combo-open { border-color: var(--accent); box-shadow: var(--ring); }
.combo > datalist { display: none; }
.combo-pop { position: fixed; z-index: 150; overflow-y: auto; overscroll-behavior: contain; padding: 8px; font-family: var(--font); font-size: 15px;
  border-radius: var(--radius); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop); animation: combo-in .12s ease-out; }
@keyframes combo-in { from { opacity: 0; translate: 0 -4px; } }
.combo-opt { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 14px; border-radius: var(--radius); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-opt:hover, .combo-opt.active { background: var(--surface-3); }
.combo-opt.sel { background: var(--accent-soft); color: var(--accent-ink); font-weight: 500; }
.combo-opt.sel::after { content: "✓"; margin-inline-start: auto; color: var(--accent); }
.combo-opt.sel.active { background: color-mix(in srgb, var(--accent) 24%, var(--surface)); }
.combo-empty { padding: 10px 14px; color: var(--muted); font-size: 13px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 24px; }
.span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 13px; font-weight: 400; color: var(--ink); }
.field .hint { color: var(--muted); font-size: 13px; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
.req { color: var(--red); }
.form-section { font-weight: 500; font-size: 15px; color: var(--ink); border-bottom: 1px solid var(--line); padding: 8px 0 8px; margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.check.sm { font-size: 13px; gap: 6px; white-space: nowrap; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline select { flex: 1; }
.info-box { background: var(--accent-soft); color: var(--ink); border-radius: var(--radius); padding: 12px 16px; }
.calc-out, .tafqeet-out { background: var(--hl-soft); border-radius: var(--radius); padding: 10px 16px; color: var(--ink); }
.calc-out { font-size: 14px; }
.calc-out:empty { display: none; }
.tafqeet-out { font-size: 17px; min-height: 48px; }
.hint-line { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.disclaimer { font-size: 13px; color: var(--amber); background: var(--amber-soft); border-radius: var(--radius); padding: 10px 14px; margin: 14px 0 0; display: flex; gap: 8px; align-items: flex-start; }

/* chips and segmented buttons */
.chips { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip-btn { height: 32px; padding: 0 14px; border: 0; border-radius: var(--radius); background: var(--gray-soft); color: var(--ink-2); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background .2s, color .2s, box-shadow .2s; }
.chip-btn:hover { background: var(--accent-soft); color: var(--accent); }
.chip-btn.on { background: var(--accent); color: var(--on-accent); }

.chip-check { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 4px 12px; font-size: 13px; cursor: pointer; }
.scope-chips { margin: 12px 0 0; }
.tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tag { font-size: 12px; background: var(--gray-soft); color: var(--secondary); border-radius: var(--round); padding: 1px 10px; }


/* badges and tones */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 12px; border-radius: var(--round); font-size: 13px; font-weight: 500; white-space: nowrap; }

.badge.plain { padding: 0 8px; }
.tone-blue { background: var(--blue-soft); color: var(--blue); }
.tone-green { background: var(--green-soft); color: var(--green); }
.tone-red { background: var(--red-soft); color: var(--red); }
.tone-amber { background: var(--amber-soft); color: var(--amber); }
.tone-teal { background: var(--teal-soft); color: var(--teal); }
.tone-gold { background: var(--hl-soft); color: var(--hl-ink); }
.tone-gray { background: var(--gray-soft); color: var(--gray-ink); }
.tone-border-red { border-inline-start-color: var(--red); }
.tone-border-amber { border-inline-start-color: var(--amber); }
.tone-border-green { border-inline-start-color: var(--green); }
.count { display: inline-block; height: 22px; line-height: 22px; min-width: 22px; padding: 0 8px; border-radius: var(--round); text-align: center; background: var(--gray-soft); color: var(--secondary); font-size: 12px; font-weight: 500; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================== 5. Cards, lists, tables ============================== */
.card { background: var(--surface); border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 20px; margin-bottom: var(--gutter); }

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card > .card-head:first-child { margin: -20px -20px 0; padding: 20px 20px 16px; }

.card-head h2 { font-size: 18px; font-weight: 500; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-head:first-child { margin: 0; border-bottom: 1px solid var(--line); }
.card.flush > .list { padding: 0 20px; }

.card.flush > .card-foot { padding: 12px 20px; border-top: 1px solid var(--line); text-align: center; font-size: 14px; }

.card.toolbar { padding: 16px 20px; }

.card.fin-strip { padding: 16px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: var(--gutter); flex-wrap: wrap; }
.page-head h1 { position: relative; font-size: 24px; font-weight: 600; padding-bottom: 8px; }
.page-head h1::after { content: ''; position: absolute; bottom: 0; inset-inline-start: 0; width: 36px; height: 3px; border-radius: 3px; background: var(--gold); }
.page-head p { margin: 4px 0 0; color: var(--ink-2); }
.page-head .muted, .page-head small { color: var(--muted); }
.page-head + .tabs.page-tabs { position: relative; }
.head-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.back { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--gutter); }
.hero { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; margin-bottom: 20px; }
.hero h1 { font-size: 24px; }
.hero p { margin: 2px 0 0; }
.alert-card { border-inline-start: 4px solid var(--amber); }
.alert-card h2 { color: var(--amber); }
.welcome { background: linear-gradient(135deg, var(--accent-soft), var(--surface) 70%); }
.welcome p { margin: 6px 0 0; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--gutter); margin-bottom: var(--gutter); }
.kpi { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 0; border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 20px; color: var(--ink-2);
  text-decoration: none !important; transition: box-shadow .25s var(--ease), transform .25s var(--ease); }

a.kpi:hover, .kpi-btn:hover { box-shadow: var(--shadow-lift); transform: translateY(-3px); color: var(--ink-2); }

.kpi b { display: block; font-size: 22px; line-height: 30px; font-weight: 500; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--ink-2); font-size: 13px; }
.kpi-ic { width: 42px; height: 42px; border-radius: var(--radius); display: grid; place-items: center; }
.kpi-btn { font: inherit; text-align: right; cursor: pointer; width: 100%; }

.list { display: flex; flex-direction: column; container-type: inline-size; }
@container (max-width: 560px) {
  .row-item { flex-wrap: wrap; }
  .row-item .ri-main { flex-basis: calc(100% - 110px); }
  .row-item .ri-side { width: 100%; justify-content: flex-start; }
  .row-item.session .ri-side { padding-right: 104px; }
  .row-item.deadline .ri-side, .row-item.task .ri-side { padding-right: 34px; }
}
@container (max-width: 380px) {
  .row-item.session .ri-date { width: 100%; flex-direction: row; gap: 8px; }
  .row-item.session .ri-main { flex-basis: 100%; }
  .row-item.session .ri-side { padding-right: 0; }
}
.row-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.row-item:last-child { border-bottom: 0; }
.row-item.link { color: var(--ink-2); text-decoration: none; align-items: center; border-radius: var(--radius); }
.row-item.link:hover { background: var(--surface-3); }
.row-item.attention { background: linear-gradient(270deg, var(--amber-soft), transparent 70%); }
.row-item.done .ri-title { text-decoration: line-through; color: var(--muted); }
.ri-date { width: 92px; flex-shrink: 0; display: flex; flex-direction: column; font-size: 13px; }
.ri-date:empty { display: none; }
.ri-date small { color: var(--muted); }
.ri-date .time { color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }
.ri-main { flex: 1; min-width: 0; }
.ri-title { font-weight: 500; color: var(--ink); }
.ri-title a { color: var(--ink); }
.ri-title a:hover { color: var(--accent-ink); }
.ri-sub { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.ri-note { font-size: 13px; color: var(--muted); margin-top: 2px; white-space: pre-wrap; }
.ri-outcome { font-size: 13px; background: var(--green-soft); color: var(--green); border-radius: var(--radius); padding: 4px 10px; margin-top: 5px; white-space: pre-wrap; }
.ri-side { display: flex; align-items: center; gap: 4px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.check-btn { width: 20px; height: 20px; border-radius: var(--radius-sm); border: 2px solid var(--line-strong); background: var(--input-bg); color: transparent; display: grid; place-items: center;
  cursor: pointer; flex-shrink: 0; margin-top: 2px; padding: 0; transition: background .15s, border-color .15s; }
.check-btn:hover { border-color: var(--accent); }
.check-btn.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.date-tile { width: 42px; height: 46px; border-radius: var(--radius); flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; gap: 3px; }
.date-tile small { font-size: 10.5px; font-weight: 500; }
.date-tile b { font-size: 18px; font-weight: 500; font-variant-numeric: tabular-nums; color: inherit; }

.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.empty p { margin: 12px 0 16px; }
.empty .ic { opacity: .5; }
.empty > svg.ic:first-child { width: 56px; height: 56px; padding: 16px; border-radius: var(--radius-lg); background: var(--accent-soft); color: var(--accent); opacity: 1; box-sizing: border-box; }


.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 15px; border: 1px solid var(--line); border-radius: var(--radius-card); overflow: hidden; background: var(--surface); }
.table > :is(thead, tbody, tfoot):last-child > tr:last-child > :is(td, th) { border-bottom: 0; }
.table > thead:first-child > tr:first-child > th:first-child { border-start-start-radius: 9px; }
.table > thead:first-child > tr:first-child > th:last-child { border-start-end-radius: 9px; }
.table th { text-align: right; font-weight: 500; color: var(--ink); font-size: 13px; letter-spacing: .2px; padding: 18px 20px; border-bottom: 1px solid var(--line); background: var(--surface); white-space: nowrap; }
.table td { padding: 12px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; line-height: 1.6; color: var(--ink-2); transition: background .15s; }
.table.compact td { padding: 8px 20px; }
.table.hover tbody tr { cursor: pointer; }
.table.hover tbody tr:hover, .table tbody tr.on td { background: var(--surface-3); }
.table .num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.table .actions { white-space: nowrap; text-align: left; width: 1%; }
.table tr.inactive td { opacity: .55; }
.table tr.row-strong td { background: var(--surface-2); font-weight: 600; color: var(--ink); }
.table.docs td { vertical-align: middle; }
.card.flush > .table, .card.flush > .rules-wrap > .table { border: 0; border-radius: 0; }
.cell-sub { font-size: 13px; color: var(--muted); max-width: 320px; }

.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar select { width: auto; min-width: 160px; }
.toolbar label { display: flex; align-items: center; gap: 6px; }
.toolbar label input { width: auto; }
.search-box { flex: 1; min-width: 220px; height: 38px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 0 14px;
  color: var(--muted); background: var(--input-bg); transition: border-color .15s, box-shadow .15s; }
.search-box:hover { border-color: var(--muted); }
.search-box:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.search-box input { border: 0; box-shadow: none !important; padding: 0; height: 100%; background: transparent; }
.search-box.sm { flex: 0 1 240px; min-width: 160px; }

.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); margin: 0 0 20px; overflow-x: auto; scrollbar-width: none; }
.tab { background: none; border: 0; padding: 9px 20px; margin-bottom: -1px; font: inherit; color: var(--ink); cursor: pointer; border-bottom: 2px solid transparent;
  display: flex; align-items: center; gap: 6px; white-space: nowrap; font-weight: 500; transition: color .15s, border-color .2s, background .2s; }
.tab:hover { color: var(--accent); }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); }
.tab-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0 12px; }
.page-tabs { max-width: 100%; margin: 0 0 var(--gutter); padding: 0 0 6px; gap: 6px; border: 0; }
.page-tabs .tab { height: 38px; padding: 0 20px; margin: 0; border: 0; border-radius: var(--radius); }
.page-tabs .tab:hover { background: var(--accent-soft); color: var(--accent); }
.page-tabs .tab.on { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-soft); }

.page-tabs .tab.on .badge, .page-tabs .tab.on .nav-count { background: var(--menu-on); color: inherit; }
.sub-h { font-size: 14px; color: var(--ink); font-weight: 500; margin: 14px 0 4px; display: flex; gap: 6px; align-items: center; }

.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px 24px; }
.info-grid small { color: var(--muted); font-size: 13px; display: block; }
.info-grid .span-all { grid-column: 1 / -1; }
.fin-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.fin-strip > div { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.fin-strip small { display: block; color: var(--muted); font-size: 13px; }
.fin-strip b { font-size: 18px; font-weight: 500; font-variant-numeric: tabular-nums; }
.fin-strip .hl { background: var(--accent-soft); border-color: transparent; }
.fin-strip .hl b { color: var(--accent-ink); }
.notes-area { min-height: 240px; }

/* breadcrumbs and the case header */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); margin: 0 0 16px; }
.crumbs a { color: var(--ink-2); }
.crumbs a:hover { color: var(--accent); }
.crumbs b { color: var(--ink); font-weight: 500; }
.case-hero { padding-bottom: 0; }
.ch-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.ch-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.ch-meta b { color: var(--ink); font-weight: 500; }
.case-hero h1 { margin: 6px 0 2px; }
.case-hero .ch-sub { margin: 0; color: var(--ink-2); }
.case-hero .info-grid { margin: 20px 0 0; padding: 20px 0 8px; border-top: 1px solid var(--line); }
.case-hero .info-grid div > div { font-weight: 500; color: var(--ink); }
.case-hero .tabs { margin: 12px -20px 0; padding: 0 8px; border-bottom: 0; border-top: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }

/* ============================== 6. Drawers and toasts ============================== */
/* Windows open as side panels from the left edge (the end side in Arabic) */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: flex; justify-content: flex-end; background: var(--scrim); animation: fade .2s linear; }
.modal { width: min(560px, 100vw); height: 100%; max-height: none; display: flex; flex-direction: column; background: var(--surface); box-shadow: var(--shadow-side); animation: drawer-in .32s var(--ease); }
.modal-sm { width: min(400px, 100vw); }
.modal-md { width: min(560px, 100vw); }
.modal-lg { width: min(920px, 100vw); }
.modal-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 18px; line-height: 28px; font-weight: 500; }
.modal-head .icon-btn { width: 32px; height: 32px; color: var(--ink-2); transition: transform .3s var(--ease), background .15s, color .15s; }

.modal-head .icon-btn:hover { transform: rotate(90deg); color: var(--ink); }

.modal-body { flex: 1; min-height: 0; padding: 24px; overflow-y: auto; }
.modal-foot { flex: none; display: flex; gap: 12px; align-items: center; padding: 16px 24px; border-top: 1px solid var(--line); }
.modal-backdrop.closing { animation: fade-out .2s linear forwards; }
.modal-backdrop.closing .modal { animation: drawer-out .2s ease-in-out forwards; }
@keyframes drawer-in { from { transform: translateX(-100%); } }
@keyframes drawer-out { to { transform: translateX(-100%); } }
@keyframes fade-out { to { opacity: 0; } }
.confirm-msg { margin: 0; font-size: 15px; white-space: pre-line; color: var(--ink); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } }
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } }
#toast-root { position: fixed; bottom: 24px; left: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { display: flex; align-items: center; gap: 10px; max-width: 420px; padding: 14px 18px; border-radius: var(--radius-card); background: var(--surface); color: var(--ink);
  border-inline-start: 4px solid var(--green); box-shadow: var(--shadow-pop); animation: toast-in .4s var(--spring); transition: opacity .3s, transform .3s; }
.toast-error { border-inline-start-color: var(--red); }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(.94); } }

/* ============================== 7. Dashboard ============================== */
.dash-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.dash-date { margin: 0; font-size: 13px; color: var(--muted); }
.dash-sum { margin: 0; font-size: 14px; color: var(--muted); }
.dash-sum b { color: var(--ink); font-weight: 500; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--gutter); margin-bottom: var(--gutter); }
.kpi-card { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 20px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-card);
  color: var(--ink-2); text-decoration: none !important; }
.kpi-card:hover { color: var(--ink-2); }
.kpi-label { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink-2); }
.kpi-label .kpi-ic { flex: none; display: grid; place-items: center; }
.kpi-val { font-size: 24px; line-height: 34px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi-val small { font-size: 14px; font-weight: 400; color: var(--muted); margin-inline-start: 4px; letter-spacing: 0; }
.kpi-foot { font-size: 12px; color: var(--muted); }
.kpi-foot.red { color: var(--red); }
.kpi-foot.amber { color: var(--amber); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(300px, 1fr); gap: var(--gutter); align-items: start; }
.dash-grid > div { display: flex; flex-direction: column; gap: var(--gutter); min-width: 0; }
.dash-grid .card { margin: 0; }
.sess-table td:first-child { width: 64px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sess-table tbody tr { cursor: pointer; }
.sess-table tr.now td { background: var(--hl-soft); }
.sess-table .t-case { font-weight: 500; color: var(--ink); }
.sess-table .t-sub { display: block; font-size: 12px; color: var(--muted); }
.dl-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.dl-row:last-child { border-bottom: 0; }
.dl-row .dl-main { flex: 1; min-width: 0; }
.dl-row .dl-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dl-row .dl-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend { display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-left: 3px; }
.legend-dots { display: flex; gap: 12px; font-size: 12px; color: var(--muted); }
.legend-dots i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-inline-end: 4px; }
.chip { font-size: 11px; border-radius: 6px; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.6; }
.chip.more { color: var(--muted); }

.kpi-card .kpi-val { font-size: 28px; line-height: 38px; }
.kpi-bars { display: flex; align-items: flex-end; gap: 4px; height: 30px; margin-top: 4px; }
.kpi-bars i { flex: 1; border-radius: 4px; background: var(--accent-soft); transition: height .5s var(--ease); }
.kpi-bars i.on { background: var(--gold); }
.kpi-meter { height: 8px; margin-top: 14px; border-radius: var(--pill); background: var(--surface-3); overflow: hidden; }
.kpi-meter i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--amber), var(--red)); }

/* Dashboard hero on the band */
.dash-hero { display: flex; align-items: center; justify-content: space-between; gap: 32px; padding: 28px 32px; margin-bottom: var(--gutter); border-radius: var(--radius); color: var(--menu-white);
  background: var(--hero); }
.dh-main { flex: 1; min-width: 0; }
.dh-date { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px; border-radius: var(--pill); font-size: 12.5px;
  background: var(--menu-hover); border: 1px solid var(--menu-line); color: var(--menu-ink); }
.dh-date i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 30%, transparent); animation: live 2.4s ease-in-out infinite; }
@keyframes live { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--green) 0%, transparent); } }
.dash-hero h1 { margin: 12px 0 4px; font-size: 28px; line-height: 1.35; font-weight: 500; color: var(--menu-white); }
.dash-hero .dash-sum { font-size: 15px; color: var(--menu-ink); }
.dash-hero .dash-sum b { color: var(--menu-white); font-weight: 600; }
.dh-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; }
.dh-actions .btn { border-color: transparent; background: var(--menu-hover); color: var(--menu-white); }
.dh-actions .btn:hover { background: var(--menu-on); color: var(--menu-white); }
.dh-actions .btn.primary { background: var(--gold); color: var(--on-gold); box-shadow: none; font-weight: 600; }
.dh-actions .btn.primary:hover { background: color-mix(in srgb, var(--gold) 86%, var(--menu-white)); color: var(--on-gold); }
.dh-scope { display: inline-flex; gap: 2px; margin-top: 14px; padding: 3px; border-radius: var(--pill); background: var(--menu-hover); border: 1px solid var(--menu-line); }
.dh-scope button { border: 0; background: none; font: inherit; font-size: 13px; color: var(--menu-ink); padding: 4px 14px; border-radius: var(--pill); cursor: pointer; transition: background .2s, color .2s; }
.dh-scope button.on { background: var(--menu-white); color: var(--accent); font-weight: 500; }
.dh-next { flex: none; width: 340px; display: flex; flex-direction: column; gap: 2px; padding: 20px; border-radius: var(--radius);
  background: var(--menu-hover); border: 1px solid var(--menu-line); }
.dh-next > small { color: var(--menu-muted); font-size: 12px; }
.dh-next > b { font-size: 18px; font-weight: 500; line-height: 1.35; margin-top: 2px; }
.dh-next-sub { color: var(--menu-ink); font-size: 13px; }
.dh-cd { display: flex; gap: 8px; margin-top: 14px; }
.dh-cd span { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 8px 0; border-radius: var(--radius); background: var(--menu-hover); }
.dh-cd b { font-size: 24px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.dh-cd small { font-size: 11.5px; color: var(--menu-muted); }
.dh-next-link { display: inline-flex; align-items: center; gap: 4px; margin-top: 12px; color: var(--menu-ink); font-size: 13px; }
.dh-next-link:hover { color: var(--menu-white); }

/* Dashboard boxes */
.bento { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr); gap: var(--gutter); align-items: stretch; grid-auto-flow: dense; }
.bento > .card { margin: 0; min-width: 0; }
.bento .b-full { grid-column: 1 / -1; }
.bento .b-week { grid-column: 1 / -1; }
/* An empty card on the home screen: one quiet line and one button. */
.quiet { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 16px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); font-size: 14px; }
/* First steps of a new office. */
.start-card { background: linear-gradient(135deg, var(--accent-soft), var(--surface) 60%); }
.start-bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-bottom: 16px; }
.start-bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .5s var(--ease); }
.start-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.start-steps li { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); }
.start-steps li > div { flex: 1 1 auto; min-width: 0; }
.start-steps b { display: block; font-size: 15px; }
.start-steps small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.start-steps .btn { flex: none; }
.start-no { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.start-steps li.done { border-style: dashed; }
.start-steps li.done b { color: var(--muted); }
.start-steps li.done .start-no { background: var(--green-soft); color: var(--green); }
.wk-n { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 16px; margin-top: 4px; }
.wk-n i { font-style: normal; font-size: 11px; line-height: 1.3; padding: 0 6px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-ink); white-space: nowrap; }
.wk-n i.r { background: var(--red-soft); color: var(--red); }
.wk-day.today .wk-n i { background: color-mix(in srgb, var(--on-accent) 22%, transparent); color: var(--on-accent); }
.tline { list-style: none; margin: 0; padding: 0; position: relative; }
.tline::before { content: ''; position: absolute; inset-inline-start: 63px; top: 14px; bottom: 14px; width: 2px; border-radius: 2px; background: var(--line); }
.tline li { display: grid; grid-template-columns: 50px 26px minmax(0, 1fr); gap: 0 6px; align-items: start; padding: 6px 0; }
.tline li[data-href] { cursor: pointer; }
.tline time { padding-top: 12px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: start; }
.tl-dot { width: 14px; height: 14px; margin: 16px auto 0; border-radius: 50%; position: relative; z-index: 1; background: var(--surface); border: 3px solid var(--accent); }
.tline li.done .tl-dot { border-color: var(--line-strong); background: var(--line-strong); }
.tline li.done time, .tline li.done .tl-ev b { color: var(--muted); }
.tline li.now .tl-dot { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 22%, transparent); animation: live 2.4s ease-in-out infinite; }
.tl-ev { padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line-2); transition: border-color .2s, transform .2s var(--ease); }
.tline li[data-href]:hover .tl-ev { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); transform: translateX(-3px); }
.tline li.now .tl-ev { background: linear-gradient(270deg, var(--accent-soft), var(--surface)); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.tl-ev b { display: block; font-weight: 600; }
.tl-ev small { display: block; color: var(--muted); font-size: 12.5px; }
.tl-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.tl-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 1px 10px; border-radius: var(--pill); background: var(--gray-soft); color: var(--ink-2); }
.dl-ring-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; }
.dl-ring-row .dl-main { flex: 1; min-width: 0; }
.dl-ring-row .dl-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dl-ring-row .dl-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ring { --c: var(--muted); flex: none; position: relative; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--gray-soft) 0); }
.ring::before { content: ''; position: absolute; inset: 5px; border-radius: 50%; background: var(--surface); }
.ring b { position: relative; font-size: 14px; font-variant-numeric: tabular-nums; }
.ring.tone-red { --c: var(--red); } .ring.tone-amber { --c: var(--amber); } .ring.tone-gray { --c: var(--accent); }
.wk-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
.wk-day { display: flex; flex-direction: column; align-items: center; padding: 10px 4px; border-radius: var(--radius); border: 1px solid var(--line); color: var(--ink); text-decoration: none !important; transition: border-color .15s, transform .2s var(--ease); }
.wk-day:hover { border-color: var(--accent); color: var(--ink); }
.wk-day small { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.wk-day b { font-size: 22px; line-height: 1.3; font-variant-numeric: tabular-nums; }
.wk-day.today { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.wk-day.today small { color: inherit; opacity: .8; }
.wk-pips { display: flex; gap: 3px; min-height: 6px; margin-top: 4px; }
.wk-pips i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.wk-pips i.r { background: var(--red); }
.wk-day.today .wk-pips i { background: var(--on-accent); }
@media (max-width: 1200px) {
  .bento { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .bento .b-tl { grid-column: 1 / -1; }
  .bento .b-week { grid-column: 1 / -1; }
}
@media (max-width: 1000px) {
  .dash-hero { flex-direction: column; align-items: stretch; gap: 20px; }
  .dh-next { width: auto; }
}
@media (max-width: 700px) {
  .bento { grid-template-columns: minmax(0, 1fr); }
  .dash-hero { padding: 20px; }
  .dash-hero h1 { font-size: 22px; }
  .dh-actions .btn:not(.primary) { padding-inline: 12px; }
  .wk-strip { gap: 4px; }
  .wk-day { padding: 8px 2px; border-radius: var(--radius); }
  .wk-day b { font-size: 17px; }
}

/* ============================== 8. Calendar ============================== */
.cv-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 16px 24px; margin: 0 0 var(--gutter); background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-card); }
.cv-nav { display: flex; gap: 4px; }
.cv-nav .icon-btn { width: 38px; height: 38px; border-radius: var(--radius); background: var(--gray-soft); color: var(--ink-2); }
.cv-nav .icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.cv-title { display: flex; flex-direction: column; }
.cv-title h1 { margin: 0; font-size: 20px; line-height: 30px; }
.cv-title span { font-size: 12px; color: var(--muted); }
.cv-bar select { width: auto; padding: 0 12px; font-size: 13px; }
.cv-body { display: flex; flex-wrap: wrap; gap: var(--gutter); align-items: flex-start; }
.cv-month { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.cv-legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12px; color: var(--ink-2); }
.cv-legend span { display: flex; align-items: center; gap: 6px; }
.mk-dot { width: 8px; height: 8px; border-radius: 4px; background: var(--blue); flex: none; }
.mk-dia { width: 7px; height: 7px; transform: rotate(45deg); border: 1.5px solid currentColor; flex: none; box-sizing: border-box; }
.mk-sq { width: 7px; height: 7px; border-radius: 2px; border: 1.5px solid currentColor; flex: none; box-sizing: border-box; }
.cf-tag { display: inline-flex; align-items: center; gap: 3px; height: 18px; padding: 0 6px; border-radius: 6px; background: var(--red); color: var(--surface); font-size: 10.5px; font-weight: 700; line-height: 18px; }
.cv-frame { overflow-x: auto; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-card); }
.cv-grid { min-width: 700px; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cv-dow { padding: 12px 10px; font-size: 13px; font-weight: 500; color: var(--ink); background: var(--surface); border-bottom: 1px solid var(--line); }
.cv-dow.off { color: var(--muted); }
.cv-cell { min-height: 124px; padding: 6px 6px 8px; display: flex; flex-direction: column; gap: 4px; text-align: right; font: inherit; color: var(--ink); cursor: pointer;
  background: var(--surface); border: 0; border-bottom: 1px solid var(--line-2); border-inline-start: 1px solid var(--line-2); overflow: hidden; transition: background .15s; }
.cv-cell:nth-child(7n + 1) { border-inline-start: 0; }
.cv-cell:hover { background: var(--surface-2); }
.cv-cell.off { background: color-mix(in srgb, var(--surface-3) 60%, var(--surface)); }
.cv-cell.today { background: var(--accent-soft); }
.cv-cell.sel:not(.today) { box-shadow: inset 0 0 0 2px var(--bright); }
.cv-cell.out .cv-num, .cv-cell.out .cv-h { color: var(--muted); opacity: .7; }
.cv-cell.out .cv-chip { opacity: .55; }
.cv-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cv-num { min-width: 26px; height: 26px; border-radius: var(--round); display: grid; place-items: center; font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; }
.cv-cell.today .cv-num { background: var(--accent); color: var(--on-accent); }
.cv-cell.off .cv-num { color: var(--muted); }
.cv-h { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv-h.m1 { color: var(--hl-ink); }
.cv-top .cf-tag { margin-inline-start: auto; }
.cv-hol { font-size: 10.5px; color: var(--red); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv-chip { display: flex; align-items: center; gap: 5px; height: 22px; padding: 0 6px; border-radius: 6px; font-size: 11px; line-height: 22px; border: 1px solid transparent; overflow: hidden; white-space: nowrap; }
.cv-chip > :last-child { overflow: hidden; text-overflow: ellipsis; }
.cv-chip b { font-weight: 600; font-variant-numeric: tabular-nums; flex: none; }
.cv-chip.s { background: var(--blue-soft); color: var(--blue); }
.cv-chip.s.past { background: var(--gray-soft); color: var(--gray-ink); }
.cv-chip.s.past .mk-dot { background: var(--muted); }
.cv-chip.d { background: var(--surface); }
.cv-chip.d.red { color: var(--red); border-color: var(--red); }
.cv-chip.d.amber { color: var(--amber); border-color: var(--amber); }
.cv-chip.d.gray { color: var(--muted); border-color: var(--line-strong); }
.cv-chip.t { background: var(--amber-soft); color: var(--amber); }
.cv-more { font-size: 11px; font-weight: 600; color: var(--muted); padding: 0 4px; }
.cv-day { flex: 1 1 320px; max-width: 400px; min-width: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-card); overflow: hidden; position: sticky; top: 84px; }
.cv-day-head { padding: 16px 20px; border-bottom: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 2px; }
.cv-day-head .eyebrow { font-size: 12px; font-weight: 600; color: var(--accent-ink); }
.cv-day-head h2 { font-size: 18px; line-height: 26px; }
.cv-day-head span { font-size: 13px; color: var(--muted); }
.cv-day-acts { display: flex; gap: 6px; flex-wrap: wrap; padding: 12px 20px 0; }
.cv-alert { margin: 16px 20px 4px; padding: 12px; border-radius: var(--radius); background: var(--red-soft); border: 1px solid color-mix(in srgb, var(--red) 25%, transparent); display: flex; flex-direction: column; gap: 8px; }
.cv-alert b { display: flex; align-items: center; gap: 8px; color: var(--red); font-size: 13px; font-weight: 600; }
.cv-alert p { margin: 0; font-size: 13px; color: var(--ink-2); }
.cv-off { margin: 12px 20px 0; padding: 8px 12px; border-radius: var(--radius); background: var(--red-soft); color: var(--red); font-size: 13px; }
.cv-items { padding: 8px 0; }
.cv-sec { padding: 12px 20px 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.cv-item { display: flex; gap: 12px; padding: 10px 20px; align-items: flex-start; color: inherit; }
.cv-item:hover { background: var(--surface-2); }
.cv-time { width: 44px; flex: none; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; direction: ltr; }
.cv-time.past { color: var(--muted); }
.cv-bar-l { width: 3px; align-self: stretch; border-radius: 2px; flex: none; background: var(--blue); }
.cv-bar-l.gray { background: var(--muted); }
.cv-bar-l.amber { background: var(--amber); }
.cv-bar-l.red { background: var(--red); }
.cv-bar-l.green { background: var(--green); }
.cv-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cv-item-main > a, .cv-item-main > .ttl { font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv-item-main > a:hover { color: var(--accent-ink); }
.cv-item-main small { font-size: 12px; color: var(--muted); }
.cv-item-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.cv-item-meta .av { width: 20px; height: 20px; border-radius: var(--radius); background: var(--accent); color: var(--on-accent); font-size: 9px; font-weight: 600; display: grid; place-items: center; }
.cv-item-meta .push { margin-inline-start: auto; display: flex; align-items: center; gap: 2px; flex-wrap: wrap; justify-content: flex-end; min-width: 0; max-width: 100%; }
.cv-empty { padding: 16px 20px; color: var(--muted); font-size: 13px; }
.cv-soon { padding: 12px 20px 16px; border-top: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 8px; }
.cv-soon > b { font-size: 13px; font-weight: 600; }
.cv-soon div { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--red); }
.cv-soon div span:nth-child(2) { flex: 1; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv-soon div em { font-style: normal; font-size: 12px; font-weight: 600; }

/* ============================== 9. Tools: deadlines, templates, editor, library ============================== */
.calc-result { margin-top: 14px; border-radius: var(--radius); padding: 14px 16px; border: 1px solid var(--line); border-inline-start-width: 4px; background: var(--surface-2); }
.calc-date { font-size: 22px; font-weight: 700; color: var(--accent-ink); margin: 2px 0 6px; }
.calc-notes { margin: 10px 0; padding-right: 18px; font-size: 13px; color: var(--ink-2); }
.row-actions { display: flex; gap: 8px; }
.row-actions select { flex: 1; }

.tpl-cat { font-size: 13px; color: var(--accent-ink); margin: 14px 0 8px; }
.tpl-cat:first-of-type { margin-top: 0; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.tpl-grid + .card { margin-top: var(--gutter); }
.tpl-card { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none !important;
  background: var(--surface); transition: border-color .15s, box-shadow .2s, transform .2s var(--ease); }
.tpl-card:hover { border-color: var(--accent); color: var(--ink); }
.tpl-card .ic { color: var(--accent); }
.tpl-card small { color: var(--muted); font-size: 12px; line-height: 1.5; }
.tpl-card.office { position: relative; border-color: color-mix(in srgb, var(--bright) 35%, var(--line)); background: linear-gradient(180deg, var(--hl-soft), var(--surface) 60%); }
.tpl-card.office .ic, .tpl-card.office svg:first-child { color: var(--hl-ink); }
.tpl-tools { position: absolute; top: 6px; left: 6px; display: flex; gap: 2px; opacity: .55; }
.tpl-card.office:hover .tpl-tools { opacity: 1; }
.tpl-head { display: flex; align-items: center; gap: 12px; margin: 22px 0 10px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line);
  border-inline-start: 4px solid var(--accent); border-radius: var(--radius); scroll-margin-top: 90px; }
.tpl-head:first-child { margin-top: 4px; }
.tpl-ic { width: 36px; height: 36px; border-radius: var(--radius); display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.tpl-head-t { display: flex; flex-direction: column; min-width: 0; }
.tpl-head h4 { margin: 0; font-size: 15.5px; color: var(--ink); }
.tpl-head small { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.tpl-head .count { margin-inline-start: auto; }
.tpl-jump { margin: 4px 0 14px; gap: 6px; flex-wrap: wrap; display: flex; }

.editor-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.doc-name { max-width: 520px; font-size: 17px; font-weight: 600; border-color: transparent; background: transparent; }
.doc-name:hover { border-color: var(--line); }
.dirty { color: var(--amber); font-size: 12.5px; white-space: nowrap; }
.editor-toolbar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; background: var(--surface); border-radius: var(--radius); padding: 8px 10px;
  margin-bottom: 16px; position: sticky; top: 72px; z-index: 10; box-shadow: var(--shadow-card); }
.editor-grid { display: grid; grid-template-columns: minmax(380px, 520px) minmax(0, 1fr); gap: 18px; align-items: start; }
.editor-form { display: flex; flex-direction: column; gap: 10px; }
.editor-preview { position: sticky; top: 138px; max-height: calc(100vh - 154px); overflow: auto; background: var(--paper-desk); border-radius: var(--radius); padding: 20px; }
/* rf:allow-colour — paper previews show real paper: white sheet and dark text in every mode */
.paper { background: var(--paper); color: var(--paper-ink); width: 100%; max-width: 794px; min-height: 1123px; margin: 0 auto; padding: 72px 80px; box-shadow: 0 4px 20px rgba(0, 0, 0, .18); }
/* rf:end */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 14px; }
.panel > summary { cursor: pointer; padding: 12px 0; font-weight: 700; color: var(--ink); list-style: none; display: flex; align-items: center; gap: 6px; }
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary::before { content: '▸'; color: var(--accent); transition: transform .2s var(--ease); display: inline-block; }
.panel[open] > summary::before { transform: rotate(90deg); }
.panel[open] { padding-bottom: 14px; }
.panel-actions { display: flex; gap: 6px; margin-top: 8px; }
.panel-actions.wrap { flex-wrap: wrap; }
.rep-row { display: grid; grid-template-columns: 130px 1fr auto; gap: 6px; align-items: start; margin-bottom: 8px; }
.rep-key { font-weight: 600; }
.rep-tools { display: flex; flex-direction: column; }
.sec-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; margin-bottom: 10px; background: var(--surface-2); }
.sec-head { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.sec-head input[data-f=title] { font-weight: 600; }
.sec-no { width: 24px; height: 24px; border-radius: var(--radius-sm); background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-size: 12px; flex-shrink: 0; }
.sec-body { min-height: 110px; background: var(--input-bg); }
.clauses { display: flex; flex-direction: column; gap: 8px; }
.clause { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; border: 1px solid var(--line-2); border-radius: var(--radius); padding: 10px 12px; background: var(--surface-2); }
.clause p { margin: 0; flex: 1; font-size: 16px; line-height: 1.8; }
.clause > div { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }

.law-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.law-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; background: var(--surface); transition: border-color .15s; }
.law-card:hover { border-color: var(--line-strong); }
.law-head { display: flex; flex-direction: column; }
.law-head b { font-size: 15px; color: var(--ink); }
.law-no { font-size: 12.5px; color: var(--accent-ink); font-weight: 600; }
.keys { margin: 0; list-style: none; font-size: 13px; display: flex; flex-direction: column; gap: 3px; border-top: 1px dashed var(--line); padding: 6px 0 0; }
.keys b { color: var(--accent-ink); margin-left: 4px; }
.law-actions { margin-top: auto; }
.sources { margin-top: 16px; padding: 10px 14px; background: var(--accent-soft); border-radius: var(--radius); font-size: 13px; }
.court-guide { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.court-item { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; background: var(--surface); }
/* A court in the drawer: the name and its copy button stay on one line at every width. */
.row-item.court-row { flex-wrap: nowrap; align-items: center; }
.row-item.court-row .ri-main { flex: 1 1 auto; min-width: 0; }
.row-item.court-row .ri-side { width: auto; flex: none; margin-inline-start: auto; padding: 0; }
button.court-item { display: block; width: 100%; text-align: start; font: inherit; color: inherit; cursor: pointer; }
button.court-item:hover { border-color: var(--accent); }
.court-item h3 { font-size: 15px; color: var(--ink); display: flex; gap: 6px; align-items: center; }
.court-item p { margin: 6px 0 0; font-size: 13.5px; color: var(--ink-2); }
.court-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; margin-bottom: 18px; }
.court-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; background: var(--surface-2); display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.court-card .cc-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.court-card b { font-size: 14px; color: var(--ink); }

/* ============================== 10. Settings, users, finance ============================== */
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.inline-form input[type=date] { width: 170px; }
.inline-form input[data-h=name] { width: 260px; }
.rules-wrap { overflow-x: auto; margin: 8px 0; }
.rules-table { min-width: 760px; }
.rules-table td { vertical-align: top; }
.rules-table td:first-child { min-width: 200px; }
.rules-table .nowrap { white-space: nowrap; }
.rules-table .row-btns { text-align: left; width: 1%; }
.tf-state { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: var(--radius); background: var(--gray-soft); color: var(--ink-2); margin-bottom: 12px; }
.tf-state.on { background: var(--green-soft); color: var(--green); }
.tf-state .badge { margin-inline-start: auto; }
.tf-pw { display: block; margin-top: 10px; }
.tf-pw input { margin-top: 4px; }
.qr-box { display: flex; justify-content: center; margin: 6px 0 10px; }
/* rf:allow-colour — the QR code needs a white background to scan */
.qr-box svg { width: 190px; height: 190px; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px; background: #fff; }
/* rf:end */
.enroll-steps { margin: 0 0 4px; padding-inline-start: 18px; font-size: 13px; color: var(--ink-2); line-height: 1.8; }
.secret { display: block; margin-top: 6px; font-size: 14px; letter-spacing: 1px; color: var(--ink); }
.who { color: var(--teal); white-space: nowrap; }
.perm-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 20px; }
.perm-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
.perm-list li { display: flex; gap: 6px; align-items: flex-start; }
.act-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line-2); font-size: 13.5px; flex-wrap: wrap; }
.act-time { color: var(--muted); width: 64px; font-size: 12.5px; }
@media (max-width: 900px) { .perm-grid { grid-template-columns: 1fr; } }

.acc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: var(--gutter); margin-bottom: var(--gutter); }
.acc-card { display: flex; flex-direction: column; gap: 8px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 20px; color: var(--ink);
  text-decoration: none !important; transition: border-color .15s, box-shadow .2s, transform .2s var(--ease); }
.acc-card:hover { color: var(--ink); }
.acc-card.inactive { opacity: .6; }
.acc-top { display: flex; gap: 10px; align-items: center; }
.acc-top b { display: block; }
.acc-top small { color: var(--muted); font-size: 12px; }
.acc-bal { font-size: 24px; font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; }
.label-link { float: left; font-size: 12px; font-weight: 600; color: var(--accent-ink); }

.conflict-box { border-radius: var(--radius); padding: 10px 12px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.conflict-box.ok { background: var(--green-soft); color: var(--green); flex-direction: row; align-items: center; gap: 6px; }
.conflict-box.info { background: var(--amber-soft); color: var(--amber); }
.conflict-box.bad { background: var(--red-soft); color: var(--red); border: 1px solid color-mix(in srgb, var(--red) 25%, transparent); }
.conflict-box .cf-row.bad { font-weight: 600; }
.doc-kind { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }

.lic-banner { flex: none; width: calc(100% - 2 * var(--gutter)); max-width: 1392px; margin: 12px auto 0; padding: 10px 16px; border-radius: var(--radius-card); background: var(--accent-soft); color: var(--accent-ink); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.lic-banner.warn { background: var(--amber-soft); color: var(--amber); }
.lic-banner.update { background: var(--green-soft); color: var(--green); }
.lic-banner a { font-weight: 600; }
.lic-banner.reload .btn { margin-inline-start: auto; }

.levels-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.levels-head h3 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 6px; color: var(--ink); }
.lv-list { list-style: none; margin: 0; padding: 0; position: relative; }
.lv { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; position: relative; }
.lv:not(:last-child)::before { content: ''; position: absolute; inset-inline-start: 13px; top: 34px; bottom: -6px; width: 2px; background: var(--line); }
.lv-dot { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; position: relative; z-index: 1;
  background: var(--gray-soft); color: var(--ink-2); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); }
.lv.cur .lv-dot { background: var(--accent); color: var(--on-accent); box-shadow: 0 0 0 1px var(--accent), 0 0 0 5px var(--accent-soft); }
.lv-main { flex: 1; min-width: 0; }
.lv-title { font-size: 14px; }
.lv-sub { color: var(--ink-2); font-size: 12.5px; }
.lv-result { margin-top: 3px; font-size: 13px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 3px 8px; display: inline-block; }
.lv-notes { font-size: 12.5px; white-space: pre-wrap; }
.lv-act { display: flex; gap: 2px; opacity: .55; }
.lv:hover .lv-act { opacity: 1; }

.rep-bar { gap: 12px; }
.rep-bar .chips { display: flex; gap: 6px; flex-wrap: wrap; }
.rep-tabs { margin: 0 0 14px; }
.table.rep td, .table.rep th { white-space: nowrap; }
.rep-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
.table.rep th.num, .table.rep td.num { text-align: left; direction: ltr; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table.rep td.num:first-child { text-align: right; direction: rtl; }
.table.rep tfoot td { background: var(--surface-2); border-top: 2px solid var(--line); }
.table.rep tbody tr.on td { background: var(--accent-soft); }
.table.rep td.bar-cell { white-space: nowrap; min-width: 120px; }
.rbar { display: inline-block; vertical-align: middle; width: 80px; height: 8px; border-radius: 4px; background: var(--line-2); overflow: hidden; margin-left: 6px; }
.rbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--bright)); border-radius: 4px; }
.rep-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 0 18px; }
.rep-drill .card { border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.rep-note { font-size: 12.5px; margin: -6px 2px 18px; }

.fee-guide { display: flex; flex-direction: column; gap: 6px; }
.fee-note { font-size: 12.5px; padding: 8px 12px; border-radius: var(--radius); line-height: 1.6; }
.fee-note.tone-gray { background: var(--gray-soft); color: var(--ink-2); }
.fee-note.tone-red { background: var(--red-soft); color: var(--red); font-weight: 600; }
.minfee-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 14px; margin: 10px 0; }
.minfee-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-2); }
.fee-calc .form-grid, .court-fees .form-grid { margin-top: 10px; }
.calc-pair { align-items: start; }
.court-fees .row-actions, .fee-calc .row-actions { flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.court-fees .row-actions select, .fee-calc .row-actions select { flex: 1 1 220px; min-width: 0; }
.fee-calc-table { margin-top: 12px; }
.fee-calc-total td { border-top: 2px solid var(--line); }
.exec-acts { white-space: nowrap; width: 1%; }
.exec-acts .btn { padding: 3px 8px; }

.sub-plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-top: 8px; }
.sub-plan { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; background: var(--surface); display: flex; flex-direction: column; gap: 6px; transition: border-color .15s; }
.sub-plan.on { border-color: var(--accent); background: var(--accent-soft); }
.sub-plan small { color: var(--muted); font-size: 12px; }
.sub-plan-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.sub-banner { display: flex; align-items: center; gap: 6px; border-radius: var(--radius); padding: 8px 12px; font-size: 13px; margin: 10px 0; background: var(--accent-soft); color: var(--accent-ink); }
.sub-banner.warn { background: var(--amber-soft); color: var(--amber); }
[data-subscription] .info-box, [data-subscription] .table, [data-sub-body] .info-box { margin-top: 10px; }

/* ============================== 11. Sharia, inheritance, administrative court ============================== */
.inh-actions { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.inh-layout { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.25fr); gap: 18px; align-items: start; }
.inh-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.heir-group { margin-top: 10px; }
.heir-group > b { display: block; font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.heir-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.heir-in { display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 1px solid var(--line-2); background: var(--surface-2); border-radius: var(--radius); padding: 6px 10px;
  transition: border-color .15s, background .15s; }
.heir-in > span { font-size: 13px; }
.heir-in input[type=number] { width: 64px; height: auto; padding: 4px 6px; text-align: center; }
.heir-in .check { margin: 0; }
.heir-in.on { border-color: var(--accent); background: var(--accent-soft); }
.branch { display: grid; grid-template-columns: 1.4fr repeat(3, .7fr) 1.2fr auto; gap: 8px; align-items: end; padding: 10px 0; border-top: 1px solid var(--line-2); }
.branch:first-of-type { border-top: 0; }
.branch .check { grid-column: 1 / -2; }
.inh-empty, .adm-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--muted); text-align: center; padding: 40px 20px; }
.inh-empty p, .adm-empty p { margin: 0; }
.inh-table td, .inh-table th { white-space: nowrap; padding: 8px; }
.inh-table td.inh-heir { white-space: normal; min-width: 150px; }
.inh-heir small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.inh-table tfoot td { font-weight: 700; background: var(--surface-2); }
.inh-result .card { overflow-x: auto; }
.blocked { display: flex; flex-wrap: wrap; gap: 6px; }
.inh-notes ul { margin: 6px 0 0; padding-inline-start: 20px; }
.inh-notes li { margin: 3px 0; font-size: 13px; }
.inh-disclaimer { font-size: 12px; line-height: 1.7; }
.sh-rules ul { margin: 0; padding-inline-start: 20px; }
.adm-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.adm-result { border-inline-start: 4px solid var(--accent); }
.adm-due { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.adm-due b { font-size: 20px; color: var(--accent-ink); }
.adm-actions { margin-top: 14px; display: flex; gap: 8px; }
.adm-notes { margin: 6px 0 0; padding-inline-start: 20px; }
.adm-notes li { margin: 4px 0; font-size: 13px; line-height: 1.7; }
.adm-flow { list-style: none; margin: 0; padding: 0; }
.adm-flow li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.adm-flow li:last-child { border-bottom: 0; }
.adm-flow p { margin: 3px 0 0; color: var(--ink-2); font-size: 13px; line-height: 1.75; }
.adm-step { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: 13px; }

/* ============================== 12. AI assistant ============================== */
.ai-privacy { font-size: 12px; color: var(--muted); margin: 10px 0 0; display: flex; gap: 6px; align-items: flex-start; }
/* استيراد قضية من مستندات */
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.import-grid { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 24px; align-items: start; }
.import-files { position: sticky; top: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.drop-zone { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 28px 16px; text-align: center; cursor: pointer; border: 2px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface-2); color: var(--muted); font-size: 12.5px; transition: border-color .15s, background .15s; }
.drop-zone b { color: var(--ink); font-size: 14px; font-weight: 600; }
.drop-zone .drop-ic { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 6px; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent); }
.drop-zone:hover, .drop-zone.over, .drop-zone:focus-within { border-color: var(--accent); background: var(--accent-soft); }
.import-file { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.import-file + .import-file { margin-top: 8px; }
.import-ic { color: var(--muted); display: grid; }
.import-meta { min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.import-meta b { unicode-bidi: plaintext; text-align: start; flex: 1 1 100%; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-meta small { color: var(--muted); font-size: 11.5px; }
.import-state { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); }
.import-state.ok { color: var(--green); }
.import-state.warn { color: var(--amber); }
.import-state.bad { color: var(--red); }
.import-file select { grid-column: 1 / -1; grid-row: 2; padding-block: 5px; font-size: 12.5px; }
.import-ai { display: flex; align-items: flex-start; gap: 8px; line-height: 1.6; padding: 10px 12px; border-radius: var(--radius); font-size: 12.5px; background: var(--accent-soft); color: var(--ink); }
.import-ai.ok { background: var(--green-soft); color: var(--green); }
.import-ai.warn { background: var(--amber-soft); color: var(--amber); }
.import-ai.bad { background: var(--red-soft); color: var(--red); }
.import-ai[hidden] { display: none; }
.import-ai > svg, .import-ai > .spinner { flex: none; margin-top: 3px; }
.import-ai > span:not(.spinner) { flex: 1; min-width: 0; }
.import-ai .btn { flex: none; }
.import-client { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; }
.import-client select { flex: 1 1 200px; }
.seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: var(--radius); background: var(--surface-3); }
.seg[hidden] { display: none; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 5px 16px; border-radius: var(--radius); font-size: 13px; font-weight: 500; color: var(--muted); transition: background .15s, color .15s; }
.seg input:checked + span { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-accent); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.import-client .hint { flex: 1 1 100%; color: var(--green); font-size: 12.5px; }
.import-form [data-new-client][hidden] { display: none; }
.field.ai-filled > label::after { content: "من المستندات"; margin-inline-start: 8px; padding: 1px 7px; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent); font-size: 10.5px; font-weight: 600; }
.field.ai-filled input, .field.ai-filled select, .field.ai-filled textarea { border-color: var(--accent); }
@media (max-width: 860px) {
  .import-grid { grid-template-columns: minmax(0, 1fr); }
  .import-files { position: static; }
}
.ai-out { margin-top: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.ai-out-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.ai-text { white-space: pre-wrap; padding: 12px 14px; max-height: 340px; overflow-y: auto; font-size: 16px; line-height: 1.9; min-height: 60px; }
.ai-page { display: grid; grid-template-columns: 264px 1fr; gap: var(--gutter); height: calc(100dvh - 104px); min-height: 480px; }
.ai-side { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 16px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.ai-new { width: 100%; justify-content: center; }
.ai-side .nav-label { color: var(--muted); margin: 6px 4px 0; }
.ai-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -6px; padding: 0 6px; }
.ai-li { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius); cursor: pointer; color: var(--ink-2); }
.ai-li > .ic { flex: none; color: var(--muted); }
.ai-li span { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ai-li b { font-weight: 500; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-li small { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-li .icon-btn { opacity: 0; flex: none; }
.ai-li:hover { background: var(--surface-2); }
.ai-li:hover .icon-btn, .ai-li:focus-within .icon-btn, .ai-li.on .icon-btn { opacity: 1; }
.ai-li.on { background: var(--accent-soft); color: var(--ink); }
.ai-li.on > .ic { color: var(--accent); }
.ai-li:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ai-list-empty { color: var(--muted); font-size: 13px; padding: 8px 4px; margin: 0; }
.ai-side-note { display: flex; gap: 6px; align-items: center; font-size: 11.5px; color: var(--muted); margin: 0; }
.ai-main { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-card); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.ai-head { display: flex; align-items: center; gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--line); }
.ai-head-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ai-head-t b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-head-t small { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 4px; }
.ai-head-t small .ic { color: var(--accent); }
.ai-case { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.ai-case select { max-width: 260px; }
.ai-side-btn { display: none; }
.ai-scroll { flex: 1; overflow-y: auto; }
.ai-thread { max-width: 820px; margin: 0 auto; padding: 24px 20px 12px; display: flex; flex-direction: column; gap: 18px; }
.ai-msg { display: flex; gap: 10px; align-items: flex-start; animation: view-in .3s var(--ease) both; }
.ai-msg.me { justify-content: flex-end; }
.ai-msg.me .ai-bubble { background: var(--accent); color: var(--on-accent); border-radius: var(--radius) var(--radius) var(--radius) 0; box-shadow: var(--shadow-accent); padding: 10px 14px; max-width: 78%; line-height: 1.75; }
.ai-ava { width: 32px; height: 32px; flex: none; border-radius: 50%; }
.ai-ava img { width: 100%; height: 100%; display: block; }
.ai-msg.bot .ai-bubble { flex: 1; min-width: 0; line-height: 1.85; color: var(--ink); padding-top: 4px; }
.ai-bubble p { margin: 0 0 8px; }
.ai-bubble h4 { margin: 12px 0 6px; font-size: 15px; }
.ai-bubble ul, .ai-bubble ol { margin: 0 0 8px; padding-inline-start: 22px; }
.ai-bubble li { margin: 2px 0; }
.ai-bubble li::marker { color: var(--accent); }
.ai-bubble code { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 4px; padding: 0 4px; font-size: .92em; }
.ai-tools { display: flex; gap: 6px; align-items: center; margin-top: 2px; opacity: .55; transition: opacity .15s; }
.ai-msg.bot:hover .ai-tools, .ai-tools:focus-within, .ai-msg.err .ai-tools { opacity: 1; }
.ai-errtxt { display: flex; gap: 6px; align-items: center; color: var(--red); background: var(--red-soft); border-radius: var(--radius); padding: 8px 10px; }
.ai-typing { display: inline-flex; gap: 4px; padding: 8px 0; }
.ai-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: ai-dot 1.1s infinite ease-in-out; }
.ai-typing i:nth-child(2) { animation-delay: .15s; }
.ai-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes ai-dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.ai-hello { text-align: center; padding: 36px 8px 8px; }
.ai-hello-logo { width: 76px; height: 76px; border-radius: 50%; }
.ai-hello h1 { margin: 14px 0 6px; font-size: 26px; justify-content: center; }
.ai-hello > p { color: var(--muted); max-width: 520px; margin: 0 auto 24px; line-height: 1.8; }
.ai-sugs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ai-sug { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); cursor: pointer;
  font: inherit; text-align: start; transition: border-color .15s, background .15s; }
.ai-sug .ic { color: var(--accent); flex: none; margin-top: 2px; }
.ai-sug span { display: flex; flex-direction: column; gap: 2px; }
.ai-sug b { font-weight: 500; font-size: 14px; }
.ai-sug small { color: var(--muted); font-size: 12.5px; }
.ai-sug:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); background: var(--accent-soft); }
.ai-composer { max-width: 820px; width: calc(100% - 40px); margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; border: 1px solid var(--line); background: var(--input-bg);
  border-radius: var(--radius); padding: 8px; box-shadow: var(--shadow-soft); transition: border-color .15s, box-shadow .15s; }
.ai-composer:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.ai-composer textarea { flex: 1; border: 0; outline: 0; resize: none; background: transparent; font: inherit; color: var(--ink); line-height: 1.7; padding: 6px 8px; max-height: 200px; min-height: 0; box-shadow: none; }
.ai-composer textarea:focus { box-shadow: none; border: 0; }
.ai-send { width: 38px; height: 38px; flex: none; border: 0; border-radius: var(--radius); box-shadow: var(--shadow-accent); background: var(--accent); color: var(--on-accent); display: grid; place-items: center; cursor: pointer; transition: background .15s, transform .15s var(--spring); }
.ai-send:hover { background: var(--accent-hover); }
.ai-send.stop { background: var(--ink); color: var(--surface); }
.ai-send .ic { transform: scaleX(-1); }
.ai-send.stop .ic { transform: none; }
.ai-foot { text-align: center; font-size: 11.5px; color: var(--muted); margin: 8px 0 10px; }
.ai-status { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; margin-inline-end: 8px; }
.ai-status .ic { color: var(--accent); }
.ai-sources { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 6px; }
.ai-src { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 3px 10px; border-radius: var(--pill); border: 1px solid var(--line); color: var(--ink-2); background: var(--surface-2); }
.ai-src.case { background: var(--blue-soft); border-color: transparent; color: var(--blue); }
.ai-src.app { background: var(--green-soft); border-color: transparent; color: var(--green); }
.ai-src.web { background: var(--amber-soft); border-color: transparent; color: var(--amber); }
.ai-links { flex-basis: 100%; display: flex; flex-direction: column; gap: 4px; margin-top: 2px; }
.ai-links a { display: block; font-size: 12.5px; color: var(--ink-2); padding: 6px 10px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--surface); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-links a b { color: var(--accent-ink); font-weight: 600; margin-inline-end: 6px; direction: ltr; unicode-bidi: isolate; }
.ai-links a:hover { border-color: var(--accent); }
@media (max-width: 900px) {
  .ai-page { grid-template-columns: 1fr; height: calc(100dvh - 92px); position: relative; }
  .ai-side { position: absolute; inset: 0 0 0 auto; width: min(300px, 86%); z-index: 5; box-shadow: var(--shadow-pop); transform: translateX(110%); transition: transform .3s var(--ease); }
  .ai-page.side-open .ai-side { transform: none; }
  .ai-side-btn { display: inline-grid; }
  .ai-case select { max-width: 130px; }
  .ai-sugs { grid-template-columns: 1fr; }
  .ai-hello h1 { font-size: 21px; }
  .ai-composer { width: calc(100% - 20px); }
  .ai-thread { padding: 16px 12px 8px; }
  .ai-msg.me .ai-bubble { max-width: 88%; }
}

/* ============================== 13. Appearance picker ============================== */
.theme-picker { display: flex; flex-direction: column; gap: 16px; }
.theme-row { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.theme-lbl { min-width: 54px; font-weight: 600; color: var(--ink-2); padding-top: 6px; }
.theme-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; flex: 1; }
.swatch { display: flex; flex-direction: column; gap: 8px; padding: 6px 6px 8px; background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); cursor: pointer;
  font: inherit; color: var(--ink-2); text-align: center; transition: border-color .15s, transform .2s var(--spring), box-shadow .2s; }
.swatch:hover { border-color: var(--line-strong); }
.swatch.on { border-color: var(--accent); box-shadow: var(--ring); color: var(--ink); font-weight: 600; }
.swatch small { font-size: 12.5px; }
/* mini preview of a look: menu strip + card with a button */
.sw-prev { display: grid; grid-template-columns: 1fr 30%; height: 58px; border-radius: var(--radius); overflow: hidden; background: var(--sw-bg); border: 1px solid var(--line-2); }
.sw-prev > span:first-child { display: flex; flex-direction: column; gap: 5px; padding: 8px; }
.sw-prev > span:first-child i { display: block; height: 6px; border-radius: 3px; background: var(--sw-line); }
.sw-prev > span:first-child i:first-child { width: 70%; }
.sw-prev > span:first-child i:last-child { width: 44%; height: 12px; border-radius: 6px; background: var(--sw-accent); margin-top: auto; }
.sw-prev > span:last-child { background: var(--sw-m1); border-inline-start: 1px solid var(--sw-line); box-shadow: inset 0 -14px 0 -8px var(--sw-accent); }

/* ============================== 14. Login screens inside the office app ============================== */
body.auth-page { background: var(--surface); }
.auth-wrap { min-height: 100vh; width: 100%; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: var(--radius); padding: 32px; }
.auth-card h1 { font-size: 26px; margin-bottom: 14px; }
.auth-card .sub-plans { text-align: right; }
.auth-card .sub-plan-actions .btn { width: 100%; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-2); }
.auth-form .btn { justify-content: center; height: 44px; font-size: 15px; margin-top: 4px; }
.auth-err { color: var(--red); font-size: 13px; margin: 0; min-height: 1em; }
.auth-note { color: var(--muted); font-size: 12.5px; margin: 12px 0 0; }

/* ============================== 15. Jordan flag ============================== */
/* rf:allow-colour — the flag and its brass staff keep their real colours */
.jo-flag { margin-inline-start: auto; flex: none; position: relative; display: inline-block; width: 34px; height: 17px; border-radius: 4px; overflow: hidden; box-shadow: 0 0 0 1px rgba(255, 255, 255, .22), 0 2px 6px rgba(0, 0, 0, .35); }
.jo-flag svg { display: block; width: 100%; height: 100%; }
.jo-flag::after { content: ''; position: absolute; inset: 0; background: linear-gradient(120deg, rgba(255, 255, 255, .28) 0%, rgba(255, 255, 255, 0) 45%, rgba(0, 0, 0, .12) 100%); pointer-events: none; }
.jo-wave { margin-right: auto; flex: none; position: relative; display: flex; align-items: flex-start; height: 62px; margin-block: -11px -11px; direction: ltr; }
.jo-staff { width: 20px; height: 62px; display: flex; flex-direction: column; align-items: center; position: relative; z-index: 1; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .28)); }
.jo-crown { width: 18px; height: 14px; display: block; flex: none; margin-bottom: -1px; }
.jo-pole { width: 4px; flex: 1; border-radius: 1px; background: linear-gradient(90deg, #7a5c28, #e2c487 50%, #7a5c28); }
.jo-base { width: 20px; height: 7px; flex: none; background: linear-gradient(180deg, #e2c487, #9a7639 70%, #6e5222); clip-path: polygon(28% 0, 72% 0, 100% 100%, 0 100%); border-radius: 0 0 2px 2px; }
.jo-cloth { display: flex; width: 76px; height: 38px; margin-top: 13px; margin-left: -8px; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .22)); }
/* rf:end */
.jo-cloth i { flex: 1; height: 100%; background-image: var(--jo); background-size: calc(var(--n) * 100%) 100%; background-repeat: no-repeat; animation: jo-flutter 2.4s ease-in-out infinite; animation-delay: calc(var(--i) * -0.075s); }
.jo-cloth i:first-child { border-radius: 1px 0 0 1px; }
.jo-cloth i:last-child { border-radius: 0 3px 3px 0; }
@keyframes jo-flutter {
  0%, 100% { transform: translateY(calc(var(--i) * 0.13px)); filter: brightness(1); }
  25% { filter: brightness(1.12); }
  50% { transform: translateY(calc(var(--i) * -0.13px)); filter: brightness(.9); }
  75% { filter: brightness(1.05); }
}
@media (max-width: 600px) { .jo-wave { height: 46px; margin-block: -6px; } .jo-staff { height: 46px; width: 16px; } .jo-crown { width: 14px; height: 11px; } .jo-base { width: 16px; height: 6px; } .jo-cloth { width: 52px; height: 26px; margin-top: 10px; margin-left: -6px; } }

/* ============================== 16. Letterhead designer and signature ============================== */
.lhd { display: grid; grid-template-columns: minmax(340px, 420px) 1fr; gap: 18px; align-items: start; }
.lhd-side { display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 170px); overflow-y: auto; padding-inline-end: 4px; }
.lhd-side .panel > summary { padding: 12px 0; gap: 8px; }
.lhd-side .panel > summary::before { display: none; }
.lhd-side .panel[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.lhd-side .panel > :last-child { margin-bottom: 14px; }
.lhd-stage { position: sticky; top: 84px; padding: 16px; background: var(--paper-desk); }
.lhd-paper-wrap { width: 100%; overflow: hidden; display: flex; justify-content: center; }
.lhd-stage .center { text-align: center; margin: 12px 0 0; }
.lhd-tpls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lhd-tpl { display: flex; flex-direction: column; gap: 6px; padding: 6px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; text-align: start; font: inherit; color: var(--ink); transition: border-color .15s; }
.lhd-tpl:hover, .lhd-emb:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.lhd-tpl.on, .lhd-emb.on, .lhd-pal.on { border-color: var(--accent); box-shadow: var(--ring); }
.lhd-tpl.on { background: var(--accent-soft); }
.lhd-tpl-name { font-size: 12px; line-height: 1.4; }
.lhd-tpl-name b { color: var(--accent-ink); }
.lhd-embs { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; }
.lhd-emb small { font-size: 11px; text-align: center; line-height: 1.3; }
.lhd-pals { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px 0; }
.lhd-pal { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; font: inherit; color: var(--ink); text-align: start; }
.lhd-pal > span { width: 16px; height: 16px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px var(--line-strong); }
.lhd-pal > span + span { margin-inline-start: -10px; }
.lhd-pal small { font-size: 11.5px; line-height: 1.3; }
.lhd input[type=color] { padding: 3px; cursor: pointer; }
.lhd input[type=range] { height: auto; accent-color: var(--accent); }
.lhd-fields .field label { font-size: 12.5px; }
/* rf:allow-colour — previews of paper, emblems and signatures stay on white */
.lhd-paper { width: 794px; flex: none; background: var(--paper); box-shadow: 0 10px 30px rgba(15, 27, 45, .18), 0 1px 3px rgba(15, 27, 45, .1); }
.lhd-mini { display: block; height: 62px; overflow: hidden; background: var(--paper); border-radius: var(--radius-sm); border: 1px solid var(--line); pointer-events: none; }
.lhd-mini-in { display: block; width: 690px; padding: 8px 12px; zoom: .25; }
.lhd-emb { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); cursor: pointer; font: inherit; color: var(--paper-ink); }
.lhd-none { width: 40px; height: 40px; display: grid; place-items: center; color: #999; }
.sig-pad { display: block; width: 100%; aspect-ratio: 600 / 220; height: auto; background: var(--paper); border: 1.5px dashed var(--line-strong); border-radius: var(--radius); touch-action: none; cursor: crosshair; margin-bottom: 8px; }
.sig-current { min-height: 70px; display: flex; align-items: center; justify-content: center; margin: 10px 0 6px; padding: 10px; border-radius: var(--radius); background: var(--paper); border: 1px solid var(--line); }
/* rf:end */
.sig-tabs { gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.sig-current .pl-sigimg { margin: 0; }
@media (max-width: 1100px) { .lhd { grid-template-columns: 1fr; } .lhd-side { max-height: none; } .lhd-stage { position: static; } }

/* ============================== 17. Responsive ============================== */
@media (max-width: 1200px) {
  .editor-grid { grid-template-columns: 1fr; }
  .editor-preview { position: static; max-height: none; }
  .inh-layout { grid-template-columns: 1fr; }
}
@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: 1fr; }
  .cv-day { max-width: none; position: static; }
  .adm-layout { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .paper { padding: 40px 32px; }
  .table { display: block; overflow-x: auto; }
  .chip { display: none; }
}
@media (max-width: 600px) {
  body { font-size: 15px; }
  :root { --gutter: 12px; }
  h1, .page-head h1 { font-size: 20px; line-height: 30px; }
  .ai-top { display: none; }
  .quick-add .btn[data-qa-toggle] { font-size: 0; gap: 0; padding: 0 11px; }
  .card { padding: 16px; }
  .card > .card-head:first-child { margin: -16px -16px 0; padding: 16px 16px 12px; }
  .card.flush > .card-head:first-child { margin: 0; }
  .case-hero .tabs { margin: 12px -16px 0; }
  .table th, .table td { padding-inline: 14px; }
  .hero { gap: 10px; margin-bottom: 12px; }
  .hero h1 { font-size: 20px; }
  .hero > div { width: 100%; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi { gap: 8px; padding: 12px; }
  .kpi b { font-size: 18px; }
  .kpi-ic { display: none; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-card { padding: 16px; }
  .kpi-card .kpi-val { font-size: 22px; line-height: 32px; }
  .row-item { flex-wrap: wrap; gap: 6px 10px; }
  .ri-main { flex: 1 1 60%; min-width: 0; }
  .ri-side { width: 100%; justify-content: flex-start; }
  .icon-btn.sm { width: 36px; height: 36px; }
  .tpl-grid { grid-template-columns: 1fr; }
  .editor-toolbar { flex-wrap: nowrap; overflow-x: auto; top: 68px; }
  .editor-toolbar .btn { flex: none; }
  .modal, .modal-sm, .modal-md, .modal-lg { width: 100vw; }
  .modal-head, .modal-body, .modal-foot { padding-inline: 16px; }
  .modal-foot { flex-wrap: wrap; }
  .inline-form input[data-h=name] { width: 100%; }
  .rep-grid { grid-template-columns: 1fr; }
  .rep-tabs { margin-bottom: 10px; }
  .rbar { width: 48px; }
  .table.rep td.bar-cell { min-width: 90px; }
  .inh-grid { grid-template-columns: 1fr; }
  .branch { grid-template-columns: 1fr 1fr; }
  .branch .check { grid-column: 1 / -1; }
  #toast-root { left: 12px; right: 12px; bottom: 12px; }
}

/* ============================== 19. Shape and motion ============================== */
/* Large surfaces use the card corner */
.kpi-card, .dash-hero, .dh-next, .cv-bar, .cv-frame, .cv-day, .acc-card, .ai-side, .ai-main, .editor-toolbar, .qa-menu, .gs-results, .combo-pop, .tpl-card, .sub-plan,
.law-card, .court-item, .panel, .swatch, .drop-zone, .ai-composer, .import-file, .tl-ev, .wk-day { border-radius: var(--radius-card); }

/* The page content rises in as a short sequence; grids follow one card after the other */
#view > * { animation: view-in .45s var(--ease) both; }
#view > *:nth-child(2) { animation-delay: .05s; }
#view > *:nth-child(3) { animation-delay: .1s; }
#view > *:nth-child(n+4) { animation-delay: .15s; }
.kpi-grid > *, .kpis > *, .bento > *, .acc-grid > *, .tpl-grid > *, .law-grid > * { animation: rise .5s var(--ease) both; }
:is(.kpi-grid, .kpis, .bento, .acc-grid) > :nth-child(2) { animation-delay: .07s; }
:is(.kpi-grid, .kpis, .bento, .acc-grid) > :nth-child(3) { animation-delay: .14s; }
:is(.kpi-grid, .kpis, .bento, .acc-grid) > :nth-child(4) { animation-delay: .21s; }
:is(.kpi-grid, .kpis, .bento, .acc-grid) > :nth-child(n+5) { animation-delay: .28s; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.modal-body > * { animation: view-in .4s var(--ease) .08s both; }

/* Press ripple on buttons, tabs and menu links */
.btn, .tab, .chip-btn, .icon-btn, .menu-btn { position: relative; overflow: hidden; }
.btn::after, .tab::after, .chip-btn::after, .icon-btn::after, .menu-btn::after, .sidebar nav a::after { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, currentColor 10%, transparent 10.5%) center / 1200% 1200% no-repeat; transition: background-size .6s var(--ease), opacity .9s; }
.btn:active::after, .tab:active::after, .chip-btn:active::after, .icon-btn:active::after, .menu-btn:active::after, .sidebar nav a:active::after { background-size: 0 0; opacity: .14; transition: none; }

/* Cards that open something lift on hover */
.kpi-card, .acc-card, .tpl-card, .law-card, .court-item, .wk-day, .sub-plan { transition: transform .28s var(--ease), box-shadow .28s var(--ease), border-color .2s; }
.kpi-card:hover, .acc-card:hover, .tpl-card:hover, .law-card:hover, .wk-day:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.kpi-ic { transition: transform .35s var(--spring); }
.kpi-card:hover .kpi-ic, a.kpi:hover .kpi-ic, .acc-card:hover .kpi-ic { transform: scale(1.08); }
.kpi-bars i { transform-origin: bottom; animation: bar-grow .6s var(--ease) both; }
.kpi-bars i:nth-child(2) { animation-delay: .05s; } .kpi-bars i:nth-child(3) { animation-delay: .1s; } .kpi-bars i:nth-child(4) { animation-delay: .15s; }
.kpi-bars i:nth-child(5) { animation-delay: .2s; } .kpi-bars i:nth-child(6) { animation-delay: .25s; } .kpi-bars i:nth-child(7) { animation-delay: .3s; }
@keyframes bar-grow { from { transform: scaleY(0); } }
.kpi-meter i, .rbar i { transform-origin: right; animation: meter-grow .9s var(--ease) .2s both; }
[dir=ltr] .kpi-meter i, [dir=ltr] .rbar i { transform-origin: left; }
@keyframes meter-grow { from { transform: scaleX(0); } }

/* Side menu: links come in one after the other; the open page settles in; urgent counts pulse */
.sidebar nav a { animation: nav-in .4s var(--ease) both; animation-delay: calc(var(--n, 0) * .02s); }
@keyframes nav-in { from { opacity: 0; transform: translateX(14px); } }
.sidebar nav a.on { animation: nav-on .35s var(--ease); }
@keyframes nav-on { from { transform: scale(.95); opacity: .6; } }
.nav-count.red { animation: pulse 2.2s ease-out infinite; }
@keyframes pulse { from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--red) 60%, transparent); } 70%, to { box-shadow: 0 0 0 7px color-mix(in srgb, var(--red) 0%, transparent); } }

.user-chip .avatar { transition: box-shadow .25s var(--ease); }
.user-chip:hover .avatar { box-shadow: 0 0 0 4px var(--accent-soft); }
.ai-top .ic { transition: transform .5s var(--spring); }
.ai-top:hover .ic { transform: rotate(12deg) scale(1.1); }

/* The dashboard panel: two fine ring groups drift slowly behind the text, and a gold rule marks its start edge */
.dash-hero { position: relative; overflow: hidden; isolation: isolate; }
.dash-hero::before, .dash-hero::after { content: ''; position: absolute; z-index: -1; border-radius: 50%; border: 1px solid var(--menu-line); opacity: .32;
  box-shadow: 0 0 0 34px var(--menu-ring), 0 0 0 35px var(--menu-line), 0 0 0 70px var(--menu-ring), 0 0 0 71px var(--menu-line); animation: drift 18s ease-in-out infinite alternate; }
.dash-hero::before { width: 320px; height: 320px; inset-inline-end: -90px; top: -150px; }
.dash-hero::after { width: 220px; height: 220px; inset-inline-end: 160px; bottom: -150px; animation-duration: 24s; animation-direction: alternate-reverse; }
@keyframes drift { to { transform: translate(28px, 18px) scale(1.08); } }
.dh-main::before { content: ''; position: absolute; inset-block: 28px; inset-inline-start: 0; width: 3px; border-radius: 3px; background: var(--gold); transform-origin: top; animation: rule-in .7s var(--ease) .15s both; }
@keyframes rule-in { from { transform: scaleY(0); } }

/* Rank marks draw in: the rule under a page title and the bar on the open menu link */
.page-head h1::after { transform-origin: right; animation: mark-in .5s var(--ease) .1s both; }
[dir=ltr] .page-head h1::after { transform-origin: left; }
@keyframes mark-in { from { transform: scaleX(0); } }
.sidebar nav a.on::before { animation: rule-in .3s var(--ease) both; }

/* Table rows follow the page in, top rows first; buttons settle when pressed */
.table tbody tr { animation: row-in .35s var(--ease) both; animation-delay: calc(min(var(--row, 0), 10) * .025s); }
.table tbody tr:nth-child(1) { --row: 1; } .table tbody tr:nth-child(2) { --row: 2; } .table tbody tr:nth-child(3) { --row: 3; } .table tbody tr:nth-child(4) { --row: 4; }
.table tbody tr:nth-child(5) { --row: 5; } .table tbody tr:nth-child(6) { --row: 6; } .table tbody tr:nth-child(7) { --row: 7; } .table tbody tr:nth-child(n+8) { --row: 8; }
@keyframes row-in { from { opacity: 0; } }
.btn { transition: background .18s, border-color .18s, color .18s, box-shadow .18s, transform .12s; }
.btn:active { transform: scale(.98); }

/* Small confirmations */
.check-btn.on { animation: tick .32s var(--spring); }
@keyframes tick { from { transform: scale(.6); } }
.empty > svg.ic:first-child { animation: float 3.6s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px); } }
.badge, .nav-count, .count { transition: background .2s, color .2s; }

/* ============================== 20. Page polish ============================== */
/* Rhythm: the page content starts one gutter under the top bar */
#view { padding-top: var(--gutter); }
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

/* Tables: a quiet header band; the row under the pointer gets a primary mark at its start edge */
.table th { background: var(--surface-2); color: var(--ink-2); font-weight: 600; padding: 14px 20px; }
.table td:first-child { position: relative; }
.table.hover tbody tr td:first-child::before { content: ''; position: absolute; inset-block: 10px; inset-inline-start: 0; width: 3px; border-radius: 3px; background: var(--accent);
  transform: scaleY(0); transition: transform .2s var(--ease); }
.table.hover tbody tr:hover td:first-child::before, .table tbody tr.on td:first-child::before { transform: scaleY(1); }
.table.hover tbody tr:hover, .table.hover tbody tr:hover td { background: var(--surface-2); }

/* Number cards: up to six in one row, so no card is left alone on a second row */
.kpis { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.kpi b { font-weight: 600; color: var(--ink); }

/* Fields: a soft outer ring shows the field in use */
input:focus, select:focus, textarea:focus { outline: none; box-shadow: var(--ring), 0 0 0 3px var(--accent-soft); }
input:is([type=checkbox], [type=radio], [type=range], [type=color], [type=file]):focus { box-shadow: none; }
input:is([type=checkbox], [type=radio], [type=range], [type=color], [type=file]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.global-search input:focus, .search-box input:focus, .combo input:focus { outline: none; }
.ai-composer textarea:focus { box-shadow: none; }
.global-search { transition: box-shadow .2s var(--ease); border-radius: var(--radius); }

/* Cards and sections */
.card-head h2, .card > h2 { font-weight: 600; }
.case-hero { background: linear-gradient(var(--accent), var(--accent)) top / 100% 3px no-repeat, var(--surface); }
.empty > svg.ic:first-child { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.disclaimer { display: block; line-height: 1.7; }
.disclaimer .ic { vertical-align: -2px; margin-inline-end: 6px; }

/* Template cards: the icon sits in a tinted tile that takes the primary colour under the pointer */
.tpl-card > svg.ic:first-child { width: 36px; height: 36px; padding: 8px; margin-bottom: 6px; border-radius: var(--radius); background: var(--accent-soft); box-sizing: border-box;
  transition: background .2s, color .2s; }
.tpl-card:hover > svg.ic:first-child { background: var(--accent); color: var(--on-accent); }
.tpl-card.office > svg.ic:first-child { background: var(--gold-soft); color: var(--gold-ink); }
.tpl-card.office:hover > svg.ic:first-child { background: var(--gold); color: var(--on-gold); }

/* Activity log rows answer the pointer */
.act-row { padding: 8px 10px; border-radius: var(--radius); transition: background .15s; }
.act-row:hover { background: var(--surface-2); }

/* Phone tables scroll sideways; the first cell keeps a readable width */
@media (max-width: 700px) { .table td:first-child { min-width: 150px; } }

/* Sign-in panel: a gold rule beside the headline */
.ra-art-body { position: relative; padding-inline-start: 22px; }
.ra-art-body::before { content: ''; position: absolute; inset-block: 6px; inset-inline-start: 0; width: 3px; border-radius: 3px; background: var(--gold); }

/* Data on its way: a thin gold line runs under the top edge while a screen loads its records */
body.is-loading::before { content: ''; position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 200; background: linear-gradient(90deg, transparent, var(--gold), transparent) 0 0 / 40% 100% no-repeat; animation: load-run 1s linear infinite; }
@keyframes load-run { from { background-position: -40% 0; } to { background-position: 140% 0; } }
body.is-loading #view { opacity: .6; transition: opacity .2s; }
.list-more { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 14px 0 4px; font-size: .86rem; }

/* Letterhead designer: the A4 preview must not push the page wider than the window */
.lhd > * { min-width: 0; }

/* ============================== 18. Reduced motion and print ============================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .sidebar, .topbar, .nav-scrim, .jo-wave { display: none !important; }
  .main { margin: 0 !important; }
}
