/* =============================================================================
 * app.css - design tokens, layout, components.
 * Rules: logical properties only (no left/right) so RTL works; system fonts only;
 * light + dark themes through [data-theme] on <html>.
 * ========================================================================== */

/* ---------- tokens ---------- */
:root {
  color-scheme: light;
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --surface-2: #F0F2F5;
  --surface-3: #E6E9EE;
  --border: #E2E5EA;
  --border-strong: #CBD1DA;
  --text: #18202D;
  --muted: #5A6577;
  --faint: #6E7889;

  --primary: #0B6B5A;
  --primary-hover: #095A4B;
  --primary-contrast: #FFFFFF;
  --primary-soft: #E3F2EE;
  --primary-text: #0B6B5A;
  --info: #2459D6;
  --info-soft: #E6EDFB;
  --info-text: #1B47B0;
  --success: #0A7A47;
  --success-soft: #E2F4EA;
  --success-text: #076339;
  --warning: #B45309;
  --warning-soft: #FDEFD9;
  --warning-text: #8A3F06;
  --danger: #B3261E;
  --danger-hover: #9A1F18;
  --danger-contrast: #FFFFFF;
  --danger-soft: #FBE8E6;
  --danger-text: #8F1B14;

  --focus: #2459D6;
  --ring: rgba(11, 107, 90, 0.22);
  --scrim: rgba(14, 19, 26, 0.5);

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 14px rgba(16, 24, 40, 0.09);
  --shadow-lg: 0 14px 36px rgba(16, 24, 40, 0.18);

  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;

  --sidebar-w: 248px;
  --sidebar-w-collapsed: 64px;
  --topbar-h: 56px;

  --chart-1: #2a78d6;
  --chart-2: #eb6834;
  --chart-3: #0f8a73;
  --chart-4: #eda100;
  --chart-5: #e87ba4;
  --chart-6: #008300;
  --chart-7: #4a3aa7;
  --chart-8: #e34948;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "SF Arabic", "Geeza Pro", Tahoma, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235A6577' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  --check-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FFFFFF' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m20 6-11 11-5-5'/%3E%3C/svg%3E");
  --dash-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FFFFFF' stroke-width='3.4' stroke-linecap='round'%3E%3Cpath d='M6 12h12'/%3E%3C/svg%3E");
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0E131A;
  --surface: #151B24;
  --surface-2: #1C2430;
  --surface-3: #263142;
  --border: #2A3442;
  --border-strong: #3B485B;
  --text: #E6EAF0;
  --muted: #9AA6B8;
  --faint: #7F8B9E;

  --primary: #3CC4A4;
  --primary-hover: #5AD3B6;
  --primary-contrast: #04201A;
  --primary-soft: rgba(60, 196, 164, 0.14);
  --primary-text: #5AD3B6;
  --info: #7BA2FF;
  --info-soft: rgba(123, 162, 255, 0.15);
  --info-text: #A9C1FF;
  --success: #47C98C;
  --success-soft: rgba(71, 201, 140, 0.15);
  --success-text: #74D9A9;
  --warning: #E8A94F;
  --warning-soft: rgba(232, 169, 79, 0.15);
  --warning-text: #F0C27F;
  --danger: #F2857D;
  --danger-hover: #F6A29B;
  --danger-contrast: #2B0A07;
  --danger-soft: rgba(242, 133, 125, 0.15);
  --danger-text: #F7A8A2;

  --focus: #8DB0FF;
  --ring: rgba(60, 196, 164, 0.28);
  --scrim: rgba(0, 0, 0, 0.62);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 14px 36px rgba(0, 0, 0, 0.55);

  --chart-1: #3987e5;
  --chart-2: #d95926;
  --chart-3: #199e70;
  --chart-4: #c98500;
  --chart-5: #d55181;
  --chart-6: #008300;
  --chart-7: #9085e9;
  --chart-8: #e66767;

  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239AA6B8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  --check-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2304201A' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m20 6-11 11-5-5'/%3E%3C/svg%3E");
  --dash-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2304201A' stroke-width='3.4' stroke-linecap='round'%3E%3Cpath d='M6 12h12'/%3E%3C/svg%3E");
}

