/* ==========================================================================
   BînaJîr design system — by Kaver
   One stylesheet: tokens → base → layout → components → charts → utilities.
   All spacing uses logical properties so every screen mirrors for ckb / ar.
   ========================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
  color-scheme: light;

  --font-latin: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-arabic: "Noto Sans Arabic", "Archivo", "Segoe UI", "Geeza Pro", Tahoma, sans-serif;
  --font-sans: var(--font-latin);
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Stone neutrals */
  --bg: #F3F2EE;
  --surface: #FDFDFB;
  --surface-2: #F7F6F2;
  --surface-3: #EFEDE8;
  --border: #E4E1DA;
  --border-strong: #D1CDC4;
  --ink: #1C1B18;
  --ink-2: #57544C;
  --ink-3: #6E6A61;

  /* Actions */
  --primary: #1C1B18;
  --primary-hover: #34322D;
  --on-primary: #FDFDFB;
  --accent: #256ABF;
  --accent-hover: #1C5CAB;
  --accent-ink: #1F5FAF;
  --accent-soft: #E6EEF9;
  --on-accent: #FFFFFF;

  /* Kaver brand */
  --ochre: #C8841F;
  --ochre-ink: #9A5B12;
  --ochre-soft: #F6EBDA;
  --basalt: #1C1B18;
  --limestone: #F3F2EE;

  /* Status — fixed, reserved meaning, always paired with icon + label */
  --good: #0CA30C;
  --warning: #FAB219;
  --serious: #EC835A;
  --critical: #D03B3B;
  --good-ink: #006300;
  --warning-ink: #8A5A00;
  --serious-ink: #B14A1C;
  --critical-ink: #B42323;
  --good-soft: #E6F4E4;
  --warning-soft: #FDF2D8;
  --serious-soft: #FBEAE2;
  --critical-soft: #F9E4E2;
  --neutral-soft: #EEECE7;

  /* Charts (validated: dataviz six checks, light surface #FDFDFB) */
  --chart-surface: var(--surface);
  --grid: #E9E7E1;
  --axis: #C9C5BB;
  --axis-label: #6E6A61;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
  --series-muted: #A8A397;
  --planned: #D8D4CB;
  --seq-100: #cde2fb; --seq-200: #9ec5f4; --seq-300: #6da7ec; --seq-400: #3987e5;
  --seq-500: #256abf; --seq-600: #184f95; --seq-700: #0d366b;

  /* Sidebar — basalt in both themes */
  --sb-bg: #191816;
  --sb-bg-2: #22211E;
  --sb-border: rgba(255, 255, 255, 0.07);
  --sb-ink: #EDEAE3;
  --sb-ink-2: #A9A59B;
  --sb-ink-3: #7C786F;
  --sb-hover: rgba(255, 255, 255, 0.05);
  --sb-active: rgba(255, 255, 255, 0.09);

  /* Shape & depth */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --shadow-1: 0 1px 2px rgba(28, 27, 24, 0.05);
  --shadow-2: 0 6px 20px -6px rgba(28, 27, 24, 0.14), 0 1px 2px rgba(28, 27, 24, 0.05);
  --shadow-3: 0 28px 56px -16px rgba(28, 27, 24, 0.28), 0 2px 6px rgba(28, 27, 24, 0.06);
  --focus-ring: 0 0 0 3px color-mix(in srgb, var(--accent) 32%, transparent);

  --sidebar-w: 260px;
  --sidebar-w-collapsed: 76px;
  --topbar-h: 64px;
  --page-pad: 28px;
  --gap: 20px;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #121210; --surface: #1B1A18; --surface-2: #211F1C; --surface-3: #292724;
    --border: #2F2D29; --border-strong: #423F39;
    --ink: #F5F4F0; --ink-2: #C6C3B9; --ink-3: #9A968C;
    --primary: #F5F4F0; --primary-hover: #E2DFD7; --on-primary: #1C1B18;
    --accent: #256ABF; --accent-hover: #2F78D0; --accent-ink: #6AA5EA; --accent-soft: rgba(57, 135, 229, 0.16);
    --ochre: #D99A3D; --ochre-ink: #E0A24A; --ochre-soft: rgba(217, 154, 61, 0.15);
    --good-ink: #3DBE3D; --warning-ink: #FAB219; --serious-ink: #EC835A; --critical-ink: #F07373;
    --good-soft: rgba(12, 163, 12, 0.16); --warning-soft: rgba(250, 178, 25, 0.14);
    --serious-soft: rgba(236, 131, 90, 0.15); --critical-soft: rgba(208, 59, 59, 0.2); --neutral-soft: #2A2825;
    --grid: #2A2926; --axis: #3D3B36; --axis-label: #9A968C;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --series-muted: #6B675F; --planned: #3A3834;
    --seq-100: #104281; --seq-200: #184f95; --seq-300: #1c5cab; --seq-400: #256abf;
    --seq-500: #3987e5; --seq-600: #6da7ec; --seq-700: #9ec5f4;
    --sb-bg: #0F0F0D; --sb-bg-2: #181715;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 8px 24px -8px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.03);
    --shadow-3: 0 28px 56px -16px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.04);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121210; --surface: #1B1A18; --surface-2: #211F1C; --surface-3: #292724;
  --border: #2F2D29; --border-strong: #423F39;
  --ink: #F5F4F0; --ink-2: #C6C3B9; --ink-3: #9A968C;
  --primary: #F5F4F0; --primary-hover: #E2DFD7; --on-primary: #1C1B18;
  --accent: #256ABF; --accent-hover: #2F78D0; --accent-ink: #6AA5EA; --accent-soft: rgba(57, 135, 229, 0.16);
  --ochre: #D99A3D; --ochre-ink: #E0A24A; --ochre-soft: rgba(217, 154, 61, 0.15);
  --good-ink: #3DBE3D; --warning-ink: #FAB219; --serious-ink: #EC835A; --critical-ink: #F07373;
  --good-soft: rgba(12, 163, 12, 0.16); --warning-soft: rgba(250, 178, 25, 0.14);
  --serious-soft: rgba(236, 131, 90, 0.15); --critical-soft: rgba(208, 59, 59, 0.2); --neutral-soft: #2A2825;
  --grid: #2A2926; --axis: #3D3B36; --axis-label: #9A968C;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  --series-muted: #6B675F; --planned: #3A3834;
  --seq-100: #104281; --seq-200: #184f95; --seq-300: #1c5cab; --seq-400: #256abf;
  --seq-500: #3987e5; --seq-600: #6da7ec; --seq-700: #9ec5f4;
  --sb-bg: #0F0F0D; --sb-bg-2: #181715;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 8px 24px -8px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.03);
  --shadow-3: 0 28px 56px -16px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.04);
}

