/* =====================================================================
   GTGCRM Design System — v2 (Phase 17)
   Single stylesheet. Token-driven. No framework. See Documentation/UI-DESIGN-SYSTEM.md
   ===================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
    /* Typography */
    --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
    --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
    --fs-xs: 0.75rem;     /* 12px */
    --fs-sm: 0.8125rem;   /* 13px */
    --fs-base: 0.875rem;  /* 14px */
    --fs-md: 1rem;        /* 16px */
    --fs-lg: 1.125rem;    /* 18px */
    --fs-xl: 1.375rem;    /* 22px */
    --fs-2xl: 1.75rem;    /* 28px */
    --lh: 1.5;

    /* Brand & primary */
    --c-primary: #1f4fd8;
    --c-primary-hover: #1a42b6;
    --c-primary-active: #163894;
    --c-primary-soft: #eef3ff;
    --c-primary-border: #c7d5fb;
    --c-brand: #c8961e;
    --c-brand-soft: #fbf3df;

    /* Navigation */
    --c-nav: #0d1a2d;
    --c-nav-raised: #15263d;
    --c-nav-border: #1f3150;
    --c-nav-text: #c5cfdd;
    --c-nav-muted: #8494ad;
    --c-nav-active: #ffffff;

    /* Surfaces & neutrals */
    --c-bg: #f3f5f8;
    --c-surface: #ffffff;
    --c-surface-2: #f8fafc;
    --c-surface-3: #eef1f5;
    --c-border: #e1e6ed;
    --c-border-strong: #c9d1dc;
    --c-text: #101828;
    --c-text-2: #344054;
    --c-text-3: #556072;   /* 6.3:1 on white */
    --c-text-4: #5f6b7e;   /* 5.4:1 on white, 4.7:1 on grey surfaces */

    /* Semantic (text colours all ≥ 4.5:1 on their soft background and on white) */
    --c-success: #067647;  --c-success-bg: #ecfdf3; --c-success-border: #abefc6; --c-success-solid: #067647;
    --c-warning: #93370d;  --c-warning-bg: #fffaeb; --c-warning-border: #fedf89; --c-warning-solid: #dc6803;
    --c-danger: #b42318;   --c-danger-bg: #fef3f2;  --c-danger-border: #fecdca;  --c-danger-solid: #b42318;
    --c-info: #175cd3;     --c-info-bg: #eff8ff;    --c-info-border: #b2ddff;    --c-info-solid: #1570ef;
    --c-neutral: #475467;  --c-neutral-bg: #f2f4f7; --c-neutral-border: #d0d5dd;
    --c-accent: #5925dc;   --c-accent-bg: #f4f3ff;  --c-accent-border: #d9d6fe;

    /* Spacing (4px scale) */
    --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px;

    /* Radius */
    --r-xs: 4px; --r-sm: 6px; --r: 8px; --r-lg: 12px; --r-xl: 16px; --r-pill: 999px;

    /* Elevation */
    --sh-xs: 0 1px 2px rgba(16, 24, 40, .05);
    --sh-sm: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
    --sh-md: 0 4px 8px -2px rgba(16, 24, 40, .08), 0 2px 4px -2px rgba(16, 24, 40, .04);
    --sh-lg: 0 16px 32px -8px rgba(16, 24, 40, .18), 0 6px 12px -6px rgba(16, 24, 40, .08);
    --focus: 0 0 0 3px rgba(31, 79, 216, .35);

    /* Layout */
    --nav-w: 252px;
    --nav-w-collapsed: 68px;
    --topbar-h: 60px;
    --content-max: 1480px;
    --ease: cubic-bezier(.2, .7, .3, 1);
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: var(--fs-base);
    line-height: var(--lh);
    color: var(--c-text);
    background: var(--c-bg);
    -webkit-font-smoothing: antialiased;
    font-variant-numeric: tabular-nums;
}
h1, h2, h3, h4 { margin: 0; color: var(--c-text); font-family: var(--font-display); letter-spacing: -0.01em; }
h1 { font-size: var(--fs-xl); font-weight: 650; line-height: 1.25; }
h2 { font-size: var(--fs-md); font-weight: 600; line-height: 1.35; }
h3 { font-size: var(--fs-base); font-weight: 600; }
h4 { font-size: var(--fs-sm); font-weight: 600; color: var(--c-text-3); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 var(--s-3); }
p:last-child { margin-bottom: 0; }
a { color: var(--c-primary); text-decoration: none; }
a:hover { color: var(--c-primary-hover); text-decoration: underline; text-underline-offset: 2px; }
code, kbd { font-family: var(--font-mono); font-size: .85em; }
code { background: var(--c-surface-3); padding: 1px 6px; border-radius: var(--r-xs); color: var(--c-text-2); }
kbd { border: 1px solid var(--c-border-strong); border-bottom-width: 2px; border-radius: var(--r-xs); padding: 0 5px; color: var(--c-text-3); background: var(--c-surface); }
ul, ol { margin: 0; padding-left: 1.25rem; }
hr { border: 0; border-top: 1px solid var(--c-border); margin: var(--s-4) 0; }
img, svg { vertical-align: middle; }
:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; border-radius: var(--r-xs); }
::selection { background: #c7d5fb; }

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: var(--s-4); top: -60px; z-index: 100; background: var(--c-primary); color: #fff; padding: var(--s-2) var(--s-4); border-radius: var(--r); font-weight: 600; }
.skip-link:focus { top: var(--s-3); color: #fff; }

/* ---------- 3. Application shell ---------- */
.app-shell {
    display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); min-height: 100vh;
    background: linear-gradient(to right, var(--c-nav) var(--nav-w), transparent var(--nav-w));
}
html.nav-collapsed .app-shell {
    grid-template-columns: var(--nav-w-collapsed) minmax(0, 1fr);
    background: linear-gradient(to right, var(--c-nav) var(--nav-w-collapsed), transparent var(--nav-w-collapsed));
}

.nav-rail {
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column;
    background: var(--c-nav); color: var(--c-nav-text);
    border-right: 1px solid var(--c-nav-border);
    z-index: 40;
}
.nav-brand { display: flex; align-items: center; gap: var(--s-3); padding: 0 var(--s-4); height: var(--topbar-h); border-bottom: 1px solid var(--c-nav-border); flex: none; }
.nav-brand a { display: flex; align-items: center; gap: var(--s-3); color: #fff; text-decoration: none; min-width: 0; }
.brand-mark { width: 34px; height: 34px; border-radius: var(--r); display: grid; place-items: center; flex: none;
    background: linear-gradient(180deg, #d9a92c, #b7861a); color: #1b1404; font-weight: 800; font-size: 13px; letter-spacing: .02em; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: .02em; color: #fff; }
.brand-sub { font-size: 11px; color: var(--c-nav-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-groups { flex: 1; overflow-y: auto; padding: var(--s-3) var(--s-3) var(--s-6); scrollbar-width: thin; scrollbar-color: #2b3e5c transparent; }
.nav-section { margin-top: var(--s-4); }
.nav-heading { margin: 0 0 var(--s-1); padding: 0 var(--s-3); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--c-nav-muted); }
.nav-link {
    display: flex; align-items: center; gap: var(--s-3);
    min-height: 36px; padding: 0 var(--s-3); margin: 1px 0;
    border-radius: var(--r-sm); color: var(--c-nav-text); font-size: var(--fs-base); font-weight: 500;
    text-decoration: none; position: relative; white-space: nowrap;
}
.nav-link .icon { color: var(--c-nav-muted); }
.nav-link:hover { background: var(--c-nav-raised); color: #fff; text-decoration: none; }
.nav-link:hover .icon { color: #dbe3ef; }
.nav-link.active { background: rgba(255, 255, 255, .09); color: var(--c-nav-active); font-weight: 600; }
.nav-link.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--c-brand); }
.nav-link.active .icon { color: #fff; }
.nav-link:focus-visible { outline-color: #8fb0ff; }
.nav-label { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.nav-count { margin-left: auto; min-width: 20px; padding: 0 6px; height: 18px; line-height: 18px; text-align: center; border-radius: var(--r-pill); background: #2a3d5c; color: #e2e8f2; font-size: 11px; font-weight: 600; }
.nav-ext { width: 13px; height: 13px; opacity: .6; }
.nav-foot { flex: none; padding: var(--s-3) var(--s-4); border-top: 1px solid var(--c-nav-border); font-size: 11px; color: var(--c-nav-muted); line-height: 1.4; }
.nav-foot strong { color: var(--c-nav-text); font-weight: 600; }

html.nav-collapsed .nav-rail .brand-text,
html.nav-collapsed .nav-rail .nav-label,
html.nav-collapsed .nav-rail .nav-count,
html.nav-collapsed .nav-rail .nav-ext,
html.nav-collapsed .nav-rail .nav-foot-text { display: none; }
html.nav-collapsed .nav-rail .nav-heading { font-size: 0; height: 1px; margin: var(--s-3) var(--s-2); background: var(--c-nav-border); padding: 0; }
html.nav-collapsed .nav-rail .nav-link { justify-content: center; padding: 0; }
html.nav-collapsed .nav-rail .nav-brand { justify-content: center; padding: 0; }
html.nav-collapsed .nav-rail .nav-groups { padding-left: var(--s-2); padding-right: var(--s-2); }
html.nav-collapsed .nav-rail .nav-link.active::before { left: -8px; }

.nav-scrim { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }

/* Top bar */
.topbar {
    position: sticky; top: 0; z-index: 30;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: var(--s-3);
    padding: 0 var(--s-6);
    background: rgba(255, 255, 255, .94);
    backdrop-filter: saturate(1.4) blur(8px);
    border-bottom: 1px solid var(--c-border);
}
.topbar-context { display: flex; align-items: center; gap: var(--s-2); min-width: 0; color: var(--c-text-3); font-size: var(--fs-sm); }
.topbar-context strong { color: var(--c-text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-section { white-space: nowrap; }
.topbar-sep { color: var(--c-text-4); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: var(--s-2); }

.global-search { position: relative; display: flex; align-items: center; }
.global-search .icon { position: absolute; left: 10px; color: var(--c-text-4); pointer-events: none; }
.global-search input[type="search"] {
    width: 300px; height: 36px; padding: 0 44px 0 36px;
    border-radius: var(--r); background: var(--c-surface-2); border: 1px solid var(--c-border);
}
.global-search input[type="search"]:focus { background: var(--c-surface); }
.global-search kbd { position: absolute; right: 10px; pointer-events: none; }

.icon-btn {
    position: relative; display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: var(--r); border: 1px solid transparent;
    background: transparent; color: var(--c-text-3); cursor: pointer; padding: 0;
}
.icon-btn:hover { background: var(--c-surface-3); color: var(--c-text); text-decoration: none; }
.icon-btn .dot-count {
    position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px;
    border-radius: var(--r-pill); background: var(--c-danger-solid); color: #fff; font-size: 10px; font-weight: 700; line-height: 17px; text-align: center;
    box-shadow: 0 0 0 2px #fff;
}
.nav-toggle { display: none; }

/* Profile / dropdown menu (details-based, no JS required) */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.profile-trigger { display: flex; align-items: center; gap: var(--s-2); padding: 3px var(--s-2) 3px 3px; border-radius: var(--r-pill); border: 1px solid var(--c-border); background: var(--c-surface); }
.profile-trigger:hover { border-color: var(--c-border-strong); }
.profile-trigger .icon { color: var(--c-text-4); width: 15px; height: 15px; }
.profile-name { font-size: var(--fs-sm); font-weight: 600; color: var(--c-text-2); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-panel {
    position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; z-index: 50;
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--sh-lg); padding: var(--s-2);
}
.menu-head { padding: var(--s-2) var(--s-3) var(--s-3); border-bottom: 1px solid var(--c-border); margin-bottom: var(--s-2); }
.menu-head strong { display: block; font-size: var(--fs-base); }
.menu-head span { font-size: var(--fs-xs); color: var(--c-text-4); }
.menu-item { display: flex; align-items: center; gap: var(--s-3); width: 100%; padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); color: var(--c-text-2); font-size: var(--fs-sm); background: none; border: 0; cursor: pointer; text-align: left; font-weight: 500; min-height: 34px; }
.menu-item:hover { background: var(--c-surface-3); color: var(--c-text); text-decoration: none; }
.menu-item .icon { color: var(--c-text-4); }
.menu-sep { height: 1px; background: var(--c-border); margin: var(--s-2) 0; }
.menu-item.danger-item { color: var(--c-danger); }
.menu-item.danger-item .icon { color: var(--c-danger); }

.avatar {
    width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
    background: var(--c-primary-soft); color: var(--c-primary); font-weight: 700; font-size: 11.5px; letter-spacing: .02em;
}
.avatar-lg { width: 52px; height: 52px; font-size: 18px; border-radius: var(--r-lg); }
.avatar-md { width: 36px; height: 36px; font-size: 13px; }

/* Content */
.content { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: var(--s-6) var(--s-8) var(--s-12); flex: 1; }

/* ---------- 4. Page header ---------- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-6); flex-wrap: wrap; }
.page-heading { min-width: 0; flex: 1 1 420px; }
.breadcrumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 0 0 var(--s-2); padding: 0; list-style: none; font-size: var(--fs-sm); color: var(--c-text-4); }
.breadcrumbs li { display: inline-flex; align-items: center; gap: 6px; }
.breadcrumbs li + li::before { content: "/"; color: var(--c-border-strong); }
.breadcrumbs a { color: var(--c-text-3); }
.breadcrumbs [aria-current] { color: var(--c-text-2); font-weight: 500; }
.title-row { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.page-subtitle { margin: var(--s-1) 0 0; color: var(--c-text-3); font-size: var(--fs-base); max-width: 80ch; }
.page-actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.page-actions form { margin: 0; }

/* ---------- 5. Alerts / feedback ---------- */
.alert {
    position: relative; display: block; margin: 0 0 var(--s-5); padding: var(--s-3) var(--s-4) var(--s-3) 44px;
    border-radius: var(--r); border: 1px solid var(--c-info-border); background: var(--c-info-bg); color: var(--c-info);
    font-size: var(--fs-base); font-weight: 500; line-height: 1.45;
}
.alert::before {
    content: ""; position: absolute; left: 14px; top: 13px; width: 18px; height: 18px; background: currentColor;
    -webkit-mask: var(--alert-icon) center / contain no-repeat; mask: var(--alert-icon) center / contain no-repeat;
    --alert-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-4M12 8h.01'/%3E%3C/svg%3E");
}
.alert-danger, .alert-error { border-color: var(--c-danger-border); background: var(--c-danger-bg); color: var(--c-danger); }
.alert-danger::before, .alert-error::before { --alert-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 8v4M12 16h.01'/%3E%3C/svg%3E"); }
.alert-warning { border-color: var(--c-warning-border); background: var(--c-warning-bg); color: var(--c-warning); }
.alert-warning::before { --alert-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3'/%3E%3Cpath d='M12 9v4M12 17h.01'/%3E%3C/svg%3E"); }
.alert-success { border-color: var(--c-success-border); background: var(--c-success-bg); color: var(--c-success); }
.alert-success::before { --alert-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M22 11.08V12a10 10 0 1 1-5.93-9.14'/%3E%3Cpath d='m9 11 3 3L22 4'/%3E%3C/svg%3E"); }
.alert-info { border-color: var(--c-info-border); background: var(--c-info-bg); color: var(--c-info); }
.alert ul { margin: var(--s-1) 0 0; }
.card .alert:last-child { margin-bottom: 0; }

/* Validation summary (Login / Reset) */
.error { color: var(--c-danger); font-weight: 500; }
p.error, div.error:not(:empty) { padding: var(--s-3) var(--s-4); border-radius: var(--r); background: var(--c-danger-bg); border: 1px solid var(--c-danger-border); margin: 0 0 var(--s-4); }
div.error.validation-summary-valid, div.error:empty { display: none; }
.error ul { margin: 0; padding-left: 1rem; }
.field-validation-error, .text-danger { color: var(--c-danger); font-size: var(--fs-sm); font-weight: 500; }
.input-validation-error { border-color: var(--c-danger-solid) !important; }

/* Callout (non-flash informational box) */
.callout { display: flex; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-radius: var(--r); border: 1px solid var(--c-border); background: var(--c-surface-2); color: var(--c-text-2); font-size: var(--fs-sm); margin-bottom: var(--s-4); }
.callout .icon { color: var(--c-text-4); margin-top: 1px; }
.callout.tone-warning { background: var(--c-warning-bg); border-color: var(--c-warning-border); color: var(--c-warning); }
.callout.tone-warning .icon { color: var(--c-warning); }
.callout.tone-danger { background: var(--c-danger-bg); border-color: var(--c-danger-border); color: var(--c-danger); }
.callout.tone-danger .icon { color: var(--c-danger); }
.callout.tone-info { background: var(--c-info-bg); border-color: var(--c-info-border); color: var(--c-info); }
.callout.tone-info .icon { color: var(--c-info); }
.callout.tone-success { background: var(--c-success-bg); border-color: var(--c-success-border); color: var(--c-success); }
.callout.tone-success .icon { color: var(--c-success); }

/* ---------- 6. Buttons ---------- */
button, .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
    height: 36px; padding: 0 var(--s-4);
    font: inherit; font-size: var(--fs-base); font-weight: 600; line-height: 1; white-space: nowrap;
    border-radius: var(--r); border: 1px solid var(--c-border-strong);
    background: var(--c-surface); color: var(--c-text-2);
    box-shadow: var(--sh-xs); cursor: pointer; text-decoration: none;
    transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease);
}
button:hover, .btn:hover { background: var(--c-surface-2); border-color: #b5bfcc; color: var(--c-text); text-decoration: none; }
button:active, .btn:active { background: var(--c-surface-3); }
button:focus-visible, .btn:focus-visible { outline: none; box-shadow: var(--focus); }
button:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
button .icon, .btn .icon { width: 16px; height: 16px; }

.primary, .btn-primary, button.primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.primary:hover, .btn-primary:hover, button.primary:hover { background: var(--c-primary-hover); border-color: var(--c-primary-hover); color: #fff; }
.primary:active, .btn-primary:active { background: var(--c-primary-active); }
.btn-danger, button.danger { background: var(--c-danger-solid); border-color: var(--c-danger-solid); color: #fff; }
.btn-danger:hover, button.danger:hover { background: #912018; border-color: #912018; color: #fff; }
.btn-danger-outline { color: var(--c-danger); border-color: var(--c-danger-border); background: var(--c-surface); }
.btn-danger-outline:hover { background: var(--c-danger-bg); color: var(--c-danger); border-color: #fda29b; }
.btn-success, button.success { background: var(--c-success-solid); border-color: var(--c-success-solid); color: #fff; }
.btn-success:hover, button.success:hover { background: #067647; border-color: #067647; color: #fff; }
.btn-ghost, .linkish { background: transparent; border-color: transparent; box-shadow: none; color: var(--c-text-3); }
.btn-ghost:hover, .linkish:hover { background: var(--c-surface-3); border-color: transparent; color: var(--c-text); }
.linkish { color: var(--c-primary); height: auto; padding: 2px 4px; font-weight: 500; }
.btn-sm, button.btn-sm { height: 30px; padding: 0 var(--s-3); font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-xs, button.btn-xs { height: 26px; padding: 0 var(--s-2); font-size: var(--fs-xs); border-radius: var(--r-sm); gap: 4px; }
.btn-lg { height: 42px; padding: 0 var(--s-5); font-size: var(--fs-md); }
.btn-block { width: 100%; }
.btn-icon { width: 36px; padding: 0; }
.btn-group { display: inline-flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }
.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.is-busy::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .5); border-top-color: #fff; animation: spin .7s linear infinite; }
button:not(.primary):not(.btn-danger):not(.danger).is-busy::after { border-color: rgba(16, 24, 40, .2); border-top-color: var(--c-text-2); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 7. Forms ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm); font-weight: 600; color: var(--c-text-2); min-width: 0; }
label.check, .check { flex-direction: row; align-items: center; gap: var(--s-2); font-weight: 500; color: var(--c-text-2); cursor: pointer; }
.req::after, label.required > .label-text::after { content: " *"; color: var(--c-danger); font-weight: 700; }
.label-text { display: inline-flex; gap: 4px; align-items: baseline; }
.hint, .field-hint { font-size: var(--fs-xs); font-weight: 400; color: var(--c-text-4); }

input:where(:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"])), select, textarea {
    width: 100%; min-height: 36px; padding: 7px var(--s-3);
    font: inherit; font-size: var(--fs-base); font-weight: 400; color: var(--c-text);
    background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: var(--r);
    box-shadow: var(--sh-xs); transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
select { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
select[multiple] { background-image: none; padding-right: var(--s-3); min-height: 96px; }
input::placeholder, textarea::placeholder { color: #8a94a6; }
input:hover:not(:disabled):not(:focus), select:hover:not(:disabled):not(:focus), textarea:hover:not(:disabled):not(:focus) { border-color: #aab4c3; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--c-primary); box-shadow: var(--focus); }
input:disabled, select:disabled, textarea:disabled, input[readonly] { background: var(--c-surface-3); color: var(--c-text-3); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--c-primary); margin: 0; flex: none; cursor: pointer; }
input[type="file"] { font-size: var(--fs-sm); color: var(--c-text-3); }
input[type="file"]::file-selector-button { font: inherit; font-weight: 600; margin-right: var(--s-3); padding: 6px 12px; border-radius: var(--r-sm); border: 1px solid var(--c-border-strong); background: var(--c-surface); color: var(--c-text-2); cursor: pointer; }
input[type="number"] { font-variant-numeric: tabular-nums; }
input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s-4); }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid .span-3 { grid-column: span 3; }
@media (max-width: 1100px) { .form-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .form-grid .span-3 { grid-column: 1 / -1; } }
.form-grid .span-all { grid-column: 1 / -1; }
.form-section { border: 0; padding: 0; margin: 0 0 var(--s-6); min-width: 0; }
.form-section > legend, .form-section-title { padding: 0; margin: 0 0 var(--s-3); font-size: var(--fs-sm); font-weight: 650; color: var(--c-text); display: flex; align-items: center; gap: var(--s-2); }
.form-section > legend .icon { color: var(--c-text-4); }
.form-stack { display: grid; gap: var(--s-4); }
.route { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.route .icon { color: var(--c-text-4); }
.inline-form.compact-form { flex-wrap: nowrap; gap: var(--s-2); justify-content: flex-end; }
.inline-form.compact-form input { width: 110px; height: 32px; }
.self-end { align-self: end; }
.approval-list { display: grid; gap: var(--s-3); margin-bottom: var(--s-5); }
.approval-card { display: flex; align-items: flex-start; gap: var(--s-4); padding: var(--s-4) var(--s-5); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--sh-xs); }
.approval-card.is-pending { border-left: 3px solid var(--c-warning-solid); }
.approval-main { flex: 1; min-width: 0; }
.approval-title { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.approval-reason { margin: var(--s-1) 0; color: var(--c-text-2); }
.approval-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--s-2); flex: none; max-width: 45%; }
@media (max-width: 767px) {
    .approval-card { flex-wrap: wrap; }
    .approval-actions { max-width: none; width: 100%; justify-content: flex-start; }
}
.deadline-group { margin-bottom: var(--s-5); }
.builder-dataset { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-3); }
.builder-dataset > label { flex: 0 1 320px; }
.builder-dataset .hint { flex: 1 1 200px; padding-bottom: 9px; }
.field-picker { border: 0; padding: 0; margin: 0; min-width: 0; }
.field-picker legend { display: flex; gap: var(--s-2); align-items: baseline; padding: 0; margin-bottom: var(--s-2); }
.check-chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.check-chip { display: inline-flex; flex-direction: row; align-items: center; width: auto; margin: 0; gap: 6px; min-height: 32px; padding: 4px 12px 4px 10px; border: 1px solid var(--c-border-strong); border-radius: var(--r-pill); background: var(--c-surface); color: var(--c-text-2); font-size: var(--fs-sm); font-weight: 500; cursor: pointer; user-select: none; }
.check-chip:hover { border-color: var(--c-primary-border); }
.check-chip input { margin: 0; width: 15px; height: 15px; accent-color: var(--c-primary); }
.check-chip:has(input:checked) { background: var(--c-primary-soft); border-color: var(--c-primary-border); color: var(--c-primary-active); }
.check-chip:has(input:focus-visible) { box-shadow: var(--focus); }
.check-chip .icon { color: var(--c-text-4); }
.matrix-cell { display: inline-block; min-width: 38px; padding: 2px 6px; border-radius: var(--r-xs); font-size: var(--fs-xs); font-weight: 600; text-align: center; }
.matrix-cell.full { background: var(--c-success-bg); color: var(--c-success); }
.matrix-cell.part { background: var(--c-info-bg); color: var(--c-info); }
.matrix-cell.none { color: var(--c-text-4); }
.rule-list > li { flex-wrap: wrap; }
.rule-list > li > .list-main { flex: 1 1 260px; min-width: 0; }
.rule-list > li > .list-main > * { white-space: normal; overflow: visible; text-overflow: clip; }
.rule-list code { overflow-wrap: anywhere; }
.rule-help { font-size: var(--fs-sm); color: var(--c-text-3); }
.setting-value { max-width: 420px; overflow-wrap: anywhere; }
.prose h2 { font-size: var(--fs-md); margin: var(--s-5) 0 var(--s-2); }
.prose h2:first-child { margin-top: 0; }
.prose p, .prose li { color: var(--c-text-2); line-height: 1.6; }
.notif-list > li.is-unread { background: var(--c-primary-soft); }
.notif-body { font-size: var(--fs-sm); color: var(--c-text-2); }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c-primary); flex: none; }
.due-chip { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-weight: 600; padding: 2px 8px; border-radius: var(--r-pill); background: var(--c-surface-3); color: var(--c-text-3); white-space: nowrap; }
.due-chip.tone-danger { background: var(--c-danger-bg); color: var(--c-danger); }
.due-chip.tone-warning { background: var(--c-warning-bg); color: var(--c-warning); }
.due-chip.tone-info { background: var(--c-info-bg); color: var(--c-info); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-top: 1px solid var(--c-border); font-size: var(--fs-sm); color: var(--c-text-3); }
.pager[hidden], [data-page-size] > [hidden] { display: none; }
.pager-btns { display: flex; gap: var(--s-2); }
.filter-bar { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); padding: var(--s-3); box-shadow: var(--sh-xs); margin-bottom: var(--s-4); }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--s-2); padding-top: var(--s-4); margin-top: var(--s-2); border-top: 1px solid var(--c-border); flex-wrap: wrap; }
.form-actions.start { justify-content: flex-start; }
.form-actions .spacer { flex: 1; }
.form-actions.sticky { position: sticky; bottom: 0; background: var(--c-surface); padding-bottom: var(--s-4); margin-bottom: calc(-1 * var(--s-5)); z-index: 2; }
.inline-form { display: flex; align-items: flex-end; gap: var(--s-3); flex-wrap: wrap; margin: 0; }
.inline-form > label { flex: 1 1 160px; }
.inline-form > label.narrow { flex: 0 1 130px; }
.inline-form > label.wide { flex: 2 1 260px; }
.inline-form > .check { flex: none; height: 36px; }
form.inline { display: inline-flex; margin: 0; }

/* Filter toolbar */
.toolbar { display: flex; align-items: flex-end; gap: var(--s-3); flex-wrap: wrap; margin: 0; }
.toolbar > label { flex: 1 1 170px; max-width: 320px; }
.toolbar > label.grow { max-width: none; flex: 3 1 260px; }
.toolbar .toolbar-end { margin-left: auto; display: flex; gap: var(--s-2); align-items: center; }
.search-field { position: relative; }
.search-field .icon { position: absolute; left: 10px; bottom: 9px; color: var(--c-text-4); pointer-events: none; }
.search-field input { padding-left: 34px !important; }

/* ---------- 8. Cards & layout ---------- */
.card {
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg);
    box-shadow: var(--sh-xs); padding: var(--s-5); margin-bottom: var(--s-5); min-width: 0;
}
.card > h2:first-child, .card > h3:first-child { margin-bottom: var(--s-4); }
.card h2 + p.muted { margin-top: calc(-1 * var(--s-3)); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin: calc(-1 * var(--s-5)) calc(-1 * var(--s-5)) var(--s-4); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--c-border); flex-wrap: wrap; }
.card-header > div:first-child { flex: 1 1 12rem; min-width: 0; }
.card-header h2 { font-size: var(--fs-md); display: flex; align-items: center; gap: var(--s-2); }
.card-header h2 .icon { color: var(--c-text-4); }
.card-header .card-sub { margin: 2px 0 0; font-size: var(--fs-sm); color: var(--c-text-4); font-weight: 400; }
.card-header-actions { display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; }
.card-footer { margin: var(--s-4) calc(-1 * var(--s-5)) calc(-1 * var(--s-5)); padding: var(--s-3) var(--s-5); border-top: 1px solid var(--c-border); background: var(--c-surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); font-size: var(--fs-sm); display: flex; gap: var(--s-3); align-items: center; justify-content: space-between; flex-wrap: wrap; }
.card-flush { padding: 0; }
.card-flush > .card-header { margin: 0; }
.card-flush > .table-wrap { border: 0; border-radius: 0 0 var(--r-lg) var(--r-lg); margin: 0; box-shadow: none; }
.card-flush > .empty-state { margin: 0; border: 0; }
.card-flush > .card-footer { margin: 0; }
.card-body { padding: var(--s-5); }
.card.tone-danger { border-color: var(--c-danger-border); }
.card.tone-danger > .card-header { background: var(--c-danger-bg); border-bottom-color: var(--c-danger-border); border-radius: var(--r-lg) var(--r-lg) 0 0; }
.card.tone-danger > .card-header h2 { color: var(--c-danger); }
.card.tone-warning { border-color: var(--c-warning-border); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-5); align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-5); align-items: start; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-4); }
.grid-2 > .card, .grid-3 > .card, .grid-4 > .card, .split > * > .card:last-child { margin-bottom: 0; }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: var(--s-5); align-items: start; }
.split-rev { display: grid; grid-template-columns: minmax(300px, 1fr) minmax(0, 2fr); gap: var(--s-5); align-items: start; }
.stack { display: grid; gap: var(--s-5); }
.stack > .card { margin-bottom: 0; }
.stack-sm { display: grid; gap: var(--s-3); }
.cluster { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }
.cluster.nowrap { flex-wrap: nowrap; white-space: normal; }
.cluster.nowrap > .avatar { flex: none; }
.section-gap { margin-top: var(--s-6); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin: var(--s-6) 0 var(--s-3); }
.section-title h2 { font-size: var(--fs-md); }
h2.section-title { justify-content: flex-start; gap: var(--s-2); font-size: var(--fs-md); }
h2.section-title > .icon { color: var(--c-text-4); }

/* ---------- 9. KPI / metrics ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--s-4); margin-bottom: var(--s-5); }
.kpi {
    position: relative; display: flex; flex-direction: column; gap: 6px;
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); padding: var(--s-4) var(--s-5);
    box-shadow: var(--sh-xs); min-width: 0; color: inherit; text-decoration: none;
}
a.kpi:hover { border-color: var(--c-primary-border); box-shadow: var(--sh-md); text-decoration: none; color: inherit; }
.kpi-label { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); font-size: var(--fs-sm); color: var(--c-text-3); font-weight: 500; }
.kpi-icon { width: 32px; height: 32px; border-radius: var(--r); display: grid; place-items: center; background: var(--c-primary-soft); color: var(--c-primary); flex: none; }
.kpi-icon .icon { width: 17px; height: 17px; }
.kpi-value { font-family: var(--font-display); font-size: var(--fs-2xl); font-weight: 650; line-height: 1.15; letter-spacing: -.02em; color: var(--c-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value small { font-size: var(--fs-sm); font-weight: 600; color: var(--c-text-4); letter-spacing: 0; margin-left: 4px; }
.kpi-value.small { font-size: var(--fs-lg); }
.kpi.tone-info .kpi-icon { background: var(--c-info-bg); color: var(--c-info); }
.bar-stack { display: flex; height: 26px; border-radius: var(--r); overflow: hidden; background: var(--c-surface-3); border: 1px solid var(--c-border); }
.bar-seg { display: flex; align-items: center; justify-content: center; font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; overflow: hidden; min-width: 0; }
.bar-seg.tone-neutral { background: var(--c-neutral-bg); color: var(--c-neutral); }
.bar-seg.tone-success { background: var(--c-success-solid); color: #fff; }
.bar-seg.tone-danger { background: var(--c-danger-solid); color: #fff; }
.bar-seg.tone-info { background: var(--c-info-solid); color: #fff; }
.bar-seg.tone-warning { background: var(--c-warning-solid); color: #fff; }
.kpi-meta { font-size: var(--fs-xs); color: var(--c-text-4); display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }
.kpi.tone-danger .kpi-icon { background: var(--c-danger-bg); color: var(--c-danger); }
.kpi.tone-warning .kpi-icon { background: var(--c-warning-bg); color: var(--c-warning); }
.kpi.tone-success .kpi-icon { background: var(--c-success-bg); color: var(--c-success); }
.kpi.tone-accent .kpi-icon { background: var(--c-accent-bg); color: var(--c-accent); }
.kpi.tone-brand .kpi-icon { background: var(--c-brand-soft); color: #8a6410; }
.kpi.tone-neutral .kpi-icon { background: var(--c-neutral-bg); color: var(--c-neutral); }
.kpi.compact { padding: var(--s-3) var(--s-4); }
.kpi.compact .kpi-value { font-size: var(--fs-xl); }
.trend-up { color: var(--c-success); font-weight: 600; }
.trend-down { color: var(--c-danger); font-weight: 600; }

/* Summary definition grid */
.summary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: var(--s-4) var(--s-5); margin: 0; }
.summary-grid > div { min-width: 0; }
.summary-grid dt { font-size: var(--fs-xs); font-weight: 600; color: var(--c-text-4); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.summary-grid dd { margin: 0; font-size: var(--fs-base); color: var(--c-text); font-weight: 500; overflow-wrap: anywhere; }
.summary-grid dd.big { font-size: var(--fs-lg); font-weight: 650; }
.kv { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: var(--s-2) var(--s-5); margin: 0; font-size: var(--fs-base); }
.kv dt { color: var(--c-text-4); font-weight: 500; }
.kv dd { margin: 0; color: var(--c-text); font-weight: 500; overflow-wrap: anywhere; }

/* Progress / bars */
.bar { height: 8px; border-radius: var(--r-pill); background: var(--c-surface-3); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: var(--c-primary); min-width: 2px; }
.bar.tone-success > span { background: var(--c-success-solid); }
.bar.tone-warning > span { background: var(--c-warning-solid); }
.bar.tone-danger > span { background: var(--c-danger-solid); }
.stage-bars { display: grid; gap: var(--s-3); margin: 0; padding: 0; list-style: none; }
.stage-bars li { display: grid; grid-template-columns: minmax(110px, 160px) 1fr auto; gap: var(--s-3); align-items: center; font-size: var(--fs-sm); }
.stage-bars .stage-name { color: var(--c-text-2); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-bars .stage-val { color: var(--c-text-3); white-space: nowrap; text-align: right; min-width: 120px; }
.stage-bars .stage-val strong { color: var(--c-text); }
.split > :last-child .stage-bars li { grid-template-columns: 1fr auto; row-gap: var(--s-1); }
.split > :last-child .stage-bars .bar { grid-column: 1 / -1; grid-row: 2; }
.split > :last-child .stage-bars .stage-val { min-width: 0; }

/* ---------- 10. Badges & status ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px;
    border-radius: var(--r-pill); border: 1px solid var(--c-neutral-border); background: var(--c-neutral-bg); color: var(--c-neutral);
    font-size: var(--fs-xs); font-weight: 600; line-height: 1; white-space: nowrap; vertical-align: middle;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; flex: none; }
.badge.plain::before, .badge.no-dot::before { display: none; }
.tone-success.badge { background: var(--c-success-bg); border-color: var(--c-success-border); color: var(--c-success); }
.tone-warning.badge { background: var(--c-warning-bg); border-color: var(--c-warning-border); color: var(--c-warning); }
.tone-danger.badge { background: var(--c-danger-bg); border-color: var(--c-danger-border); color: var(--c-danger); }
.tone-info.badge { background: var(--c-info-bg); border-color: var(--c-info-border); color: var(--c-info); }
.tone-accent.badge { background: var(--c-accent-bg); border-color: var(--c-accent-border); color: var(--c-accent); }
.tone-brand.badge { background: var(--c-brand-soft); border-color: #f1d99a; color: #7a5609; }
.badge-lg { height: 26px; padding: 0 10px; font-size: var(--fs-sm); }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: var(--r-xs); background: var(--c-surface-3); color: var(--c-text-2); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; }
.tag .icon { width: 13px; height: 13px; }
.vip { display: inline-flex; align-items: center; gap: 3px; height: 20px; padding: 0 7px; border-radius: var(--r-pill); background: var(--c-brand-soft); color: #7a5609; border: 1px solid #f1d99a; font-size: 11px; font-weight: 700; letter-spacing: .03em; }
.vip .icon { width: 12px; height: 12px; }
.count-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 20px; padding: 0 7px; border-radius: var(--r-pill); background: var(--c-surface-3); color: var(--c-text-3); font-size: 11.5px; font-weight: 600; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c-neutral-border); }
.status-dot.tone-success { background: var(--c-success-solid); } .status-dot.tone-warning { background: var(--c-warning-solid); }
.status-dot.tone-danger { background: var(--c-danger-solid); } .status-dot.tone-info { background: var(--c-info-solid); }

/* legacy chips */
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-bottom: var(--s-4); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: var(--r-pill); background: var(--c-surface); border: 1px solid var(--c-border); color: var(--c-text-2); font-size: var(--fs-sm); font-weight: 500; }
.chip strong { color: var(--c-text); }

/* ---------- 11. Tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--sh-xs); margin-bottom: var(--s-5); -webkit-overflow-scrolling: touch; }
.card .table-wrap { box-shadow: none; margin-bottom: 0; }
.card .table-wrap + * { margin-top: var(--s-4); }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-base); }
.table-wrap > table { min-width: 560px; }
.table-wrap.compact > table { min-width: 0; }
.table-wrap td:first-child > .cell-main { min-width: 170px; }
th, td { padding: 10px var(--s-4); text-align: left; vertical-align: middle; border-bottom: 1px solid var(--c-border); }
thead th {
    position: sticky; top: 0; z-index: 1;
    background: var(--c-surface-2); color: var(--c-text-3);
    font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
    padding-top: 9px; padding-bottom: 9px;
}
tbody tr:last-child > td { border-bottom: 0; }
tbody tr:hover > td { background: #f9fafc; }
tfoot td { background: var(--c-surface-2); font-weight: 650; border-top: 1px solid var(--c-border-strong); border-bottom: 0; }
td.num, th.num, .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.nowrap, th.nowrap { white-space: nowrap; }
td.actions, th.actions { text-align: right; white-space: nowrap; width: 1%; }
td.actions form { display: inline-flex; margin: 0 0 0 4px; }
td.actions .btn-group { justify-content: flex-end; flex-wrap: nowrap; }
.cell-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cell-main > a, .cell-main > strong { font-weight: 600; }
.cell-sub { font-size: var(--fs-xs); color: var(--c-text-4); }
.cell-person { display: flex; align-items: center; gap: var(--s-3); }
.row-unread > td { background: #f6f9ff; }
.row-unread > td:first-child { box-shadow: inset 3px 0 0 var(--c-primary); }
tr.row-danger > td { background: #fff8f7; }
tr.row-danger > td:first-child { box-shadow: inset 3px 0 0 var(--c-danger-solid); }
tr.row-warning > td:first-child { box-shadow: inset 3px 0 0 var(--c-warning-solid); }
tr.row-muted > td { color: var(--c-text-4); }
tr.row-success > td { background: var(--c-success-bg); }
tr.row-success > td:first-child { box-shadow: inset 3px 0 0 var(--c-success-solid); }
.list > li.is-replaced { opacity: .72; }
.list > li.is-replaced s { color: var(--c-text-3); }
.mono { font-family: var(--font-mono); font-size: var(--fs-sm); }
.data-table { margin-bottom: var(--s-5); }
table.sortable th[data-sort] { cursor: pointer; user-select: none; }
table.sortable th[data-sort]::after { content: "↕"; margin-left: 4px; opacity: .35; font-size: 10px; }
table.sortable th[aria-sort="ascending"]::after { content: "↑"; opacity: .9; }
table.sortable th[aria-sort="descending"]::after { content: "↓"; opacity: .9; }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--c-border); background: var(--c-surface); border-radius: var(--r-lg) var(--r-lg) 0 0; }
.table-count { font-size: var(--fs-sm); color: var(--c-text-4); }
.table-count strong { color: var(--c-text-2); }

/* ---------- 12. Tabs, segmented controls, link navs ---------- */
.tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--c-border); margin-bottom: var(--s-5); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
    position: relative; display: inline-flex; align-items: center; gap: var(--s-2); height: 42px; padding: 0 var(--s-3);
    border: 0; border-radius: 0; background: none; box-shadow: none; color: var(--c-text-3); font-weight: 600; font-size: var(--fs-base); white-space: nowrap;
}
.tab:hover { background: none; color: var(--c-text); }
.tab[aria-selected="true"], .tab.active { color: var(--c-primary); }
.tab[aria-selected="true"]::after, .tab.active::after { content: ""; position: absolute; left: var(--s-2); right: var(--s-2); bottom: -1px; height: 2px; border-radius: 2px 2px 0 0; background: var(--c-primary); }
.tab .count-pill { height: 18px; min-width: 20px; font-size: 11px; }
.tab[aria-selected="true"] .count-pill { background: var(--c-primary-soft); color: var(--c-primary); }
.tab:focus-visible { box-shadow: inset var(--focus); }
.tab-panel[hidden] { display: none; }
html.no-js .tab-panel[hidden] { display: block; }

.seg, .workspace-tabs, .report-nav { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: var(--r); background: var(--c-surface-3); border: 1px solid var(--c-border); margin-bottom: var(--s-5); }
.seg a, .workspace-tabs a, .report-nav a, .seg button {
    display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 var(--s-3); border-radius: var(--r-sm);
    color: var(--c-text-3); font-size: var(--fs-sm); font-weight: 600; text-decoration: none; border: 0; background: none; box-shadow: none; white-space: nowrap;
}
.seg a:hover, .workspace-tabs a:hover, .report-nav a:hover { color: var(--c-text); background: rgba(255, 255, 255, .6); text-decoration: none; }
.seg a.active, .workspace-tabs a.active, .report-nav a.active, .seg a[aria-current] { background: var(--c-surface); color: var(--c-text); box-shadow: var(--sh-sm); }

/* ---------- 13. Workflow stepper ---------- */
.stepper { display: flex; list-style: none; margin: 0 0 var(--s-5); padding: var(--s-4) var(--s-5); gap: 0; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--sh-xs); overflow-x: auto; }
.step { flex: 1 1 0; min-width: 92px; display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; text-align: center; font-size: var(--fs-xs); font-weight: 600; color: var(--c-text-4); }
.step::before { content: ""; position: absolute; top: 13px; left: calc(-50% + 18px); right: calc(50% + 18px); height: 2px; background: var(--c-border); }
.step:first-child::before { display: none; }
.step-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--c-surface); border: 2px solid var(--c-border-strong); color: var(--c-text-4); font-size: 12px; font-weight: 700; position: relative; z-index: 1; }
.step-dot .icon { width: 14px; height: 14px; stroke-width: 2.5; }
.step.done { color: var(--c-text-2); }
.step.done::before { background: var(--c-success-solid); }
.step.done .step-dot { background: var(--c-success-solid); border-color: var(--c-success-solid); color: #fff; }
.step.current { color: var(--c-primary); }
.step.current::before { background: var(--c-success-solid); }
.step.current .step-dot { background: var(--c-primary); border-color: var(--c-primary); color: #fff; box-shadow: 0 0 0 4px var(--c-primary-soft); }
.step.blocked .step-dot { background: var(--c-danger-solid); border-color: var(--c-danger-solid); color: #fff; }
.step.blocked { color: var(--c-danger); }
.step-sub { display: block; font-weight: 500; color: var(--c-text-4); font-size: 11px; }

/* ---------- 14. Record header (workspace pages) ---------- */
.record-head { display: flex; gap: var(--s-4); align-items: flex-start; }
.record-head .avatar-lg { margin-top: 2px; }
.record-meta { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); margin-top: var(--s-2); color: var(--c-text-3); font-size: var(--fs-sm); }
.record-meta span { display: inline-flex; align-items: center; gap: 6px; }
.record-meta .icon { width: 15px; height: 15px; color: var(--c-text-4); }

/* ---------- 15. Lists, timeline, activity ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) 0; border-bottom: 1px solid var(--c-border); min-width: 0; }
.list > li:first-child { padding-top: 0; }
.list > li:last-child { border-bottom: 0; padding-bottom: 0; }
.list > li.align-start { align-items: flex-start; }
.card-flush > .list > li { padding: var(--s-3) var(--s-5); }
.aging-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.list .list-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.list .list-main > a, .list .list-main > strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .list-sub { font-size: var(--fs-xs); color: var(--c-text-4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .list-end { margin-left: auto; display: flex; align-items: center; gap: var(--s-2); flex: none; text-align: right; }
.list-icon { width: 32px; height: 32px; border-radius: var(--r); display: grid; place-items: center; background: var(--c-surface-3); color: var(--c-text-3); flex: none; }
.list-icon .icon { width: 16px; height: 16px; }
.list-icon.tone-danger { background: var(--c-danger-bg); color: var(--c-danger); }
.list-icon.tone-warning { background: var(--c-warning-bg); color: var(--c-warning); }
.list-icon.tone-info { background: var(--c-info-bg); color: var(--c-info); }
.list-icon.tone-success { background: var(--c-success-bg); color: var(--c-success); }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 11px; top: 6px; bottom: 6px; width: 2px; background: var(--c-border); }
.timeline-item { position: relative; padding: 0 0 var(--s-4) 36px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before { content: ""; position: absolute; left: 5px; top: 5px; width: 14px; height: 14px; border-radius: 50%; background: var(--c-surface); border: 3px solid var(--c-primary); }
.timeline-item.tone-success::before { border-color: var(--c-success-solid); }
.timeline-item.tone-warning::before { border-color: var(--c-warning-solid); }
.timeline-item.tone-neutral::before { border-color: var(--c-border-strong); }
.timeline-item.tone-brand::before { border-color: var(--c-brand); background: var(--c-brand-soft); }
.timeline-item.tone-accent::before { border-color: var(--c-accent); }
.timeline-item.tone-info::before { border-color: var(--c-info-solid); }
.timeline-item.is-future { opacity: .78; }
.timeline-item.is-future::before { border-style: dashed; }
.timeline-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.timeline-head strong { font-weight: 600; }
.timeline-time { font-size: var(--fs-xs); color: var(--c-text-4); }
.timeline-body { margin-top: 4px; color: var(--c-text-2); font-size: var(--fs-sm); white-space: pre-wrap; overflow-wrap: anywhere; }
.timeline-item .muted { font-size: var(--fs-xs); }

/* ---------- 16. Pipeline board ---------- */
.pipeline { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: var(--s-4); overflow-x: auto; padding-bottom: var(--s-3); align-items: start; }
.pipe-col { background: var(--c-surface-3); border: 1px solid var(--c-border); border-radius: var(--r-lg); padding: var(--s-3); min-height: 240px; transition: background .15s, border-color .15s; }
.pipe-col.drag-over { background: var(--c-primary-soft); border-color: var(--c-primary-border); }
.pipe-col-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: 2px var(--s-1) var(--s-3); }
.pipe-col-head h2 { font-size: var(--fs-sm); font-weight: 650; display: flex; align-items: center; gap: var(--s-2); }
.pipe-col-total { font-size: var(--fs-xs); color: var(--c-text-4); font-weight: 600; }
.pipe-card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r); padding: var(--s-3); margin-bottom: var(--s-2); box-shadow: var(--sh-xs); cursor: grab; }
.pipe-card:hover { border-color: var(--c-border-strong); box-shadow: var(--sh-md); }
.pipe-card:active { cursor: grabbing; }
.pipe-card.dragging { opacity: .5; }
.pipe-card a { font-weight: 600; display: block; margin-bottom: 4px; overflow-wrap: anywhere; }
.pipe-card-meta { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); font-size: var(--fs-xs); color: var(--c-text-4); }
.pipe-card-meta strong { color: var(--c-text); font-size: var(--fs-sm); }

