/* outflowIQ — modern theme redesigned to tuvl-design standards.
   Neutrals and colors match current theme; layout, typography, Geist/Geist Mono fonts follow tuvl-design. */

@font-face {
  font-family: "Geist";
  src: url("../fonts/Geist.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("../fonts/GeistMono.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  /* color theme preserved from outflowIQ */
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f8fafc; --ink: #0f172a; --muted: #64748b; --faint: #94a3b8;
  --line: #e4e7ec; --line-strong: #cbd5e1;
  --accent: #4f46e5; --accent-ink: #ffffff; --accent-soft: #e0e7ff; --accent-line: #a5b4fc;
  --ok: #15803d; --ok-soft: #dcfce7; --warn: #b45309; --warn-soft: #fef3c7; --bad: #b91c1c; --bad-soft: #fee2e2;
  --info: #1d4ed8; --info-soft: #dbeafe; --violet: #6d28d9; --violet-soft: #ede9fe; --orange: #c2410c; --orange-soft: #ffedd5;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 10px 30px rgba(15, 23, 42, .07);
  --shadow-lg: 0 18px 50px rgba(15, 23, 42, .22);

  /* tuvl-design typography and radii */
  --radius: 12px; --radius-sm: 8px; --radius-ctrl: 10px;
  --font: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0a1016; --surface: #111a23; --surface-2: #0e1720; --ink: #e8eef4; --muted: #93a3b5; --faint: #66778a;
  --line: #1e2b37; --line-strong: #2c3c4b;
  --accent: #818cf8; --accent-ink: #10123a; --accent-soft: #1d1f4d; --accent-line: #3b3f9e;
  --ok: #4ade80; --ok-soft: #10301d; --warn: #fbbf24; --warn-soft: #3a2a0a; --bad: #f87171; --bad-soft: #3b1414;
  --info: #7aa7ff; --info-soft: #14274a; --violet: #b69cff; --violet-soft: #271b4d; --orange: #fb923c; --orange-soft: #3a1d0b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 14px 36px rgba(0, 0, 0, .45);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .25s ease, color .25s ease;
}

h1, h2, h3, h4 { margin: 0; }
h1 { font-size: 22px; line-height: 1.25; font-weight: 700; letter-spacing: -0.025em; }
h2 { font-size: 16px; font-weight: 650; letter-spacing: -0.015em; }
h3 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
h4 { font-size: 12.5px; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12.5px; letter-spacing: -0.01em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hide { display: none !important; }

/* layout helpers */
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.gap-s { gap: 6px; } .gap-l { gap: 18px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-s { display: flex; flex-direction: column; gap: 8px; }
.right { margin-inline-start: auto; }

/* app shell */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--surface);
  border-inline-end: 1px solid var(--line);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 16px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.03em;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.brand-img { width: 30px; height: 30px; border-radius: 8px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title { font-weight: 700; font-size: 16px; letter-spacing: -0.025em; }
.brand .iq { color: var(--accent); font-weight: 800; }
.brand .sub { font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: .02em; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 600;
  padding: 12px 10px 4px;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--ink);
  font-weight: 500;
  font-size: 13.5px;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .ico { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav .badge { margin-inline-start: auto; }

.side-foot {
  margin-top: auto;
  padding: 14px 10px 6px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 4px;
}

.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 50px;
  padding: 10px 32px;
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  transition: background .2s ease;
}
.top.scrolled {
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(10px);
}
.search { position: relative; flex: 1; max-width: 480px; margin-inline-end: auto; }
.search input {
  width: 100%;
  padding: 8px 14px 8px 36px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  border-radius: 10px;
  font-size: 13.5px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.search input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface);
}
.search svg { position: absolute; inset-inline-start: 12px; top: 10px; width: 16px; height: 16px; color: var(--faint); }
.search kbd {
  position: absolute;
  inset-inline-end: 10px;
  top: 8px;
  font: 11px var(--mono);
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 5px;
  background: var(--surface);
}
.search-results {
  position: absolute;
  top: 42px;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 360px;
  overflow: auto;
  z-index: 20;
  padding: 6px;
}
.search-results button {
  display: flex;
  gap: 10px;
  width: 100%;
  align-items: center;
  text-align: start;
  background: none;
  border: 0;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
}
.search-results button:hover, .search-results button[aria-selected="true"] { background: var(--surface-2); }

.page { padding: 12px 32px 64px; max-width: 1240px; margin: 0 auto; width: 100%; }
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 8px 0 24px;
  flex-wrap: wrap;
}
.page-head p { color: var(--muted); margin-top: 3px; font-size: 14px; }

/* controls */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  cursor: pointer;
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn .spin { width: 14px; height: 14px; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--faint); }
.input, select.input, textarea.input, input, select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-ctrl);
  background: var(--surface);
  font-size: 13.5px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea.input { min-height: 120px; resize: vertical; font-family: inherit; }