:root:lang(ckb), :root:lang(ar) { --font-sans: var(--font-arabic); }

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01" on, "cv11" on;
}
h1, h2, h3, h4, h5, p { margin: 0; }
h1, h2, h3, h4 { font-weight: 650; letter-spacing: -0.012em; line-height: 1.2; }
:root:lang(ckb) h1, :root:lang(ar) h1, :root:lang(ckb) h2, :root:lang(ar) h2 { letter-spacing: 0; line-height: 1.4; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }
::selection { background: color-mix(in srgb, var(--accent) 24%, transparent); }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
[hidden] { display: none !important; }

.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon--sm { width: 15px; height: 15px; }
.icon--xs { width: 13px; height: 13px; }
.icon--lg { width: 22px; height: 22px; }
.icon--xl { width: 28px; height: 28px; }
img.icon--img { object-fit: contain; border-radius: 3px; }
[dir="rtl"] .icon--flip { transform: scaleX(-1); }

/* ---------- 3. App layout ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}
.app.is-collapsed { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }
.main { min-width: 0; display: flex; flex-direction: column; }
.page { padding: 24px var(--page-pad) 56px; display: flex; flex-direction: column; gap: var(--gap); max-width: 1600px; width: 100%; margin-inline: auto; }

/* Sidebar */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--sb-bg); color: var(--sb-ink);
  display: flex; flex-direction: column;
  border-inline-end: 1px solid var(--sb-border);
  overflow: hidden; z-index: 40;
}
.sidebar__brand { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 18px 18px 14px; min-height: var(--topbar-h); }
.sidebar__brand .brand-lockup { color: var(--sb-ink); }
.sidebar__project {
  margin: 4px 12px 10px; padding: 10px 12px; border-radius: var(--radius);
  background: var(--sb-bg-2); border: 1px solid var(--sb-border);
  display: flex; align-items: center; gap: 10px; cursor: pointer; text-align: start; width: calc(100% - 24px); color: inherit;
}
.sidebar__project:hover { border-color: rgba(255, 255, 255, 0.14); }
.sidebar__project-mark { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(145deg, #3a3833, #262521); display: grid; place-items: center; color: var(--ochre); flex: none; font-weight: 700; font-size: 12px; letter-spacing: 0.02em; }
.sidebar__project-name { font-weight: 600; font-size: 13px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar__project-meta { color: var(--sb-ink-2); font-size: 11.5px; white-space: nowrap; }
.sidebar__project .icon { color: var(--sb-ink-3); margin-inline-start: auto; }
.sidebar__nav { flex: 1; overflow-y: auto; padding: 4px 10px 12px; scrollbar-width: thin; scrollbar-color: #3a3833 transparent; }
.nav-group { margin-top: 14px; }
.nav-group__label { font-size: 10.5px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--sb-ink-3); padding: 0 10px 6px; font-weight: 600; white-space: nowrap; }
:root:lang(ckb) .nav-group__label, :root:lang(ar) .nav-group__label { letter-spacing: 0; font-size: 11.5px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; margin: 1px 0; border-radius: 8px;
  color: var(--sb-ink-2); font-size: 13.5px; font-weight: 500; white-space: nowrap;
}
.nav-item:hover { background: var(--sb-hover); color: var(--sb-ink); text-decoration: none; }
.nav-item.is-active { background: var(--sb-active); color: #FFFFFF; }
.nav-item.is-active::before {
  content: ""; position: absolute; inset-inline-start: -10px; top: 8px; bottom: 8px; width: 3px;
  border-start-end-radius: 3px; border-end-end-radius: 3px; background: var(--ochre);
}
.nav-item .icon { width: 18px; height: 18px; }
.nav-item.is-active .icon { color: var(--ochre); }
.nav-item__badge { margin-inline-start: auto; font-size: 11px; font-weight: 600; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: inline-grid; place-items: center; background: rgba(255, 255, 255, 0.08); color: var(--sb-ink); font-variant-numeric: tabular-nums; }
.nav-item__badge--alert { background: rgba(208, 59, 59, 0.22); color: #FFB4B0; }
.nav-item__tag { margin-inline-start: auto; font-size: 10px; font-weight: 700; letter-spacing: 0.04em; padding: 2px 6px; border-radius: 5px; background: rgba(200, 132, 31, 0.18); color: #F0C27E; }
.sidebar__foot { padding: 10px; border-top: 1px solid var(--sb-border); display: flex; flex-direction: column; gap: 2px; }
.sidebar__user { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 8px; margin-top: 4px; }
.sidebar__user:hover { background: var(--sb-hover); }
.sidebar__user-name { font-size: 13px; font-weight: 600; color: var(--sb-ink); line-height: 1.2; white-space: nowrap; }
.sidebar__user-role { font-size: 11.5px; color: var(--sb-ink-2); white-space: nowrap; }
.app.is-collapsed .sidebar .hide-collapsed { display: none; }
.app.is-collapsed .nav-item { justify-content: center; padding-inline: 0; }
.app.is-collapsed .nav-group__label { visibility: hidden; height: 6px; padding: 0; }
.app.is-collapsed .sidebar__project { justify-content: center; padding-inline: 0; }
.app.is-collapsed .sidebar__brand { justify-content: center; padding-inline: 0; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h); display: flex; align-items: center; gap: 12px;
  padding: 0 var(--page-pad);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-3); min-width: 0; white-space: nowrap; }
.crumbs strong { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.crumbs .icon { width: 14px; height: 14px; }
[dir="rtl"] .crumbs .icon { transform: scaleX(-1); }
.topbar__spacer { flex: 1; }
.search {
  display: flex; align-items: center; gap: 8px; height: 38px; width: min(340px, 30vw);
  padding: 0 10px 0 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border);
  color: var(--ink-3); font-size: 13px; cursor: text;
}
.search:hover { border-color: var(--border-strong); }
.search > span:not(.kbd) { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kbd { font-family: var(--font-mono); font-size: 11px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border); background: var(--surface-2); color: var(--ink-3); line-height: 18px; }
.topbar__tools { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  position: relative; width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 10px;
  background: transparent; border: 1px solid transparent; color: var(--ink-2);
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn.topbar__menu { display: none; }
.icon-btn .dot { position: absolute; top: 8px; inset-inline-end: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--critical); box-shadow: 0 0 0 2px var(--bg); }
.lang-btn { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.lang-btn:hover { border-color: var(--border-strong); color: var(--ink); }

/* Popover menus */
.menu { position: absolute; top: calc(100% + 6px); inset-inline-end: 0; min-width: 220px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-3); z-index: 60; }
.menu__item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; border: 0; background: transparent; text-align: start; font-size: 13px; color: var(--ink); }
.menu__item:hover { background: var(--surface-3); text-decoration: none; }
.menu__item[aria-checked="true"]::after { content: ""; margin-inline-start: auto; width: 16px; height: 16px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center/16px no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center/16px no-repeat; }
.menu__sep { height: 1px; background: var(--border); margin: 6px 4px; }
.menu__label { font-size: 11px; color: var(--ink-3); padding: 6px 10px 4px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.pop { position: relative; }

/* Page header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head__title { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
:root:lang(ckb) .page-head__title, :root:lang(ar) .page-head__title { letter-spacing: 0; }
.page-head__sub { color: var(--ink-3); font-size: 13.5px; margin-top: 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.page-head__sub > span { display: inline-flex; align-items: center; gap: 6px; }
.page-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.eyebrow { font-size: 11.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px; }
:root:lang(ckb) .eyebrow, :root:lang(ar) .eyebrow { letter-spacing: 0; }

/* Filter row — one row, above what it scopes */
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filters__label { font-size: 12px; color: var(--ink-3); margin-inline-end: 2px; }
.filters__spacer { flex: 1; }

/* Grid */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); }
.span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; } .span-9 { grid-column: span 9; } .span-12 { grid-column: 1 / -1; }
.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); }
.cols-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); }

