/* =============================================================================
   Twenty and Twenty Dark: opt-in themes for the signed-in app (/app) and the
   operator console (/admin). Ali, 5 Nov 2026: Twenty UI (twenty-ui 2.55, MIT)
   as a theme the user PICKS, never the forced default.

   Switch: data-ui="twenty" | "twenty-dark" on <html> (ui-theme.js, set before
   first paint from localStorage / cookie "splitty_ui"). Without the attribute
   this file changes nothing, so the Classic look is untouched.

   Values are copied from https://design.bhd.om/twenty.css into --stw-* names.
   The kit is NOT linked: app.css is Tailwind v3 and owns the --tw-* helper
   names, and the island reads --accent / --muted / --border with other
   meanings. Twenty Dark also sets data-theme="dark", so every existing dark
   rule (money tones, category scale, dark: utilities) fires under it.

   Selectors use :root:root so they outrank the island's lazily loaded sheet
   (:root[data-theme=dark] :is([data-bui-root]) is (0,3,0)).
   ========================================================================== */

@import url("https://fonts.bhd.om/css2?family=Inter:wght@400;500;600&family=IBM+Plex+Sans+Arabic:wght@400;500;600&family=DM+Mono:wght@400;500&display=swap");

/* The OMR / SAR / AED marks (U+E200-E202, currency-font.css). The full Inter
   from fonts.bhd.om also claims those code points and drew "N" with a cedilla,
   so the currency face leads every Twenty stack, limited to the three marks. */
@font-face{font-family:"Splitty Currency";src:url("fonts/splitty-currency.woff2") format("woff2");unicode-range:U+E200-E202;font-weight:100 900;font-style:normal;font-display:block}

