/* Nabd Workforce Intelligence - design tokens, layout and components.
   Light and dark themes; RTL via [dir=rtl]; WCAG 2.2 AA focus and contrast. */
:root {
  color-scheme: light;
  --bg: #f4f5f3;
  --surface: #ffffff;
  --surface-2: #f7f7f5;
  --surface-3: #eeeeeb;
  --border: #e2e2dd;
  --border-strong: #cfcfc8;
  --text: #121211;
  --text-2: #4f4e4a;
  --text-3: #6f6e69;
  --brand: #0f766e;
  --brand-strong: #0b5e57;
  --brand-soft: #e3f3f1;
  --focus: #2a78d6;
  --nav-bg: #10201f;
  --nav-text: #c9d6d4;
  --nav-active: #ffffff;
  --nav-hover: #1b3331;
  --shadow: 0 1px 2px rgba(16, 24, 23, .06), 0 2px 8px rgba(16, 24, 23, .04);
  --radius: 10px;
  /* categorical series - fixed order (validated palette) */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  /* status (reserved: always with label) */
  --good: #0ca30c; --warn: #fab219; --serious: #ec835a; --bad: #d03b3b;
  --good-text: #006300; --warn-text: #8a5a00; --bad-text: #b02a2a;
  --good-soft: #e5f5e5; --warn-soft: #fff4dc; --bad-soft: #fbe7e7; --info-soft: #e6effb;
  --productive: #0ca30c; --unproductive: #d03b3b; --neutral: #9a9992; --pending: #fab219; --passive: #cfcfc8; --meeting: #6250d6;
  --grid: #ececE8;
  --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #6da7ec; --seq-4: #3987e5; --seq-5: #256abf; --seq-6: #184f95; --seq-7: #0d366b;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #20201f; --surface-3: #2a2a28; --border: #31312e; --border-strong: #43433f;
    --text: #f0efec; --text-2: #c3c2b7; --text-3: #9d9c94; --brand: #2fb3a6; --brand-strong: #49c7ba; --brand-soft: #173533;
    --nav-bg: #0c1615; --nav-hover: #172826;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --good-text: #5fd35f; --warn-text: #fac35a; --bad-text: #f08a8a; --good-soft: #17301a; --warn-soft: #34290f; --bad-soft: #3a1b1b; --info-soft: #172840;
    --neutral: #7c7b74; --passive: #43433f; --meeting: #9085e9; --grid: #2a2a28;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #20201f; --surface-3: #2a2a28; --border: #31312e; --border-strong: #43433f;
  --text: #f0efec; --text-2: #c3c2b7; --text-3: #9d9c94; --brand: #2fb3a6; --brand-strong: #49c7ba; --brand-soft: #173533;
  --nav-bg: #0c1615; --nav-hover: #172826;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --good-text: #5fd35f; --warn-text: #fac35a; --bad-text: #f08a8a; --good-soft: #17301a; --warn-soft: #34290f; --bad-soft: #3a1b1b; --info-soft: #172840;
  --neutral: #7c7b74; --passive: #43433f; --meeting: #9085e9; --grid: #2a2a28;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body { font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Arabic", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 14px; } h4 { font-size: 13px; }
.muted { color: var(--text-3); } .small { font-size: 12px; } .tiny { font-size: 11px; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }

/* Layout */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.nav { background: var(--nav-bg); color: var(--nav-text); padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: #fff; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #14b8a6, #0f766e); display: grid; place-items: center; }
.brand b { font-size: 16px; letter-spacing: .02em; } .brand small { display: block; font-size: 10.5px; color: var(--nav-text); opacity: .8; }
.nav-group { margin: 12px 0 4px; padding: 0 10px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; opacity: .55; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--nav-text); font-size: 13.5px; }
.nav a:hover { background: var(--nav-hover); text-decoration: none; color: #fff; }
.nav a.active { background: var(--brand); color: var(--nav-active); }
.nav a .ico { width: 18px; height: 18px; opacity: .9; flex: none; }
.nav a .count { margin-inline-start: auto; background: rgba(255,255,255,.15); border-radius: 10px; padding: 0 7px; font-size: 11px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 10px 22px; background: var(--surface);
  border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.topbar .title { flex: 1; min-width: 160px; }
.topbar .title h1 { font-size: 18px; } .topbar .title .crumb { font-size: 12px; color: var(--text-3); }
.content { padding: 20px 22px 60px; max-width: 1480px; width: 100%; }
.menu-toggle { display: none; }
.env-banner { background: var(--warn-soft); color: var(--warn-text); font-size: 12px; padding: 4px 22px; border-bottom: 1px solid var(--border); }

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .nav { position: fixed; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); transition: transform .2s; z-index: 50; }
  [dir=rtl] .nav { inset: 0 0 0 auto; transform: translateX(100%); }
  .nav.open { transform: none; }
  .menu-toggle { display: inline-flex; }
  .content { padding: 16px; }
  .topbar { padding: 10px 16px; }
}

/* Controls */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  padding: 6px 12px; border-radius: 8px; font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-strong); }
.btn.danger { color: var(--bad-text); border-color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn { position: relative; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; width: 34px; height: 32px; display: inline-grid; place-items: center; cursor: pointer; color: var(--text-2); }
.icon-btn .dot { position: absolute; top: 3px; inset-inline-end: 3px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--bad); color: #fff; font-size: 10px; display: grid; place-items: center; padding: 0 4px; }
select, input, textarea { font: inherit; font-size: 13px; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 6px 9px; }
textarea { width: 100%; min-height: 80px; }
label.field { display: grid; gap: 4px; font-size: 12.5px; color: var(--text-2); }
label.field input, label.field select, label.field textarea { width: 100%; }
label.check { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 5px 10px; font: inherit; font-size: 12.5px; cursor: pointer; color: var(--text-2); }
.seg button + button { border-inline-start: 1px solid var(--border-strong); }
.seg button.on { background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack { display: grid; gap: 16px; }
.stack > *, .grid > * { min-width: 0; }  /* let wide tables and tab bars scroll instead of stretching the page */

/* Cards and grids */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.span2 { grid-column: span 2; } .span3 { grid-column: span 3; }
@media (max-width: 1200px) { .g5, .g6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .g2, .g3, .g4, .g5, .g6 { grid-template-columns: 1fr; } .span2, .span3 { grid-column: auto; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; align-items: flex-start; gap: 8px 10px; padding: 14px 16px 6px; flex-wrap: wrap; }
.card-h .t { flex: 1; min-width: 140px; } .card-h .sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.card-b { padding: 8px 16px 16px; }
.card-b.flush { padding: 0; }
.card.pad { padding: 16px; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 6px 0 2px; }

/* KPI tiles */
.kpi { padding: 14px 16px; display: grid; gap: 4px; }
.kpi .l { font-size: 12px; color: var(--text-2); display: flex; gap: 6px; align-items: center; }
.kpi .v { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .v small { font-size: 13px; font-weight: 500; color: var(--text-3); margin-inline-start: 2px; }
.kpi .d { font-size: 12px; display: flex; gap: 6px; align-items: center; color: var(--text-3); }
.delta-good { color: var(--good-text); } .delta-bad { color: var(--bad-text); }
.kpi .bar { height: 6px; border-radius: 3px; background: var(--surface-3); position: relative; overflow: hidden; margin-top: 4px; }
.kpi .bar > span { position: absolute; inset-block: 0; inset-inline-start: 0; border-radius: 3px; background: var(--s1); }
.kpi .bar > i { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 550; border: 1px solid transparent; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge.plain::before { display: none; }
.b-good { background: var(--good-soft); color: var(--good-text); } .b-warn { background: var(--warn-soft); color: var(--warn-text); }
.b-bad { background: var(--bad-soft); color: var(--bad-text); } .b-info { background: var(--info-soft); color: var(--s1); }
.b-neutral { background: var(--surface-3); color: var(--text-2); } .b-brand { background: var(--brand-soft); color: var(--brand-strong); }

/* Tables */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: start; font-weight: 600; font-size: 12px; color: var(--text-2); padding: 8px 10px; border-bottom: 1px solid var(--border); background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; }
.tbl th.sortable { cursor: pointer; } .tbl th.sortable:hover { color: var(--text); }
.tbl td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: var(--surface-2); }
.tbl td.r, .tbl th.r { text-align: end; font-variant-numeric: tabular-nums; }
.tbl-tools { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tbl-tools input { min-width: 200px; }
.tbl-foot { display: flex; gap: 8px; align-items: center; padding: 8px 12px; font-size: 12px; color: var(--text-3); }
.mini-bar { display: inline-block; height: 6px; border-radius: 3px; background: var(--s1); vertical-align: middle; }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 9px 12px; font: inherit; font-size: 13.5px; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--brand-strong); border-bottom-color: var(--brand); font-weight: 600; }
.tabs button .count { background: var(--surface-3); border-radius: 9px; padding: 0 6px; font-size: 11px; margin-inline-start: 4px; }

/* Charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis text, .chart text.lbl { fill: var(--text-3); font-size: 11px; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--border-strong); stroke-width: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text-2); margin: 4px 0 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend i.line { height: 3px; border-radius: 2px; width: 14px; }
.tip { position: fixed; z-index: 90; pointer-events: none; background: var(--text); color: var(--surface); font-size: 12px; padding: 7px 9px; border-radius: 7px;
  box-shadow: 0 4px 16px rgba(0,0,0,.2); max-width: 280px; display: none; }
.tip b { font-weight: 600; } .tip .tr { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.tip i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-inline-end: 4px; }

/* Timeline */
.tl { display: grid; gap: 4px; }
.tl-row { display: grid; grid-template-columns: 170px 1fr; gap: 10px; align-items: center; font-size: 12.5px; }
.tl-track { position: relative; height: 18px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.tl-track span { position: absolute; top: 0; bottom: 0; }
.tl-track span.m { top: 12px; bottom: 0; background: var(--meeting); opacity: .85; }
.tl-axis { display: grid; grid-template-columns: 170px 1fr; gap: 10px; font-size: 10.5px; color: var(--text-3); }
.tl-axis div:last-child { display: flex; justify-content: space-between; }

/* Misc */
.empty { padding: 28px; text-align: center; color: var(--text-3); }
.loading { padding: 40px; text-align: center; color: var(--text-3); }
.loading::before { content: ""; display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border-strong); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px; margin-inline-end: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
.callout { border: 1px solid var(--border); background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font-size: 12.5px; color: var(--text-2); display: flex; gap: 10px; }
.callout.info { background: var(--info-soft); border-color: transparent; }
.callout.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn-text); }
.callout.good { background: var(--good-soft); border-color: transparent; color: var(--good-text); }
.list { display: grid; gap: 0; }
.list .it { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list .it:last-child { border-bottom: 0; }
.list .it .grow { flex: 1; min-width: 0; }
.action-tile { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); }
.action-tile:hover { border-color: var(--brand); text-decoration: none; }
.action-tile .n { font-size: 22px; font-weight: 650; min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; }
.narrative { white-space: pre-wrap; font-size: 13.5px; line-height: 1.6; }
.pill-toggle { display: inline-flex; gap: 6px; }
.factor { display: grid; grid-template-columns: 1fr 110px 50px; gap: 8px; align-items: center; font-size: 12.5px; padding: 4px 0; }
.factor .fbar { height: 8px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.factor .fbar span { display: block; height: 100%; background: var(--s1); border-radius: 4px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
pre.code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px; overflow-x: auto; font-size: 12px; }
hr.sep { border: 0; border-top: 1px solid var(--border); margin: 12px 0; }
.tree ul { list-style: none; padding-inline-start: 18px; margin: 0; }
.tree li { padding: 2px 0; }
.tree > ul { padding-inline-start: 0; }

/* Modal & drawer */
.overlay { position: fixed; inset: 0; background: rgba(10, 14, 14, .45); z-index: 70; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border-radius: 12px; width: min(640px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { width: min(1000px, 100%); }
.modal-h { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-h h2 { flex: 1; }
.modal-b { padding: 16px 18px; }
.modal-f { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--border); }
.toasts { position: fixed; bottom: 18px; inset-inline-end: 18px; z-index: 95; display: grid; gap: 8px; }
.toast { background: var(--text); color: var(--surface); padding: 10px 14px; border-radius: 8px; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 420px; }
.toast.bad { background: var(--bad); color: #fff; } .toast.good { background: #0b6b0b; color: #fff; }
.dropdown { position: absolute; top: 44px; inset-inline-end: 12px; width: 360px; max-height: 70vh; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.18); z-index: 60; }

/* Login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login .hero { background: radial-gradient(1200px 600px at 0% 0%, #14b8a6 0%, #0f766e 35%, #0b2b29 100%); color: #e9f5f3; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login .hero h1 { font-size: 34px; line-height: 1.15; max-width: 520px; color: #fff; }
.login .hero ul { padding-inline-start: 18px; line-height: 1.9; opacity: .92; }
.login .panel { display: grid; place-items: center; padding: 32px; }
.login form { width: min(380px, 100%); display: grid; gap: 14px; }
.persona-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.persona-grid button { text-align: start; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 6px 8px; font: inherit; font-size: 12px; cursor: pointer; color: var(--text); }
.persona-grid button:hover { border-color: var(--brand); }
.persona-grid small { display: block; color: var(--text-3); font-size: 10.5px; }
@media (max-width: 900px) { .login { grid-template-columns: 1fr; } .login .hero { display: none; } }

/* Tour */
.tour { position: fixed; bottom: 20px; inset-inline-start: 256px; z-index: 65; width: 360px; background: var(--surface); border: 1px solid var(--brand); border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,.2); padding: 14px 16px; }
@media (max-width: 900px) { .tour { inset-inline-start: 16px; } }

/* Forced colours / print */
@media (forced-colors: active) { .badge::before, .legend i { forced-color-adjust: none; } }
@media print { .nav, .topbar, .tabs, .btn, .icon-btn { display: none !important; } .app { display: block; } .card { break-inside: avoid; box-shadow: none; } }