/* ---------- 4. Components ---------- */

/* Card */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); min-width: 0; display: flex; flex-direction: column; }
.card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.card__title { font-size: 15px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.card__title .icon { color: var(--ink-3); }
.card__sub { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }
.card__actions { display: flex; align-items: center; gap: 6px; flex: none; }
.card__body { padding: 16px 20px 20px; flex: 1; min-width: 0; }
.card__body--flush { padding: 12px 0 0; }
.card__foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12.5px; color: var(--ink-3); }
.card--sunken { background: var(--surface-2); box-shadow: none; }
.card--ink { background: var(--basalt); color: #F5F4F0; border-color: #2F2D29; }
.card--ink .card__sub, .card--ink .muted { color: #A9A59B; }
.card--pad { padding: 20px; }
.card-link { display: block; color: inherit; }
.card-link:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow-2); }

/* Section heading inside page */
.section-title { font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-3); display: flex; align-items: center; gap: 8px; }
:root:lang(ckb) .section-title, :root:lang(ar) .section-title { letter-spacing: 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); font-size: 13.5px; font-weight: 600; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s, transform 0.06s;
}
.btn:hover { border-color: var(--border-strong); background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn .icon { width: 16px; height: 16px; }
.btn--primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn--accent { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn--accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--ink); }
.btn--danger { background: #C43434; color: #fff; border-color: #C43434; }
.btn--danger:hover { background: #B02C2C; border-color: #B02C2C; }
/* A refusal is a real decision, so it is not hidden — but it does not shout over the
   one that lets the work go on, so it carries the colour without the fill. */
.btn--danger-ghost { background: transparent; color: #C43434; border-color: color-mix(in srgb, #C43434 38%, transparent); }
.btn--danger-ghost:hover { background: color-mix(in srgb, #C43434 12%, transparent); border-color: #C43434; }
.btn--good { background: #0B7A0B; color: #fff; border-color: #0B7A0B; }
.btn--good:hover { background: #096A09; border-color: #096A09; }
.btn--sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; gap: 6px; }
.btn--sm .icon { width: 14px; height: 14px; }
.btn--lg { height: 46px; padding: 0 20px; font-size: 15px; border-radius: 12px; }
.btn--xl { height: 60px; padding: 0 24px; font-size: 17px; border-radius: 14px; }
.btn--icon { width: 38px; padding: 0; }
.btn--icon.btn--sm { width: 30px; }
.btn--block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* Segmented control */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--border); }
.seg button { height: 30px; padding: 0 11px; border: 0; border-radius: 7px; background: transparent; font-size: 12.5px; font-weight: 600; color: var(--ink-3); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--border); }
.seg--sm button { height: 26px; padding: 0 9px; font-size: 12px; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; padding: 10px 12px 12px; border: 0; background: none; color: var(--ink-3); font-size: 13.5px; font-weight: 600; white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"], .tab.is-active { color: var(--ink); }
.tab[aria-selected="true"]::after, .tab.is-active::after { content: ""; position: absolute; inset-inline: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--ink); }
.tab .count { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 10px; background: var(--surface-3); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tab-panel { padding-top: 16px; }

/* Chips / badges */
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--neutral-soft); color: var(--ink-2); line-height: 1;
}
.chip .icon { width: 13px; height: 13px; stroke-width: 2.2; }
.chip--sm { height: 20px; padding: 0 7px; font-size: 11px; }
.chip--good { background: var(--good-soft); color: var(--good-ink); }
.chip--warning { background: var(--warning-soft); color: var(--warning-ink); }
.chip--serious { background: var(--serious-soft); color: var(--serious-ink); }
.chip--critical { background: var(--critical-soft); color: var(--critical-ink); }
.chip--accent { background: var(--accent-soft); color: var(--accent-ink); }
.chip--ochre { background: var(--ochre-soft); color: var(--ochre-ink); }
.chip--outline { background: transparent; border: 1px solid var(--border-strong); color: var(--ink-2); }
.chip--ink { background: var(--ink); color: var(--surface); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--series-muted); }
.status-dot--good { background: var(--good); } .status-dot--warning { background: var(--warning); }
.status-dot--serious { background: var(--serious); } .status-dot--critical { background: var(--critical); }
.status-dot--planned { background: var(--planned); box-shadow: inset 0 0 0 1px var(--border-strong); }
.tag-code { font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); background: var(--surface-3); padding: 1px 6px; border-radius: 5px; white-space: nowrap; }
.ccy { font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border-strong); color: var(--ink-2); vertical-align: 1px; }