/* ---------- Twenty values ---------- */
:root:root[data-ui="twenty"] {
  --stw-bg-primary: #ffffff;
  --stw-bg-secondary: #fcfcfc;
  --stw-bg-tertiary: #f1f1f1;
  --stw-bg-quaternary: #ebebeb;
  --stw-bg-app: #f9f9f9;
  --stw-overlay: rgba(0, 0, 0, 0.36);
  --stw-fill-light: rgba(0, 0, 0, 0.039);
  --stw-fill-medium: rgba(0, 0, 0, 0.078);
  --stw-text-primary: #333333;
  --stw-text-secondary: #666666;
  --stw-text-tertiary: #999999;
  --stw-text-light: #b3b3b3;
  --stw-text-inverted: #ffffff;
  --stw-border-light: #f1f1f1;
  --stw-border-medium: #ebebeb;
  --stw-border-strong: #d6d6d6;
  --stw-accent: #3e63dd;
  --stw-accent-hover: #3358d4;
  --stw-accent-text: #3a5bc7;
  --stw-accent-soft: #edf2fe;
  --stw-accent-border: #d2deff;
  --stw-on-accent: #ffffff;
  --stw-danger: #e5484d;
  --stw-danger-text: #ce2c31;
  --stw-danger-soft: #fbecec;
  --stw-warning: #ff9c00;
  --stw-warning-text: #c25700;
  --stw-warning-soft: #fff4e5;
  --stw-success: #30a46c;
  --stw-success-text: #218358;
  --stw-success-soft: #e9f6ec;
  --stw-shadow-light: 0 2px 4px rgba(0, 0, 0, 0.039), 0 0 4px rgba(0, 0, 0, 0.078);
  --stw-shadow-strong: 2px 4px 16px rgba(0, 0, 0, 0.161), 0 2px 4px rgba(0, 0, 0, 0.078);
  color-scheme: light;
}
:root:root[data-ui="twenty-dark"] {
  --stw-bg-primary: #1b1b1b;
  --stw-bg-secondary: #1d1d1d;
  --stw-bg-tertiary: #222222;
  --stw-bg-quaternary: #2a2a2a;
  --stw-bg-app: #171717;
  --stw-overlay: rgba(0, 0, 0, 0.36);
  --stw-fill-light: rgba(255, 255, 255, 0.059);
  --stw-fill-medium: rgba(255, 255, 255, 0.102);
  --stw-text-primary: #ebebeb;
  --stw-text-secondary: #b3b3b3;
  --stw-text-tertiary: #818181;
  --stw-text-light: #666666;
  --stw-text-inverted: #171717;
  --stw-border-light: #1d1d1d;
  --stw-border-medium: #222222;
  --stw-border-strong: #333333;
  --stw-accent: #3e63dd;
  --stw-accent-hover: #5472e4;
  --stw-accent-text: #9db1ff;
  --stw-accent-soft: rgba(53, 102, 255, 0.14);
  --stw-accent-border: #3a4f97;
  --stw-on-accent: #ffffff;
  --stw-danger: #e5484d;
  --stw-danger-text: #ff9592;
  --stw-danger-soft: rgba(229, 72, 77, 0.16);
  --stw-warning: #ff9c00;
  --stw-warning-text: #ffa057;
  --stw-warning-soft: rgba(255, 156, 0, 0.14);
  --stw-success: #30a46c;
  --stw-success-text: #3dd68c;
  --stw-success-soft: rgba(48, 164, 108, 0.16);
  --stw-shadow-light: 0 2px 4px rgba(0, 0, 0, 0.6), 0 0 4px rgba(0, 0, 0, 0.6);
  --stw-shadow-strong: 2px 4px 16px rgba(0, 0, 0, 0.6), 0 2px 4px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

/* ---------- Splitty's own roles, re-pointed (root and body) ----------
   Declared on body too: ui.js writes the open trip's world inputs (--ring,
   --kitty, --world-*, --positive ...) inline on <html>, and an inline value
   outranks any sheet there. Declaring them on body wins by inheritance. */
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]),
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) body {
  --ui-bg: var(--stw-bg-app);
  --ui-bg-2: var(--stw-bg-primary);
  --ui-bg-3: var(--stw-bg-tertiary);
  --ui-bg-4: var(--stw-bg-quaternary);
  --ui-text: var(--stw-text-primary);
  --ui-text-2: var(--stw-text-secondary);
  --ui-text-3: var(--stw-text-tertiary);
  --ui-border: var(--stw-border-medium);
  --ui-border-strong: var(--stw-border-strong);
  --ui-bullet: var(--stw-accent);
  --ui-fill: var(--stw-bg-secondary);
  --ui-fill-2: var(--stw-bg-tertiary);
  --ui-radius-card: 8px;
  --ui-radius-icon: 4px;
  --ui-scrim: var(--stw-overlay);

  --bg: var(--stw-bg-app);
  --page: var(--stw-bg-app);
  --surface: var(--stw-bg-primary);
  --surface-2: var(--stw-bg-tertiary);
  --surface-3: var(--stw-bg-quaternary);
  --text: var(--stw-text-primary);
  --text-muted: var(--stw-text-secondary);
  --text-faint: var(--stw-text-tertiary);
  --border: var(--stw-border-medium);
  --border-strong: var(--stw-border-strong);
  --muted: var(--stw-text-secondary);
  --line: var(--stw-border-medium);
  --primary: var(--stw-accent);
  --primary-press: var(--stw-accent-hover);
  --on-primary: var(--stw-on-accent);
  --primary-text: var(--stw-accent-text);
  --brand: var(--stw-accent);
  --brand-600: var(--stw-accent-hover);
  --brand-700: var(--stw-accent-hover);
  --accent: var(--stw-accent);
  --ring: var(--stw-accent);
  --kitty: var(--stw-accent);
  --world-kitty: var(--stw-accent);
  --world-accent: var(--stw-accent);
  --world-accent-ink: var(--stw-on-accent);
  --world-ink: var(--stw-text-primary);
  --world-paper: var(--stw-bg-primary);
  --success: var(--stw-success-text);
  --warning: var(--stw-warning-text);
  --danger: var(--stw-danger-text);
  --info: var(--stw-accent-text);
  --success-bg: var(--stw-success-soft);
  --warning-bg: var(--stw-warning-soft);
  --danger-bg: var(--stw-danger-soft);
  --info-bg: var(--stw-accent-soft);
  --positive: var(--stw-success);
  --expense: var(--stw-danger);
  --positive-text: var(--stw-success-text);
  --expense-text: var(--stw-danger-text);
  --positive-on-hero: var(--stw-success-text);
  --expense-on-hero: var(--stw-danger-text);
  --shadow-sm: var(--stw-shadow-light);
  --shadow-md: var(--stw-shadow-light);
  --shadow-lg: var(--stw-shadow-strong);
  --shadow-pop: none;
  --glass-fill: var(--stw-bg-primary);
  --glass-fill-strong: var(--stw-bg-primary);
  --glass-border: var(--stw-border-medium);
  --glass-blur: 0px;
  --blob-1: transparent;
  --blob-2: transparent;
  --blob-3: transparent;
  --r-xs: 4px; --r-sm: 4px; --r-md: 8px; --r-lg: 8px; --r-xl: 8px; --r-2xl: 8px;
  --section-radius: 8px;
  --font-display: "Splitty Currency", "Inter", "IBM Plex Sans Arabic", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: "Splitty Currency", "Inter", "IBM Plex Sans Arabic", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "Splitty Currency", "DM Mono", ui-monospace, Menlo, Consolas, monospace;
  --tracking-tight: 0; --tracking-display: -.01em;
  --fw-display: 600; --fw-bold: 600;

  /* Shell, direction B */
  --b-paper: var(--stw-bg-app);
  --b-ink: var(--stw-text-primary);
  --b-action: var(--stw-accent);
  --b-hair: var(--stw-border-medium);
  --b-muted: var(--stw-text-secondary);

  /* Operator console */
  --ops-sans: var(--font-body);
  --ops-mono: var(--font-mono);
  --ops-r: 8px;
  --ops-ink: #000;
  --ops-tint: var(--stw-accent-soft);
}

