/* RuleFirm — office app design system (December 2026)
   One token system for every screen. Colours live only in the token blocks at the top;
   every rule below uses var(--…). Looks: blue (default), emerald, wine, indigo, graphite — 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: #F3F6FA; --surface: #FFFFFF; --surface-2: #F7F9FC; --surface-3: #EEF3F9; --input-bg: #FFFFFF;
  --ink: #0F1B2D; --ink-2: #3B4A61; --muted: #6B7A90;
  --line: #E2E8F0; --line-2: #EDF1F6; --line-strong: #C9D3E1;
  /* look: blue */
  --accent: #0B5CD5; --accent-hover: #0A4FB8; --accent-ink: #0A4FB8; --accent-soft: #E8F1FD; --on-accent: #FFFFFF;
  --bright: #3BA0FF; --hl-soft: #E6F4FF; --hl-ink: #0B63C4;
  --menu-1: #071A3A; --menu-2: #0A3A7A; --menu-3: #0E5CC0;
  /* side menu text on the gradient (same in every look) */
  --menu-ink: #DCE6F5; --menu-muted: #93A6C4; --menu-hover: rgba(255, 255, 255, .08); --menu-on: rgba(255, 255, 255, .15); --menu-line: rgba(255, 255, 255, .1); --menu-white: #FFFFFF;
  /* status */
  --green: #16835A; --green-soft: #E5F5EE;
  --red: #C8322B; --red-hover: #A9271F; --red-soft: #FDECEB;
  --amber: #B96A00; --amber-soft: #FFF3DF;
  --blue: #1F63D6; --blue-soft: #E8F0FD;
  --teal: #0F7B7B; --teal-soft: #E0F3F2;
  --gray-soft: #EEF2F7; --gray-ink: #4A5869;
  /* surfaces that show paper stay white in every mode */
  --paper: #FFFFFF; --paper-ink: #1A1A1A; --paper-desk: #DDE3EC;
  /* depth */
  --shadow-pop: 0 18px 48px -12px rgba(15, 27, 45, .28), 0 2px 6px rgba(15, 27, 45, .06);
  --shadow-soft: 0 1px 2px rgba(15, 27, 45, .05);
  --shadow-card: 0 22px 44px -28px rgba(15, 27, 45, .4), 0 1px 2px rgba(15, 27, 45, .04);
  --shadow-side: -24px 0 70px rgba(5, 10, 20, .22);
  --scrim: rgba(7, 18, 38, .5);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7A90' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  /* compatibility names used by older markup */
  --brand: var(--accent); --brand-2: var(--accent-ink); --brand-soft: var(--accent-soft);
  --gold: var(--bright); --gold-ink: var(--hl-ink); --gold-soft: var(--hl-soft); --on-gold: var(--on-accent);
  --sub: var(--muted); --head-bg: var(--surface-3); --row-hover: var(--surface-2);
  --side: var(--menu-1); --side-2: var(--menu-on);
  /* shape, type, motion */
  --radius: 20px; --radius-sm: 10px; --pill: 999px;
  --ctl-h: 40px; --ctl-h-sm: 32px;
  --side-w: 248px; --nav-pad: 12px;
  --font: 'IBM Plex Sans Arabic', 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --spring: cubic-bezier(.22, 1.2, .36, 1);
}
:root[data-mode=dark] {
  color-scheme: dark;
  --bg: #0A1220; --surface: #101B2C; --surface-2: #152236; --surface-3: #1A2840; --input-bg: #0D1726;
  --ink: #E7EEF8; --ink-2: #B3C0D3; --muted: #8293AB;
  --line: #22324A; --line-2: #1B2A3F; --line-strong: #33486A;
  --accent: #4C9BFF; --accent-hover: #6AAEFF; --accent-ink: #7DB6FF; --accent-soft: #13294A; --on-accent: #04101F;
  --bright: #4C9BFF; --hl-soft: #132C4D; --hl-ink: #8CC3FF;
  --menu-1: #060E1C; --menu-2: #0A1F44; --menu-3: #0D2C5E;
  --green: #4ADE9B; --green-soft: #0F2E22;
  --red: #FF8A80; --red-hover: #FFA59D; --red-soft: #3A1518;
  --amber: #FFB547; --amber-soft: #3A2A0E;
  --blue: #7DB6FF; --blue-soft: #13294A;
  --teal: #5FD4D4; --teal-soft: #0E2F31;
  --gray-soft: #1C2A3E; --gray-ink: #B3C0D3;
  --paper-desk: #1A2840;
  --shadow-pop: 0 18px 48px -12px rgba(0, 0, 0, .65), 0 0 0 1px rgba(255, 255, 255, .04);
  --shadow-soft: none;
  --shadow-card: 0 22px 44px -26px rgba(0, 0, 0, .7);
  --shadow-side: -24px 0 70px rgba(0, 0, 0, .5);
  --scrim: rgba(2, 6, 14, .66);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238293AB' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* look: emerald */
:root[data-accent=emerald] {
  --accent: #0E7C66; --accent-hover: #0B6754; --accent-ink: #0B6754; --accent-soft: #E3F4EF;
  --bright: #22B896; --hl-soft: #DDF7F0; --hl-ink: #0A6B57;
  --menu-1: #03211B; --menu-2: #07463A; --menu-3: #0B6E5A;
}
:root[data-mode=dark][data-accent=emerald] {
  --accent: #34C7A5; --accent-hover: #52D6B7; --accent-ink: #5FD9BC; --accent-soft: #0F2C27; --on-accent: #03140F;
  --bright: #34C7A5; --hl-soft: #0F302A; --hl-ink: #6FE0C5;
  --menu-1: #020F0C; --menu-2: #052A23; --menu-3: #083B31;
}
/* look: wine */
:root[data-accent=wine] {
  --accent: #9B1C3C; --accent-hover: #821632; --accent-ink: #861834; --accent-soft: #FBE9EE;
  --bright: #E0577A; --hl-soft: #FCE8EE; --hl-ink: #8E1B3A;
  --menu-1: #23050F; --menu-2: #520E24; --menu-3: #85193A;
}
:root[data-mode=dark][data-accent=wine] {
  --accent: #F0708F; --accent-hover: #F48CA5; --accent-ink: #F58FA8; --accent-soft: #33141D; --on-accent: #2A0610;
  --bright: #F0708F; --hl-soft: #3A1621; --hl-ink: #F7A3B7;
  --menu-1: #120408; --menu-2: #330A18; --menu-3: #4A0F23;
}
/* look: indigo */
:root[data-accent=indigo] {
  --accent: #5B3FD6; --accent-hover: #4A30BD; --accent-ink: #4A30BD; --accent-soft: #EEEAFD;
  --bright: #8B7BFF; --hl-soft: #F0EDFF; --hl-ink: #4D33C4;
  --menu-1: #120A36; --menu-2: #2A1A74; --menu-3: #4A31C2;
}
:root[data-mode=dark][data-accent=indigo] {
  --accent: #9D8CFF; --accent-hover: #B3A6FF; --accent-ink: #B5A9FF; --accent-soft: #211A45; --on-accent: #120A33;
  --bright: #9D8CFF; --hl-soft: #251D4D; --hl-ink: #C4BAFF;
  --menu-1: #09061C; --menu-2: #1C144A; --menu-3: #291D66;
}
/* look: graphite (neutral greys with an amber accent) */
:root[data-accent=graphite] {
  --bg: #F4F5F7; --surface-2: #F8F9FA; --surface-3: #EFF1F4; --line: #E3E6EB; --line-2: #EEF0F3; --line-strong: #CDD2DA;
  --ink: #111827; --ink-2: #374151; --muted: #6B7280;
  --accent: #1F2937; --accent-hover: #111827; --accent-ink: #B45309; --accent-soft: #F1F2F4;
  --bright: #D97706; --hl-soft: #FEF3E2; --hl-ink: #B45309;
  --menu-1: #0B0F17; --menu-2: #1A212D; --menu-3: #2B3442;
}
:root[data-mode=dark][data-accent=graphite] {
  --bg: #0C0E12; --surface: #14171D; --surface-2: #1A1E25; --surface-3: #20252E; --input-bg: #111419;
  --ink: #ECEEF1; --ink-2: #BAC0CA; --muted: #8B93A0; --line: #2A2F38; --line-2: #22262E; --line-strong: #3A414D;
  --accent: #F59E0B; --accent-hover: #FBB13C; --accent-ink: #FBBF4D; --accent-soft: #2A2416; --on-accent: #1A1203;
  --bright: #F59E0B; --hl-soft: #2E2511; --hl-ink: #FCC65E;
  --menu-1: #05070B; --menu-2: #11151C; --menu-3: #1A2029;
  --gray-soft: #22262E; --gray-ink: #BAC0CA; --paper-desk: #20252E;
}

/* ============================== 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); font-size: 14px; line-height: 22px; -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.35; }
h1 { font-size: 28px; line-height: 38px; font-weight: 700; letter-spacing: -.2px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 16px; line-height: 24px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 15px; font-weight: 600; }
code { background: var(--gray-soft); padding: 1px 6px; border-radius: 6px; 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: 12px; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.center { text-align: center; }

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

/* Side menu: deep gradient panel with rounded inner corners */
.sidebar { width: var(--side-w); position: fixed; inset: 0 0 0 auto; z-index: 30; display: flex; flex-direction: column;
  background: linear-gradient(170deg, var(--menu-1) 0%, var(--menu-2) 62%, var(--menu-3) 100%); color: var(--menu-ink); }
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px 14px; color: var(--menu-white); text-decoration: none !important; overflow: hidden; white-space: nowrap; }
.brand-mark { flex: none; width: 40px; height: 40px; 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: 16px; font-weight: 700; letter-spacing: .2px; }
.brand small { display: block; font-size: 12px; color: var(--menu-muted); }
.brand-text { transition: opacity .2s; }
.sidebar nav { padding: 6px var(--nav-pad) 14px; display: flex; flex-direction: column; flex: 1; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--menu-line) transparent; }
.sidebar nav::-webkit-scrollbar { width: 4px; }
.sidebar nav::-webkit-scrollbar-thumb { background: var(--menu-line); border-radius: 4px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { margin: 18px 12px 6px; height: 18px; font-size: 11.5px; font-weight: 500; color: var(--menu-muted); white-space: nowrap; overflow: hidden;
  transition: opacity .2s, margin .3s var(--ease), height .3s var(--ease); }
.nav-group:first-child .nav-label { margin-top: 4px; }
.sidebar nav a { position: relative; display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border-radius: var(--pill);
  color: var(--menu-ink); font-weight: 400; text-decoration: none; overflow: hidden; white-space: nowrap; transition: background .15s, color .15s; }
.sidebar nav a span { transition: opacity .2s; }
.sidebar nav a .ic { color: currentColor; }
.sidebar nav a:hover { background: var(--menu-hover); color: var(--menu-white); }
.sidebar nav a.on { background: var(--menu-on); color: var(--menu-white); font-weight: 600; box-shadow: inset 0 0 0 1px var(--menu-line); }
.sidebar nav a.on::before { content: ''; position: absolute; inset-inline-start: 4px; top: 12px; bottom: 12px; width: 3px; border-radius: 3px; background: var(--bright); }
.nav-count { margin-inline-start: auto; height: 20px; line-height: 20px; min-width: 22px; padding: 0 7px; border-radius: var(--pill); text-align: center;
  font-style: normal; font-size: 11px; font-weight: 700; background: var(--menu-on); color: var(--menu-white); }
.nav-count:empty { display: none; }
.nav-count.red { background: var(--red); color: var(--menu-white); }
.nav-count.amber { background: var(--amber); color: var(--menu-1); }
.sidebar-foot { padding: 14px 20px; border-top: 1px solid var(--menu-line); color: var(--menu-muted); white-space: nowrap; overflow: hidden; }


.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
@media (min-width: 901px) { .sidebar { display: none; } }

/* Top header: brand, grouped menu with large panels, search and account */
.topbar { position: sticky; top: 0; z-index: 30; height: 68px; display: flex; align-items: center; gap: 24px; padding: 0 max(32px, calc((100% - 1376px) / 2));
  background: color-mix(in srgb, var(--surface) 86%, transparent); backdrop-filter: blur(16px) saturate(1.4); -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid var(--line); }
.top-brand { flex: none; display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 18px; text-decoration: none !important; }
.top-brand:hover { color: var(--ink); }
.top-brand .brand-mark { width: 36px; height: 36px; background: none; }
.topnav { display: flex; gap: 2px; height: 100%; align-items: center; }
.tn-group { position: relative; height: 100%; display: flex; align-items: center; }
.tn-btn { position: relative; display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; border: 0; border-radius: var(--pill); background: none;
  font: inherit; font-size: 14px; color: var(--ink-2); cursor: pointer; white-space: nowrap; transition: background .15s, color .15s; }
.tn-btn .ic { transition: transform .25s var(--ease); opacity: .7; }
.tn-btn:hover, .tn-group.open .tn-btn { background: var(--surface-3); color: var(--ink); }
.tn-group.open .tn-btn .ic { transform: rotate(180deg); }
.tn-group.on .tn-btn { color: var(--accent); font-weight: 600; }
.tn-group.on .tn-btn::after { content: ''; position: absolute; bottom: -15px; inset-inline: 14px; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent); }
.tn-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); }
.tn-dot[hidden] { display: none; }
.tn-panel { position: absolute; top: calc(100% - 4px); inset-inline-start: 0; z-index: 40; width: 320px; display: grid; gap: 2px; padding: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-pop);
  opacity: 0; visibility: hidden; transform: translateY(-6px) scale(.98); transform-origin: top right; transition: opacity .18s, transform .22s var(--ease), visibility 0s .2s; }