/* Stat tile */
.stat { padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; min-width: 0; position: relative; }
.stat__label { font-size: 12.5px; color: var(--ink-3); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat__label .icon { width: 15px; height: 15px; }
.stat__value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; white-space: nowrap; }
.stat__value small { font-size: 14px; color: var(--ink-3); font-weight: 500; margin-inline-start: 4px; letter-spacing: 0; }
.stat__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--ink-3); min-height: 22px; }
.stat__spark { height: 28px; width: 96px; flex: none; }
.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-row > .stat + .stat { border-inline-start: 1px solid var(--border); }
.stat-row--5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stat-row--6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-size: 12px; white-space: nowrap; }
.delta .icon { width: 13px; height: 13px; stroke-width: 2.4; }
.delta--good { color: var(--good-ink); }
.delta--bad { color: var(--critical-ink); }
.delta--flat { color: var(--ink-3); }

/* Hero figure — exactly one per view */
.hero-figure { font-size: 56px; font-weight: 700; letter-spacing: -0.035em; line-height: 1; }
.hero-figure small { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink-3); margin-inline-start: 2px; }

/* Meter — fill carries severity, track is a lighter step of the same ramp */
.meter { position: relative; height: 8px; border-radius: 999px; background: var(--accent-soft); overflow: visible; }
.meter__fill { position: absolute; inset-block: 0; inset-inline-start: 0; width: var(--value, 0%); max-width: 100%; border-radius: 999px; background: var(--accent); }
.meter__marker { position: absolute; top: -4px; bottom: -4px; inset-inline-start: var(--marker, 100%); width: 2px; margin-inline-start: -1px; border-radius: 1px; background: var(--ink); }
.meter--good { background: var(--good-soft); } .meter--good .meter__fill { background: var(--good); }
.meter--warning { background: var(--warning-soft); } .meter--warning .meter__fill { background: var(--warning); }
.meter--critical { background: var(--critical-soft); } .meter--critical .meter__fill { background: var(--critical); }
.meter--neutral { background: var(--surface-3); } .meter--neutral .meter__fill { background: var(--series-muted); }
.meter--thin { height: 5px; }
.meter--thick { height: 12px; }
.meter-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 12.5px; margin-bottom: 6px; }
.meter-row b { font-weight: 600; font-variant-numeric: tabular-nums; }

/* Tables */
.table-wrap { overflow-x: auto; min-width: 0; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th {
  position: sticky; top: 0; z-index: 1; text-align: start; font-weight: 600; font-size: 11.5px; letter-spacing: 0.03em; text-transform: uppercase;
  color: var(--ink-3); background: var(--surface-2); padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
:root:lang(ckb) .table th, :root:lang(ar) .table th { text-transform: none; letter-spacing: 0; font-size: 12px; }
.th-sort { all: unset; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; border-radius: 5px; }
.th-sort:hover { color: var(--ink); }
.th-sort:focus-visible { box-shadow: var(--focus-ring); }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--surface-3) 55%, transparent); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.is-selected td { background: var(--accent-soft); }
.table tr.is-alert td:first-child { box-shadow: inset 3px 0 0 var(--critical); }
[dir="rtl"] .table tr.is-alert td:first-child { box-shadow: inset -3px 0 0 var(--critical); }
.table .num, .num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table th.num { text-align: end; }
.table td:first-child, .table th:first-child { padding-inline-start: 20px; }
.table td:last-child, .table th:last-child { padding-inline-end: 20px; }
.table--compact td { padding-block: 7px; }
.table tfoot td { font-weight: 650; background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 0; }
.cell-main { font-weight: 600; color: var(--ink); line-height: 1.3; }
.cell-sub { font-size: 12px; color: var(--ink-3); line-height: 1.3; margin-top: 2px; }
.cell-flex { display: flex; align-items: center; gap: 10px; }