.input:disabled, input:disabled { background: var(--surface-2); color: var(--muted); opacity: .7; }
.input:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.seg {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-ctrl);
  overflow: hidden;
  background: var(--surface);
}
.seg button {
  border: 0;
  background: none;
  padding: 6px 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  border-right: 1px solid var(--line);
  transition: background 0.15s ease, color 0.15s ease;
}
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  cursor: pointer;
  font-weight: 550;
  font-size: 12.5px;
  color: var(--muted);
  transition: all 0.15s ease;
}
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip .n { font-variant-numeric: tabular-nums; opacity: .8; font-weight: 600; }

/* surfaces & cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--line);
}
.card-b { padding: 18px 20px 20px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.kpi {
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.kpi .k { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi .v { font-size: 26px; font-weight: 700; letter-spacing: -.025em; font-variant-numeric: tabular-nums; margin-top: 4px; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 3px; }
.kpi.bad .v { color: var(--bad); } .kpi.warn .v { color: var(--warn); } .kpi.ok .v { color: var(--ok); }

/* tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.t th {
  text-align: start;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  font-weight: 600;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
.t td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr.click { cursor: pointer; }
.t tbody tr.click:hover td { background: var(--surface-2); }
.t th.num, .t td.num { text-align: right; }
.cust { font-weight: 600; } .sub { color: var(--muted); font-size: 12px; }

/* pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.pill.violet { background: var(--violet-soft); color: var(--violet); border-color: transparent; }
.pill.orange { background: var(--orange-soft); color: var(--orange); border-color: transparent; }
.badge { min-width: 20px; padding: 1px 7px; border-radius: 999px; background: var(--bad); color: #fff; font-size: 11.5px; font-weight: 700; text-align: center; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 22px; flex-wrap: wrap; }
.tabs button {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  transition: color .15s ease, background .15s ease;
}
.tabs button:hover { color: var(--ink); background: var(--surface-2); }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); background: transparent; }

/* charts & bars */
.aging { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; align-items: end; height: 300px; padding-top: 10px; }
.aging .col { display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; height: 100%; gap: 6px; text-align: center; cursor: default; }
.aging .bar { border-radius: 6px 6px 2px 2px; min-height: 3px; transition: height .35s ease; }
.aging .amt { font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; }
.aging .lbl { font-size: 11.5px; color: var(--muted); }
.hbar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.hbar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.stackbar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }

/* drawer + dialog */
.scrim { position: fixed; inset: 0; background: rgba(8, 15, 24, .45); z-index: 40; animation: fade .15s ease; }
.drawer { position: fixed; top: 0; inset-inline-end: 0; bottom: 0; width: min(880px, 100vw); background: var(--surface); z-index: 41; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .2s ease; }
.drawer-h { cursor: grab; padding: 18px 22px 14px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; }
.drawer-b { padding: 18px 22px 28px; overflow: auto; flex: 1; }
.dialog { position: fixed; z-index: 51; left: 50%; top: 8vh; transform: translateX(-50%); width: min(640px, 94vw); max-height: 84vh; overflow: auto; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); animation: pop .15s ease; }
.dialog-h { padding: 18px 22px 0; } .dialog-b { padding: 14px 22px; } .dialog-f { padding: 12px 22px 18px; display: flex; gap: 8px; justify-content: flex-end; position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); }
@keyframes fade { from { opacity: 0; } } @keyframes slide { from { transform: translateX(24px); opacity: 0; } } @keyframes pop { from { opacity: 0; transform: translate(-50%, 6px); } }