/* ---------- React island (shadcn + the beautiful-ui kit) ---------- */
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) :is([data-bui-root], [data-splitty-portal]) {
  --radius: 0.5rem;
  --background: var(--stw-bg-app);
  --foreground: var(--stw-text-primary);
  --card: var(--stw-bg-primary);
  --card-foreground: var(--stw-text-primary);
  --popover: var(--stw-bg-primary);
  --popover-foreground: var(--stw-text-primary);
  --primary: var(--stw-accent);
  --primary-foreground: var(--stw-on-accent);
  --secondary: var(--stw-bg-tertiary);
  --secondary-foreground: var(--stw-text-primary);
  --muted: var(--stw-bg-tertiary);
  --muted-foreground: var(--stw-text-secondary);
  --accent-foreground: var(--stw-text-primary);
  --destructive: var(--stw-danger-text);
  --border: var(--stw-border-medium);
  --input: var(--stw-border-strong);
  --ring: var(--stw-accent);
  --sunshine: var(--stw-accent);
  --money-in: var(--stw-success-text);
  --money-out: var(--stw-danger-text);
  --dial-track: var(--stw-bg-tertiary);

  --page: var(--stw-bg-app);
  --canvas: var(--stw-bg-tertiary);
  --surface: var(--stw-bg-primary);
  --inset: var(--stw-bg-secondary);
  --hover: var(--stw-bg-tertiary);
  --hover-2: var(--stw-bg-quaternary);
  --ink: var(--stw-text-primary);
  --ink-2: var(--stw-text-secondary);
  --ink-3: var(--stw-text-tertiary);
  --line: var(--stw-border-medium);
  --line-strong: var(--stw-border-strong);
  --field: var(--stw-bg-primary);
  --stripe-bg: var(--stw-bg-tertiary);
  --accent-ink: var(--stw-accent-text);
  --accent-tint: var(--stw-accent-soft);
  --green: var(--stw-success-text);
  --green-tint: var(--stw-success-soft);
  --orange: var(--stw-warning-text);
  --orange-tint: var(--stw-warning-soft);
  --red: var(--stw-danger-text);
  --red-tint: var(--stw-danger-soft);
  --radius-chip: 4px;
  --radius-control: 4px;
  --radius-card: 8px;
  --shadow-card: 0 0 0 1px var(--stw-border-medium);
  --shadow-raised: 0 0 0 1px var(--stw-border-medium), var(--stw-shadow-light);
  --shadow-overlay: 0 0 0 1px var(--stw-border-medium), var(--stw-shadow-strong);
  --shadow-btn: 0 0 0 1px var(--stw-border-strong);
  --shadow-hairline: 0 0 0 1px var(--stw-border-medium);
  --font-inter: "Splitty Currency", "Inter", "IBM Plex Sans Arabic";
  --font-mono-face: "Splitty Currency", "DM Mono";
  --font-sans: "Splitty Currency", "Inter", "IBM Plex Sans Arabic", ui-sans-serif, system-ui, sans-serif;
}
/* Legacy nodes inside the island get the legacy names back (styles.css). */
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) [data-bui-root] [data-legacy] {
  --accent: var(--stw-accent);
  --border: var(--stw-border-medium);
  --muted: var(--stw-text-secondary);
  --primary: var(--stw-accent);
  --ring: var(--stw-accent);
}