/* ---------- reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
:lang(ar) { line-height: 1.65; }
:lang(ar) *, :lang(ar) *::before, :lang(ar) *::after { letter-spacing: 0 !important; text-transform: none !important; }
html.has-overlay body { overflow: hidden; }
[hidden] { display: none !important; }
h1, h2, h3, h4, p { margin-block: 0; }
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
img, svg { max-inline-size: 100%; }
hr { border: 0; border-block-start: 1px solid var(--border); margin-block: 12px; }
code, kbd, pre, .mono { font-family: var(--mono); }
code, kbd, bdi.mono { unicode-bidi: isolate; direction: ltr; }
.mono { font-size: 0.93em; }
bdi.mono, .id { font-feature-settings: "tnum"; letter-spacing: 0; }
::selection { background: var(--primary-soft); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute !important; inline-size: 1px; block-size: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; inset-block-start: -48px; inset-inline-start: 12px; z-index: 300; background: var(--primary); color: var(--primary-contrast); padding: 8px 14px; border-radius: 0 0 8px 8px; border: 0; cursor: pointer; }
.skip-link:focus { inset-block-start: 0; }

/* ---------- utilities ---------- */
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.stack-lg { display: flex; flex-direction: column; gap: 24px; }
.row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row-wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.end { justify-content: flex-end; }
.center { justify-content: center; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid-2, .grid-3, .grid-4, .grid-auto { 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-auto { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.span-2 { grid-column: span 2; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.num { font-variant-numeric: tabular-nums; text-align: end; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.nowrap { white-space: nowrap; }
.wrap-any { overflow-wrap: anywhere; }
.text-start { text-align: start; }
.text-end { text-align: end; }
.text-center { text-align: center; }
.w-full { inline-size: 100%; }
.mt-1 { margin-block-start: 4px; } .mt-2 { margin-block-start: 8px; } .mt-3 { margin-block-start: 12px; } .mt-4 { margin-block-start: 16px; } .mt-6 { margin-block-start: 24px; }
.mb-1 { margin-block-end: 4px; } .mb-2 { margin-block-end: 8px; } .mb-3 { margin-block-end: 12px; } .mb-4 { margin-block-end: 16px; } .mb-6 { margin-block-end: 24px; }
.p-3 { padding: 12px; } .p-4 { padding: 16px; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.no-print { }
.print-only { display: none; }
.tone-success { color: var(--success-text); } .tone-warning { color: var(--warning-text); } .tone-danger { color: var(--danger-text); } .tone-info { color: var(--info-text); } .tone-brand { color: var(--primary-text); }
.icon { flex: none; vertical-align: middle; }
:dir(rtl) .icon-dir { transform: scaleX(-1); }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-block-size: 100vh; min-block-size: 100dvh; }
:root[data-sidebar="collapsed"] .app { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.view { flex: 1 1 auto; inline-size: 100%; max-inline-size: 1480px; margin-inline: auto; padding: 24px 28px 64px; outline: none; min-width: 0; }
.view-pad { min-width: 0; }
.view-kit { max-inline-size: 1560px; }
#boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); color: var(--muted); z-index: 500; }

/* laptop widths: give the content a little more room */
@media (min-width: 901px) and (max-width: 1366px) {
  :root { --sidebar-w: 224px; }
  .view { padding-inline: 20px; }
}

/* sidebar */
.sidebar {
  position: sticky; inset-block-start: 0; block-size: 100vh; block-size: 100dvh;
  background: var(--surface); border-inline-end: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 40; overflow: hidden;
}
.sb-brand { display: flex; align-items: center; gap: 10px; block-size: var(--topbar-h); padding-inline: 14px; border-block-end: 1px solid var(--border); flex: none; text-decoration: none; color: var(--text); }
.sb-brand:hover { text-decoration: none; }
.sb-logo { inline-size: 32px; block-size: 32px; border-radius: 9px; background: var(--primary); color: var(--primary-contrast); display: grid; place-items: center; flex: none; }
.sb-brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.sb-brand-name { font-weight: 650; font-size: 14px; }
.sb-brand-sub { font-size: 11px; color: var(--muted); }
.sb-nav { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; padding: 6px 10px 12px; scrollbar-width: thin; }
.sb-section { margin-block-start: 6px; }
.sb-section-title { padding: 14px 10px 6px; font-size: 11px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.sb-item {
  display: flex; align-items: center; gap: 10px; inline-size: 100%; block-size: 36px; padding-inline: 10px; border: 0; background: none;
  border-radius: var(--radius-sm); color: var(--text); font-weight: 500; cursor: pointer; text-decoration: none; position: relative; text-align: start;
}
.sb-item:hover { background: var(--surface-2); text-decoration: none; }
.sb-item .icon { color: var(--muted); }
.sb-item.is-active { background: var(--primary-soft); color: var(--primary-text); font-weight: 650; }
.sb-item.is-active .icon { color: var(--primary-text); }
.sb-item.is-active::before { content: ""; position: absolute; inset-inline-start: -10px; inset-block: 8px; inline-size: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }
:dir(rtl) .sb-item.is-active::before { border-radius: 3px 0 0 3px; }
.sb-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-caret { color: var(--muted); transition: transform 0.15s; }
.sb-group.is-open > .sb-item .sb-caret { transform: rotate(180deg); }
.sb-badge { font-size: 11px; font-weight: 650; min-inline-size: 20px; block-size: 20px; padding-inline: 6px; border-radius: 999px; display: inline-grid; place-items: center; background: var(--danger-soft); color: var(--danger-text); }
.sb-children { display: none; margin-inline-start: 19px; padding-inline-start: 8px; border-inline-start: 1px solid var(--border); margin-block: 2px 4px; }
.sb-group.is-open > .sb-children { display: block; }
.sb-child { display: flex; align-items: center; block-size: 32px; padding-inline: 10px; border-radius: var(--radius-sm); color: var(--muted); font-size: 13px; text-decoration: none; font-weight: 500; }
.sb-child:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sb-child.is-active { color: var(--primary-text); font-weight: 650; background: var(--primary-soft); }
.sb-footer { flex: none; border-block-start: 1px solid var(--border); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.sb-mode { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 12px; color: var(--muted); }
.sb-mode strong { color: var(--text); font-weight: 600; display: block; line-height: 1.2; }
.sb-collapse { display: flex; }
.scrim { display: none; }

@media (min-width: 901px) {
  :root[data-sidebar="collapsed"] .sb-brand-text,
  :root[data-sidebar="collapsed"] .sb-label,
  :root[data-sidebar="collapsed"] .sb-caret,
  :root[data-sidebar="collapsed"] .sb-badge,
  :root[data-sidebar="collapsed"] .sb-children,
  :root[data-sidebar="collapsed"] .sb-mode-text { display: none; }
  :root[data-sidebar="collapsed"] .sb-section-title { block-size: 1px; padding: 0; margin: 10px 8px; background: var(--border); overflow: hidden; font-size: 0; }
  :root[data-sidebar="collapsed"] .sb-item { justify-content: center; padding-inline: 0; }
  :root[data-sidebar="collapsed"] .sb-item.is-active::before { inset-inline-start: -10px; }
  :root[data-sidebar="collapsed"] .sb-brand { justify-content: center; padding-inline: 0; }
  :root[data-sidebar="collapsed"] .sb-mode { justify-content: center; padding-inline: 0; }
}

/* topbar */
.topbar {
  position: sticky; inset-block-start: 0; z-index: 30; block-size: var(--topbar-h); background: var(--surface);
  border-block-end: 1px solid var(--border); display: flex; align-items: center; gap: 8px; padding-inline: 16px 20px;
}
.topbar .tb-menu { display: none; }
.tb-company { display: flex; align-items: center; gap: 8px; font-weight: 650; flex: 0 1 auto; max-inline-size: 360px; min-inline-size: 0; margin-inline-end: 4px; }
.tb-company .icon { flex: none; }
.tb-company-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-inline-size: 0; }
.tb-env { flex: none; font-size: 11px; font-weight: 650; padding: 2px 8px; border-radius: 999px; background: var(--info-soft); color: var(--info-text); white-space: nowrap; }
.tb-search { position: relative; flex: 1 1 200px; max-inline-size: 520px; min-width: 120px; }
.tb-search .search-box { inline-size: 100%; }
.tb-search .search-input { background: var(--surface-2); border-color: transparent; padding-inline-end: 54px; }
.tb-search .search-input:focus { background: var(--surface); }
.tb-kbd { position: absolute; inset-inline-end: 8px; inset-block-start: 50%; transform: translateY(-50%); pointer-events: none; }
.tb-search .search-box:focus-within ~ .tb-kbd, .tb-search.has-value .tb-kbd { display: none; }
.tb-spacer { flex: 1 1 0; }
.tb-actions { display: flex; align-items: center; gap: 6px; }
.topbar .tb-search-btn { display: none; }
.pill-status { display: inline-flex; align-items: center; gap: 7px; block-size: 30px; padding-inline: 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--text); white-space: nowrap; }
.pill-status:hover { background: var(--surface-2); }
.pill-dot { inline-size: 8px; block-size: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.pill-status.is-offline { background: var(--warning-soft); border-color: transparent; color: var(--warning-text); }
.pill-status.is-offline .pill-dot { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }
.lang-seg .seg { padding-inline: 9px; min-inline-size: 34px; justify-content: center; }
.lang-seg { background: var(--surface-2); }
.bell-btn { position: relative; }
.bell-dot { position: absolute; inset-block-start: 5px; inset-inline-end: 5px; inline-size: 9px; block-size: 9px; border-radius: 50%; background: var(--danger); border: 2px solid var(--surface); }

/* offline banner */
.offline-banner { display: flex; align-items: center; gap: 12px; padding: 10px 20px; background: var(--warning-soft); color: var(--warning-text); border-block-end: 1px solid color-mix(in srgb, var(--warning) 35%, transparent); font-size: 13px; }
.offline-banner .ob-text { flex: 1 1 auto; min-width: 0; }
.offline-banner strong { font-weight: 650; }
.ob-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-block-start: 4px; }
.ob-chip { background: color-mix(in srgb, var(--warning) 16%, transparent); padding: 1px 8px; border-radius: 999px; font-weight: 600; font-size: 12px; }

/* search dropdown */
.search-pop { position: absolute; inset-inline-start: 0; inline-size: max(100%, 400px); max-inline-size: calc(100vw - 24px); inset-block-start: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-block-size: min(70vh, 460px); overflow-y: auto; z-index: 60; padding: 6px; }
.sr-group { padding: 8px 10px 4px; font-size: 11px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.sr-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; cursor: pointer; }
.sr-item:hover, .sr-item.is-active { background: var(--primary-soft); text-decoration: none; }
.sr-item .sr-ico { inline-size: 28px; block-size: 28px; border-radius: 7px; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); flex: none; }
.sr-item.is-active .sr-ico { background: var(--surface); color: var(--primary-text); }
.sr-main { min-width: 0; flex: 1 1 auto; line-height: 1.3; }
.sr-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-empty { padding: 18px 12px; text-align: center; color: var(--muted); }
.sr-foot { padding: 6px 10px 2px; font-size: 11px; color: var(--faint); display: flex; gap: 10px; }

/* notifications + user menu */
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-block-end: 1px solid var(--border); font-weight: 650; }
.notif-list { max-block-size: 360px; overflow-y: auto; }
.notif-item { display: flex; gap: 10px; padding: 10px 14px; border-block-end: 1px solid var(--border); color: var(--text); text-decoration: none; }
.notif-item:last-child { border-block-end: 0; }
.notif-item:hover { background: var(--surface-2); text-decoration: none; }
.notif-item.is-unread { background: color-mix(in srgb, var(--primary-soft) 55%, transparent); }
.notif-ico { inline-size: 30px; block-size: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--surface-2); }
.notif-ico.tone-danger { background: var(--danger-soft); } .notif-ico.tone-warning { background: var(--warning-soft); } .notif-ico.tone-info { background: var(--info-soft); } .notif-ico.tone-success { background: var(--success-soft); }
.notif-title { font-weight: 600; line-height: 1.35; }
.notif-body { font-size: 12.5px; color: var(--muted); line-height: 1.35; margin-block-start: 1px; }
.notif-time { font-size: 12px; color: var(--muted); margin-block-start: 2px; }
.user-card { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-block-end: 1px solid var(--border); }
.user-card .u-name { font-weight: 650; line-height: 1.25; }
.user-card .u-role { font-size: 12px; color: var(--muted); }
.conn-pop { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.conn-pop h3 { font-size: 14px; font-weight: 650; }
.conn-pop p { color: var(--muted); font-size: 13px; }
.pop-pad { padding: 12px 14px; }
.pop-pad p { margin-block-start: 4px; font-size: 13px; }

/* ---------- avatar ---------- */
.avatar { display: inline-grid; place-items: center; border-radius: 50%; flex: none; font-weight: 650; line-height: 1; background: hsl(var(--av-h, 170) 42% 90%); color: hsl(var(--av-h, 170) 55% 24%); user-select: none; }
:root[data-theme="dark"] .avatar { background: hsl(var(--av-h, 170) 32% 24%); color: hsl(var(--av-h, 170) 70% 85%); }
.user-btn { border: 0; background: none; padding: 2px; border-radius: 50%; cursor: pointer; display: grid; }
.user-btn:hover .avatar { box-shadow: 0 0 0 3px var(--surface-3); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; block-size: 36px; padding-inline: 14px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-weight: 550; cursor: pointer; white-space: nowrap; text-decoration: none; user-select: none; line-height: 1;
  transition: background-color 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.btn:hover { text-decoration: none; }
.btn-sm { block-size: 30px; padding-inline: 10px; font-size: 13px; gap: 6px; }
.btn-lg { block-size: 42px; padding-inline: 18px; font-size: 15px; }
.btn-icon { padding: 0; inline-size: 36px; }
.btn-sm.btn-icon { inline-size: 30px; }
.btn-lg.btn-icon { inline-size: 42px; }
.btn-block { inline-size: 100%; }
.btn-primary { background: var(--primary); color: var(--primary-contrast); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: var(--danger-contrast); }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn.is-active { background: var(--primary-soft); color: var(--primary-text); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn-label { overflow: hidden; text-overflow: ellipsis; }
.spinner { inline-size: 14px; block-size: 14px; border-radius: 50%; border: 2px solid currentColor; border-inline-end-color: transparent; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.chip { display: inline-flex; align-items: center; gap: 6px; block-size: 28px; padding-inline: 11px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 13px; font-weight: 500; color: var(--text); cursor: default; text-decoration: none; }
button.chip, a.chip { cursor: pointer; }
.chip.is-active { background: var(--primary-soft); border-color: transparent; color: var(--primary-text); }
.chip-x { border: 0; background: none; padding: 0; display: grid; cursor: pointer; color: var(--muted); border-radius: 50%; }
.chip-x:hover { color: var(--text); }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; block-size: 22px; padding-inline: 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1; }
.badge .icon { margin-inline-start: -2px; }
.badge-dot { inline-size: 6px; block-size: 6px; border-radius: 50%; background: currentColor; }
.badge-neutral { background: var(--surface-2); color: var(--muted); box-shadow: inset 0 0 0 1px var(--border); }
.badge-brand { background: var(--primary-soft); color: var(--primary-text); }
.badge-info { background: var(--info-soft); color: var(--info-text); }
.badge-success { background: var(--success-soft); color: var(--success-text); }
.badge-warning { background: var(--warning-soft); color: var(--warning-text); }
.badge-danger { background: var(--danger-soft); color: var(--danger-text); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 20px 0; flex-wrap: wrap; }
.card-titles { min-width: 0; flex: 1 1 200px; }
.card-title { margin: 0; font-size: 15px; font-weight: 650; line-height: 1.35; }
.card-sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.card-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-body { padding: 16px 20px 20px; min-width: 0; }
.card-body.has-head { padding-block-start: 14px; }
.card-body.is-flush { padding: 0; overflow: hidden; border-end-start-radius: var(--radius); border-end-end-radius: var(--radius); }
.card-body.is-flush.has-head { margin-block-start: 14px; border-block-start: 1px solid var(--border); }
.card-foot { padding: 12px 20px; border-block-start: 1px solid var(--border); background: var(--surface-2); border-end-start-radius: var(--radius); border-end-end-radius: var(--radius); }
.error-stack { margin: 8px 0 0; font-size: 11px; white-space: pre-wrap; color: var(--muted); }

/* ---------- KPI ---------- */
.kpi { display: flex; flex-direction: column; gap: 8px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); min-width: 0; color: inherit; text-decoration: none; position: relative; }
.kpi.is-link { cursor: pointer; }
.kpi.is-link:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); text-decoration: none; }
.kpi-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 550; }
.kpi-icon { inline-size: 28px; block-size: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); flex: none; }
.kpi-info .kpi-icon { background: var(--info-soft); color: var(--info-text); }
.kpi-success .kpi-icon { background: var(--success-soft); color: var(--success-text); }
.kpi-warning .kpi-icon { background: var(--warning-soft); color: var(--warning-text); }
.kpi-danger .kpi-icon { background: var(--danger-soft); color: var(--danger-text); }
.kpi-neutral .kpi-icon { background: var(--surface-2); color: var(--muted); }
.kpi-value { font-size: 24px; font-weight: 650; line-height: 1.25; font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }
.kpi-value .money-cur { font-size: 13px; }
.kpi-value .money { display: inline-flex; flex-wrap: wrap; align-items: baseline; column-gap: 0.32em; max-inline-size: 100%; } /* long figures wrap the currency instead of overflowing the card */
.kpi-value .money-cur { margin-inline-start: 0; }
.kpi-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; min-block-size: 28px; }
.kpi-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi-delta { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 650; flex-wrap: wrap; }
.delta-success { color: var(--success-text); } .delta-danger { color: var(--danger-text); } .delta-neutral { color: var(--muted); }
.kpi-hint, .kpi-delta-label { color: var(--muted); font-size: 12px; font-weight: 450; }
.kpi-spark { flex: none; }