.tn-panel.wide { width: 560px; grid-template-columns: 1fr 1fr; }
.tn-group.open .tn-panel { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
@media (hover: hover) { .tn-group:not([data-hold]):hover .tn-panel { opacity: 1; visibility: visible; transform: none; transition-delay: .06s; } }
.tn-panel a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; color: var(--ink); text-decoration: none !important; transition: background .15s; }
.tn-panel a:hover { background: var(--surface-2); color: var(--ink); }
.tn-panel a.on { background: var(--accent-soft); }
.tn-ic { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); transition: background .15s, color .15s; }
.tn-panel a:hover .tn-ic, .tn-panel a.on .tn-ic { background: var(--accent); color: var(--on-accent); }
.tn-t { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.tn-t b { font-weight: 600; font-size: 14px; }
.tn-t small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tn-panel .nav-count { background: var(--accent-soft); color: var(--accent-ink); }
.tn-panel .nav-count.red { background: var(--red); color: var(--menu-white); }
.tn-panel .nav-count.amber { background: var(--amber); color: var(--menu-1); }
.top-end { margin-inline-start: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.top-end .quick-add { margin: 0; }
.ai-top { color: var(--accent); background: var(--accent-soft); }
.ai-top:hover { background: var(--accent); color: var(--on-accent); }

#view { position: relative; padding: 36px max(32px, calc((100% - 1376px) / 2)) 48px; width: 100%; }
/* The coloured band behind the top of every page */
#view::before, #view::after { content: ''; position: absolute; inset: 0 0 auto 0; height: var(--band-h, 250px); pointer-events: none; transition: height .3s var(--ease); }
#view::before { background: radial-gradient(560px 380px at 8% -30%, color-mix(in srgb, var(--bright) 42%, transparent), transparent 70%),
  linear-gradient(115deg, var(--menu-1) 0%, var(--menu-2) 55%, var(--menu-3) 100%); }
#view::after { background-image: linear-gradient(var(--menu-line) 1px, transparent 1px), linear-gradient(90deg, var(--menu-line) 1px, transparent 1px);
  background-size: 44px 44px; opacity: .5; -webkit-mask-image: linear-gradient(90deg, transparent, black 75%); mask-image: linear-gradient(90deg, transparent, black 75%); }