.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; }
.fact .k { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.fact .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.tl { position: relative; padding-inline-start: 22px; margin: 0; list-style: none; }
.tl::before { content: ""; position: absolute; inset-inline-start: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl li { position: relative; padding: 0 0 14px; }
.tl li::before { content: ""; position: absolute; inset-inline-start: -21px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.tl li.warn::before { border-color: var(--warn); } .tl li.bad::before { border-color: var(--bad); } .tl li.ok::before { border-color: var(--ok); }

.callout { padding: 11px 16px; border-radius: var(--radius-ctrl); border: 1px solid var(--line); background: var(--surface-2); font-size: 13.5px; }
.callout.info { background: var(--info-soft); border-color: transparent; color: var(--info); }
.callout.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.callout.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.callout.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.empty { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 6px; font-weight: 650; }

.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: sheen 1.3s infinite; }
@keyframes sheen { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.toasts { position: fixed; inset-inline-end: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); max-width: 380px; animation: fade .15s; font-size: 13.5px; font-weight: 500; }
.toast.bad { background: var(--bad); color: #fff; }
.spin { animation: rot .8s linear infinite; } @keyframes rot { to { transform: rotate(360deg); } }

/* sign in */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.auth-card { width: min(480px, 100%); padding: 32px; border-radius: 14px; }
.auth .brand { border-bottom: 0; padding: 0 0 16px; justify-content: center; }
.auth-footer { font-family: var(--mono); font-size: 12px; color: var(--muted); letter-spacing: 0.02em; }
.auth-footer a { color: var(--accent); font-weight: 600; }

/* responsive layout */
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px 14px; align-items: center; border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .brand { border-bottom: 0; padding: 4px 8px; }
  .nav-label, .side-foot { display: none; }
  .nav { display: flex; flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .nav a { padding: 6px 10px; font-size: 13px; }
  .top, .page { padding-left: 16px; padding-right: 16px; }
  .g2, .g3, .cols-2, .cols-3, .cols-4, .g-main { grid-template-columns: 1fr; }
  .facts { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .page-head { flex-direction: column; align-items: stretch; }
  .search { max-width: none; }
  .t th, .t td { padding: 8px 10px; }
  .drawer { width: 100vw; }
  .dialog { top: 2vh; max-height: 96vh; }
}

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* phase 2 & widgets */
button.kpi { text-align: start; font: inherit; color: inherit; cursor: pointer; width: 100%; }
button.kpi:hover { border-color: var(--accent); }
.conf { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.conf .meter { width: 54px; height: 7px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; display: inline-block; }
.conf .meter i { display: block; height: 100%; background: currentColor; }
.conf.ok { color: var(--ok); } .conf.warn { color: var(--warn); } .conf.bad { color: var(--bad); }
.cols { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 12px; align-items: end; padding-top: 6px; }
.cols .c { display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; gap: 5px; text-align: center; min-height: 210px; }
.cols .bar { border-radius: 6px 6px 2px 2px; } .cols .amt { font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; } .cols .lbl { font-size: 12px; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12.5px; }

/* stage tracker & worklist */
.track { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0; margin: 6px 0 2px; }
.track .s { position: relative; text-align: center; padding-top: 30px; font-size: 12.5px; color: var(--faint); font-weight: 600; }
.track .s::before { content: ""; position: absolute; top: 9px; left: 0; right: 0; height: 3px; background: var(--line); }
.track .s:first-child::before { inset-inline-start: 50%; left: auto; } .track .s:last-child::before { inset-inline-end: 50%; right: auto; }
.track .s i { position: absolute; top: 2px; left: 50%; transform: translateX(-50%); width: 17px; height: 17px; border-radius: 50%; background: var(--surface); border: 3px solid var(--line-strong); z-index: 1; }
.track .s.done { color: var(--ok); } .track .s.done::before, .track .s.done + .s::before { background: var(--ok); } .track .s.done i { background: var(--ok); border-color: var(--ok); }
.track .s.current { color: var(--accent); } .track .s.current i { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.track .s .at { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }
.track.stopped .s.done i { background: var(--warn); border-color: var(--warn); } .track.stopped .s.done { color: var(--warn); }

.worklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.wl { display: flex; flex-direction: column; gap: 8px; }
.wl .top-row { display: flex; align-items: baseline; gap: 8px; } .wl .count { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.wl .items a, .wl .items button { display: flex; width: 100%; text-align: start; gap: 8px; padding: 6px 0; border: 0; background: none; border-top: 1px solid var(--line); cursor: pointer; font-size: 13px; color: inherit; }
.wl .items button:hover { color: var(--accent); }
.progress { height: 6px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; min-width: 70px; }
.progress i { display: block; height: 100%; background: var(--accent); }

.table-wrap.flat { border: 0; }
.check { display: inline-flex; align-items: center; gap: 6px; }

/* ── right to left (Arabic) ─────────────────────────────────────────────── */
html[lang="ar"] { --font: "Geist", "SF Arabic", "Segoe UI", Tahoma, "Noto Sans Arabic", "Geeza Pro", "Helvetica Neue", system-ui, sans-serif; }
html[lang="ar"] body { font-size: 15px; line-height: 1.65; }
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3, html[lang="ar"] h4, html[lang="ar"] .t th, html[lang="ar"] .nav-label, html[lang="ar"] .label, html[lang="ar"] .kpi .k { letter-spacing: 0; text-transform: none; }
[dir="rtl"] .mono, [dir="rtl"] .num, [dir="rtl"] .at, [dir="rtl"] input[type="email"], [dir="rtl"] input[type="number"], [dir="rtl"] input[type="date"] { direction: ltr; unicode-bidi: isolate; }
[dir="rtl"] input[type="email"], [dir="rtl"] input[type="number"], [dir="rtl"] input[type="date"] { text-align: right; }
[dir="rtl"] .ico { transform: scaleX(1); }
[dir="rtl"] .drawer { animation-name: slide-rtl; box-shadow: 18px 0 50px rgba(15, 23, 42, .22); }
@keyframes slide-rtl { from { transform: translateX(-24px); opacity: 0; } }

.lang-switch { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; background: var(--surface); }
.lang-switch button { background: none; border: 0; padding: 4px 12px; cursor: pointer; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.lang-switch button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 650; }

.chips-in { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-pick { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px; background: var(--surface); cursor: pointer; font-size: 12.5px; }
.chip-pick[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.region-preview { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }

.t td.mono { white-space: nowrap; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; font-weight: 650; } .linkbtn:hover { text-decoration: underline; }
.drawer .t td:not(:first-child), .drawer .t th { white-space: nowrap; } .drawer .table-wrap { overflow-x: auto; }

/* ── movable, resizable, detachable side panels (macOS controls) ───────── */
.drawer { max-width: 100vw; }
.drawer-tools { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); cursor: grab; user-select: none; flex-shrink: 0; direction: ltr; }
.drawer-tools .grip { flex: 1; color: var(--faint); font-size: 11px; letter-spacing: 3px; text-align: center; }
.mac-controls { display: inline-flex; align-items: center; gap: 7px; user-select: none; flex-shrink: 0; }
.mac-dot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.16); padding: 0; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; position: relative; transition: transform 0.1s ease, filter 0.1s ease; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3); background: var(--surface-3, #ccc); }
.mac-dot:hover { filter: brightness(0.9); }
.mac-dot:active { transform: scale(0.92); filter: brightness(0.8); }
.mac-dot.close { background: #ff5f56; border-color: #e0443e; }
.mac-dot.min { background: #ffbd2e; border-color: #dea123; }
.mac-dot.max { background: #27c93f; border-color: #1aab29; }
.mac-glyph { width: 8px; height: 8px; opacity: 0; transition: opacity 0.15s ease; color: rgba(0, 0, 0, 0.72); }
.mac-controls:hover .mac-glyph { opacity: 1; }
.drawer-edge { position: absolute; top: 0; bottom: 0; inset-inline-start: -4px; width: 8px; cursor: col-resize; z-index: 3; } .drawer-edge:hover { background: var(--accent-soft); }
.drawer.floating { inset-inline-end: auto; bottom: auto; right: auto; border: 1px solid var(--line-strong); border-radius: 12px; resize: both; overflow: hidden; min-width: 380px; min-height: 260px; box-shadow: var(--shadow-lg); animation: fade .15s ease; }
.drawer.floating .drawer-edge { display: none; }
.drawer.maximized { inset-inline-end: auto !important; bottom: auto !important; left: 12px !important; top: 12px !important; width: calc(100vw - 24px) !important; height: calc(100vh - 24px) !important; max-width: none !important; border-radius: 12px !important; border: 1px solid var(--line-strong) !important; box-shadow: var(--shadow-lg) !important; resize: none !important; animation: pop .15s ease !important; }
.drawer.maximized .drawer-edge { display: none !important; }
body.dragging { user-select: none; cursor: grabbing; } body.dragging iframe { pointer-events: none; }
.grid > * { min-width: 0; } .card .table-wrap { overflow-x: auto; }