/* ---------- money, ids, links ---------- */
.money { white-space: nowrap; font-variant-numeric: tabular-nums; }
.money-cur { margin-inline-start: 0.32em; color: var(--muted); font-size: 0.82em; font-weight: 550; }
.money.is-neg .money-num { color: var(--danger-text); }
.doc-link { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); color: var(--primary-text); font-weight: 550; font-size: 13px; text-decoration: none; white-space: nowrap; }
.doc-link:hover { background: var(--primary-soft); border-color: transparent; text-decoration: none; }

/* ---------- empty / alert ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 40px 20px; color: var(--muted); }
.empty.is-compact { padding: 28px 16px; }
.empty-icon { inline-size: 52px; block-size: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); margin-block-end: 4px; }
.empty.is-compact .empty-icon { inline-size: 42px; block-size: 42px; }
.empty-title { color: var(--text); font-weight: 650; font-size: 15px; }
.empty-hint { max-inline-size: 420px; font-size: 13px; }
.empty-action { margin-block-start: 10px; }
.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius); align-items: flex-start; border: 1px solid transparent; }
.alert-icon { flex: none; margin-block-start: 1px; }
.alert-body { flex: 1 1 auto; min-width: 0; }
.alert-title { font-weight: 650; }
.alert-text { font-size: 13px; }
.alert-actions { flex: none; align-self: center; display: flex; gap: 8px; }
.alert-info { background: var(--info-soft); color: var(--info-text); border-color: color-mix(in srgb, var(--info) 28%, transparent); }
.alert-success { background: var(--success-soft); color: var(--success-text); border-color: color-mix(in srgb, var(--success) 28%, transparent); }
.alert-warning { background: var(--warning-soft); color: var(--warning-text); border-color: color-mix(in srgb, var(--warning) 32%, transparent); }
.alert-danger { background: var(--danger-soft); color: var(--danger-text); border-color: color-mix(in srgb, var(--danger) 28%, transparent); }
.alert-brand { background: var(--primary-soft); color: var(--primary-text); border-color: color-mix(in srgb, var(--primary) 28%, transparent); }
.alert-neutral { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.divider { border: 0; border-block-start: 1px solid var(--border); margin-block: 12px; }

/* ---------- page header, breadcrumbs, toolbar ---------- */
.page-header { margin-block-end: 20px; }
.breadcrumbs ol { display: flex; flex-wrap: wrap; align-items: center; list-style: none; padding: 0; margin: 0 0 6px; gap: 4px; font-size: 13px; color: var(--muted); }
.breadcrumbs li { display: inline-flex; align-items: center; gap: 4px; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--primary-text); }
.breadcrumbs [aria-current] { color: var(--text); font-weight: 550; }
.crumb-sep { color: var(--faint); }
.page-header-main { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.page-titles { min-width: 0; flex: 1 1 280px; }
.page-title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-title { font-size: 22px; line-height: 1.3; margin: 0; font-weight: 650; outline: none; overflow-wrap: anywhere; }
.page-sub { margin-block-start: 4px; color: var(--muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-block-end: 12px; }
.toolbar-main { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; flex: 1 1 auto; min-width: 0; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter { display: inline-flex; align-items: center; gap: 6px; }
.filter-label { color: var(--muted); font-size: 13px; white-space: nowrap; }
.filter-select { inline-size: auto; min-inline-size: 130px; block-size: 34px; }

/* ---------- tabs / segmented ---------- */
.tabs { display: flex; gap: 2px; border-block-end: 1px solid var(--border); overflow-x: auto; scrollbar-width: thin; max-inline-size: 100%; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 7px; block-size: 40px; padding-inline: 14px; border: 0; background: none; color: var(--muted); font-weight: 550; cursor: pointer; white-space: nowrap; border-radius: 6px 6px 0 0; }
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.is-active { color: var(--primary-text); }
.tab.is-active::after { content: ""; position: absolute; inset-inline: 10px; inset-block-end: -1px; block-size: 2px; background: var(--primary); border-radius: 2px; }
.tab-count { font-size: 11px; font-weight: 650; background: var(--surface-2); color: var(--muted); padding: 1px 7px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.tab.is-active .tab-count { background: var(--primary-soft); color: var(--primary-text); }
.tabs-pill { border-block-end: 0; gap: 6px; padding-block: 2px; }
.tabs-pill .tab { block-size: 32px; border: 1px solid var(--border); border-radius: 999px; padding-inline: 12px; background: var(--surface); }
.tabs-pill .tab.is-active { background: var(--primary-soft); border-color: transparent; }
.tabs-pill .tab.is-active::after { display: none; }
.segmented { display: inline-flex; padding: 2px; background: var(--surface-2); border-radius: 8px; border: 1px solid var(--border); gap: 2px; }
.seg { block-size: 30px; padding-inline: 12px; border: 0; background: none; border-radius: 6px; font-weight: 550; color: var(--muted); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; justify-content: center; white-space: nowrap; }
.seg:hover { color: var(--text); }
.seg.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented.is-sm .seg { block-size: 26px; padding-inline: 10px; font-size: 13px; }

/* ---------- form controls ---------- */
.input, .select, .textarea {
  inline-size: 100%; block-size: 36px; padding-inline: 11px; background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); font: inherit; min-width: 0; transition: border-color 0.12s, box-shadow 0.12s;
}
.textarea { block-size: auto; min-block-size: 76px; padding-block: 8px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--faint); opacity: 1; }
.input:hover, .select:hover, .textarea:hover { border-color: color-mix(in srgb, var(--text) 35%, var(--border-strong)); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.input.is-invalid, .has-error .input, .has-error .select { border-color: var(--danger); }
.has-error .input:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 25%, transparent); }
.input.is-numeric { text-align: end; font-variant-numeric: tabular-nums; }
.input[type="date"] { min-inline-size: 140px; }
.select { appearance: none; -webkit-appearance: none; padding-inline-end: 32px; background-image: var(--select-arrow); background-repeat: no-repeat; background-size: 14px; background-position: calc(100% - 11px) center; cursor: pointer; text-overflow: ellipsis; }
:dir(rtl) .select { background-position: 11px center; }
.select option { background: var(--surface); color: var(--text); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-weight: 550; font-size: 13px; }
.req { color: var(--danger); margin-inline-start: 3px; }
.opt { color: var(--muted); font-weight: 400; margin-inline-start: 6px; }
.field-hint { color: var(--muted); font-size: 12px; }
.field-error { display: flex; gap: 5px; align-items: center; color: var(--danger-text); font-size: 12px; font-weight: 550; }
.input-group { display: flex; min-width: 0; }
.input-group > * { border-radius: 0; }
.input-group > * + * { margin-inline-start: -1px; }
.input-group > :first-child { border-start-start-radius: var(--radius-sm); border-end-start-radius: var(--radius-sm); }
.input-group > :last-child { border-start-end-radius: var(--radius-sm); border-end-end-radius: var(--radius-sm); }
.input-addon { display: inline-flex; align-items: center; padding-inline: 11px; background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--muted); font-size: 13px; white-space: nowrap; }
.input-group .input:focus { position: relative; z-index: 1; }
.search-box { position: relative; inline-size: var(--search-w, 280px); max-inline-size: 100%; }
.search-icon { position: absolute; inset-inline-start: 11px; inset-block-start: 50%; transform: translateY(-50%); color: var(--faint); display: grid; pointer-events: none; }
.search-input { padding-inline: 34px 30px; }
.search-input::-webkit-search-cancel-button, .search-input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }
.search-clear { position: absolute; inset-inline-end: 6px; inset-block-start: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); cursor: pointer; display: grid; padding: 4px; border-radius: 50%; }
.search-clear:hover { background: var(--surface-3); color: var(--text); }

