/* SPLAT desk -- one stylesheet.
   Palette from the official SPLAT guideline: red #BA0C2F is the single
   corporate colour and the four tints do the structural work. Red never
   means "something is wrong" -- warnings use vermilion, which is outside
   the brand set on purpose. Type is Jost (open Futura revival) with
   Arial, the fallback the guideline itself sanctions. */

:root {
  --brand: #ba0c2f;
  --brand-d: #96091f;
  --brand-w: rgba(186, 12, 47, .10);

  --t1: #f3f7fc;   /* page ground */
  --t2: #eaf4fc;   /* surfaces */
  --t3: #e6f3eb;   /* positive */
  --t4: #d7eced;   /* borders, chart ground */

  --bg: #ffffff;
  --page: var(--t1);
  --surf: #ffffff;
  --surf2: var(--t2);
  --line: #dbe6f0;
  --line-s: #c7d7e5;

  --ink: #0e1726;
  --ink2: #3d4c60;
  --ink3: #6b7b90;
  --ink4: #95a3b5;

  --warn: #b93d0b;        /* vermilion, not brand red */
  --warn-w: rgba(185, 61, 11, .10);
  --good: #1c7a4a;
  --good-w: rgba(28, 122, 74, .10);
  --info: #1f5f9e;

  --r: 12px;
  --r-s: 8px;
  --sh: 0 1px 2px rgba(14, 23, 38, .05), 0 4px 14px rgba(14, 23, 38, .04);
  --sh-2: 0 10px 40px rgba(14, 23, 38, .14);

  --rail: 232px;
  --fs: 14px;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --sans: Jost, "Futura", Arial, system-ui, -apple-system, "Segoe UI", sans-serif;
  --arab: "IBM Plex Sans Arabic", Jost, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #0b1220; --surf: #121b2b; --surf2: #16202f;
    --line: #223044; --line-s: #2d3e55;
    --ink: #eef3f9; --ink2: #b8c6d6; --ink3: #8b9bad; --ink4: #67768a;
    --t1: #0b1220; --t2: #16202f; --t3: #14251c; --t4: #16292b;
    --brand-w: rgba(186, 12, 47, .20);
    --warn-w: rgba(185, 61, 11, .18);
    --good-w: rgba(28, 122, 74, .18);
    --sh: 0 1px 2px rgba(0, 0, 0, .3);
    --sh-2: 0 10px 40px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  --page: #0b1220; --surf: #121b2b; --surf2: #16202f;
  --line: #223044; --line-s: #2d3e55;
  --ink: #eef3f9; --ink2: #b8c6d6; --ink3: #8b9bad; --ink4: #67768a;
  --t1: #0b1220; --t2: #16202f; --t3: #14251c; --t4: #16292b;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--page); color: var(--ink);
  font: var(--fs)/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
body[dir="rtl"] { font-family: var(--arab); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
svg.ic { flex: 0 0 auto; vertical-align: -2px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }
.rail {
  background: var(--surf); border-inline-end: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.rail-h { padding: 16px 16px 12px; display: flex; gap: 11px; align-items: center; }
.logo { width: 52px; height: 34px; background: var(--brand); border-radius: 3px;
  display: grid; place-items: center; flex: 0 0 auto; }
.logo img { width: 44px; height: auto; display: block; }
.rail-h b { display: block; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; }
.rail-h em { display: block; font-style: normal; font-size: 12px; color: var(--brand); font-weight: 500; }
#nav { flex: 1; overflow-y: auto; padding: 4px 8px 16px; }
.nv-g { font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink4); padding: 14px 10px 5px; font-weight: 600; }
.nv { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: var(--r-s);
  color: var(--ink2); font-weight: 500; }
.nv:hover { background: var(--surf2); color: var(--ink); }
.nv.on { background: var(--brand-w); color: var(--brand); font-weight: 600; }
.nv span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nv-n { font-style: normal; font-size: 11px; font-weight: 600; background: var(--brand);
  color: #fff; border-radius: 9px; padding: 1px 6px; }
.rail-f { border-top: 1px solid var(--line); padding: 12px 16px; }
#who { display: flex; gap: 9px; align-items: center; font-size: 12px; }
#who b { display: block; font-weight: 600; }
#who em { font-style: normal; color: var(--ink3); }
.av { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 600; flex: 0 0 auto; }

.body { min-width: 0; display: flex; flex-direction: column; }
#head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: space-between;
  padding: 10px 20px; background: var(--surf); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30; }
.hd-l, .hd-r { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; }
.hd-s, .hd-q { background: var(--surf2); border: 1px solid var(--line); border-radius: var(--r-s);
  padding: 6px 9px; min-width: 0; }
.hd-q { width: 190px; max-width: 40vw; }
#main { padding: 20px; display: grid; gap: 16px; align-content: start; min-width: 0; }
.load { padding: 40px; text-align: center; color: var(--ink3); }

/* ---------- segmented ---------- */
.seg { display: inline-flex; flex-wrap: wrap; max-width: 100%; background: var(--surf2);
  border: 1px solid var(--line); border-radius: var(--r-s); padding: 2px; gap: 2px; }
.sg { background: none; border: 0; padding: 5px 10px; border-radius: 6px; cursor: pointer;
  color: var(--ink2); font-weight: 500; }
.sg:hover { background: var(--surf); }
.sg.on { background: var(--surf); color: var(--brand); font-weight: 600; box-shadow: var(--sh); }

/* ---------- scope picker ---------- */
.sc { position: relative; }
.sc-b { display: inline-flex; gap: 7px; align-items: center; background: var(--surf2);
  border: 1px solid var(--line); border-radius: var(--r-s); padding: 6px 10px; cursor: pointer; }
.sc-p { display: none; position: absolute; z-index: 60; top: calc(100% + 5px); inset-inline-start: 0;
  min-width: 214px; background: var(--surf); border: 1px solid var(--line-s);
  border-radius: var(--r); box-shadow: var(--sh-2); padding: 6px; }
.sc-p.open { display: block; }
.sc-r { display: flex; gap: 9px; align-items: center; padding: 7px 9px; border-radius: 6px; cursor: pointer; }
.sc-r:hover { background: var(--surf2); }
.sc-f { border-top: 1px solid var(--line); margin-top: 5px; padding-top: 6px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; gap: 6px; align-items: center; justify-content: center;
  background: var(--surf); border: 1px solid var(--line-s); border-radius: var(--r-s);
  padding: 7px 12px; font-weight: 500; cursor: pointer; }
.btn:hover:not(:disabled) { background: var(--surf2); border-color: var(--ink4); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--brand-d); border-color: var(--brand-d); }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn.ghost { background: none; border-color: transparent; color: var(--ink2); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn.busy { opacity: .6; }
.btn.block { width: 100%; }

/* ---------- the editable field ---------- */
.fld { display: inline-flex; flex-direction: column; gap: 3px; position: relative; min-width: 0; }
.fld-l { font-size: 11px; letter-spacing: .05em; text-transform: uppercase;
  color: var(--ink3); font-weight: 600; }
.fld-i { background: var(--surf); border: 1px solid var(--line-s); border-radius: var(--r-s);
  padding: 6px 9px; width: 100%; min-width: 0; transition: border-color .12s, box-shadow .12s; }
.fld-i:hover { border-color: var(--ink4); }
.fld-i:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-w); }
.fld-i.num { text-align: end; font-variant-numeric: tabular-nums; }
.fld-i.area { min-height: 62px; resize: vertical; }
.fld-in { position: relative; display: block; min-width: 0; }
.fld-s { position: absolute; inset-inline-end: 9px; top: 50%; transform: translateY(-50%);
  font-size: 12px; color: var(--ink4); pointer-events: none; }
