/* Design tokens: design.md section 1.2 (exact names). /brand.css (from settings) overrides the brand block. */
:root {
  /* ---------- fixed neutrals ("night" family, replaces finance za'atar) ---------- */
  --night-950: #0B1519;
  --night-900: #102027;
  --night-800: #142830;      /* sidebar */
  --night-700: #1D3742;
  --night-600: #29495A;
  --sand: #F5EFE3;           /* toast text, warm paper */

  /* ---------- brand (defaults; /brand.css overrides these from settings) ---------- */
  --brand: #0F5E78;                 /* settings.primaryColor */
  --brand-ink: #FFFFFF;             /* text on --brand (computed: black or white) */
  --brand-text: #0F5E78;            /* brand as TEXT on light surfaces, >= 4.5:1 on #fff (computed) */
  --brand-on-dark: #7CC3DA;         /* brand as TEXT/fill on dark surfaces, >= 4.5:1 on --night-800 (computed) */
  --brand-on-dark-ink: #0B1519;     /* text on --brand-on-dark */
  --accent: #E07A1F;                /* settings.accentColor: public CTAs, active-nav bar, highlights */
  --accent-ink: #1A1206;            /* text on --accent (computed) */
  --accent-text: #9A4A06;           /* accent as TEXT on light, >= 4.5:1 (computed) */
  --accent-on-dark: #F2A35E;        /* accent on dark surfaces, >= 3:1 on --night-800 (computed) */

  /* ---------- surfaces & text (light) ---------- */
  --bg: #F2F5F6;
  --surface: #FFFFFF;
  --surface-2: #F6F8F9;      /* row hover, table header */
  --surface-3: #E8EEF0;      /* pressed, chips, skeleton */
  --line: #DDE4E7;
  --line-strong: #B9C6CC;    /* input borders: 3.0:1 on white */
  --text: #13212A;           /* 15.6:1 */
  --text-2: #3E505A;         /* 8.4:1 */
  --text-3: #596A73;         /* 5.6:1 on white, 5.2:1 on --bg (lightest text allowed) */
  --text-on-dark: #E6EEF1;

  /* ---------- sidebar ---------- */
  --sidebar-bg: var(--night-800);
  --sidebar-text: rgba(230, 238, 241, .80);
  --sidebar-text-strong: #FFFFFF;
  --sidebar-hover: rgba(255, 255, 255, .06);
  --sidebar-active-bg: rgba(255, 255, 255, .10);
  --sidebar-active-bar: var(--accent-on-dark);
  --sidebar-section: rgba(230, 238, 241, .55);
  --sidebar-line: rgba(255, 255, 255, .10);

  /* ---------- interactive (derived from brand) ---------- */
  --primary: var(--brand);
  --primary-hover: color-mix(in oklab, var(--brand) 84%, black);
  --primary-ink: var(--brand-ink);
  --primary-soft: color-mix(in oklab, var(--brand) 11%, white);   /* selected rows, chips, active tab bg */
  --link: var(--brand-text);
  --focus-color: #C2410C;            /* burnt orange, fixed (not brand): 4.6:1 on --bg; always visible */
  --focus-ring: 0 0 0 2px var(--surface), 0 0 0 4px var(--focus-color);

  /* ---------- semantics (same values as finance) ---------- */
  --positive: #2E6B2E;  --positive-bg: #E2EDD8;
  --negative: #A8322A;  --negative-bg: #F7DEDA;
  --warning: #7A5413;   --warning-bg: #F6E8CC;  --warning-solid: #B7832F;
  --info: #24506F;      --info-bg: #E3ECF3;
  --neutral: #4F5546;   --neutral-bg: #ECEDE6;
  --danger: #B3362B;    --danger-hover: #962B22;

  /* ---------- money semantics ---------- */
  --cost: #7A4A12;      --cost-bg: #F4EADB;     /* supplier cost (brass brown, like finance credit) */
  --sell: #24506F;      --sell-bg: #E3ECF3;     /* customer price (slate blue, like finance debit) */

  /* ---------- item types: icon colour / tile background ---------- */
  --it-package: var(--brand-text);  --it-package-bg: var(--primary-soft);
  --it-flight: #1F5A8A;    --it-flight-bg: #E1ECF6;
  --it-hotel: #6A4A8C;     --it-hotel-bg: #EEE6F5;
  --it-visa: #7A5413;      --it-visa-bg: #F6E8CC;
  --it-transfer: #23695E;  --it-transfer-bg: #DDEFEA;
  --it-insurance: #4F5546; --it-insurance-bg: #ECEDE6;
  --it-activity: #9C4221;  --it-activity-bg: #F8E3DA;
  --it-other: #4F5546;     --it-other-bg: #ECEDE6;

  /* ---------- availability calendar ---------- */
  --cal-available: #2E6B2E;     --cal-available-bg: #E8F2E0;
  --cal-limited: #7A5413;       --cal-limited-bg: #FBEFD6;
  --cal-unavailable: #6B7780;   --cal-unavailable-bg: #EEF1F2;   /* + diagonal hatch + strike, see 4.11 */
  --cal-selected: var(--brand); --cal-selected-ink: var(--brand-ink);
  --cal-range-bg: color-mix(in oklab, var(--brand) 14%, white);
  --cal-today-ring: var(--text);

  /* ---------- chart (CVD-safe) ---------- */
  --chart-1: #2F6F7E;   /* revenue / sell */
  --chart-2: #C8653D;   /* cost */
  --chart-3: #13212A;   /* profit line */
  --chart-grid: #DDE4E7; --chart-axis: #596A73;

  /* ---------- typography ---------- */
  --font-ui: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, "Noto Sans Arabic", Tahoma, sans-serif;
  --font-rtl: "Segoe UI", "Noto Sans Arabic", "Noto Naskh Arabic", "Noto Sans Arabic UI", Tahoma, "Geeza Pro", "Arabic Typesetting", system-ui, sans-serif;
  --font-mono: "Cascadia Mono", Consolas, "SF Mono", ui-monospace, Menlo, monospace;
  --fs-11: .6875rem; --fs-12: .75rem; --fs-13: .8125rem; --fs-14: .875rem; --fs-16: 1rem;
  --fs-18: 1.125rem; --fs-20: 1.25rem; --fs-22: 1.375rem; --fs-28: 1.75rem; --fs-36: 2.25rem; --fs-48: 3rem;
  --fw-regular: 400; --fw-medium: 500; --fw-semibold: 600; --fw-bold: 700;
  --lh-tight: 1.25; --lh-body: 1.5; --lh-rtl: 1.75;   /* Arabic script needs taller lines (ckb and ar) */

  /* ---------- spacing (4px grid, same as finance) ---------- */
  --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; --sp-20: 80px; --sp-24: 96px;

  /* ---------- sizes ---------- */
  --h-sm: 30px; --h-md: 36px; --h-lg: 44px; --h-xl: 52px;   /* xl: public CTAs */
  --row-h: 36px; --row-h-comfy: 44px;
  --sidebar-w: 236px; --sidebar-rail-w: 64px; --topbar-h: 56px;
  --content-max: 1440px; --drawer-w: 480px; --drawer-w-wide: 760px; --wizard-max: 880px;
  --site-max: 1200px;  --site-gutter: 16px;   /* public; 24px >= 640, 32px >= 1024 */
  --site-header-h: 64px;

  /* ---------- shape ---------- */
  --r-xs: 4px; --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px; /* xl: public cards, hero panel */
  --r-pill: 999px;

  /* ---------- elevation ---------- */
  --shadow-1: 0 1px 2px rgba(11, 21, 25, .06);
  --shadow-2: 0 4px 12px -2px rgba(11, 21, 25, .10), 0 1px 3px rgba(11, 21, 25, .06);
  --shadow-3: 0 24px 60px -20px rgba(11, 21, 25, .35), 0 2px 6px rgba(11, 21, 25, .08);
  --shadow-card-hover: 0 10px 24px -8px rgba(11, 21, 25, .18);   /* public package cards */
  --scrim: rgba(8, 16, 20, .48);

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

  /* ---------- layers ---------- */
  --z-sticky: 10; --z-topbar: 20; --z-sidebar: 30; --z-dropdown: 40; --z-drawer: 50; --z-modal: 60;
  --z-toast: 70; --z-fab: 35;   /* public WhatsApp button */

  color-scheme: light;
}