/* ---------- 17. Empty, loading & state pages ---------- */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; padding: var(--s-8) var(--s-5); color: var(--c-text-3); border: 1px dashed var(--c-border-strong); border-radius: var(--r-lg); background: var(--c-surface-2); }
.card .empty-state { border-color: var(--c-border); }
.empty-icon { width: 40px; height: 40px; padding: 9px; border-radius: 50%; background: var(--c-surface); color: var(--c-text-4); border: 1px solid var(--c-border); stroke-width: 1.6; margin-bottom: var(--s-1); }
.empty-title { margin: 0; font-weight: 600; color: var(--c-text-2); font-size: var(--fs-base); }
.empty-text { margin: 0; font-size: var(--fs-sm); max-width: 46ch; color: var(--c-text-4); }
.empty-state .btn, .empty-state button { margin-top: var(--s-3); }
.empty-state.sm { padding: var(--s-5) var(--s-4); }
.empty { color: var(--c-text-4); font-size: var(--fs-sm); }

.skeleton { display: block; border-radius: var(--r-sm); background: linear-gradient(90deg, var(--c-surface-3) 25%, #f7f8fa 37%, var(--c-surface-3) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; height: 12px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.state-page { max-width: 560px; margin: var(--s-12) auto; text-align: center; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-xl); padding: var(--s-10) var(--s-8); box-shadow: var(--sh-sm); }
.state-icon { width: 56px; height: 56px; border-radius: 50%; display: inline-grid; place-items: center; margin-bottom: var(--s-4); background: var(--c-danger-bg); color: var(--c-danger); }
.state-icon .icon { width: 26px; height: 26px; }
.state-icon.tone-warning { background: var(--c-warning-bg); color: var(--c-warning); }
.state-icon.tone-info { background: var(--c-info-bg); color: var(--c-info); }
.state-page h1 { margin-bottom: var(--s-2); }
.state-page p { color: var(--c-text-3); }
.state-page .btn-group { justify-content: center; margin-top: var(--s-5); }
.state-page .alert { text-align: left; }

/* ---------- 18. Drawers / modals (native <dialog>) ---------- */
dialog.drawer, dialog.modal { border: 0; padding: 0; background: var(--c-surface); color: var(--c-text); box-shadow: var(--sh-lg); }
dialog.drawer { margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(640px, 100vw); max-width: 100vw; border-radius: var(--r-xl) 0 0 var(--r-xl); }
dialog.modal { width: min(560px, calc(100vw - 32px)); border-radius: var(--r-xl); }
dialog::backdrop { background: rgba(13, 26, 45, .45); backdrop-filter: blur(2px); }
dialog[open].drawer { animation: drawer-in .22s var(--ease); }
@keyframes drawer-in { from { transform: translateX(32px); opacity: 0; } to { transform: none; opacity: 1; } }
.dialog-inner { display: flex; flex-direction: column; height: 100%; max-height: inherit; }
.dialog-inner > form { display: flex; flex-direction: column; min-height: 0; flex: 1; margin: 0; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); padding: var(--s-5) var(--s-6); border-bottom: 1px solid var(--c-border); flex: none; }
.dialog-head h2 { font-size: var(--fs-lg); }
.dialog-head p { margin: 2px 0 0; color: var(--c-text-4); font-size: var(--fs-sm); }
.dialog-body { padding: var(--s-6); overflow-y: auto; flex: 1; min-height: 0; }
.dialog-foot { display: flex; justify-content: flex-end; gap: var(--s-2); padding: var(--s-4) var(--s-6); border-top: 1px solid var(--c-border); background: var(--c-surface-2); flex: none; }
.dialog-foot .spacer { flex: 1; }

/* Collapsible panel (details) */
details.disclosure { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); margin-bottom: var(--s-5); box-shadow: var(--sh-xs); }
details.disclosure > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-5); font-weight: 600; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary .icon:last-child { margin-left: auto; color: var(--c-text-4); transition: transform .2s; }
details.disclosure[open] > summary { border-bottom: 1px solid var(--c-border); }
details.disclosure[open] > summary .icon:last-child { transform: rotate(180deg); }
details.disclosure > summary .summary-sub { font-weight: 400; color: var(--c-text-4); font-size: var(--fs-sm); }
details.disclosure > .disclosure-body { padding: var(--s-5); }
details.inline-disclosure > summary { list-style: none; cursor: pointer; display: inline-flex; }
details.inline-disclosure > summary::-webkit-details-marker { display: none; }
details.inline-disclosure[open] > summary { margin-bottom: var(--s-3); }
details.card > summary { cursor: pointer; font-weight: 600; }

