/* Vertex Operations Platform — design system
   Light theme first. Restrained colour: navy for primary actions, teal for
   meaningful accents, semantic tones only for status. */

@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter-var.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans Arabic";
  src: url("/static/fonts/plex-arabic-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: "IBM Plex Sans Arabic";
  src: url("/static/fonts/plex-arabic-600.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}

:root {
  --navy: #154e7a;
  --navy-hover: #0f3d61;
  --navy-50: #eef4f9;
  --navy-100: #dce8f2;
  --teal: #0d9488;
  --teal-50: #effaf8;
  --bg: #fafaf9;
  --surface: #ffffff;
  --subtle: #f5f5f4;
  --text: #1c1917;
  --text-2: #57534e;
  --text-3: #78716c;
  --border: #e7e5e4;
  --border-strong: #d6d3d1;

  --positive: #15803d; --positive-bg: #f0fdf4; --positive-border: #bbf7d0;
  --warning: #b45309;  --warning-bg: #fffbeb;  --warning-border: #fde68a;
  --info: #1e5a8a;     --info-bg: #eff6fb;     --info-border: #c8dcec;
  --negative: #b91c1c; --negative-bg: #fef2f2; --negative-border: #fecaca;
  --neutral: #57534e;  --neutral-bg: #f5f5f4;  --neutral-border: #e7e5e4;

  --radius: 6px;
  --radius-lg: 8px;
  --shadow-sm: 0 1px 2px rgba(28, 25, 23, .05);
  --shadow: 0 1px 3px rgba(28, 25, 23, .06), 0 1px 2px rgba(28, 25, 23, .04);
  --shadow-lg: 0 12px 32px -8px rgba(28, 25, 23, .18), 0 4px 8px -4px rgba(28, 25, 23, .08);
  --focus: 0 0 0 3px rgba(21, 78, 122, .18);

  --sidebar-w: 252px;
  --topbar-h: 56px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "IBM Plex Sans Arabic", sans-serif;
  --font-ar: "IBM Plex Sans Arabic", "Geeza Pro", "Segoe UI", Tahoma, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--navy-hover); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }
[lang="ar"], .ar { font-family: var(--font-ar); }
.num, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }

.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 20px; height: 20px; }
.icon-xl { width: 24px; height: 24px; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 40;
}
.brand { height: var(--topbar-h); display: flex; align-items: center; padding: 0 16px; border-bottom: 1px solid var(--border); flex: none; }
.brand a { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand-mark {
  width: 30px; height: 30px; border-radius: 7px; background: var(--navy); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 15px; letter-spacing: -.02em;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.15);
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 14px; font-weight: 650; }
.brand-text small { font-size: 11.5px; color: var(--text-3); }

.nav { flex: 1; overflow-y: auto; padding: 10px 10px 16px; scrollbar-width: thin; }
.nav-group { margin-bottom: 2px; }
.nav-group > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius);
  font-size: 13.5px; font-weight: 500; color: var(--text-2);
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary:hover { background: var(--subtle); color: var(--text); }
.nav-group > summary .chev { margin-left: auto; transition: transform .15s ease; color: var(--text-3); }
.nav-group[open] > summary .chev { transform: rotate(90deg); }
.nav-group.is-active > summary { color: var(--text); }
.nav-sub { padding: 2px 0 6px 18px; margin-left: 17px; border-left: 1px solid var(--border); }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: var(--radius);
  color: var(--text-2); font-size: 13.5px; font-weight: 450; position: relative;
}
.nav-sub .nav-item { padding: 5px 10px; font-size: 13px; }
.nav-item:hover { background: var(--subtle); color: var(--text); }
.nav-item.active { background: var(--navy-50); color: var(--navy); font-weight: 550; }
.nav-sub .nav-item.active::before { content: ""; position: absolute; left: -19px; top: 6px; bottom: 6px; width: 2px; background: var(--navy); border-radius: 2px; }
.sidebar-foot { border-top: 1px solid var(--border); padding: 12px 16px; font-size: 12px; color: var(--text-3); flex: none; }
.sidebar-foot .company { color: var(--text-2); font-weight: 500; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  background: rgba(255,255,255,.92); backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 0 24px;
}
.topbar .menu-toggle { display: none; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-3); min-width: 0; flex: 1; }
.crumbs a { color: var(--text-2); }
.crumbs a:hover { color: var(--text); }
.crumbs .sep { color: var(--border-strong); }
.crumbs .current { color: var(--text); font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-search { position: relative; width: 340px; flex: none; }
.topbar-search input[type="search"] {
  width: 100%; height: 34px; padding: 0 44px 0 34px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--subtle); font: inherit; font-size: 13px; color: var(--text); transition: all .15s;
}
.topbar-search input[type="search"]:focus { outline: none; background: #fff; border-color: var(--navy); box-shadow: var(--focus); }
.topbar-search > .icon { position: absolute; left: 11px; top: 9px; color: var(--text-3); pointer-events: none; }
.topbar-search kbd { position: absolute; right: 8px; top: 7px; }
.topbar-search input:not(:placeholder-shown) ~ kbd { display: none; }
kbd {
  font-family: var(--font); font-size: 11px; color: var(--text-3); background: #fff; border: 1px solid var(--border);
  border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; line-height: 17px;
}
.topbar-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.icon-btn {
  position: relative; display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius);
  border: 0; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--subtle); color: var(--text); }