#view > * { position: relative; z-index: 1; }
body[data-page=assistant] #view::before, body[data-page=assistant] #view::after { height: 150px; }
/* One entrance per page: the page content rises in as a short sequence */
#view > * { animation: view-in .42s var(--ease) both; }
#view > *:nth-child(2) { animation-delay: .04s; }
#view > *:nth-child(3) { animation-delay: .08s; }
#view > *:nth-child(4) { animation-delay: .12s; }
#view > *:nth-child(n+5) { animation-delay: .16s; }
@keyframes view-in { from { opacity: 0; transform: translateY(10px); } }

.global-search { position: relative; flex: 0 1 260px; min-width: 150px; height: 40px; display: flex; align-items: center; gap: 8px; padding: 0 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--pill); color: var(--muted); transition: border-color .15s, box-shadow .15s, background .15s; }
.global-search:focus-within { border-color: var(--accent); background: var(--input-bg); box-shadow: var(--ring); }
.global-search kbd { margin-inline-start: auto; font: inherit; font-size: 11px; line-height: 18px; padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--muted); }
.global-search:focus-within { flex-basis: 360px; }
.global-search input { border: 0; min-width: 0; outline: 0; background: transparent; flex: 1; padding: 0; height: 100%; font: inherit; color: var(--ink); box-shadow: none; }
.gs-results { position: absolute; top: calc(100% + 8px); right: 0; left: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-pop); max-height: 420px; overflow: auto; padding: 6px; animation: pop .16s var(--ease); }
.gs-results a { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 10px; color: var(--ink); text-decoration: none; }
.gs-results a.on, .gs-results a:hover { background: var(--accent-soft); }
.gs-results a b { display: block; font-weight: 600; }
.gs-results a small { color: var(--muted); }
.quick-add { position: relative; }
.qa-menu { position: absolute; top: calc(100% + 8px); left: 0; z-index: 40; min-width: 220px; display: flex; flex-direction: column; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; 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: 9px 12px; font: inherit; color: var(--ink); text-align: right; border-radius: 10px; cursor: pointer; }
.qa-menu button:hover { background: var(--surface-3); }

