:root {
  /* ---------- brand family (shared with the restaurant) ---------- */
  --zaatar-950: #161B13;
  --zaatar-900: #1D2419;
  --zaatar-800: #232B1F;
  --zaatar-700: #2F3929;
  --zaatar-600: #3E4A36;
  --brass: #A8844A;
  --brass-light: #D8BD85;
  --brass-dark: #7E6232;
  --ember: #C8553D;
  --linen: #F4EFE2;

  /* ---------- surfaces & text (light) ---------- */
  --bg: #F3F3EE;            /* page */
  --surface: #FFFFFF;       /* cards, tables, inputs */
  --surface-2: #F7F7F3;     /* row hover, table header, subtle fills */
  --surface-3: #ECEDE5;     /* pressed, chips, skeleton base */
  --line: #E2E3DA;          /* hairlines, row dividers */
  --line-strong: #C6C9BA;   /* input borders, totals rule */
  --text: #1C2117;          /* 15.9:1 on white */
  --text-2: #4B5243;        /* 7.9:1 secondary */
  --text-3: #646B5A;        /* 5.6:1 on white, 5.1:1 on --bg: hints, captions (min AA) */
  --text-on-dark: #ECE9DD;

  /* ---------- sidebar ---------- */
  --sidebar-bg: var(--zaatar-800);
  --sidebar-text: rgba(236, 233, 221, .80);
  --sidebar-text-strong: #FFFFFF;
  --sidebar-hover: rgba(255, 255, 255, .06);
  --sidebar-active-bg: rgba(216, 189, 133, .14);
  --sidebar-active-bar: var(--brass-light);
  --sidebar-section: rgba(236, 233, 221, .52);   /* section labels, 12px caps; decorative-level, still 4.6:1 */
  --sidebar-line: rgba(216, 189, 133, .14);

  /* ---------- interactive ---------- */
  --primary: #3D5230;          /* olive; white text 8.5:1 */
  --primary-hover: #31432A;
  --primary-ink: #FFFFFF;
  --primary-soft: #E6ECDD;     /* selected row, active tab underline bg */
  --link: #3D5230;
  --focus-color: #B8472F;      /* ember, 4.4:1 on --bg (non-text 3:1 required) */
  --focus-ring: 0 0 0 2px var(--surface), 0 0 0 4px var(--focus-color);

  /* ---------- accounting semantics ---------- */
  --debit: #24506F;            /* slate blue, 8.6:1 */
  --debit-bg: #E3ECF3;
  --credit: #7A4A12;           /* brass brown, 7.4:1 */
  --credit-bg: #F4EADB;
  --positive: #2E6B2E;         /* profit, balanced, in-flow: 6.4:1 */
  --positive-bg: #E2EDD8;
  --negative: #A8322A;         /* loss, out of balance, negative balances: 6.3:1 */
  --negative-bg: #F7DEDA;
  --warning: #7A5413;          /* text colour for warnings: 6.5:1 */
  --warning-bg: #F6E8CC;
  --warning-solid: #B7832F;    /* icons, bars */
  --info: #24506F;
  --info-bg: #E3ECF3;
  --neutral: #4F5546;
  --neutral-bg: #ECEDE6;
  --danger: #B3362B;           /* destructive buttons; white text 5.9:1 */
  --danger-hover: #962B22;

  /* ---------- chart (CVD-safe pair: blue vs orange) ---------- */
  --chart-revenue: #2F6F7E;
  --chart-expenses: #C8653D;
  --chart-profit: #1C2117;
  --chart-grid: #E2E3DA;
  --chart-axis: #646B5A;

  /* ---------- typography ---------- */
  --font-ui: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, "Noto Sans Arabic", Tahoma, sans-serif;
  --font-ar: "Segoe UI", "Noto Sans Arabic", "Noto Naskh Arabic", Tahoma, "Geeza Pro", "Arabic Typesetting", sans-serif;
  --font-mono: "Cascadia Mono", Consolas, "SF Mono", ui-monospace, Menlo, monospace;  /* account codes, entry numbers */
  --font-mark: Georgia, "Times New Roman", serif;   /* only the "E&O" monogram in the brand arch */

  --fs-11: 0.6875rem;  /* 11px  micro labels (chart ticks) */
  --fs-12: 0.75rem;    /* 12px  captions, badges, section labels */
  --fs-13: 0.8125rem;  /* 13px  table cells (dense), hints */
  --fs-14: 0.875rem;   /* 14px  body, inputs, buttons (desktop) */
  --fs-16: 1rem;       /* 16px  card titles, body on mobile, inputs on touch */
  --fs-18: 1.125rem;   /* 18px  drawer / dialog titles */
  --fs-22: 1.375rem;   /* 22px  page title */
  --fs-28: 1.75rem;    /* 28px  KPI numbers */
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --lh-tight: 1.25;
  --lh-body: 1.5;
  --lh-ar: 1.7;        /* Arabic needs taller lines */

  /* ---------- spacing (4px grid) ---------- */
  --sp-0: 0;
  --sp-half: 2px;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* ---------- sizes ---------- */
  --h-sm: 30px;        /* small buttons, inline table controls */
  --h-md: 36px;        /* default control height (desktop) */
  --h-lg: 44px;        /* touch / primary on mobile */
  --row-h: 36px;       /* dense table row */
  --row-h-comfy: 44px;
  --sidebar-w: 236px;
  --sidebar-rail-w: 64px;
  --topbar-h: 56px;
  --content-max: 1440px;
  --drawer-w: 480px;
  --drawer-w-wide: 760px;

  /* ---------- shape ---------- */
  --r-xs: 4px;
  --r-sm: 6px;         /* inputs, buttons, badges-square */
  --r-md: 8px;         /* cards, menus */
  --r-lg: 12px;        /* dialogs, drawers' inner corners, login card */
  --r-pill: 999px;     /* badges, chips */
  --arch: 999px 999px var(--r-sm) var(--r-sm);  /* brand arch */

  /* ---------- elevation ---------- */
  --shadow-1: 0 1px 2px rgba(22, 27, 19, .06);
  --shadow-2: 0 4px 12px -2px rgba(22, 27, 19, .10), 0 1px 3px rgba(22, 27, 19, .06);   /* menus, popovers */
  --shadow-3: 0 24px 60px -20px rgba(22, 27, 19, .35), 0 2px 6px rgba(22, 27, 19, .08); /* dialogs, drawers */
  --scrim: rgba(18, 22, 15, .45);

  /* ---------- motion ---------- */
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --dur-1: 120ms;      /* hover, colour */
  --dur-2: 200ms;      /* menus, toasts */
  --dur-3: 260ms;      /* drawers, dialogs */

  /* ---------- layers ---------- */
  --z-sticky: 10;      /* table headers, sticky totals bars */
  --z-topbar: 20;
  --z-sidebar: 30;
  --z-dropdown: 40;    /* combobox lists, menus */
  --z-drawer: 50;
  --z-modal: 60;
  --z-toast: 70;

  color-scheme: light;
}