.fld.has-s .fld-i { padding-inline-end: 28px; }
.fld-h { font-size: 11.5px; color: var(--ink3); }
.fld-m { font-size: 11.5px; min-height: 0; color: var(--ink3); }
.fld.ok .fld-i { border-color: var(--good); }
.fld.ok .fld-m { color: var(--good); }
.fld.bad .fld-i { border-color: var(--warn); }
.fld.bad .fld-m { color: var(--warn); }
.fld.busy .fld-i { opacity: .7; }
/* Never set: the reason fourteen reps sat at B = 0 without anyone noticing. */
.fld.unset .fld-i { border-color: var(--warn); border-style: dashed; background: var(--warn-w); }
.fld.w-sm { width: 96px; } .fld.w-md { width: 148px; } .fld.w-lg { width: 230px; }
.fld.grow { flex: 1; }

.sw { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.sw input { position: absolute; opacity: 0; width: 0; height: 0; }
.sw-t { width: 38px; height: 22px; border-radius: 11px; background: var(--line-s);
  position: relative; transition: background .15s; flex: 0 0 auto; }
.sw-t::after { content:""; position: absolute; top: 2px; inset-inline-start: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: var(--sh); }
.sw input:checked + .sw-t { background: var(--brand); }
.sw input:checked + .sw-t::after { transform: translateX(16px); }
body[dir="rtl"] .sw input:checked + .sw-t::after { transform: translateX(-16px); }
.sw input:focus-visible + .sw-t { box-shadow: 0 0 0 3px var(--brand-w); }
.sw-x { font-size: 12.5px; color: var(--ink2); }

.frow { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; min-width: 0; }
.frow > * { min-width: 0; }
.fgrid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.fgrid > * { min-width: 0; }

/* ---------- cards, kpis ---------- */
.card { background: var(--surf); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); }
.card-h { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start;
  padding: 14px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-h h3 { font-size: 15px; }
.card-h p { font-size: 12.5px; color: var(--ink3); margin-top: 2px; }
.card-r { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; }
.card-r > * { min-width: 0; }
.card-h > div { min-width: 0; }
.card-b { padding: 16px; min-width: 0; }
.card-b > * { min-width: 0; }
#main > * { min-width: 0; }
.card-b.flush { padding: 0; }
.card-f { padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surf2);
  border-radius: 0 0 var(--r) var(--r); }