.user-menu { position: relative; }
.user-chip { display: flex; align-items: center; gap: 10px; background: transparent; border: 0; border-radius: var(--pill); padding: 3px; cursor: pointer; font: inherit; color: var(--ink); }
.user-chip:hover { background: var(--surface-3); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: linear-gradient(140deg, var(--accent), var(--bright)); color: var(--on-accent); }
.um-text { display: flex; flex-direction: column; line-height: 1.25; text-align: right; }
@media (max-width: 1440px) { .um-text { display: none; } }
.um-text b { font-size: 13px; font-weight: 600; }
.um-text small { font-size: 12px; color: var(--muted); }
.um-menu { left: 0; min-width: 250px; }
.um-menu button { white-space: nowrap; }
.um-tag { margin-inline-start: auto; font-size: 11px; color: var(--muted); background: var(--gray-soft); border-radius: var(--pill); padding: 1px 8px; white-space: nowrap; }
.um-tag.on { color: var(--green); background: var(--green-soft); }


/* Menu button and the mobile side menu (up to 900px) */
.menu-btn, .nav-close, .nav-scrim { display: none; }
@media (max-width: 900px) {
  .menu-btn { display: inline-grid; place-items: center; flex: none; order: 99; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 12px; cursor: pointer;
    color: var(--menu-white); background: linear-gradient(150deg, var(--menu-2), var(--menu-3)); transition: transform .15s var(--ease); }
  .menu-btn .ic { transition: transform .3s var(--ease); }
  .menu-btn:hover .ic, .menu-btn:focus-visible .ic { transform: translateX(-2px); }
  .menu-btn:active { transform: scale(.92); }
  .sidebar { inset: 0 auto 0 0; width: min(300px, 86vw); border-radius: 0 24px 24px 0; transform: translateX(-105%); z-index: 50;
    transition: transform .5s var(--spring), box-shadow .4s; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-side); }
  .brand { padding: 24px 20px 16px; padding-inline-end: 64px; }
  .nav-close { display: grid; place-items: center; position: absolute; top: 24px; inset-inline-end: 16px; width: 38px; height: 38px; border-radius: 50%; z-index: 2;
    border: 1px solid var(--menu-line); background: var(--menu-hover); color: var(--menu-ink); cursor: pointer; transition: transform .3s var(--ease), background .15s; }
  .nav-close:hover { background: var(--menu-on); transform: rotate(90deg); }
  body.nav-open .sidebar nav a { animation: nav-in .45s var(--ease) both; animation-delay: calc(.12s + var(--n, 0) * .03s); }
  .nav-scrim { display: block; position: fixed; inset: 0; z-index: 45; background: var(--scrim); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
    opacity: 0; pointer-events: none; transition: opacity .35s var(--ease); }
  body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }
  .topnav, .global-search kbd { display: none; }
  .topbar { height: 60px; gap: 10px; padding: 0 16px; }
  .top-end { flex: 1; gap: 6px; }
  .global-search { flex: 1 1 auto; min-width: 0; }
  .global-search:focus-within { flex-basis: auto; }
  #view { padding: 24px 16px 32px; }
  .um-text { display: none; }
}
@keyframes nav-in { from { opacity: 0; transform: translateX(-16px); } }