/* ---------- 19. Quick actions & module cards ---------- */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--s-4); margin-bottom: var(--s-5); }
.quick-card {
    display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-4) var(--s-5);
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--sh-xs);
    color: var(--c-text); text-decoration: none; min-width: 0;
}
.quick-card:hover { border-color: var(--c-primary-border); box-shadow: var(--sh-md); text-decoration: none; color: var(--c-text); }
.quick-card .kpi-icon { margin-top: 1px; }
.quick-icon { flex: none; display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r); background: var(--c-primary-soft); color: var(--c-primary); }
.quick-card:hover .quick-icon { background: var(--c-primary); color: #fff; }
.cluster.between { justify-content: space-between; }
.mt-1 { margin-top: var(--s-1); }
.mb-3 { margin-bottom: var(--s-3); }
table.matrix th.num, table.matrix td.num { text-align: center; }
.quick-title { display: block; font-weight: 600; }
.quick-text { display: block; font-size: var(--fs-sm); color: var(--c-text-4); margin-top: 2px; }
.quick-count { margin-left: auto; }
.module-tile { display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-4); border: 1px solid var(--c-border); border-radius: var(--r-lg); background: var(--c-surface); text-decoration: none; color: var(--c-text); min-width: 0; }
.module-tile:hover { border-color: var(--c-primary-border); box-shadow: var(--sh-md); text-decoration: none; color: var(--c-text); }
.module-tile-head { display: flex; align-items: center; gap: var(--s-3); font-weight: 600; }
.module-tile-value { font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 650; }
.module-tile-value small { font-size: var(--fs-sm); color: var(--c-text-4); font-weight: 500; margin-left: 4px; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: var(--s-3); }