/* ---------- dark ---------- */
:root[data-theme="dark"] {
  --bg: #111410;
  --surface: #191D16;
  --surface-2: #1F241B;
  --surface-3: #283022;
  --line: #2C3427;
  --line-strong: #434E3A;
  --text: #E9EBE2;
  --text-2: #BCC1AF;
  --text-3: #959C87;
  --sidebar-bg: #0E110C;
  --primary: #A9BF84;
  --primary-hover: #BCD097;
  --primary-ink: #172010;
  --primary-soft: #26301E;
  --link: #B9CC95;
  --focus-color: #E8876D;
  --debit: #9DC4E6;   --debit-bg: #1B2A36;
  --credit: #E3B979;  --credit-bg: #33281A;
  --positive: #94CF7F; --positive-bg: #1F3319;
  --negative: #F2A497; --negative-bg: #3E1D19;
  --warning: #E8C57E;  --warning-bg: #3A2F17; --warning-solid: #D9A548;
  --info: #9DC4E6;     --info-bg: #1B2A36;
  --neutral: #B3B9A4;  --neutral-bg: #262D21;
  --danger: #D2574A;   --danger-hover: #E06A5D;
  --chart-revenue: #6FB3C2;
  --chart-expenses: #E8875F;
  --chart-profit: #E9EBE2;
  --chart-grid: #2C3427;
  --chart-axis: #959C87;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 6px 16px -4px rgba(0, 0, 0, .6);
  --shadow-3: 0 24px 60px -20px rgba(0, 0, 0, .75);
  --scrim: rgba(0, 0, 0, .6);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    /* identical values to :root[data-theme="dark"] above. Copy the whole block, do not drift. */
    --bg: #111410; --surface: #191D16; --surface-2: #1F241B; --surface-3: #283022;
    --line: #2C3427; --line-strong: #434E3A;
    --text: #E9EBE2; --text-2: #BCC1AF; --text-3: #959C87;
    --sidebar-bg: #0E110C;
    --primary: #A9BF84; --primary-hover: #BCD097; --primary-ink: #172010; --primary-soft: #26301E; --link: #B9CC95;
    --focus-color: #E8876D;
    --debit: #9DC4E6; --debit-bg: #1B2A36; --credit: #E3B979; --credit-bg: #33281A;
    --positive: #94CF7F; --positive-bg: #1F3319; --negative: #F2A497; --negative-bg: #3E1D19;
    --warning: #E8C57E; --warning-bg: #3A2F17; --warning-solid: #D9A548;
    --info: #9DC4E6; --info-bg: #1B2A36; --neutral: #B3B9A4; --neutral-bg: #262D21;
    --danger: #D2574A; --danger-hover: #E06A5D;
    --chart-revenue: #6FB3C2; --chart-expenses: #E8875F; --chart-profit: #E9EBE2;
    --chart-grid: #2C3427; --chart-axis: #959C87;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4); --shadow-2: 0 6px 16px -4px rgba(0, 0, 0, .6);
    --shadow-3: 0 24px 60px -20px rgba(0, 0, 0, .75); --scrim: rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

/* ---------- Arabic ---------- */
:root[lang="ar"] { --font-ui: var(--font-ar); }
:root[lang="ar"] body { line-height: var(--lh-ar); }

/* ---------- touch & small screens: bigger targets ---------- */
@media (pointer: coarse), (max-width: 860px) {
  :root { --h-md: 44px; --h-sm: 36px; --row-h: 44px; }
}