/* ============================== 4. Controls ============================== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 16px; border-radius: var(--pill);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
  text-decoration: none !important; transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .1s; }
.btn:hover { background: var(--surface-3); border-color: var(--line-strong); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600;
  box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--accent) 70%, transparent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn.dark { background: var(--menu-1); border-color: var(--menu-1); color: var(--menu-white); font-weight: 600; }
.btn.dark:hover { background: var(--menu-2); border-color: var(--menu-2); color: var(--menu-white); }
.btn.danger { background: var(--red); border-color: var(--red); color: var(--on-accent); font-weight: 600; }
.btn.danger:hover { background: var(--red-hover); border-color: var(--red-hover); }
.btn.danger-ghost { color: var(--red); }
.btn.danger-ghost:hover { background: var(--red-soft); border-color: transparent; color: var(--red); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent-ink); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.ai-btn, .ai-top { background: var(--hl-soft); border-color: transparent; color: var(--hl-ink); font-weight: 600; gap: 6px; }
.btn.ai-btn:hover, .ai-top:hover { background: var(--bright); border-color: var(--bright); color: var(--on-accent); }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); cursor: pointer;
  transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn.sm { width: 28px; height: 28px; }
.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); border-radius: var(--radius-sm);
  padding: 9px 12px; outline: none; width: 100%; transition: border-color .15s, box-shadow .15s; }
input:hover, textarea:hover { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: var(--ring); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
textarea { resize: vertical; line-height: 1.7; padding: 10px 12px; }
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: 500; }
: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: 12px 36px;
  background-color: var(--input-bg); background-image: var(--chev); background-repeat: no-repeat; background-size: 14px; 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(--line-strong); }
select:disabled, input:disabled { opacity: .6; 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: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); padding: 4px; margin-block: 4px;
    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 12px; border-radius: 8px; 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: 600; }
  select option::checkmark { order: 1; margin-inline-start: auto; color: var(--accent); content: "✓"; }
  select option:disabled { opacity: .5; cursor: default; }
  select optgroup { font-weight: 600; color: var(--muted); font-size: 12px; padding: 6px 8px 2px; }
}
select.sm, input.sm, .rules-row select, .rules-row input, .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, .rules-row select, .cv-bar select, .ai-case select, .stage-select { padding-block: 0; padding-inline: 10px 30px; background-position: left 10px center; background-size: 12px; }
.rules-row input, input.sm { padding-block: 0; }
.stage-select { width: auto; }

/* combo: text input with suggestions, same look as the select */
.combo { position: relative; }
.combo > input[data-combo] { width: 100%; padding-inline-end: 36px; background-color: var(--input-bg); background-image: var(--chev); background-repeat: no-repeat;
  background-size: 14px; background-position: left 12px center; }
[dir=ltr] .combo > input[data-combo] { background-position: right 12px center; }
.combo > input.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; scrollbar-width: thin; padding: 4px; font-family: var(--font); font-size: 14px;
  border: 1px solid var(--line); border-radius: 12px; 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 12px; border-radius: 8px; 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: 600; }