/* ---------- Base: type and quiet chrome ---------- */
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) body {
  font-family: var(--font-body);
  background: var(--stw-bg-app);
  color: var(--stw-text-primary);
  -webkit-font-smoothing: antialiased;
}
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) :is([lang="ar"], [dir="rtl"]) {
  font-family: "Splitty Currency", "IBM Plex Sans Arabic", "Inter", sans-serif;
  letter-spacing: 0 !important;
}
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) :focus-visible {
  outline: 2px solid var(--stw-accent);
  outline-offset: 1px;
}
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) ::selection { background: var(--stw-accent-soft); }
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) :is(.font-display, h1, h2, h3) {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}

/* Glass and backdrop blobs: Twenty is flat. */
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) :is(.glass, .card, .sheet, .modal, .bottom-nav, .shell-top) {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

/* Cards and controls: quiet border, small radius, no lift. */
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) .splitty-app .card {
  background: var(--stw-bg-primary);
  border: 1px solid var(--stw-border-medium);
  border-radius: 8px;
  box-shadow: none;
}
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) .splitty-app :is(.btn-primary, .btn-secondary, .btn-ghost, .btn-line, .btn-danger) {
  border-radius: 4px;
  box-shadow: none;
  font-weight: 500;
}
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) .splitty-app .btn-primary {
  background: var(--stw-accent);
  background-image: none;
  color: var(--stw-on-accent);
}
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) .splitty-app .btn-primary:hover:not(:disabled) { background: var(--stw-accent-hover); }
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) .splitty-app :is(.btn-secondary, .btn-line) {
  background: var(--stw-bg-primary);
  color: var(--stw-text-primary);
  border: 1px solid var(--stw-border-strong);
}
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) .splitty-app .btn-danger { background: var(--stw-danger); color: #fff; }
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) .splitty-app :is(input, select, textarea):not([type="checkbox"], [type="radio"], [type="range"]) {
  background-color: var(--stw-bg-primary);
  color: var(--stw-text-primary);
  border-color: var(--stw-border-strong);
  border-radius: 4px;
}
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) .splitty-app :is(input, textarea)::placeholder { color: var(--stw-text-tertiary); }
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) .splitty-app :is(.chip, .seg-tab, .tab-btn) { border-radius: 4px; }