/* Option cards (TMC options, selectable) */
.option-list { display: grid; gap: var(--s-3); }
.option-card { display: grid; grid-template-columns: auto 1fr auto; gap: var(--s-3) var(--s-4); align-items: center; padding: var(--s-3) var(--s-4); border: 1px solid var(--c-border); border-radius: var(--r); background: var(--c-surface); cursor: pointer; font-weight: 400; color: var(--c-text); }
.option-card:hover { border-color: var(--c-border-strong); }
.option-card:has(input:checked) { border-color: var(--c-primary); background: var(--c-primary-soft); box-shadow: 0 0 0 1px var(--c-primary); }
.option-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.option-title { font-weight: 600; display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; }
.option-sub { font-size: var(--fs-xs); color: var(--c-text-4); }
.option-price { text-align: right; font-weight: 650; font-size: var(--fs-md); white-space: nowrap; }
.option-price small { display: block; font-size: var(--fs-xs); color: var(--c-text-4); font-weight: 500; }

/* Holiday components */
.component-row { border: 1px solid var(--c-border); border-radius: var(--r); padding: var(--s-3) var(--s-4); background: var(--c-surface); }
.component-row + .component-row { margin-top: var(--s-3); }
.component-top { display: flex; flex-wrap: wrap; gap: var(--s-3) var(--s-5); align-items: center; }
.component-top > * { flex: none; }
.component-name { display: flex; align-items: center; gap: var(--s-3); min-width: 0; flex: 1 1 200px; }
.component-name > strong + .cell-sub { display: block; }
.component-name:not(:has(.list-icon)) { flex-direction: column; align-items: flex-start; gap: 2px; }
.component-name strong { display: block; overflow-wrap: anywhere; }
.component-fig { text-align: right; font-size: var(--fs-sm); white-space: nowrap; }
.component-fig span { display: block; font-size: 11px; color: var(--c-text-4); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.swap-panel { margin-top: var(--s-3); padding: var(--s-3) var(--s-4); background: var(--c-surface-2); border-radius: var(--r); border: 1px dashed var(--c-border-strong); }
.swap-panel-title { font-size: var(--fs-sm); font-weight: 600; margin-bottom: var(--s-3); display: flex; gap: var(--s-2); align-items: center; color: var(--c-text-2); }

/* Profit figures */
.profit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s-3); }
.profit-cell { display: flex; flex-direction: column; gap: var(--s-1); padding: var(--s-4); border-radius: var(--r-lg); background: var(--c-surface); border: 1px solid var(--c-border); box-shadow: var(--sh-xs); }
.profit-cell.tone-info { border-top: 3px solid var(--c-info-solid); }
.profit-cell.tone-neutral { border-top: 3px solid var(--c-border-strong); }
.profit-cell.tone-success { background: var(--c-success-bg); border-color: var(--c-success-border); border-top: 3px solid var(--c-success-solid); }
.profit-cell.tone-success .kpi-value { color: var(--c-success); }
.profit-cell.tone-danger { background: var(--c-danger-bg); border-color: var(--c-danger-border); border-top: 3px solid var(--c-danger-solid); }
.profit-cell.tone-danger .kpi-value { color: var(--c-danger); }