.combo-opt.sel::after { content: "✓"; margin-inline-start: auto; color: var(--accent); }
.combo-opt.sel.active { background: color-mix(in srgb, var(--accent-soft) 70%, var(--surface-3)); }
.combo-empty { padding: 10px 12px; color: var(--muted); font-size: 13px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 13px; font-weight: 500; color: var(--ink); }
.field .hint { color: var(--muted); font-size: 12px; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.req { color: var(--red); }
.form-section { font-weight: 600; font-size: 14px; color: var(--ink); border-bottom: 1px solid var(--line-2); padding: 8px 0 6px; margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; }
.check.sm { font-size: 12.5px; gap: 5px; 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: 12px; padding: 12px 14px; }
.calc-out, .tafqeet-out { background: var(--hl-soft); border-radius: 12px; padding: 10px 14px; }
.calc-out { font-size: 13.5px; }
.calc-out:empty { display: none; }
.tafqeet-out { font-size: 17px; min-height: 48px; }
.hint-line { color: var(--muted); font-size: 12.5px; margin: 0 0 10px; }
.disclaimer { font-size: 12.5px; color: var(--amber); background: var(--amber-soft); border-radius: 10px; padding: 8px 12px; margin: 14px 0 0; display: flex; gap: 6px; align-items: flex-start; }

/* chips and segmented buttons */
.chips { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: var(--pill); background: var(--surface-2); margin-bottom: 12px; }
.chip-btn { height: 30px; padding: 0 14px; border: 0; border-radius: var(--pill); background: transparent; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer;
  transition: background .2s var(--ease), color .15s; }
.chip-btn:hover { color: var(--ink); }
.chip-btn.on { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.chip-check { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); border-radius: var(--pill); padding: 3px 12px; font-size: 13px; cursor: pointer; }
.scope-chips { margin: 12px 0 0; }
.tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tag { font-size: 11.5px; background: var(--gray-soft); color: var(--ink-2); border-radius: var(--pill); padding: 0 8px; }

/* badges and tones */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 10px; border-radius: var(--pill); font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge.plain::before { display: none; }
.badge.plain { border-radius: 6px; padding: 0 8px; font-weight: 600; }
.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: 20px; line-height: 20px; padding: 0 8px; border-radius: var(--pill); background: var(--gray-soft); color: var(--muted); font-size: 12px; font-weight: 600; }
.spinner { display: inline-block; width: 12px; height: 12px; 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: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 20px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card > .card-head:first-child { margin: -20px -20px 16px; padding: 14px 20px; min-height: 56px; border-bottom: 1px solid var(--line-2); }
.card-head h2 { font-size: 16px; font-weight: 600; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-head:first-child { margin: 0; }
.card.flush > .list { padding: 0 20px; }
.card.flush > .card-foot { padding: 12px 20px; border-top: 1px solid var(--line-2); text-align: center; font-size: 13px; }
.card.toolbar { padding: 12px 16px; }
.card.fin-strip { padding: 14px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; min-height: 86px; color: var(--menu-white); }
.page-head h1 { color: var(--menu-white); font-size: 32px; line-height: 1.25; font-weight: 700; letter-spacing: -.3px; }
.page-head p { margin: 6px 0 0; color: var(--menu-ink); opacity: .85; }
.page-head .back, .page-head a:not(.btn) { color: var(--menu-ink); }
.page-head .btn { border-color: var(--menu-line); background: var(--menu-hover); color: var(--menu-white); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.page-head .btn:hover { background: var(--menu-on); color: var(--menu-white); }
.page-head .btn.primary { border-color: transparent; background: var(--menu-white); color: var(--menu-1); box-shadow: 0 10px 24px -12px var(--menu-1); }
.page-head .btn.primary:hover { background: var(--menu-ink); color: var(--menu-1); }
.page-head .badge { background: var(--menu-on); color: var(--menu-white); }
.page-head .muted, .page-head small { color: var(--menu-muted); }
.page-head + .tabs.page-tabs { position: relative; }
.head-actions { display: flex; gap: 8px; 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: 16px; }
.grid-2 > .card { margin-bottom: 16px; }
.hero { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; margin-bottom: 20px; }
.hero h1 { font-size: 26px; }
.hero p { margin: 2px 0 0; }
.alert-card { border-color: color-mix(in srgb, var(--amber) 35%, var(--line)); border-inline-start: 4px solid var(--amber); }
.alert-card h2 { color: var(--amber); }
.welcome { background: linear-gradient(135deg, var(--accent-soft), var(--surface) 70%); border-color: color-mix(in srgb, var(--accent) 22%, var(--line)); }
.welcome p { margin: 6px 0 0; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; color: var(--ink); text-decoration: none !important; }
a.kpi:hover, .kpi-btn:hover { border-color: var(--line-strong); }
.kpi b { display: block; font-size: 26px; line-height: 34px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-size: 12.5px; }
.kpi-ic { width: 36px; height: 36px; border-radius: 12px; 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-2); }
.row-item:last-child { border-bottom: 0; }
.row-item.link { color: var(--ink); text-decoration: none; align-items: center; border-radius: 10px; }
.row-item.link:hover { background: var(--surface-2); }
.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: 600; font-variant-numeric: tabular-nums; }
.ri-main { flex: 1; min-width: 0; }
.ri-title { font-weight: 500; }
.ri-title a { color: var(--ink); }
.ri-title a:hover { color: var(--accent-ink); }
.ri-sub { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.ri-note { font-size: 12.5px; color: var(--muted); margin-top: 2px; white-space: pre-wrap; }
.ri-outcome { font-size: 13px; background: var(--green-soft); color: var(--green); border-radius: 8px; padding: 4px 8px; 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: 6px; border: 1.5px 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, transform .15s var(--spring); }
.check-btn:hover { border-color: var(--green); }
.check-btn.on { background: var(--green); border-color: var(--green); color: var(--surface); transform: scale(1.08); }
.date-tile { width: 42px; height: 46px; border-radius: 12px; flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; gap: 3px; }
.date-tile small { font-size: 10px; font-weight: 500; }
.date-tile b { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }

.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: 50%; background: var(--accent-soft); color: var(--accent); opacity: 1; box-sizing: border-box; }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: right; font-weight: 600; color: var(--muted); font-size: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table.compact td { padding: 8px 16px; }
.table.hover tbody tr { cursor: pointer; }
.table.hover tbody tr:hover, .table tbody tr.on td { background: var(--surface-2); }
.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: 700; }
.table.docs td { vertical-align: middle; }
.cell-sub { font-size: 12px; color: var(--muted); max-width: 320px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.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: 40px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: var(--pill); padding: 0 14px;
  color: var(--muted); background: var(--input-bg); transition: border-color .15s, box-shadow .15s; }
.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: 4px; border-bottom: 1px solid var(--line); margin: 0 0 16px; overflow-x: auto; }
.tab { background: none; border: 0; padding: 12px; margin-bottom: -1px; font: inherit; color: var(--muted); 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; }
.tab:hover { color: var(--ink); }
.tab.on { color: var(--accent-ink); border-bottom-color: var(--accent); font-weight: 600; }
.tab-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0 10px; }
.page-tabs { width: fit-content; max-width: 100%; margin: 0 0 18px; padding: 5px; gap: 2px; border: 1px solid var(--line); border-radius: var(--pill); background: var(--surface); box-shadow: var(--shadow-card); scrollbar-width: none; }
.page-tabs .tab { padding: 8px 16px; margin: 0; border: 0; border-radius: var(--pill); transition: background .2s, color .15s; }
.page-tabs .tab.on { background: var(--accent); color: var(--on-accent); }
.page-tabs .tab.on .badge, .page-tabs .tab.on .nav-count { background: var(--menu-on); color: inherit; }
.sub-h { font-size: 13.5px; color: var(--ink-2); 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: 14px 22px; }
.info-grid small { color: var(--muted); font-size: 12px; 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: 12px; }
.fin-strip > div { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 12px; padding: 10px 14px; }
.fin-strip small { display: block; color: var(--muted); font-size: 12px; }
.fin-strip b { font-size: 17px; 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: 13px; color: var(--menu-muted); margin: 0 0 16px; }
.crumbs a { color: var(--menu-ink); }
.crumbs a:hover { color: var(--menu-white); }
.crumbs b { color: var(--menu-white); font-weight: 600; }
.case-hero { box-shadow: var(--shadow-card); }
.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: 600; }
.case-hero h1 { margin: 6px 0 2px; }
.case-hero .ch-sub { margin: 0; color: var(--muted); }
.case-hero .info-grid { margin: 20px 0 0; padding: 20px 0 4px; border-top: 1px solid var(--line-2); }
.case-hero .info-grid div > div { font-weight: 500; }
.case-hero .tabs { margin: 12px -20px 0; padding: 0 12px; border-bottom: 0; border-top: 1px solid var(--line-2); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }

/* ============================== 6. Modals and toasts ============================== */
/* Windows open as drawers 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);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fade .25s ease-out; }
.modal { width: min(560px, 100vw); height: 100%; max-height: none; display: flex; flex-direction: column; background: var(--surface);
  border-inline-start: 1px solid var(--line); border-radius: 0 28px 28px 0; box-shadow: var(--shadow-side); animation: drawer-in .42s var(--spring); }
.modal-sm { width: min(440px, 100vw); }
.modal-md { width: min(560px, 100vw); }
.modal-lg { width: min(920px, 100vw); }
.modal-head { flex: none; position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 22px 28px 18px; border-bottom: 1px solid var(--line-2); }
.modal-head::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 4px; border-radius: 0 28px 0 0; background: linear-gradient(270deg, var(--menu-1), var(--menu-3), var(--bright)); }
.modal-head h3 { font-size: 20px; line-height: 28px; font-weight: 700; }
.modal-head .icon-btn { border: 1px solid var(--line); border-radius: 50%; transition: transform .3s var(--ease), background .15s; }
.modal-head .icon-btn:hover { transform: rotate(90deg); }
.modal-body { flex: 1; min-height: 0; padding: 22px 28px; overflow-y: auto; }
.modal-foot { flex: none; display: flex; gap: 8px; align-items: center; padding: 16px 28px; border-top: 1px solid var(--line-2); background: var(--surface-2); border-radius: 0 0 28px 0; }
.modal-backdrop.closing { animation: fade-out .26s ease-in forwards; }
.modal-backdrop.closing .modal { animation: drawer-out .26s var(--ease) 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; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(10px) scale(.97); opacity: 0; } }
#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: 8px; max-width: 420px; padding: 12px 18px; border-radius: 14px; background: var(--menu-1); color: var(--menu-white);
  box-shadow: var(--shadow-pop); animation: toast-in .35s var(--spring); transition: opacity .3s, transform .3s; }
.toast-error { background: var(--red); color: var(--surface); }
:root[data-mode=dark] .toast { background: var(--surface-3); color: var(--ink); border: 1px solid var(--line-strong); }
:root[data-mode=dark] .toast-error { background: var(--red-soft); color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, transparent); }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.96); } }

/* ============================== 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: 16px; margin-bottom: 24px; }
.kpi-card { position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 8px; padding: 20px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--ink); text-decoration: none !important; transition: border-color .2s, box-shadow .2s, transform .2s var(--ease); }
.kpi-card::after { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, var(--bright), var(--accent)); opacity: 0; transition: opacity .2s; }
.kpi-card:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); color: var(--ink); box-shadow: var(--shadow-pop); transform: translateY(-2px); }
.kpi-card:hover::after { opacity: 1; }
.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: 32px; line-height: 40px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.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: 16px; align-items: start; }
.dash-grid > div { display: flex; flex-direction: column; gap: 16px; 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: 36px; font-weight: 700; letter-spacing: -1px; }
.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: linear-gradient(180deg, var(--bright), var(--accent)); }
.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: flex-end; justify-content: space-between; gap: 40px; min-height: 210px; padding-bottom: 92px; color: var(--menu-white); }
.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: 14px 0 6px; font-size: 42px; line-height: 1.2; font-weight: 700; letter-spacing: -.5px; color: var(--menu-white); }
.dash-hero .dash-sum { font-size: 16px; color: var(--menu-ink); }
.dash-hero .dash-sum b { color: var(--menu-white); font-weight: 600; }
.dh-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.dh-actions .btn { border-color: var(--menu-line); background: var(--menu-hover); color: var(--menu-white); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.dh-actions .btn:hover { background: var(--menu-on); color: var(--menu-white); }
.dh-actions .btn.primary { border-color: transparent; background: var(--menu-white); color: var(--menu-1); font-weight: 600; }
.dh-actions .btn.primary:hover { background: var(--menu-ink); color: var(--menu-1); }
.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(--menu-1); font-weight: 600; }
.dh-next { flex: none; width: 340px; display: flex; flex-direction: column; gap: 2px; padding: 20px; border-radius: 22px;
  background: var(--menu-hover); border: 1px solid var(--menu-line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.dh-next > small { color: var(--menu-muted); font-size: 12px; }
.dh-next > b { font-size: 19px; 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: 14px; 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); }
.dash-hero + .kpi-grid { margin-top: -64px; }
.kpi-grid .kpi-card { border-radius: 22px; box-shadow: var(--shadow-card); }

/* Dashboard boxes */
.bento { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; grid-auto-flow: dense; }
.bento > .card { margin: 0; min-width: 0; }
.bento .b-full { grid-column: 1 / -1; }
.bento .b-tl { grid-row: span 2; }
.bento .b-week { grid-column: span 2; }
.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: 16px; 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: 16px; 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); transform: translateY(-2px); }
.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: linear-gradient(160deg, var(--accent), var(--menu-3)); 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-row: auto; 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-bottom: 76px; }
  .dash-hero h1 { font-size: 28px; }
  .dh-actions .btn:not(.primary) { padding-inline: 12px; }
  .wk-strip { gap: 4px; }
  .wk-day { padding: 8px 2px; border-radius: 12px; }
  .wk-day b { font-size: 17px; }
}