/* Location path  A2 › F14 › 1403 */
.loc { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.loc b { font-weight: 600; color: var(--ink); }
.loc i { font-style: normal; color: var(--ink-3); opacity: 0.7; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.label .hint { font-weight: 500; color: var(--ink-3); font-size: 12px; }
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--ink); font-size: 14px; transition: border-color 0.12s, box-shadow 0.12s;
}
.textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.45; }
.input:hover, .select:hover { border-color: color-mix(in srgb, var(--ink) 30%, var(--border-strong)); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }
.input[readonly] { background: var(--surface-2); color: var(--ink-2); }
.input--lg { height: 52px; font-size: 18px; font-weight: 600; }
.select { appearance: none; -webkit-appearance: none; padding-inline-end: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236E6A61' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-size: 16px; background-position: right 12px center; }
[dir="rtl"] .select { background-position: left 12px center; }
.input[type=number] { appearance: textfield; -moz-appearance: textfield; }
.input[type=number]::-webkit-inner-spin-button, .input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.select--sm, .input--sm { height: 32px; font-size: 13px; border-radius: 8px; }
.input-group { display: flex; align-items: stretch; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); overflow: hidden; }
.input-group:focus-within { border-color: var(--accent); box-shadow: var(--focus-ring); }
.input-group .input { border: 0; border-radius: 0; box-shadow: none !important; }
.input-group__addon { display: flex; align-items: center; gap: 6px; padding: 0 12px; background: var(--surface-2); color: var(--ink-3); font-size: 13px; font-weight: 600; white-space: nowrap; }
.help { font-size: 12px; color: var(--ink-3); display: flex; align-items: flex-start; gap: 6px; }
.help .icon { width: 14px; height: 14px; margin-top: 1px; }
.help--critical { color: var(--critical-ink); } .help--warning { color: var(--warning-ink); } .help--good { color: var(--good-ink); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; font-size: 13px; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; width: 36px; height: 20px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background 0.15s; margin: 0; cursor: pointer; }
.switch input::after { content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: inset-inline-start 0.15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { inset-inline-start: 18px; }
.stepper { display: flex; align-items: stretch; border: 1px solid var(--border-strong); border-radius: 12px; overflow: hidden; background: var(--surface); }
.stepper button { width: 52px; border: 0; background: var(--surface-2); font-size: 22px; font-weight: 600; color: var(--ink); display: grid; place-items: center; }
.stepper button:hover { background: var(--surface-3); }
.stepper input { flex: 1; min-width: 0; border: 0; text-align: center; font-size: 22px; font-weight: 650; background: transparent; font-variant-numeric: tabular-nums; }
.stepper input:focus { outline: none; }
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: 12px; padding: 18px; display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: 13px; background: var(--surface-2); }

/* Avatars */
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; background: var(--surface-3); color: var(--ink-2); letter-spacing: 0.02em; }
.avatar--sm { width: 24px; height: 24px; font-size: 10px; }
.avatar--lg { width: 48px; height: 48px; font-size: 16px; }
.avatar--xl { width: 64px; height: 64px; font-size: 20px; border-radius: 16px; }
.avatar--ochre { background: var(--ochre-soft); color: var(--ochre-ink); }
.avatar--accent { background: var(--accent-soft); color: var(--accent-ink); }
.avatar--ink { background: #2E2C28; color: #F0C27E; }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar + .avatar { margin-inline-start: -8px; }

/* Lists */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--border); }
.list-item:first-child { border-top: 0; }
.list-item:hover { background: color-mix(in srgb, var(--surface-3) 45%, transparent); }
.list-item__body { flex: 1; min-width: 0; }
.list-item__title { font-weight: 600; font-size: 13.5px; line-height: 1.35; }
.list-item__meta { font-size: 12px; color: var(--ink-3); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
/* The line wraps between facts, never inside one: a "·" that ends up alone on a line is
   separating nothing, and reads as a bullet nobody meant to write. */
.list-item__meta > span { white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.list-item__meta > span.is-wrap { white-space: normal; }
.list-item__aside { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }

/* Icon badge (status icon in a soft circle) */
.ibadge { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--ink-2); }
.ibadge .icon { width: 17px; height: 17px; }
.ibadge--good { background: var(--good-soft); color: var(--good-ink); }
.ibadge--warning { background: var(--warning-soft); color: var(--warning-ink); }
.ibadge--serious { background: var(--serious-soft); color: var(--serious-ink); }
.ibadge--critical { background: var(--critical-soft); color: var(--critical-ink); }
.ibadge--accent { background: var(--accent-soft); color: var(--accent-ink); }
.ibadge--ochre { background: var(--ochre-soft); color: var(--ochre-ink); }
.ibadge--lg { width: 44px; height: 44px; border-radius: 12px; }
.ibadge--lg .icon { width: 21px; height: 21px; }

/* Callouts */
.callout { display: flex; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; }
.callout .icon { margin-top: 1px; }
.callout__title { font-weight: 650; margin-bottom: 2px; }
.callout--critical { background: var(--critical-soft); border-color: color-mix(in srgb, var(--critical) 30%, transparent); }
.callout--critical > .icon { color: var(--critical-ink); }
.callout--warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 40%, transparent); }
.callout--warning > .icon { color: var(--warning-ink); }
.callout--good { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.callout--good > .icon { color: var(--good-ink); }
.callout--accent { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.callout--accent > .icon { color: var(--accent-ink); }

/* Workflow steps (approval chain / lifecycle) */
.steps { display: flex; align-items: flex-start; gap: 0; }
.step { flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; position: relative; font-size: 12px; color: var(--ink-3); min-width: 0; }
.step::before { content: ""; position: absolute; top: 13px; inset-inline-start: calc(-50% + 16px); inset-inline-end: calc(50% + 16px); height: 2px; background: var(--border-strong); }
.step:first-child::before { display: none; }
.step__dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--border-strong); color: var(--ink-3); z-index: 1; font-size: 11px; font-weight: 700; }
.step__dot .icon { width: 14px; height: 14px; stroke-width: 2.6; }
.step__label { font-weight: 600; color: var(--ink-2); font-size: 12px; line-height: 1.3; }
.step.is-done .step__dot { background: var(--good); border-color: var(--good); color: #fff; }
.step.is-done::before, .step.is-current::before { background: var(--good); }
.step.is-current .step__dot { border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 4px var(--accent-soft); }
.step.is-current .step__label { color: var(--ink); }
.step.is-blocked .step__dot { background: var(--critical); border-color: var(--critical); color: #fff; }
.step.is-blocked .step__label { color: var(--critical-ink); }
.step__meta { font-size: 11px; color: var(--ink-3); line-height: 1.3; }

/* Timeline */
.timeline { display: flex; flex-direction: column; }
.tl-item { display: grid; grid-template-columns: 28px 1fr; gap: 10px; position: relative; padding-bottom: 16px; }
.tl-item::before { content: ""; position: absolute; inset-inline-start: 13px; top: 26px; bottom: 0; width: 2px; background: var(--border); }
.tl-item:last-child::before { display: none; }
.tl-item__dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-2); }
.tl-item__dot .icon { width: 14px; height: 14px; }
.tl-item__title { font-weight: 600; font-size: 13px; }
.tl-item__meta { font-size: 12px; color: var(--ink-3); }