/* A grid track is minmax(auto, 1fr) by default, so an item whose
   min-content is wider than the track pushes the whole row past the
   viewport. min-width:0 on the items is what stops that, and it is the
   reason three screens were overflowing sideways at desktop width. */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(192px, 1fr)); }
.kpis > * { min-width: 0; }
.kpi { background: var(--surf); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px 16px; border-inline-start: 3px solid var(--line-s); box-shadow: var(--sh);
  min-width: 0; overflow: hidden; }
.kpi-l, .kpi-s { overflow-wrap: anywhere; }
.kpi-v { overflow-wrap: anywhere; }
.kpi-a { display: flex; gap: 8px; flex-wrap: wrap; min-width: 0; }
.kpi-l { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink3); font-weight: 600; }
.kpi-v { font-size: 27px; font-weight: 600; letter-spacing: -.02em; margin-top: 3px; line-height: 1.15; }
.kpi-s { font-size: 12px; color: var(--ink3); margin-top: 3px; }
.kpi-a { margin-top: 9px; }
.kpi.brand { border-inline-start-color: var(--brand); }
.kpi.warn { border-inline-start-color: var(--warn); }
.kpi.good { border-inline-start-color: var(--good); }

/* ---------- notice ---------- */
/* Several of these stack on a screen where a lot is switched off, so
   they stay tight enough not to push the real work below the fold. */
.notice { display: flex; gap: 10px; align-items: center; padding: 9px 13px;
  border-radius: var(--r); border: 1px solid; flex-wrap: wrap; }
.notice p { font-size: 12.5px; margin-top: 1px; opacity: .9; }
.notice strong { font-size: 13.5px; }
.notice + .notice { margin-top: -6px; }
.notice.warn { background: var(--warn-w); border-color: rgba(185, 61, 11, .3); color: var(--warn); }
.notice.bad { background: var(--warn-w); border-color: var(--warn); color: var(--warn); }
.notice.info { background: var(--t2); border-color: var(--line-s); color: var(--ink2); }
.notice.good { background: var(--good-w); border-color: rgba(28, 122, 74, .3); color: var(--good); }
.notice > div { flex: 1 1 200px; min-width: 0; }
.notice-a { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; min-width: 0; }
.notice-a .fld { width: 140px; }
.notice .btn { white-space: normal; text-align: start; }

/* ---------- table ---------- */
.tw { overflow-x: auto; max-width: 100%; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: start; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink3); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--line);
  white-space: nowrap; background: var(--surf); position: sticky; top: 0; z-index: 1; }
.tbl th[data-sortkey] { cursor: pointer; user-select: none; }
.tbl th[data-sortkey]:hover { color: var(--brand); }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:hover { background: var(--surf2); }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.risk td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.tbl .r { text-align: end; font-variant-numeric: tabular-nums; }
.tbl .c { text-align: center; }
.tbl tfoot td { font-weight: 600; border-top: 2px solid var(--line-s); border-bottom: 0;
  background: var(--surf2); }
.tbl .num { font-variant-numeric: tabular-nums; }
.tbl .dim { color: var(--ink3); }
.sub { font-size: 12px; color: var(--ink3); display: block; }

/* A data table stays one line per record and scrolls sideways inside
   .tw rather than growing rows three lines tall. */
.tbl th, .tbl td { white-space: nowrap; }
.tbl td .sub { white-space: nowrap; }

/* Inside a table the column heading already IS the label, and a hint
   repeated on every row is noise. Both stay in the DOM for screen
   readers and survive as the input's tooltip. */