.icon-btn .dot-count {
  position: absolute; top: 1px; right: -1px; min-width: 15px; height: 15px; padding: 0 3px; border-radius: 8px;
  background: var(--negative); color: #fff; font-size: 9.5px; font-weight: 650; line-height: 15px; text-align: center;
  border: 2px solid #fff; box-sizing: border-box; min-width: 19px; height: 19px; line-height: 15px;
}
.user-btn { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border: 0; background: transparent; border-radius: var(--radius); cursor: pointer; font: inherit; text-align: left; }
.user-btn:hover { background: var(--subtle); }
.user-btn .who { display: flex; flex-direction: column; line-height: 1.2; }
.user-btn .who strong { font-size: 13px; font-weight: 550; }
.user-btn .who small { font-size: 11.5px; color: var(--text-3); }

.content { padding: 24px 32px 48px; flex: 1; width: 100%; max-width: 1480px; }

/* ---------- Avatars ---------- */
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  background: var(--navy-100); color: var(--navy); font-size: 11.5px; font-weight: 650; letter-spacing: .02em;
}
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }

/* ---------- Dropdowns ---------- */
.dropdown { position: relative; }
.dropdown-panel {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 6px; z-index: 50; display: none;
}
.dropdown.open > .dropdown-panel { display: block; }
.dropdown-panel.wide { width: 380px; padding: 0; }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin: -6px -6px 6px; padding: 12px 14px; }
.menu-head strong { display: block; font-size: 13px; }
.menu-head span { font-size: 12px; color: var(--text-3); }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border-radius: 5px;
  color: var(--text); font: inherit; font-size: 13px; background: none; border: 0; cursor: pointer; text-align: left;
}
.menu-item:hover { background: var(--subtle); color: var(--text); }
.menu-item .icon { color: var(--text-3); }
.menu-sep { height: 1px; background: var(--border); margin: 6px -6px; }
.menu-item.danger { color: var(--negative); }
.menu-item.danger .icon { color: var(--negative); }