/* Kanban */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 6px; }
.kanban-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.kanban-col__head { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 650; padding: 2px 4px 4px; }
.kanban-col__head .count { margin-inline-start: auto; font-size: 11.5px; color: var(--ink-3); font-weight: 600; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; box-shadow: var(--shadow-1); display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; }
.kcard:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.kcard__title { font-weight: 650; font-size: 13px; line-height: 1.35; }
.kcard__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--ink-3); }

.kanban--fit { grid-auto-columns: minmax(208px, 1fr); gap: 12px; }

/* Drawer & modal */
.overlay { position: fixed; inset: 0; background: rgba(18, 18, 16, 0.42); z-index: 80; animation: fade 0.15s ease-out; }
.drawer {
  position: fixed; top: 0; bottom: 0; inset-inline-end: 0; width: min(480px, 100vw); z-index: 90;
  background: var(--surface); border-inline-start: 1px solid var(--border); box-shadow: var(--shadow-3);
  display: flex; flex-direction: column; animation: slide-in 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
[dir="rtl"] .drawer { animation-name: slide-in-rtl; }
.drawer__head { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; gap: 12px; }
.drawer__body { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.drawer__body > * { flex-shrink: 0; }
.drawer__foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.modal { position: fixed; z-index: 90; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 64px); overflow: auto; background: var(--surface); border-radius: var(--radius-xl); box-shadow: var(--shadow-3); border: 1px solid var(--border); }
@keyframes fade { from { opacity: 0; } }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }
@keyframes slide-in-rtl { from { transform: translateX(-24px); opacity: 0; } }

/* Key–value rows */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; text-align: end; font-weight: 600; font-variant-numeric: tabular-nums; }
.kv--rule { column-gap: 0; }
.kv--rule dt, .kv--rule dd { padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.kv--rule dt { padding-inline-end: 16px; }
.kv .total { font-size: 15px; font-weight: 700; color: var(--ink); }

/* Equation (settlement math) */
.equation { display: flex; align-items: stretch; flex-wrap: wrap; gap: 8px; }
.equation__term { flex: 1; min-width: 120px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.equation__term small { display: block; font-size: 11.5px; color: var(--ink-3); font-weight: 500; }
.equation__term b { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.equation__op { display: grid; place-items: center; font-size: 18px; color: var(--ink-3); font-weight: 600; }
.equation__term--result { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.equation__term--result small { color: color-mix(in srgb, var(--surface) 70%, transparent); }

/* Journal entry block */
.je { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; font-size: 12.5px; }
.je__line { display: grid; grid-template-columns: 56px 1fr 110px 110px; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--border); align-items: center; }
.je__line:first-child { border-top: 0; }
.je__line--head { background: var(--surface-2); font-weight: 600; color: var(--ink-3); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.je__line--head .num { font-family: inherit; }
:root:lang(ckb) .je__line--head, :root:lang(ar) .je__line--head { letter-spacing: 0; text-transform: none; font-size: 11.5px; }
.je__line .acct { font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); }
.je__line .cr-name { padding-inline-start: 18px; }
.je__line .num { font-family: var(--font-mono); font-size: 12px; }
.je__foot { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: var(--surface-2); border-top: 1px solid var(--border); font-weight: 600; }

/* Empty state */
.empty { text-align: center; padding: 36px 20px; color: var(--ink-3); display: flex; flex-direction: column; align-items: center; gap: 10px; }

/* Brand lockup (in-app) */
.brand-lockup { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); }
.brand-lockup__mark { width: 34px; height: 34px; flex: none; }
.brand-lockup__name { font-weight: 750; font-size: 17px; letter-spacing: -0.01em; line-height: 1; font-family: var(--font-latin); }
.brand-lockup__by { display: block; font-size: 10.5px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--sb-ink-3); margin-top: 4px; font-family: var(--font-latin); }

/* Skip link */
.skip { position: absolute; inset-inline-start: 8px; top: -60px; z-index: 100; padding: 8px 12px; background: var(--ink); color: var(--surface); border-radius: 8px; }
.skip:focus { top: 8px; }

/* Language links for bare pages (login, portal, field) — reload with ?lang= */
.lang-links { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--border); }
.lang-links a { height: 30px; padding: 0 12px; border-radius: 7px; display: inline-flex; align-items: center; font-size: 12.5px; font-weight: 600; color: var(--ink-3); text-decoration: none; }
.lang-links a:hover { color: var(--ink); }
.lang-links a[aria-current="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--border); }
.lang-links a[lang="ckb"], .lang-links a[lang="ar"] { font-family: var(--font-arabic); }

/* Glove-sized stepper for field use */
.stepper--xl button { width: 64px; font-size: 28px; }
.stepper--xl input { font-size: 30px; height: 64px; }

/* Journal entries with IQD-sized amounts */
.je--wide .je__line { grid-template-columns: 44px minmax(0, 1fr) 124px 124px; }

/* Toast */
.toast-wrap { position: fixed; bottom: 20px; inset-inline-end: 20px; z-index: 120; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--ink); color: var(--surface); box-shadow: var(--shadow-3); font-size: 13px; animation: fade 0.15s; }