/* ============================== 8. Calendar ============================== */
.cv-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 18px; margin: 0 0 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-card); }
.cv-nav { display: flex; gap: 4px; }
.cv-nav .icon-btn { width: 38px; height: 38px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.cv-nav .icon-btn:hover { background: var(--surface-3); }
.cv-title { display: flex; flex-direction: column; }
.cv-title h1 { margin: 0; font-size: 22px; 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: 16px; 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: 1px solid var(--line); border-radius: var(--radius); }
.cv-grid { min-width: 700px; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cv-dow { padding: 8px 10px; font-size: 12px; font-weight: 600; color: var(--ink); background: var(--surface-2); 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); box-shadow: inset 0 0 0 2px var(--accent); }
.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: 13px; 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: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; position: sticky; top: 80px; }
.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: 12px; 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: 10px; 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: 10px; 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: 12px; 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-card { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; 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: color-mix(in srgb, var(--accent) 40%, var(--line)); box-shadow: var(--shadow-pop); transform: translateY(-2px); 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: 14px; scroll-margin-top: 90px; }
.tpl-head:first-child { margin-top: 4px; }
.tpl-ic { width: 36px; height: 36px; border-radius: 12px; 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: 1px solid var(--line); border-radius: 14px; padding: 8px 10px;
  margin-bottom: 14px; position: sticky; top: 66px; z-index: 10; box-shadow: var(--shadow-soft); }
.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: 128px; max-height: calc(100vh - 144px); overflow: auto; background: var(--paper-desk); border-radius: 14px; 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: 14px; 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: 12px; 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: 8px; 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: 12px; 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: 14px; 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: 12px; 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: 14px; padding: 14px 16px; background: var(--surface); }
.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: 12px; 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-table { display: flex; flex-direction: column; gap: 4px; overflow-x: auto; }
.rules-row { display: grid; grid-template-columns: 2fr .8fr 70px 80px 1.6fr 1.6fr 32px; gap: 4px; align-items: center; min-width: 900px; }
.rules-row.head { font-size: 12px; color: var(--muted); font-weight: 600; padding: 0 4px; }
.lan-urls { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.lan-urls code { font-size: 15px; background: var(--accent-soft); color: var(--accent-ink); padding: 6px 10px; border-radius: 10px; user-select: all; direction: ltr; text-align: left; }
.tf-state { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 12px; 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: 12px; 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: 14px; margin-bottom: 18px; }
.acc-card { display: flex; flex-direction: column; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; color: var(--ink);
  text-decoration: none !important; transition: border-color .15s, box-shadow .2s, transform .2s var(--ease); }
.acc-card:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); box-shadow: var(--shadow-pop); transform: translateY(-2px); 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: 700; font-variant-numeric: tabular-nums; }
.label-link { float: left; font-size: 12px; font-weight: 600; color: var(--accent-ink); }

.conflict-box { border-radius: 10px; 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 { background: var(--accent-soft); color: var(--accent-ink); padding: 8px 32px; font-size: 13px; display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--line); }
.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: 700; }
.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: 8px; 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: 10px; 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: 14px; 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: 10px; 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: 10px; 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; }
.ai-out { margin-top: 12px; border: 1px solid var(--line); border-radius: 14px; 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: 16px; height: calc(100dvh - 128px); min-height: 480px; }
.ai-side { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; 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: 12px; 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: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.ai-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line-2); background: var(--surface-2); }
.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: 18px 18px 18px 6px; padding: 10px 14px; max-width: 78%; line-height: 1.75; }
.ai-ava { width: 32px; height: 32px; flex: none; border-radius: 50%; background: radial-gradient(circle, var(--paper) 0 73%, transparent 74%); }
.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: 10px; 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%; background: radial-gradient(circle, var(--paper) 0 73%, transparent 74%); }
.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: 14px; 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: 20px; 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: 40px; height: 40px; flex: none; border: 0; border-radius: 50%; 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); transform: scale(1.06); }
.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: 10px; 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-top span { display: none; }
  .ai-page { grid-template-columns: 1fr; height: calc(100dvh - 110px); 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: 16px; 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); transform: translateY(-2px); }
.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: 10px; 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: linear-gradient(170deg, var(--sw-m1), var(--sw-m2)); }

/* ============================== 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: 20px; padding: 28px; }
.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; scrollbar-width: thin; }
.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: 76px; 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: 12px; 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: 10px; 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: 8px; 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: 12px; 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: 12px; 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: 12px; 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; }
  .lic-banner { padding: 8px 16px; }
}
@media (max-width: 600px) {
  body { font-size: 15px; }
  h1, .page-head h1 { font-size: 22px; line-height: 30px; }
  #view { padding: 16px 12px 28px; }
  .topbar { gap: 8px; padding: 0 10px; }
  .top-brand b, .ai-top { display: none; }
  .global-search { padding: 0 10px; }
  .global-search input { font-size: 14px; }
  .quick-add .btn[data-qa-toggle] { font-size: 0; gap: 0; padding: 0 11px; }
  .card { padding: 14px 12px; margin-bottom: 12px; }
  .card > .card-head:first-child { margin: -14px -12px 12px; padding: 12px; }
  .case-hero .tabs { margin: 12px -12px 0; }
  .hero { gap: 10px; margin-bottom: 12px; }
  .hero h1 { font-size: 19px; }
  .hero > div { width: 100%; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
  .kpi { gap: 8px; padding: 10px; }
  .kpi b { font-size: 18px; }
  .kpi-ic { display: none; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-card { padding: 14px; }
  .kpi-val { font-size: 24px; 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: 58px; }
  .editor-toolbar .btn { flex: none; }
  .modal, .modal-sm, .modal-md, .modal-lg { width: 100vw; border-radius: 0; border: 0; }
  .modal-head::before, .modal-foot { border-radius: 0; }
  .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; }
}

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