/* notifications */
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.notif-head strong { font-size: 13.5px; }
.notif-list { max-height: 420px; overflow-y: auto; }
.notif { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text); }
.notif:last-child { border-bottom: 0; }
.notif:hover { background: var(--bg); color: var(--text); }
.notif .sev { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.notif .sev.info { background: var(--info-bg); color: var(--info); }
.notif .sev.warning { background: var(--warning-bg); color: var(--warning); }
.notif .sev.critical { background: var(--negative-bg); color: var(--negative); }
.notif .sev.success { background: var(--positive-bg); color: var(--positive); }
.notif .t { font-size: 13px; font-weight: 550; }
.notif .b { font-size: 12.5px; color: var(--text-2); margin-top: 1px; }
.notif .when { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.notif.unread .t::after { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--navy); margin-left: 6px; vertical-align: middle; }

/* search dropdown */
.search-dropdown { position: absolute; left: 0; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); z-index: 50; overflow: hidden; }
.search-dropdown:empty { display: none; }
.search-group-label { padding: 8px 12px 4px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.search-hit { display: flex; align-items: center; gap: 10px; padding: 7px 12px; color: var(--text); }
.search-hit:hover, .search-hit.focused { background: var(--navy-50); color: var(--text); }
.search-hit .icon { color: var(--text-3); }
.search-hit .st { font-size: 12px; color: var(--text-3); margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; }
.search-foot { display: block; padding: 8px 12px; border-top: 1px solid var(--border); font-size: 12.5px; background: var(--bg); }
.search-empty { padding: 14px 12px; font-size: 13px; color: var(--text-2); }

/* ---------- Page header ---------- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header h1 { font-size: 21px; line-height: 1.3; }
.page-header .sub { color: var(--text-2); margin-top: 3px; font-size: 13.5px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 13px;
  border-radius: var(--radius); border: 1px solid var(--border-strong); background: #fff; color: var(--text);
  font: inherit; font-size: 13.5px; font-weight: 550; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s;
  box-shadow: var(--shadow-sm); text-decoration: none; position: relative;
}
.btn:hover { background: var(--subtle); color: var(--text); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn .icon { width: 15px; height: 15px; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-hover); border-color: var(--navy-hover); color: #fff; }
.btn-danger { color: var(--negative); }
.btn-danger:hover { background: var(--negative-bg); border-color: var(--negative-border); color: var(--negative); }
.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--subtle); color: var(--text); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .55; pointer-events: none; }
.htmx-request .btn[type="submit"], .btn.htmx-request { color: transparent !important; pointer-events: none; }
.htmx-request .btn[type="submit"]::after, .btn.htmx-request::after {
  content: ""; position: absolute; width: 14px; height: 14px; border: 2px solid currentColor; border-radius: 50%;
  border-color: rgba(255,255,255,.9) rgba(255,255,255,.9) rgba(255,255,255,.9) transparent; animation: spin .7s linear infinite;
}
.htmx-request .btn[type="submit"]:not(.btn-primary)::after { border-color: var(--text-2) var(--text-2) var(--text-2) transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--navy); cursor: pointer; font-size: 12.5px; font-weight: 550; }
.link-btn:hover { color: var(--navy-hover); text-decoration: underline; }

/* ---------- Panels / cards ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.panel-head h2, .panel-head h3 { font-size: 14px; font-weight: 600; }
.panel-head .sub { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }
.panel-body { padding: 18px; }
.panel-foot { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--bg); border-radius: 0 0 var(--radius-lg) var(--radius-lg); display: flex; justify-content: flex-end; gap: 8px; align-items: center; }
.panel-foot.between { justify-content: space-between; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack > * + * { margin-top: 16px; }

/* ---------- Metric cards ---------- */
.metric { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.metric .label { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.metric .label .icon { color: var(--text-3); }
.metric .value { font-size: 24px; font-weight: 650; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.metric .foot { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.metric.link { display: block; text-decoration: none; transition: box-shadow .12s, border-color .12s; }
.metric.link:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }

/* ---------- Charts (inline SVG, IMPLEMENTATION_PLAN.md §1.3) ---------- */
.chart-card .panel-body { padding: 18px 18px 8px; }
.chart { display: block; width: 100%; height: 180px; overflow: visible; }
.chart-axis { stroke: var(--border); stroke-width: .5; }
.chart-bar rect, .chart-stacked rect { transition: opacity .12s; }
.chart-bar rect:hover, .chart-stacked rect:hover { opacity: .82; }
.chart-groups { display: flex; margin-top: 6px; font-size: 11px; color: var(--text-3); }
.chart-groups > span { flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; padding-bottom: 10px; }
.chart-legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.chart-legend-item .chart-swatch { width: 9px; height: 9px; flex: none; }
.chart-line-dot { fill: var(--surface); stroke-width: 2; }
.chart-donut-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.chart-donut { width: 140px; height: 140px; flex: none; }
.chart-donut circle { transition: stroke-width .12s; }
.chart-donut-center { text-anchor: middle; dominant-baseline: middle; font-size: 7px; font-weight: 650; fill: var(--text); }

/* ---------- Dashboard sections & insights ---------- */
.dash-section .panel-body { padding: 14px 18px; }
.dash-section dl.kv { grid-template-columns: 1fr auto; }
.insight-list { list-style: none; margin: 0; padding: 0; }
.insight-item { display: flex; gap: 10px; padding: 11px 18px; border-bottom: 1px solid var(--border); }
.insight-item:last-child { border-bottom: 0; }
.insight-item .ic { flex: none; margin-top: 1px; }
.insight-item.warning .ic { color: var(--warning); }
.insight-item.critical .ic { color: var(--negative); }
.insight-item .t { font-size: 13.5px; font-weight: 550; }
.insight-item .d { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 4px;
  font-size: 12px; font-weight: 550; white-space: nowrap; border: 1px solid;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.plain::before { display: none; }
.badge.neutral { color: var(--neutral); background: var(--neutral-bg); border-color: var(--neutral-border); }
.badge.positive { color: var(--positive); background: var(--positive-bg); border-color: var(--positive-border); }
.badge.warning { color: var(--warning); background: var(--warning-bg); border-color: var(--warning-border); }
.badge.info { color: var(--info); background: var(--info-bg); border-color: var(--info-border); }
.badge.negative { color: var(--negative); background: var(--negative-bg); border-color: var(--negative-border); }
.badge.teal { color: var(--teal); background: var(--teal-50); border-color: #b5e4de; }
.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 4px; background: var(--subtle); color: var(--text-2); font-size: 12px; font-weight: 500; border: 1px solid var(--border); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; position: relative; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-size: 12px; font-weight: 550; color: var(--text-2); background: var(--bg);
  padding: 9px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table th:first-child, .table td:first-child { padding-left: 18px; }
.table th:last-child, .table td:last-child { padding-right: 18px; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fcfcfb; }
.table tr[data-href] { cursor: pointer; }
.table .sort { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.table .sort:hover { color: var(--text); }
.table .sort .icon { width: 13px; height: 13px; color: var(--text-3); }
.table .sort.active { color: var(--text); }
.table .sort.active .icon { color: var(--navy); }
.table .actions { text-align: right; white-space: nowrap; width: 1%; }
.table td input[type=text], .table td input[type=number] { min-width: 76px; }
.cell-user { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.cell-user .n { font-weight: 550; }
.cell-user .e { font-size: 12.5px; color: var(--text-3); }
.cell-title { font-weight: 550; color: var(--text); }
.cell-sub { font-size: 12.5px; color: var(--text-3); }

.toolbar { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.toolbar .search { position: relative; flex: 1; min-width: 200px; max-width: 340px; }
.toolbar .search input { padding-left: 32px; }
.toolbar .search .icon { position: absolute; left: 10px; top: 10px; color: var(--text-3); pointer-events: none; }
.toolbar select { width: auto; min-width: 150px; }
.toolbar .spacer { flex: 1; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 9px 12px; color: var(--text-2); font-weight: 500; font-size: 13.5px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--navy); border-bottom-color: var(--navy); font-weight: 600; }
.tab .count { font-size: 11.5px; color: var(--text-3); background: var(--subtle); border-radius: 10px; padding: 0 7px; line-height: 18px; font-weight: 550; }
.tab.active .count { background: var(--navy-50); color: var(--navy); }
.panel > .tabs { padding: 0 12px; margin-bottom: 0; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 18px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); flex-wrap: wrap; }
.pages { display: flex; gap: 4px; align-items: center; }
.pages a, .pages span { min-width: 28px; height: 28px; display: inline-grid; place-items: center; border-radius: 5px; padding: 0 6px; color: var(--text-2); font-weight: 500; }
.pages a:hover { background: var(--subtle); color: var(--text); }
.pages .current { background: var(--navy); color: #fff; }
.pages .disabled { color: var(--border-strong); }

/* ---------- Empty states ---------- */
.empty { text-align: center; padding: 48px 24px; }
.empty .ic { width: 44px; height: 44px; margin: 0 auto 14px; border-radius: 10px; background: var(--subtle); border: 1px solid var(--border); display: grid; place-items: center; color: var(--text-3); }
.empty h3 { font-size: 15px; }
.empty p { color: var(--text-2); margin: 6px auto 16px; max-width: 420px; font-size: 13.5px; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-section + .form-section { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--border); }
.form-section h3 { font-size: 14px; }
.form-section .desc { color: var(--text-3); font-size: 12.5px; margin: 2px 0 14px; }
.form-section h3 + .form-grid { margin-top: 12px; }
.field label { display: block; font-size: 13px; font-weight: 550; margin-bottom: 5px; color: var(--text); }
.field .req { color: var(--negative); margin-left: 2px; }
.field .opt { color: var(--text-3); font-weight: 400; margin-left: 4px; font-size: 12px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], input[type=url], input[type=search], input[type=date], select, textarea {
  width: 100%; height: 36px; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: #fff; font: inherit; font-size: 13.5px; color: var(--text); transition: border-color .12s, box-shadow .12s;
}
textarea { height: auto; min-height: 84px; padding: 8px 11px; resize: vertical; }
select {
  appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2378716c' 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-position: right 9px center;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy); box-shadow: var(--focus); }
input[readonly], input:disabled, select:disabled { background: var(--subtle); color: var(--text-2); cursor: default; }
input[dir="rtl"] { font-family: var(--font-ar); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--negative); }
.field.has-error input:focus { box-shadow: 0 0 0 3px rgba(185, 28, 28, .14); }
.field-error { color: var(--negative); font-size: 12.5px; margin-top: 5px; display: flex; gap: 5px; align-items: center; }
.hint { color: var(--text-3); font-size: 12.5px; margin-top: 5px; }
.input-group { display: flex; }
.input-group input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group .addon { display: grid; place-items: center; padding: 0 11px; border: 1px solid var(--border-strong); border-left: 0; border-radius: 0 var(--radius) var(--radius) 0; background: var(--subtle); color: var(--text-2); font-size: 13px; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.check input { margin-top: 3px; width: 15px; height: 15px; accent-color: var(--navy); flex: none; }
.check .l { font-weight: 550; font-size: 13.5px; }
.check .d { font-size: 12.5px; color: var(--text-3); }
.switch { position: relative; display: inline-block; vertical-align: middle; width: 34px; height: 20px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 20px; transition: .15s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--navy); }
.switch input:checked + span::after { transform: translateX(14px); }
.switch input:focus-visible + span { box-shadow: var(--focus); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.form-error-banner { display: flex; gap: 10px; padding: 10px 12px; border: 1px solid var(--negative-border); background: var(--negative-bg); color: var(--negative); border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; }

/* ---------- Notices ---------- */
.notice { display: flex; gap: 12px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid; font-size: 13px; }
.notice .icon { margin-top: 1px; }
.notice strong { font-weight: 600; }
.notice.info { background: var(--info-bg); border-color: var(--info-border); color: #174a72; }
.notice.warning { background: var(--warning-bg); border-color: var(--warning-border); color: #8a4108; }
.notice.positive { background: var(--positive-bg); border-color: var(--positive-border); color: #166534; }
.notice.negative { background: var(--negative-bg); border-color: var(--negative-border); color: var(--negative); }
.notice p + p { margin-top: 4px; }

/* ---------- Key/value ---------- */
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 9px 14px; font-size: 13.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; color: var(--text); min-width: 0; }

/* ---------- Progress ---------- */
.progress { height: 6px; border-radius: 3px; background: var(--subtle); overflow: hidden; border: 1px solid var(--border); }
.progress > span { display: block; height: 100%; background: var(--teal); border-radius: 3px; }

/* ---------- Checklist ---------- */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--border); }
.checklist li:last-child { border-bottom: 0; }
.checklist .st { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none; border: 1.5px solid var(--border-strong); color: transparent; }
.checklist .st.done { background: var(--teal); border-color: var(--teal); color: #fff; }
.checklist .st .icon { width: 13px; height: 13px; stroke-width: 3; }
.checklist .l { font-weight: 550; font-size: 13.5px; }
.checklist .d { font-size: 12.5px; color: var(--text-3); }
.checklist a.go { margin-left: auto; color: var(--text-3); }
.checklist a.go:hover { color: var(--navy); }

/* ---------- Activity feed ---------- */
.feed { list-style: none; margin: 0; padding: 4px 18px; }
.feed li { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); position: relative; }
.feed li:last-child { border-bottom: 0; }
.feed .ic { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--subtle); color: var(--text-2); flex: none; border: 1px solid var(--border); }
.feed .m { font-size: 13.5px; }
.feed .w { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ---------- Settings layout ---------- */
.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; align-items: start; }
.settings-nav { position: sticky; top: calc(var(--topbar-h) + 24px); display: flex; flex-direction: column; gap: 1px; }
.settings-nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius); color: var(--text-2); font-size: 13.5px; font-weight: 500; }
.settings-nav a:hover { background: var(--subtle); color: var(--text); }
.settings-nav a.active { background: var(--navy-50); color: var(--navy); font-weight: 600; }
.settings-nav .sep { height: 1px; background: var(--border); margin: 8px 10px; }

/* ---------- Permission matrix ---------- */
.matrix th.act, .matrix td.act { text-align: center; width: 92px; }
.matrix td.act input { width: 16px; height: 16px; accent-color: var(--navy); cursor: pointer; }
.matrix .mod { font-weight: 550; }
.matrix .mod-d { font-size: 12.5px; color: var(--text-3); }
.access-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--border-strong); }
.access-dot.full { background: var(--navy); border-color: var(--navy); }
.access-dot.partial { background: linear-gradient(90deg, var(--navy) 50%, transparent 50%); border-color: var(--navy); }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--text-2); align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Modal / drawer ---------- */
dialog { border: 0; padding: 0; color: var(--text); background: transparent; max-width: none; max-height: none; }
dialog::backdrop { background: rgba(28, 25, 23, .38); }
dialog.modal[open] { animation: pop .16s ease-out; }
.modal-card { width: min(560px, calc(100vw - 32px)); background: #fff; border-radius: 10px; box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-card.sm { width: min(420px, calc(100vw - 32px)); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 16px; }
.modal-head p { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.modal-body { padding: 20px; max-height: calc(100vh - 220px); overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--bg); }
dialog.drawer { margin: 0 0 0 auto; height: 100vh; }
dialog.drawer[open] { animation: slide .2s ease-out; }
dialog.drawer .modal-card { width: min(500px, 100vw); height: 100vh; border-radius: 0; display: flex; flex-direction: column; }
dialog.drawer form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
dialog.drawer .modal-body { flex: 1; max-height: none; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes slide { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; min-width: 280px; max-width: 420px;
  padding: 12px 14px; background: var(--text); color: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  font-size: 13.5px; animation: pop .18s ease-out;
}
.toast .icon { margin-top: 2px; }
.toast.success .icon { color: #4ade80; }
.toast.error .icon { color: #f87171; }
.toast.info .icon { color: #93c5fd; }
.toast .x { margin-left: auto; background: none; border: 0; color: #a8a29e; cursor: pointer; padding: 0; }
.toast.leaving { opacity: 0; transform: translateY(4px); transition: .2s; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: #fff; }
.auth-brand {
  background: var(--navy); color: #fff; padding: 40px 56px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.auth-brand::before {
  content: ""; position: absolute; inset: 0; opacity: .08;
  background-image: linear-gradient(rgba(255,255,255,.9) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.9) 1px, transparent 1px);
  background-size: 44px 44px; mask-image: linear-gradient(160deg, #000 20%, transparent 75%);
}
.auth-brand > * { position: relative; }
.auth-brand .brand { height: auto; padding: 0; border: 0; }
.auth-brand .brand-mark { background: #fff; color: var(--navy); }
.auth-brand h1 { font-size: 30px; line-height: 1.2; letter-spacing: -.02em; max-width: 460px; font-weight: 650; }
.auth-brand .lead { color: rgba(255,255,255,.78); margin-top: 14px; font-size: 15px; max-width: 460px; }
.auth-points { list-style: none; padding: 0; margin: 32px 0 0; display: grid; gap: 14px; max-width: 460px; }
.auth-points li { display: flex; gap: 12px; color: rgba(255,255,255,.9); font-size: 14px; }
.auth-points .icon { color: #5eead4; margin-top: 2px; }
.auth-foot { font-size: 12.5px; color: rgba(255,255,255,.6); }
.auth-form { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h2 { font-size: 22px; }
.auth-card .sub { color: var(--text-2); margin: 6px 0 24px; }
.auth-card .field + .field { margin-top: 14px; }
.auth-card .btn { height: 40px; margin-top: 20px; }
.demo-creds { margin-top: 24px; padding: 12px 14px; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--bg); font-size: 12.5px; color: var(--text-2); }
.demo-creds code { font-family: var(--mono); color: var(--text); font-size: 12px; }

/* ---------- Misc ---------- */
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.error-page { max-width: 480px; margin: 64px auto; text-align: center; }
.error-page .code { font-size: 13px; font-weight: 600; color: var(--navy); letter-spacing: .06em; }
.error-page h1 { font-size: 24px; margin-top: 6px; }
.error-page p { color: var(--text-2); margin: 10px 0 24px; }
.preview-bullets { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.preview-bullets li { display: flex; gap: 10px; font-size: 13.5px; }
.preview-bullets .icon { color: var(--teal); margin-top: 2px; }
.invoice-preview { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; background: var(--bg); font-size: 12.5px; }
.invoice-preview .row { display: flex; justify-content: space-between; gap: 16px; }
.invoice-preview .ar { text-align: right; direction: rtl; }
.invoice-preview strong { font-size: 13px; }
.team-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 18px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.team-row:last-child { border-bottom: 0; }
.status-line { display: flex; align-items: center; gap: 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar-search { width: 260px; }
}
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .sidebar-open .sidebar { transform: none; }
  .sidebar-open .scrim { position: fixed; inset: 0; background: rgba(28,25,23,.35); z-index: 35; }
  .main { margin-left: 0; }
  .topbar .menu-toggle { display: inline-grid; }
  .grid-main, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .settings { grid-template-columns: minmax(0, 1fr); }
  .settings-nav { position: static; flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 4px; }
  .settings-nav .sep { display: none; }
  .settings-nav a { white-space: nowrap; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-brand { display: none; }
}
@media (max-width: 720px) {
  .content { padding: 16px 16px 40px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-search { width: auto; flex: 1; }
  .topbar-search kbd, .crumbs, .user-btn .who { display: none; }
  .grid-2, .grid-4, .form-grid, .form-grid-3 { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: auto; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
  .dropdown-panel.wide { width: calc(100vw - 24px); right: -60px; }
  .page-header h1 { font-size: 19px; }
}

/* ---- Invoice print / PDF document (finance/invoice_print.html) ---- */
.invoice-doc {
  max-width: 900px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 40px; color: var(--text);
}
.invoice-doc-head { display: flex; justify-content: space-between; gap: 24px; border-bottom: 2px solid var(--border-strong); padding-bottom: 20px; margin-bottom: 20px; }
.invoice-doc-head h2 { margin: 0 0 4px; font-size: 17px; }
.invoice-doc-head p { margin: 2px 0; }
.invoice-doc-title { text-align: right; }
.invoice-doc-title h1 { margin: 0; font-size: 22px; }
.invoice-doc-title .tag { display: inline-block; margin: 4px 0; padding: 2px 10px; border-radius: 999px; background: var(--subtle); font-size: 12px; font-weight: 600; }
.invoice-doc-title img { margin-top: 10px; border: 1px solid var(--border); border-radius: 6px; }
.invoice-doc-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 24px; }
.invoice-doc-meta .label { color: var(--text-3); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; margin: 0 0 6px; }
.invoice-doc-lines { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.invoice-doc-lines th, .invoice-doc-lines td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; font-size: 13px; }
.invoice-doc-lines th { background: var(--subtle); }
.invoice-doc-totals { display: flex; justify-content: flex-end; margin-bottom: 20px; }
.invoice-doc-totals .kv { grid-template-columns: 1fr auto; min-width: 320px; gap: 4px 20px; }
.invoice-doc-notes { padding: 12px; background: var(--subtle); border-radius: 8px; font-size: 13px; }
.invoice-doc-foot { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); color: var(--text-2); font-size: 12px; }

@media print {
  .sidebar, .topbar, .scrim, #modal-root, .toasts, .no-print { display: none !important; }
  .shell, .main { display: block !important; margin: 0 !important; }
  .content { padding: 0 !important; }
  .invoice-doc { border: none; border-radius: 0; max-width: none; padding: 0; }
  body { background: #fff; }
}