/* Danger zone / confirmation */
.danger-zone { border: 1px solid var(--c-danger-border); border-radius: var(--r-lg); padding: var(--s-4) var(--s-5); background: var(--c-surface); }
.danger-zone h3 { color: var(--c-danger); display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-1); }
.danger-zone p { color: var(--c-text-3); font-size: var(--fs-sm); }
.confirm-box { border: 1px solid var(--c-warning-border); background: var(--c-warning-bg); border-radius: var(--r); padding: var(--s-3) var(--s-4); }

/* Insights (report alerts; NOT using alert* class names) */
.insight-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.insight-list li { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3); border-radius: var(--r); background: var(--c-surface-2); border: 1px solid var(--c-border); font-size: var(--fs-sm); }
.insight-kind { flex: none; }

/* ---------- 20. Utilities ---------- */
.muted { color: var(--c-text-4); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-strong, .strong { font-weight: 600; color: var(--c-text); }
.form-narrow { max-width: 560px; }
.card-footer > label.grow { flex: 1 1 240px; min-width: 0; }
.card-footer > label.grow select { width: 100%; }
.text-danger-strong { color: var(--c-danger); font-weight: 600; }
.text-success { color: var(--c-success); font-weight: 600; }
.text-warning { color: var(--c-warning); font-weight: 600; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.mt-0 { margin-top: 0 !important; } .mt-2 { margin-top: var(--s-2); } .mt-3 { margin-top: var(--s-3); } .mt-4 { margin-top: var(--s-4); } .mt-6 { margin-top: var(--s-6); }
.mb-0 { margin-bottom: 0 !important; } .mb-2 { margin-bottom: var(--s-2); } .mb-4 { margin-bottom: var(--s-4); }
.gap-2 { gap: var(--s-2); }
.flex { display: flex; align-items: center; gap: var(--s-2); }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.w-full { width: 100%; }
.inline { display: inline; }
.divider { height: 1px; background: var(--c-border); margin: var(--s-4) 0; }

/* ---------- 21. Authentication ---------- */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(380px, 1fr) minmax(0, 1.15fr); background: var(--c-surface); }
.auth-aside { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: var(--s-10); background: var(--c-nav); color: #dbe3ee; }
.auth-aside::after { content: ""; position: absolute; inset: auto -20% -35% auto; width: 520px; height: 520px; border-radius: 50%; border: 1px solid rgba(200, 150, 30, .25); box-shadow: 0 0 0 60px rgba(200, 150, 30, .04), 0 0 0 140px rgba(200, 150, 30, .03); pointer-events: none; }
.auth-brand { display: flex; align-items: center; gap: var(--s-3); }
.auth-brand .brand-name { font-size: 18px; }
.auth-pitch h2 { color: #fff; font-size: 30px; line-height: 1.2; font-weight: 650; max-width: 18ch; margin-bottom: var(--s-4); }
.auth-pitch p { color: #a9b6c9; max-width: 44ch; font-size: var(--fs-md); }
.auth-points { list-style: none; padding: 0; margin: var(--s-6) 0 0; display: grid; gap: var(--s-3); }
.auth-points li { display: flex; gap: var(--s-3); align-items: center; color: #c9d3e1; }
.auth-points .icon { color: var(--c-brand); }
.auth-foot { font-size: var(--fs-xs); color: var(--c-nav-muted); position: relative; z-index: 1; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: var(--s-10) var(--s-6); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: var(--fs-2xl); margin-bottom: var(--s-2); }
.auth-card .lead { color: var(--c-text-3); margin-bottom: var(--s-6); }
.auth-card form { display: grid; gap: var(--s-4); }
.auth-card .btn-lg { width: 100%; }
.auth-links { display: flex; justify-content: space-between; align-items: center; font-size: var(--fs-sm); }
.auth-secure { display: flex; gap: var(--s-2); align-items: center; margin-top: var(--s-6); padding-top: var(--s-4); border-top: 1px solid var(--c-border); font-size: var(--fs-xs); color: var(--c-text-4); }
.auth-secure .icon { width: 15px; height: 15px; }
.auth-mobile-brand { display: none; }

/* ---------- 22. Responsive ---------- */
@media (max-width: 1279px) {
    .content { padding: var(--s-5) var(--s-6) var(--s-10); }
    .global-search input[type="search"] { width: 220px; }
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .split { grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); }
}

@media (max-width: 1023px) {
    .app-shell, html.nav-collapsed .app-shell { grid-template-columns: minmax(0, 1fr); background: none; }
    .nav-rail {
        position: fixed; left: 0; top: 0; bottom: 0; width: min(300px, 86vw); height: 100%;
        transform: translateX(-102%); transition: transform .22s var(--ease); box-shadow: var(--sh-lg);
    }
    html.nav-collapsed .nav-rail .brand-text, html.nav-collapsed .nav-rail .nav-label, html.nav-collapsed .nav-rail .nav-count,
    html.nav-collapsed .nav-rail .nav-foot-text { display: revert; }
    html.nav-collapsed .nav-rail .nav-label { display: block; }
    html.nav-collapsed .nav-rail .nav-heading { font-size: 11px; height: auto; margin: 0 0 var(--s-1); background: none; padding: 0 var(--s-3); }
    html.nav-collapsed .nav-rail .nav-link { justify-content: flex-start; padding: 0 var(--s-3); }
    html.nav-collapsed .nav-rail .nav-brand { justify-content: flex-start; padding: 0 var(--s-4); }
    html.nav-open .nav-rail { transform: none; }
    html.nav-open .nav-scrim { display: block; position: fixed; inset: 0; background: rgba(13, 26, 45, .45); z-index: 35; }
    html.nav-open body { overflow: hidden; }
    .nav-toggle { display: inline-flex; }
    .nav-collapse-btn { display: none; }
    .topbar { padding: 0 var(--s-4); }
    .global-search kbd { display: none; }
    .split, .split-rev { grid-template-columns: minmax(0, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .profit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .auth-shell { grid-template-columns: minmax(0, 1fr); }
    .auth-aside { display: none; }
    .auth-mobile-brand { display: flex; margin-bottom: var(--s-8); }
    .auth-mobile-brand .brand-name { color: var(--c-text); }
}

@media (max-width: 767px) {
    :root { --topbar-h: 56px; }
    .content { padding: var(--s-4) var(--s-4) var(--s-10); }
    .topbar-context .topbar-section, .topbar-context .topbar-sep { display: none; }
    .hide-sm { display: none !important; }
    .global-search { width: 40px; height: 40px; }
    .global-search input[type="search"] { width: 40px; padding: 0; border-color: transparent; background: transparent; color: transparent; box-shadow: none; cursor: pointer; }
    .global-search input[type="search"]::placeholder { color: transparent; }
    .global-search .icon { left: 11px; color: var(--c-text-3); }
    .global-search input[type="search"]:focus { position: fixed; left: var(--s-3); right: var(--s-3); top: 10px; width: auto; height: 36px; padding: 0 var(--s-3) 0 36px; background: var(--c-surface); border-color: var(--c-primary); color: var(--c-text); z-index: 60; cursor: text; }
    .global-search input[type="search"]:focus::placeholder { color: #8a94a6; }
    .global-search:focus-within .icon { position: fixed; z-index: 61; left: calc(var(--s-3) + 10px); top: 20px; }
    .profile-name, .profile-trigger > .icon { display: none; }
    .profile-trigger { padding: 2px; border: 0; }
    .quick-create-label { display: none; }
    .page-header { flex-direction: column; gap: var(--s-3); margin-bottom: var(--s-5); }
    .page-heading { flex-basis: auto; }
    .page-actions { width: 100%; }
    .page-actions > .btn, .page-actions > button, .page-actions > form { flex: 1 1 auto; }
    .page-actions > form > button { width: 100%; }
    h1 { font-size: 1.25rem; }
    .grid-2, .grid-3, .grid-4, .form-grid.cols-2, .form-grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .form-grid .span-2, .form-grid .span-3 { grid-column: auto; }
    .form-grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
    .kpi { padding: var(--s-3) var(--s-4); }
    .kpi-value { font-size: var(--fs-xl); }
    .kpi-icon { width: 28px; height: 28px; }
    .card { padding: var(--s-4); border-radius: var(--r); }
    .card-header { margin: calc(-1 * var(--s-4)) calc(-1 * var(--s-4)) var(--s-4); padding: var(--s-3) var(--s-4); }
    .card-footer { margin: var(--s-4) calc(-1 * var(--s-4)) calc(-1 * var(--s-4)); padding: var(--s-3) var(--s-4); }
    .card-flush > .card-header, .card-flush > .card-footer { margin: 0; }
    .toolbar > label { max-width: none; flex: 1 1 100%; }
    .toolbar > button, .toolbar .toolbar-end { flex: 1 1 auto; margin-left: 0; }
    .inline-form > label, .inline-form > label.narrow, .inline-form > label.wide { flex: 1 1 100%; }
    .inline-form > button { flex: 1 1 auto; }
    th, td { padding: 9px var(--s-3); }
    .table-wrap > table { min-width: 520px; }
    .stepper { padding: var(--s-3); }
    .step { min-width: 74px; font-size: 11px; }
    .component-name { flex-basis: 100%; }
    .component-top > form, .component-top > .component-actions { flex-basis: 100%; }
    .component-fig { text-align: left; }
    .stage-bars li { grid-template-columns: 1fr auto; }
    .stage-bars .bar { grid-column: 1 / -1; grid-row: 2; }
    .stage-bars .stage-val { min-width: 0; }
    .option-card { grid-template-columns: auto 1fr; }
    .option-price { grid-column: 2; text-align: left; }
    .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
    .kv dd { margin-bottom: var(--s-2); }
    .record-head .avatar-lg { width: 44px; height: 44px; font-size: 15px; }
    dialog.drawer { border-radius: 0; width: 100vw; }
    .dialog-head, .dialog-body, .dialog-foot { padding-left: var(--s-4); padding-right: var(--s-4); }
    .seg, .workspace-tabs, .report-nav { display: flex; overflow-x: auto; flex-wrap: nowrap; max-width: 100%; }
    .state-page { margin: var(--s-6) auto; padding: var(--s-8) var(--s-5); }
    .pipeline { grid-auto-columns: minmax(240px, 82vw); }
    .auth-main { padding: var(--s-8) var(--s-5); align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
    .nav-rail, .topbar, .page-actions, .nav-scrim, .skip-link, nav.tabs, .breadcrumbs { display: none !important; }
    .app-shell { display: block; background: none !important; }
    .content { padding: 0; max-width: none; }
    .card, .table-wrap { box-shadow: none; break-inside: avoid; }
    body { background: #fff; }
}