input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; inline-size: 16px; block-size: 16px; margin: 0; flex: none; border: 1.5px solid var(--border-strong); border-radius: 4px;
  background: var(--surface) center / 12px no-repeat; cursor: pointer; display: inline-grid; place-content: center; transition: background-color 0.1s, border-color 0.1s;
}
input[type="checkbox"]:hover { border-color: var(--muted); }
input[type="checkbox"]:checked { background-color: var(--primary); border-color: var(--primary); background-image: var(--check-mark); }
input[type="checkbox"]:indeterminate { background-color: var(--primary); border-color: var(--primary); background-image: var(--dash-mark); }
input[type="checkbox"]:disabled { opacity: 0.5; cursor: not-allowed; }
.check { display: inline-flex; gap: 9px; align-items: flex-start; cursor: pointer; min-block-size: 20px; }
.check.is-disabled, .toggle.is-disabled { opacity: 0.6; cursor: not-allowed; }
.check-text { display: flex; flex-direction: column; line-height: 1.35; }
.check > input { margin-block-start: 2px; }
.check-hint { color: var(--muted); font-size: 12px; }
.toggle { display: inline-flex; gap: 10px; align-items: center; cursor: pointer; position: relative; }
.toggle > input { position: absolute; opacity: 0; inline-size: 36px; block-size: 20px; margin: 0; cursor: pointer; }
.toggle-track { position: relative; inline-size: 36px; block-size: 20px; border-radius: 999px; background: var(--border-strong); transition: background-color 0.15s; flex: none; }
.toggle-thumb { position: absolute; inset-block-start: 2px; inset-inline-start: 2px; inline-size: 16px; block-size: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: inset-inline-start 0.15s; }
.toggle > input:checked + .toggle-track { background: var(--primary); }
.toggle > input:checked + .toggle-track .toggle-thumb { inset-inline-start: calc(100% - 18px); }
.toggle > input:focus-visible + .toggle-track { outline: 2px solid var(--focus); outline-offset: 2px; }
.toggle-text { display: flex; flex-direction: column; line-height: 1.35; }