/* ---------- 5. Charts ---------- */
.viz { position: relative; min-width: 0; }
.viz-plot { position: relative; }
.viz-plot svg { overflow: visible; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 10px; }
.viz-legend__item { display: inline-flex; align-items: center; gap: 7px; border: 0; background: none; padding: 2px 0; color: inherit; font-size: inherit; }
.viz-legend__item[aria-pressed="false"] { opacity: 0.45; }
.viz-key-line { width: 14px; height: 2px; border-radius: 1px; flex: none; }
.viz-key-rect { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.viz-key-icon { display: inline-grid; place-items: center; }
.viz-tooltip {
  position: absolute; z-index: 20; pointer-events: none; min-width: 150px; max-width: 260px;
  padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-3); font-size: 12px; color: var(--ink-2);
}
.viz-tooltip__title { font-weight: 600; color: var(--ink-3); font-size: 11.5px; margin-bottom: 6px; }
.viz-tooltip__row { display: grid; grid-template-columns: 14px auto 1fr; align-items: center; gap: 8px; margin-top: 3px; }
.viz-tooltip__row b { color: var(--ink); font-weight: 650; font-size: 13px; font-variant-numeric: tabular-nums; }
.viz-tooltip__row span:last-child { text-align: end; color: var(--ink-3); }
.viz-table { width: 100%; }
.viz .tick { font-size: 11px; fill: var(--axis-label); font-variant-numeric: tabular-nums; font-family: var(--font-latin); }
.viz .gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.viz .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.viz .crosshair { stroke: var(--ink-3); stroke-width: 1; shape-rendering: crispEdges; }
.viz .end-label { font-size: 12px; fill: var(--ink-2); font-weight: 600; font-family: var(--font-latin); paint-order: stroke; stroke: var(--chart-surface); stroke-width: 4px; stroke-linejoin: round; }
.viz .end-label tspan.v { fill: var(--ink); font-weight: 700; }
.viz .annot { font-size: 11px; fill: var(--ink-3); font-weight: 600; font-family: var(--font-latin); paint-order: stroke; stroke: var(--chart-surface); stroke-width: 4px; }
.viz .annot-line { stroke: var(--ink-3); stroke-width: 1; shape-rendering: crispEdges; }
.viz .leader { stroke: var(--axis); stroke-width: 1; }
.viz .bar { transition: opacity 0.1s; }
.viz .bar:hover, .viz .bar:focus { opacity: 0.82; outline: none; }
.viz .cap-label { paint-order: stroke; stroke: var(--chart-surface); stroke-width: 3px; font-size: 11.5px; font-weight: 650; fill: var(--ink-2); font-variant-numeric: tabular-nums; font-family: var(--font-latin); }
.viz.is-loading .viz-plot { opacity: 0.45; transition: opacity 0.2s; }

:root:lang(ckb) .viz text, :root:lang(ar) .viz text { font-family: var(--font-arabic); }

/* Horizontal bar chart (HTML, mirrors in RTL) */
.hbars { display: flex; flex-direction: column; gap: 4px; }
.hbar { display: grid; grid-template-columns: minmax(120px, 34%) 1fr 76px; align-items: center; gap: 12px; padding: 6px 0; border-radius: 8px; }
.hbar:hover, .hbar:focus-within { background: color-mix(in srgb, var(--surface-3) 50%, transparent); }
.hbar__label { min-width: 0; font-size: 13px; }
.hbar__label b { font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar__label small { color: var(--ink-3); font-size: 11.5px; display: flex; align-items: center; gap: 6px; }
.hbar__track { position: relative; height: 18px; }
.hbar__bar { position: absolute; inset-block: 1px; inset-inline-start: 0; border-start-end-radius: 4px; border-end-end-radius: 4px; background: var(--series-1); }
.hbar__marker { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-inline-start: -1px; background: var(--ink); border-radius: 1px; }
.hbar__value { text-align: end; font-size: 12.5px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hbar__value small { display: block; font-weight: 500; color: var(--ink-3); font-size: 11px; }
.hbars__axis { display: grid; grid-template-columns: minmax(120px, 34%) 1fr 76px; gap: 12px; }
.hbars__ticks { position: relative; height: 18px; border-top: 1px solid var(--axis); }
.hbars__ticks span { position: absolute; top: 4px; font-size: 11px; color: var(--axis-label); transform: translateX(-50%); font-variant-numeric: tabular-nums; }
[dir="rtl"] .hbars__ticks span { transform: translateX(50%); }
.hbars__grid { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--grid); }

/* "Both" currency mode: the IQD figure that rides after the USD one */
.money-alt { font-size: 0.8em; color: var(--ink-3); font-weight: 500; letter-spacing: 0; }
.stat__value .money-alt, .hero-figure .money-alt { font-size: 0.55em; }
td .money-alt, .num .money-alt { display: block; font-size: 11px; }

/* Status legend (icon + label) */
.status-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--ink-2); }
.status-legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.swatch--good { background: var(--good); } .swatch--warning { background: var(--warning); }
.swatch--critical { background: var(--critical); } .swatch--serious { background: var(--serious); }
.swatch--planned { background: var(--planned); box-shadow: inset 0 0 0 1px var(--border-strong); }