/* The trip hero: Twenty record headers are neutral. A photo hero keeps its
   scrim and paper text (the pair was measured against the photo). */
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) .hero-card:not(.hero-card--photo) {
  --tile-ink: var(--stw-text-primary);
  --tile-ink-soft: var(--stw-text-secondary);
  --tile-veil: var(--stw-bg-tertiary);
  --hero-wash: transparent;
  background-color: var(--stw-bg-primary);
  background-image: none;
  color: var(--stw-text-primary);
  border: 1px solid var(--stw-border-medium);
  box-shadow: none;
}

/* Shell: flat white bar, indigo underline on the active tab. */
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) .splitty-app :is(.shell-top, .bottom-nav) {
  background: var(--stw-bg-primary);
  border-color: var(--stw-border-medium);
  box-shadow: none;
}
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) .splitty-app .shell-nav .nav-side { font-weight: 500; font-size: 13px; }
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) .splitty-app .shell-nav .nav-side.active::after,
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) .splitty-app .bottom-nav .nav-btn.active::before { background: var(--stw-accent); height: 2px; }

/* Sheets, modals and their scrim. */
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) :is(.sheet, .modal) {
  border-radius: 8px;
  background: var(--stw-bg-primary);
  color: var(--stw-text-primary);
  border: 1px solid var(--stw-border-medium);
  box-shadow: var(--stw-shadow-strong);
}

/* Tables scroll in their own box, never the page. */
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) :is(.table-wrap, .ops-table-wrap, [style*="overflow-x:auto"], [style*="overflow-x: auto"]):has(> table) {
  max-width: 100%;
  overflow-x: auto;
  contain: paint;
}

/* ---------- Twenty type and shape (legacy views, island, console) ----------
   Sentence-case labels, weight 600 at most, 4 px controls, 8 px cards.
   Avatars and member dots keep their circles: only controls are squared. */
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) :is(.uppercase, .ops-auth__facts dt, .ops-auth label, .ops-rail__area,
  .ops-sheet__range > span, .ops-panel__h, .ops-card__t, .ops-stat__l, table.ops-t th, .ops-dial__cap, .ops-b__t,
  .ops-drawer h4, .ops-mobile-context label, .ops-sheet__kicker, .ops-drivers__i > span:first-child, .ops-camp-form label,
  .ops-camp__k, .ops-camp-prev small) {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) :is(.ops-rail__area, .ops-panel__h, .ops-card__t) { font-size: 12px; }
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) :is(.font-extrabold, .font-black, .font-bold, strong, b, h1, h2, h3) { font-weight: 600; }
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) :is([class*="tracking-[-"], .tracking-tight, .tracking-tighter) { letter-spacing: -0.01em; }
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) :is(button, a, [role="button"], input, select, .chip, .btn-primary, .btn-secondary, .btn-ghost, .btn-line, .home-quick):is(.rounded-full, .rounded-xl, .rounded-2xl, .rounded-3xl, .rounded-lg, .chip, .btn-primary, .btn-secondary, .btn-ghost, .btn-line, .home-quick, [class*="rounded-["]) {
  border-radius: 4px;
}
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) :is(div, section, article, aside, li, form, dialog):is(.rounded-2xl, .rounded-3xl, .rounded-xl, [class*="rounded-[2"], [class*="rounded-[3"]) {
  border-radius: 8px;
}
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) body,
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) :is([data-bui-root], [data-splitty-portal]) { font-family: var(--font-body); }
:root:root:is([data-ui="twenty"], [data-ui="twenty-dark"]) .shell-lang-pick { border-radius: 4px !important; }

/* ---------- Theme picker (Settings, console sheet) ---------- */
.ui-theme-pick { display: inline-flex; gap: 2px; padding: 2px; border-radius: 6px; background: var(--surface-2); max-width: 100%; flex-wrap: wrap; }
:root .ui-theme-pick button {
  min-height: 32px; padding: 0 10px; border: 0; border-radius: 4px; background: transparent;
  color: var(--text-muted); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
:root .ui-theme-pick button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border-strong); }
:root .ui-theme-pick button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