.tbl td .fld-l, .tbl td .fld-h, .tbl td .fld-m:empty {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.tbl td .fld { width: 100%; }
.tbl td .fld-i { padding: 4px 8px; }
.tbl td select.fld-i { min-width: 92px; }
.tbl td input.fld-i[data-kind="num"] { min-width: 74px; }
.tbl td input.fld-i[data-kind="date"] { min-width: 132px; }
.tbl td .fld.has-s .fld-i { padding-inline-end: 26px; }
.tbl td { padding: 7px 11px; }

.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 999px; background: var(--surf2); color: var(--ink2); white-space: nowrap; }
.pill.brand { background: var(--brand-w); color: var(--brand); }
.pill.warn { background: var(--warn-w); color: var(--warn); }
.pill.good { background: var(--good-w); color: var(--good); }
.pill.info { background: var(--t2); color: var(--info); }

.bar { display: block; height: 5px; border-radius: 3px; background: var(--t4); overflow: hidden; min-width: 44px; }
.bar-f { display: block; height: 100%; background: var(--brand); border-radius: 3px; }
.bar-f.good { background: var(--good); }
.bar-f.warn { background: var(--warn); }

.tbl-more { padding: 9px 12px; font-size: 12px; color: var(--ink3);
  border-top: 1px solid var(--line); background: var(--surf2); }
.empty { padding: 34px 16px; text-align: center; color: var(--ink3); display: grid; gap: 9px; justify-items: center; }

/* ---------- charts ---------- */
.chart svg { width: 100%; height: 150px; display: block; }
.ch-b { fill: var(--info); }
.ch-b.brand { fill: var(--brand); }
.ch-b.good { fill: var(--good); }
.ch-b.warn { fill: var(--warn); }
.ch-t { stroke: var(--ink); stroke-width: .4; stroke-dasharray: 1.4 1.1; }
.chart-x { display: flex; margin-top: 5px; }
.chart-x span { flex: 1; text-align: center; font-size: 10.5px; color: var(--ink3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dots svg { width: 100%; height: 120px; display: block; }
.dt { fill: var(--info); opacity: .72; }
.dt.warn { fill: var(--warn); opacity: .85; }
.dt.good { fill: var(--good); opacity: .72; }
.dt-ax { stroke: var(--t4); stroke-width: .4; }

/* ---------- drawer ---------- */
#drawer { position: fixed; inset: 0; z-index: 90; pointer-events: none; visibility: hidden; }
#drawer.open { pointer-events: auto; visibility: visible; }
.dw-scrim { position: absolute; inset: 0; background: rgba(14, 23, 38, .34); opacity: 0; transition: opacity .18s; }
#drawer.open .dw-scrim { opacity: 1; }
.dw { position: absolute; inset-block: 0; inset-inline-end: 0; width: min(560px, 100%);
  background: var(--surf); border-inline-start: 1px solid var(--line);
  box-shadow: var(--sh-2); display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .2s; }
body[dir="rtl"] .dw { transform: translateX(-100%); }
#drawer.open .dw { transform: none; }
.dw-h { display: flex; gap: 12px; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--line); }
.dw-h h3 { font-size: 16px; }
#drawerBody { flex: 1; overflow-y: auto; padding: 16px; display: grid; gap: 14px; align-content: start; }

.sec { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.sec-h { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 13px; background: var(--surf2); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.sec-h h4 { font-size: 13px; letter-spacing: .02em; }
.sec-b { padding: 13px; display: grid; gap: 11px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; inset-block-end: 18px; inset-inline-end: 18px; z-index: 120;
  display: grid; gap: 8px; justify-items: end; }
.toast { background: var(--ink); color: #fff; border-radius: var(--r-s); padding: 9px 14px;
  font-size: 13px; box-shadow: var(--sh-2); max-width: 340px; transition: opacity .3s, transform .3s; }
.toast.bad { background: var(--warn); }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ---------- phone ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; align-items: center;
    overflow-x: auto; border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .rail-h { padding: 10px 14px; }
  .rail-h .rail-t { display: none; }
  #nav { display: flex; gap: 4px; padding: 8px; overflow-x: auto; flex: 1; }
  .nv-g { display: none; }
  .nv { white-space: nowrap; padding: 7px 11px; }
  .rail-f { display: none; }
  #main { padding: 14px 16px; }
  #head { padding: 9px 16px; }
  .hd-q { width: 100%; max-width: none; }
  .hd-r { width: 100%; }
  .kpi-v { font-size: 23px; }
  .dw { width: 100%; }
}
@media (max-width: 460px) {
  #main { padding: 12px 16px; }
  .card-b { padding: 13px; }
  .fld.w-md, .fld.w-lg { width: 100%; }
  .frow > .fld { flex: 1 1 140px; }
}

@media print {
  .rail, #head, #toasts, #drawer { display: none !important; }
  #main { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}