/* ---------- table ---------- */
.table-container { inline-size: 100%; min-width: 0; }
.table-wrap { overflow: auto; max-block-size: var(--table-max-h, 72vh); -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.table { inline-size: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
.table th {
  position: sticky; inset-block-start: 0; z-index: 2; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 650; text-align: start;
  block-size: 38px; padding-inline: 12px; border-block-end: 1px solid var(--border); white-space: nowrap; text-transform: uppercase; letter-spacing: 0.04em;
}
.table td { block-size: 40px; padding: 6px 12px; border-block-end: 1px solid var(--border); white-space: nowrap; line-height: 1.4; vertical-align: middle; }
.table tbody tr:last-child td { border-block-end: 0; }
.table th.num, .table td.num { text-align: end; }
.table .align-center { text-align: center; } .table .align-end { text-align: end; } .table .align-start { text-align: start; }
.table td.wrap { white-space: normal; min-inline-size: 180px; }
.table td.wrap-sm { white-space: normal; min-inline-size: 120px; }
.table .col-select { inline-size: 40px; padding-inline: 12px 0; }
.table.is-dense td { block-size: 32px; padding-block: 3px; }
.table.is-dense th { block-size: 32px; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tbody tr.is-clickable { cursor: pointer; }
.table tbody tr.is-clickable:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.table tbody tr.is-selected td { background: var(--primary-soft); }
.table tbody tr.row-empty td { block-size: auto; padding: 0; white-space: normal; border: 0; }
.table tbody tr.row-empty:hover td { background: none; }
.table tfoot td { font-weight: 650; background: var(--surface-2); border-block-start: 1px solid var(--border); border-block-end: 0; position: sticky; inset-block-end: 0; z-index: 1; }
.th-btn { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 0; margin: 0; cursor: pointer; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; block-size: 100%; border-radius: 4px; }
.th-btn:hover { color: var(--text); }
.table th.num .th-btn, .table th.align-end .th-btn { flex-direction: row-reverse; } /* keep the number-column label flush with its figures */
.sort-ico { opacity: 0; transition: opacity 0.1s; }
.table th:hover .sort-ico { opacity: 0.55; }
.table th.is-sorted .sort-ico { opacity: 1; color: var(--primary-text); }
.table th.is-sorted { color: var(--text); }
.table-pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 12px; border-block-start: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.pager-btns { display: flex; gap: 4px; }

/* ---------- progress / timeline / stepper / kv ---------- */
.progress-head { display: flex; justify-content: space-between; font-size: 13px; margin-block-end: 6px; color: var(--muted); }
.progress-track { block-size: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress.is-sm .progress-track { block-size: 5px; }
.progress-bar { block-size: 100%; border-radius: 999px; background: var(--primary); transition: inline-size 0.3s; }
.progress-info .progress-bar { background: var(--info); } .progress-success .progress-bar { background: var(--success); }
.progress-warning .progress-bar { background: var(--warning); } .progress-danger .progress-bar { background: var(--danger); }
.timeline { list-style: none; margin: 0; padding: 0; }
.tl-item { position: relative; display: flex; gap: 12px; padding-block-end: 18px; }
.tl-item:not(:last-child)::before { content: ""; position: absolute; inset-inline-start: 11px; inset-block: 26px 2px; inline-size: 2px; background: var(--border); }
.tl-dot { inline-size: 24px; block-size: 24px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--muted); }
.tl-success .tl-dot { background: var(--success-soft); color: var(--success-text); } .tl-danger .tl-dot { background: var(--danger-soft); color: var(--danger-text); }
.tl-warning .tl-dot { background: var(--warning-soft); color: var(--warning-text); } .tl-info .tl-dot { background: var(--info-soft); color: var(--info-text); } .tl-brand .tl-dot { background: var(--primary-soft); color: var(--primary-text); }
.tl-body { min-width: 0; flex: 1 1 auto; }
.tl-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: baseline; }
.tl-title { font-weight: 600; }
.tl-time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.tl-text { color: var(--muted); font-size: 13px; margin-block-start: 2px; }
.stepper { display: flex; list-style: none; padding: 0; margin: 0; }
.step { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; text-align: center; min-width: 0; font-size: 12.5px; color: var(--muted); }
.step::before { content: ""; position: absolute; inset-block-start: 11px; inset-inline-start: calc(-50% + 16px); inset-inline-end: calc(50% + 16px); block-size: 2px; background: var(--border); }
.step:first-child::before { display: none; }
.step-dot { inline-size: 24px; block-size: 24px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--border-strong); background: var(--surface); font-size: 12px; font-weight: 650; position: relative; z-index: 1; font-variant-numeric: tabular-nums; }
.step.is-done::before, .step.is-current::before { background: var(--primary); }
.step.is-done .step-dot { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
.step.is-current .step-dot { border-color: var(--primary); color: var(--primary-text); box-shadow: 0 0 0 3px var(--ring); }
.step.is-current, .step.is-done { color: var(--text); font-weight: 550; }
.kv { display: grid; margin: 0; }
.kv-row { display: grid; grid-template-columns: minmax(100px, 38%) minmax(0, 1fr); gap: 12px; padding-block: 7px; border-block-end: 1px dashed var(--border); align-items: baseline; }
.kv-row:last-child { border-block-end: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.kv-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; }

/* ---------- overlays ---------- */
#overlay-root { position: relative; z-index: 100; }
.overlay { position: fixed; inset: 0; z-index: 100; display: flex; background: var(--scrim); opacity: 0; transition: opacity 0.16s; }
.overlay.is-open { opacity: 1; }
.modal-overlay { align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); inline-size: 100%; max-block-size: calc(100dvh - 32px); display: flex; flex-direction: column; transform: translateY(10px) scale(0.98); transition: transform 0.16s; outline: none; }
.overlay.is-open .modal { transform: none; }
.modal-sm { max-inline-size: 420px; } .modal-md { max-inline-size: 580px; } .modal-lg { max-inline-size: 820px; } .modal-xl { max-inline-size: 1060px; }
.modal-head, .drawer-head { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; padding: 18px 20px 12px; }
.modal-title, .drawer-title { margin: 0; font-size: 17px; font-weight: 650; line-height: 1.35; }
.overlay-sub { margin-block-start: 2px; color: var(--muted); font-size: 13px; }
.overlay-titles { min-width: 0; }
.modal-body, .drawer-body { padding: 4px 20px 18px; overflow: auto; flex: 1 1 auto; min-block-size: 0; }
.modal-foot, .drawer-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-block-start: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
.modal-foot { border-end-start-radius: var(--radius-lg); border-end-end-radius: var(--radius-lg); }
.confirm-body { display: flex; gap: 12px; align-items: flex-start; }
.confirm-icon { inline-size: 36px; block-size: 36px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--primary-soft); }
.confirm-icon.tone-danger { background: var(--danger-soft); }
.drawer-overlay { justify-content: flex-end; }
.drawer-overlay.is-start { justify-content: flex-start; }
.drawer { --slide-from: 100%; block-size: 100%; inline-size: 100%; background: var(--surface); display: flex; flex-direction: column; border-inline-start: 1px solid var(--border); box-shadow: var(--shadow-lg); transform: translateX(var(--slide-from)); transition: transform 0.2s; outline: none; }
.drawer:dir(rtl) { --slide-from: -100%; }
.is-start .drawer { --slide-from: -100%; border-inline-start: 0; border-inline-end: 1px solid var(--border); }
.is-start .drawer:dir(rtl) { --slide-from: 100%; }
.overlay.is-open .drawer { transform: none; }
.drawer-sm { max-inline-size: 360px; } .drawer-md { max-inline-size: 480px; } .drawer-lg { max-inline-size: 680px; } .drawer-xl { max-inline-size: 920px; }
.popover { position: fixed; z-index: 130; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); min-inline-size: 180px; max-inline-size: calc(100vw - 16px); opacity: 0; transform: translateY(-4px); transition: opacity 0.12s, transform 0.12s; outline: none; }
.popover.is-open { opacity: 1; transform: none; }
.menu { padding: 4px; display: flex; flex-direction: column; min-inline-size: 210px; }
.menu-item { display: flex; align-items: center; gap: 10px; padding-inline: 10px; block-size: 34px; border-radius: 6px; color: var(--text); background: none; border: 0; text-align: start; cursor: pointer; text-decoration: none; inline-size: 100%; }
.menu-item:hover { background: var(--surface-2); text-decoration: none; }
.menu-item:focus-visible { outline: none; background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--focus); }
.menu-item .icon { color: var(--muted); }
.menu-item.is-danger, .menu-item.is-danger .icon { color: var(--danger-text); }
.menu-item:disabled { opacity: 0.5; cursor: not-allowed; }
.menu-icon-gap { inline-size: 16px; flex: none; }
.menu-label { flex: 1 1 auto; white-space: nowrap; }
.menu-sep { block-size: 1px; background: var(--border); margin-block: 4px; }
.menu-header { padding: 8px 10px 3px; font-size: 11px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.kbd { margin-inline-start: auto; font-family: var(--mono); font-size: 11px; color: var(--muted); border: 1px solid var(--border-strong); border-radius: 4px; padding: 0 5px; background: var(--surface-2); line-height: 1.6; }
.toasts { position: fixed; inset-block-end: 16px; inset-inline-end: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; inline-size: min(400px, calc(100vw - 32px)); pointer-events: none; }
.toast { --tone: var(--muted); pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-inline-start: 4px solid var(--tone); border-radius: var(--radius); box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(10px); transition: opacity 0.18s, transform 0.18s; }
.toast.is-open { opacity: 1; transform: none; }
.toast-success { --tone: var(--success); } .toast-info { --tone: var(--info); } .toast-warning { --tone: var(--warning); } .toast-danger { --tone: var(--danger); }
.toast-icon { color: var(--tone); flex: none; margin-block-start: 1px; }
.toast-msg { flex: 1 1 auto; min-width: 0; line-height: 1.45; padding-block-start: 1px; overflow-wrap: anywhere; }
.toast-action { border: 0; background: none; color: var(--primary-text); font-weight: 650; cursor: pointer; padding: 2px 6px; border-radius: 4px; white-space: nowrap; }
.toast-action:hover { background: var(--primary-soft); }
.toast-x { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 3px; border-radius: 50%; display: grid; flex: none; }
.toast-x:hover { background: var(--surface-2); color: var(--text); }

/* ---------- charts ---------- */
.chart { position: relative; inline-size: 100%; min-width: 0; }
.chart-holder { inline-size: 100%; min-width: 0; }
.chart-svg { display: block; inline-size: 100%; overflow: visible; font-family: inherit; }
.chart-svg .grid-line { stroke: var(--border); stroke-width: 1; }
.chart-svg .axis-zero { stroke: var(--border-strong); stroke-width: 1; }
.chart-svg .axis-label { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-svg .bar { stroke: var(--surface); stroke-width: 1.5; }
.chart-svg .bar-value { fill: var(--muted); font-size: 11px; font-weight: 600; }
.chart-svg .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .dot { stroke: var(--surface); stroke-width: 2; transition: r 0.1s; }
.chart-svg .chart-band { fill: var(--text); fill-opacity: 0.06; pointer-events: none; }
.chart-tip { position: absolute; z-index: 5; pointer-events: none; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: var(--shadow-md); padding: 8px 10px; font-size: 12px; min-inline-size: 150px; max-inline-size: 260px; }
.tip-head { font-weight: 650; margin-block-end: 4px; }
.tip-row { display: flex; align-items: center; gap: 6px; line-height: 1.6; }
.tip-name { color: var(--muted); }
.tip-val { margin-inline-start: auto; padding-inline-start: 14px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.swatch { display: inline-block; inline-size: 10px; block-size: 10px; border-radius: 3px; flex: none; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; margin: 10px 0 0; padding: 0; color: var(--muted); font-size: 12px; }
.chart-legend li { display: inline-flex; align-items: center; gap: 6px; }
.chart-donut { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut-svg { inline-size: auto; flex: none; }
.donut-track { stroke: var(--surface-2); }
.donut-seg { transition: opacity 0.15s; }
.donut-seg.is-dim { opacity: 0.25; }
.donut-center-label { fill: var(--muted); font-size: 11px; }
.donut-center-value { fill: var(--text); font-size: 18px; font-weight: 650; }
.donut-legend { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; flex: 1 1 200px; min-inline-size: 180px; }
.donut-legend li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto 42px; gap: 8px; align-items: center; padding: 3px 6px; border-radius: 6px; font-size: 13px; }
.donut-legend li:hover { background: var(--surface-2); }
.dl-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-val { font-variant-numeric: tabular-nums; font-weight: 600; }
.dl-pct { color: var(--muted); text-align: end; font-variant-numeric: tabular-nums; }
.spark { display: block; overflow: visible; }
.spark-line { fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.spark-dot { stroke: var(--surface); stroke-width: 1.5; }
.qr { display: block; background: #fff; border-radius: 4px; border: 1px solid var(--border); }

/* ---------- kit gallery ---------- */
.kit-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.kit-pane { border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 14px; min-width: 0; background: var(--bg); }
.kit-pane-tag { font-size: 11px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-block-end: 12px; }
.kit-h1 { font-size: 22px; font-weight: 650; }
.kit-h2 { font-size: 17px; font-weight: 650; }
.kit-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.kit-swatch { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.kit-swatch-chip { inline-size: 28px; block-size: 28px; border-radius: 7px; border: 1px solid var(--border-strong); flex: none; }
.kit-badge-row { display: flex; gap: 10px; align-items: flex-start; padding-block: 4px; }
.kit-kind { inline-size: 56px; flex: none; color: var(--muted); font-size: 12px; padding-block-start: 2px; }
.kit-gap { block-size: 16px; }
.kit-chart-title { font-weight: 650; font-size: 13px; color: var(--muted); }
.kit-qrs { gap: 20px; }
.kit-icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.kit-icon { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 11px; color: var(--muted); text-align: center; overflow-wrap: anywhere; background: var(--surface); }
.kit-icon .icon { color: var(--text); }
.kit-section { scroll-margin-block-start: 72px; }

/* ---------- responsive ---------- */
@media (max-width: 1320px) {
  .tb-env { display: none; }
}
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kit-pair { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  :root[data-sidebar="collapsed"] .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    --sb-tx: -105%;
    position: fixed; inset-block: 0; inset-inline-start: 0; inline-size: min(300px, 86vw); block-size: 100dvh; z-index: 120;
    transform: translateX(var(--sb-tx)); transition: transform 0.2s; box-shadow: var(--shadow-lg);
  }
  .sidebar:dir(rtl) { --sb-tx: 105%; }
  .sidebar-open .sidebar { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 110; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
  .sidebar-open .scrim { opacity: 1; pointer-events: auto; }
  .topbar .tb-menu { display: inline-flex; }
  .sb-collapse { display: none; }
  .view { padding: 18px 16px 56px; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { padding-inline: 12px; }
}
@media (max-width: 760px) {
  .tb-company { display: none; }
  .tb-search { display: none; }
  .topbar .tb-search-btn { display: inline-flex; }
  .topbar.search-open .tb-search { display: block; position: absolute; inset: 0; max-inline-size: none; padding: 9px 12px; background: var(--surface); z-index: 5; }
  .topbar.search-open .search-pop { inset-inline: 12px; inline-size: auto; max-inline-size: none; }
  .topbar.search-open .tb-search-close { display: inline-flex; }
  .tb-kbd { display: none; }
}
.topbar .tb-search-close { display: none; position: absolute; inset-inline-end: 18px; inset-block-start: 50%; transform: translateY(-50%); z-index: 6; }
@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .span-2 { grid-column: auto; }
  .page-title { font-size: 20px; }
  .page-actions { inline-size: 100%; }
  .toolbar-main, .toolbar-actions { inline-size: 100%; }
  .search-box { inline-size: 100%; }
  .card-head { padding: 14px 16px 0; }
  .card-body { padding: 14px 16px 16px; }
  .kv-row { grid-template-columns: minmax(90px, 40%) minmax(0, 1fr); }
  .kv-cols-2 { grid-template-columns: minmax(0, 1fr); }
  .modal-foot .btn, .drawer-foot .btn { flex: 1 1 auto; }
  .toasts { inset-inline: 16px; inline-size: auto; }
  .kpi-value { font-size: 20px; }
  .step { font-size: 11px; }
  .pill-status .pill-text { display: none; }
  .pill-status { padding-inline: 8px; }
  .offline-banner { padding-inline: 14px; flex-wrap: wrap; }
}
@media (max-width: 520px) {
  .modal .segmented { display: flex; inline-size: 100%; }
  .modal .segmented .seg { flex: 1 1 0; min-inline-size: 0; block-size: auto; min-block-size: 30px; padding-block: 5px; white-space: normal; text-align: center; line-height: 1.25; justify-content: center; }
  .bell-btn { display: none; }
  .grid-4 { grid-template-columns: minmax(0, 1fr); }
  /* KPI rows stay two-up on phones so the list starts on the first screen instead of the third */
  .grid-4:has(> .kpi) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .grid-4:has(> .kpi) > .kpi { padding: 12px; gap: 6px; }
  .grid-4:has(> .kpi) > .kpi .kpi-top { font-size: 12px; align-items: flex-start; }
  .grid-4:has(> .kpi) > .kpi .kpi-icon { display: none; }
  .grid-4:has(> .kpi) > .kpi .kpi-value { font-size: 18px; }
  .grid-4:has(> .kpi) > .kpi .kpi-hint { font-size: 11.5px; }
  .tb-actions { gap: 4px; }
}
@media (max-width: 900px) {
  .table-wrap { max-block-size: none; }
}

/* ---------- motion + print ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
@page { size: A4; margin: 12mm 10mm; }
@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --muted: #333; --border: #ccc; }
  body { background: #fff; color: #000; }
  .sidebar, .topbar, .offline-banner, .scrim, #overlay-root, .no-print, .page-actions, .toolbar, .skip-link, .breadcrumbs, .tabs { display: none !important; }
  .app { display: block; }
  .view { padding: 0; max-inline-size: none; }
  .card, .kpi { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .table-wrap { max-block-size: none; overflow: visible; }
  .table th { position: static; background: #f2f2f2; color: #000; }
  .table tfoot td { position: static; }
  .print-only { display: block; }
  a { color: inherit; }
}

/* language switch: no transitions while dir flips */
.is-switching *, .is-switching *::before, .is-switching *::after { transition: none !important; animation-duration: 0s !important; }