/* ---------- dark (back office only) ---------- */
:root[data-theme="dark"] {
  --bg: #0E1518; --surface: #141D21; --surface-2: #19242A; --surface-3: #22313A;
  --line: #26343C; --line-strong: #3E525D;
  --text: #E6EEF1; --text-2: #B6C4CB; --text-3: #8FA1AA;
  --sidebar-bg: #0A1215;
  --primary: var(--brand-on-dark); --primary-hover: color-mix(in oklab, var(--brand-on-dark) 85%, white);
  --primary-ink: var(--brand-on-dark-ink);
  --primary-soft: color-mix(in oklab, var(--brand-on-dark) 16%, #141D21);
  --link: var(--brand-on-dark);
  --focus-color: #F59E5B;
  --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;
  --cost: #E3B979; --cost-bg: #33281A; --sell: #9DC4E6; --sell-bg: #1B2A36;
  --it-package: var(--brand-on-dark); --it-package-bg: var(--primary-soft);
  --it-flight: #8DBCE6;    --it-flight-bg: #182B3B;
  --it-hotel: #C7A8E6;     --it-hotel-bg: #2A2036;
  --it-visa: #E8C57E;      --it-visa-bg: #3A2F17;
  --it-transfer: #86D0C1;  --it-transfer-bg: #15302B;
  --it-insurance: #B3B9A4; --it-insurance-bg: #262D21;
  --it-activity: #F0A688;  --it-activity-bg: #3B2219;
  --it-other: #B3B9A4;     --it-other-bg: #262D21;
  --cal-available: #94CF7F; --cal-available-bg: #1F3319;
  --cal-limited: #E8C57E;   --cal-limited-bg: #3A2F17;
  --cal-unavailable: #8FA1AA; --cal-unavailable-bg: #19242A;
  --cal-selected: var(--brand-on-dark); --cal-selected-ink: var(--brand-on-dark-ink);
  --cal-range-bg: color-mix(in oklab, var(--brand-on-dark) 18%, #141D21);
  --cal-today-ring: var(--text);
  --chart-1: #6FB3C2; --chart-2: #E8875F; --chart-3: #E6EEF1; --chart-grid: #26343C; --chart-axis: #8FA1AA;
  --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"]):not([data-site]) {
    /* Exactly the declarations of :root[data-theme="dark"] above (copy them all, do not drift; a test can compare).
       The public site sets <html data-site>, so it never turns dark. Duplicated on purpose, as in finance. */
    --bg: #0E1518; --surface: #141D21; --surface-2: #19242A; --surface-3: #22313A;
    --line: #26343C; --line-strong: #3E525D;
    --text: #E6EEF1; --text-2: #B6C4CB; --text-3: #8FA1AA;
    --sidebar-bg: #0A1215;
    --primary: var(--brand-on-dark); --primary-hover: color-mix(in oklab, var(--brand-on-dark) 85%, white);
    --primary-ink: var(--brand-on-dark-ink);
    --primary-soft: color-mix(in oklab, var(--brand-on-dark) 16%, #141D21);
    --link: var(--brand-on-dark); --focus-color: #F59E5B;
    --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;
    --cost: #E3B979; --cost-bg: #33281A; --sell: #9DC4E6; --sell-bg: #1B2A36;
    --it-package: var(--brand-on-dark); --it-package-bg: var(--primary-soft);
    --it-flight: #8DBCE6; --it-flight-bg: #182B3B; --it-hotel: #C7A8E6; --it-hotel-bg: #2A2036;
    --it-visa: #E8C57E; --it-visa-bg: #3A2F17; --it-transfer: #86D0C1; --it-transfer-bg: #15302B;
    --it-insurance: #B3B9A4; --it-insurance-bg: #262D21; --it-activity: #F0A688; --it-activity-bg: #3B2219;
    --it-other: #B3B9A4; --it-other-bg: #262D21;
    --cal-available: #94CF7F; --cal-available-bg: #1F3319; --cal-limited: #E8C57E; --cal-limited-bg: #3A2F17;
    --cal-unavailable: #8FA1AA; --cal-unavailable-bg: #19242A;
    --cal-selected: var(--brand-on-dark); --cal-selected-ink: var(--brand-on-dark-ink);
    --cal-range-bg: color-mix(in oklab, var(--brand-on-dark) 18%, #141D21); --cal-today-ring: var(--text);
    --chart-1: #6FB3C2; --chart-2: #E8875F; --chart-3: #E6EEF1; --chart-grid: #26343C; --chart-axis: #8FA1AA;
    --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;
  }
}

/* ---------- RTL scripts (ckb and ar) ---------- */
:root[lang="ar"], :root[lang="ckb"] { --font-ui: var(--font-rtl); }
:root[lang="ar"] body, :root[lang="ckb"] body { line-height: var(--lh-rtl); }

/* ---------- touch & small screens ---------- */
@media (pointer: coarse), (max-width: 860px) {
  :root { --h-md: 44px; --h-sm: 36px; --row-h: 44px; }
}
@media (min-width: 640px)  { :root { --site-gutter: 24px; } }
@media (min-width: 1024px) { :root { --site-gutter: 32px; } }