/* RTL: keep Latin figures, money and codes reading left-to-right inside Kurdish / Arabic text */
[dir="rtl"] .tnum:not(td):not(th), [dir="rtl"] .hero-figure, [dir="rtl"] .stat__value,
[dir="rtl"] .tag-code, [dir="rtl"] .mono, [dir="rtl"] .ltr { direction: ltr; unicode-bidi: isolate; }
[dir="rtl"] .hero-figure, [dir="rtl"] .stat__value { text-align: right; }
[dir="rtl"] .num { unicode-bidi: isolate; }
.loc { direction: ltr; unicode-bidi: isolate; }

/* ---------- 6. Utilities ---------- */
.muted { color: var(--ink-3); }
.ink-2 { color: var(--ink-2); }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.tnum { font-variant-numeric: tabular-nums; }
.strong { font-weight: 650; }
.small { font-size: 12.5px; }
.xsmall { font-size: 11.5px; }
.nowrap { white-space: nowrap; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* A class called "row" has to guarantee a row. Without the direction it only means "flex", and
   inside anything that stacks — a list item's aside, for one — it silently came out as a column. */
.row { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.row--top { align-items: flex-start; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.stack--lg { gap: 16px; }
.stack--xl { gap: 24px; }
.grow { flex: 1; min-width: 0; }
.mt-0 { margin-top: 0; } .mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.text-good { color: var(--good-ink); } .text-warning { color: var(--warning-ink); } .text-critical { color: var(--critical-ink); } .text-accent { color: var(--accent-ink); } .text-ochre { color: var(--ochre-ink); }
.divider-v { width: 1px; align-self: stretch; background: var(--border); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.show-mobile { display: none; }

/* ---------- 7. Responsive ---------- */
@media (max-width: 1280px) {
  .span-8.lg-span-12, .span-4.lg-span-12, .span-5.lg-span-12, .span-6.lg-span-12, .span-7.lg-span-12, .span-9.lg-span-12, .span-3.lg-span-12 { grid-column: span 12; }
  .span-4.lg-span-6, .span-5.lg-span-6, .span-7.lg-span-6 { grid-column: span 6; }
  .stat-row, .stat-row--5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-row > .stat:nth-child(odd) { border-inline-start: 0; }
  .stat-row > .stat:nth-child(n+3) { border-top: 1px solid var(--border); }
  .stat-row--6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat-row--6 > .stat:nth-child(odd) { border-inline-start: 1px solid var(--border); }
  .stat-row--6 > .stat:nth-child(3n+1) { border-inline-start: 0; }
  .stat-row--6 > .stat:nth-child(-n+3) { border-top: 0; }
}
@media (max-width: 1024px) {
  :root { --page-pad: 20px; }
  .app, .app.is-collapsed { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: var(--sidebar-w); transform: translateX(-100%); transition: transform 0.22s ease; box-shadow: none; }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  /* the folded-away drawer sits just past the edge; in right-to-left that edge is the scrollable
     side, and without this the page opens scrolled sideways with its heading clipped */
  html { overflow-x: hidden; }
  .app.is-nav-open .sidebar { transform: none; box-shadow: var(--shadow-3); }
  .app.is-collapsed .sidebar .hide-collapsed { display: revert; }
  .icon-btn.topbar__menu { display: inline-grid; }
  .search { width: 38px; padding: 0; justify-content: center; }
  .search span, .search .kbd { display: none; }
  .grid > [class*="span-"] { grid-column: 1 / -1; }
  .cols-3, .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hide-tablet { display: none !important; }
}
@media (max-width: 640px) {
  :root { --page-pad: 16px; --gap: 14px; }
  .page { padding-top: 18px; }
  .page-head__title { font-size: 22px; }
  .cols-2, .cols-3, .cols-4, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .stat-row, .stat-row--5, .stat-row--6 { grid-template-columns: minmax(0, 1fr); }
  .stat-row > .stat + .stat { border-inline-start: 0; border-top: 1px solid var(--border); }
  .hero-figure { font-size: 44px; }
  .crumbs > :not(strong) { display: none; }
  .hide-mobile { display: none !important; }
  .show-mobile { display: revert; }
  .hbar, .hbars__axis { grid-template-columns: minmax(90px, 38%) 1fr 64px; gap: 8px; }
  .card__head { padding: 16px 16px 0; }
  .card__body { padding: 14px 16px 16px; }
  .card__body.card__body--flush { padding: 12px 0 0; }
  .table td:first-child, .table th:first-child { padding-inline-start: 16px; }
  .table td:last-child, .table th:last-child { padding-inline-end: 16px; }
  .lang-btn span { display: none; }
  .toast-wrap { inset-inline: 16px; bottom: 16px; }
}

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .app { display: block; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
