/* ==========================================================================
   Syria Pay Dashboard — design system
   White and blue. Built from scratch: no framework, no purchased template.
   Layers: tokens → reset → primitives → layout → components → utilities.
   ========================================================================== */

/* --------------------------------------------------------------- 1. tokens */

:root {
    /* Blue ramp — the single brand hue, from tint to ink. */
    --blue-50:  #EEF3FE;
    --blue-100: #DBE6FD;
    --blue-200: #B9CDFB;
    --blue-300: #8DACF7;
    --blue-400: #5985F0;
    --blue-500: #2F65E8;
    --blue-600: #1256E0;
    --blue-700: #0E44B4;
    --blue-800: #0C378F;
    --blue-900: #0A2B6E;

    /* Neutral ramp — cool greys so white surfaces read crisp, not yellow. */
    --grey-0:   #FFFFFF;
    --grey-25:  #FBFCFE;
    --grey-50:  #F6F8FC;
    --grey-100: #EDF1F7;
    --grey-200: #E1E7F0;
    --grey-300: #CBD4E1;
    --grey-400: #9AA7BC;
    --grey-500: #6B7A92;
    --grey-600: #4C5A70;
    --grey-700: #364154;
    --grey-800: #232C3D;
    --grey-900: #141A26;
    --grey-950: #0B0F17;

    /* Status hues. Green is the accent; the rest are functional only. */
    --green-50:  #E7F7F0;
    --green-500: #0EA36A;
    --green-600: #0B8A59;
    --green-700: #086B45;

    --amber-50:  #FEF5E7;
    --amber-500: #D98C0A;
    --amber-600: #B87308;

    --red-50:    #FDEDED;
    --red-500:   #D92D20;
    --red-600:   #B42318;

    --cyan-50:   #E6F6FA;
    --cyan-500:  #0B8FAD;

    --violet-50:  #F1EDFD;
    --violet-500: #6941C6;

    /* Semantic surfaces */
    --bg-canvas:      var(--grey-50);
    --bg-surface:     var(--grey-0);
    --bg-surface-alt: var(--grey-25);
    --bg-sunken:      var(--grey-100);
    --bg-inverse:     var(--grey-900);
    --bg-hover:       var(--grey-50);
    --bg-active:      var(--blue-50);
    --bg-glass:       rgba(255, 255, 255, 0.72);
    --bg-scrim:       rgba(11, 15, 23, 0.45);

    /* Semantic text */
    --text-primary:   var(--grey-900);
    --text-secondary: var(--grey-600);
    --text-muted:     var(--grey-500);
    --text-faint:     var(--grey-400);
    --text-inverse:   var(--grey-0);
    --text-brand:     var(--blue-600);
    --text-link:      var(--blue-700);

    /* Borders */
    --border:        var(--grey-200);
    --border-strong: var(--grey-300);
    --border-brand:  var(--blue-200);

    /* Brand aliases */
    --brand:         var(--blue-600);
    --brand-hover:   var(--blue-700);
    --brand-active:  var(--blue-800);
    --brand-soft:    var(--blue-50);
    --brand-contrast: #FFFFFF;

    --accent:        var(--green-500);
    --accent-soft:   var(--green-50);

    --success:       var(--green-600);
    --success-soft:  var(--green-50);
    --warning:       var(--amber-600);
    --warning-soft:  var(--amber-50);
    --danger:        var(--red-600);
    --danger-soft:   var(--red-50);
    --info:          var(--cyan-500);
    --info-soft:     var(--cyan-50);

    /* Focus — always visible, always 3:1 against both surfaces. */
    --focus-ring: 0 0 0 3px var(--blue-200), 0 0 0 1px var(--blue-600);

    /* Radii */
    --r-xs: 6px;
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 20px;
    --r-2xl: 28px;
    --r-full: 999px;

    /* Shadows — soft, wide, low opacity. Nothing harsh. */
    --shadow-xs: 0 1px 2px rgba(20, 26, 38, 0.05);
    --shadow-sm: 0 1px 3px rgba(20, 26, 38, 0.06), 0 1px 2px rgba(20, 26, 38, 0.04);
    --shadow-md: 0 4px 12px rgba(20, 26, 38, 0.07), 0 2px 4px rgba(20, 26, 38, 0.04);
    --shadow-lg: 0 12px 28px rgba(20, 26, 38, 0.09), 0 4px 10px rgba(20, 26, 38, 0.05);
    --shadow-xl: 0 24px 56px rgba(20, 26, 38, 0.14), 0 8px 20px rgba(20, 26, 38, 0.06);
    --shadow-brand: 0 6px 20px rgba(18, 86, 224, 0.22);
    --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.6);

    /* Spacing scale (4px base) */
    --s-1: 4px;
    --s-2: 8px;
    --s-3: 12px;
    --s-4: 16px;
    --s-5: 20px;
    --s-6: 24px;
    --s-7: 32px;
    --s-8: 40px;
    --s-9: 48px;
    --s-10: 64px;

    /* Typography */
    --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --font-arabic: "Noto Sans Arabic", "Segoe UI", "Dubai", "Tajawal", system-ui, Tahoma, sans-serif;
    --font-mono: "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;

    --fs-11: 0.6875rem;
    --fs-12: 0.75rem;
    --fs-13: 0.8125rem;
    --fs-14: 0.875rem;
    --fs-15: 0.9375rem;
    --fs-16: 1rem;
    --fs-18: 1.125rem;
    --fs-20: 1.25rem;
    --fs-24: 1.5rem;
    --fs-30: 1.875rem;
    --fs-36: 2.25rem;

    --lh-tight: 1.2;
    --lh-snug: 1.4;
    --lh-normal: 1.6;

    /* Layout */
    --sidebar-w: 268px;
    --sidebar-w-collapsed: 76px;
    --topbar-h: 64px;
    --content-max: 1600px;

    /* Motion */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --dur-fast: 120ms;
    --dur: 200ms;
    --dur-slow: 320ms;

    --z-sticky: 100;
    --z-sidebar: 200;
    --z-dropdown: 300;
    --z-modal: 400;
    --z-toast: 500;
}

/* Dark mode — same hues, re-anchored. Blue lifts so it stays legible on ink. */
[data-theme="dark"] {
    --bg-canvas:      var(--grey-950);
    --bg-surface:     #131A26;
    --bg-surface-alt: #182130;
    --bg-sunken:      #0F151F;
    --bg-inverse:     var(--grey-0);
    --bg-hover:       #1B2433;
    --bg-active:      rgba(47, 101, 232, 0.16);
    --bg-glass:       rgba(19, 26, 38, 0.72);
    --bg-scrim:       rgba(0, 0, 0, 0.62);

    --text-primary:   #E9EEF6;
    --text-secondary: #A8B4C7;
    --text-muted:     #8492A8;
    --text-faint:     #63718A;
    --text-inverse:   var(--grey-900);
    --text-brand:     var(--blue-300);
    --text-link:      var(--blue-300);

    --border:         #253044;
    --border-strong:  #33415A;
    --border-brand:   #2A4C8F;

    --brand:          var(--blue-500);
    --brand-hover:    var(--blue-400);
    --brand-active:   var(--blue-300);
    --brand-soft:     rgba(47, 101, 232, 0.14);
    --brand-contrast: #FFFFFF;

    --accent-soft:    rgba(14, 163, 106, 0.14);
    --success:        #34C88A;
    --success-soft:   rgba(14, 163, 106, 0.14);
    --warning:        #E9A63B;
    --warning-soft:   rgba(217, 140, 10, 0.14);
    --danger:         #F27168;
    --danger-soft:    rgba(217, 45, 32, 0.14);
    --info:           #3FB6D4;
    --info-soft:      rgba(11, 143, 173, 0.14);

    --focus-ring: 0 0 0 3px rgba(47, 101, 232, 0.35), 0 0 0 1px var(--blue-400);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 24px 56px rgba(0, 0, 0, 0.6);
    --shadow-brand: 0 6px 20px rgba(18, 86, 224, 0.35);
    --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* ---------------------------------------------------------------- 2. reset */

*, *::before, *::after { box-sizing: border-box; }

* { margin: 0; padding: 0; }

html {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    font-size: var(--fs-14);
    line-height: var(--lh-normal);
    color: var(--text-primary);
    background: var(--bg-canvas);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv02", "cv03", "cv04", "tnum";
    min-height: 100vh;
    overflow-wrap: break-word;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

/* Arabic gets its own stack and slightly taller lines. */
[dir="rtl"] body,
html[lang="ar"] body {
    font-family: var(--font-arabic);
    line-height: 1.75;
}

img, svg, video, canvas { display: block; max-width: 100%; }

button, input, select, textarea {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
}

button { cursor: pointer; }
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; }

a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }

ul, ol { list-style: none; }

table { border-collapse: collapse; width: 100%; }

h1, h2, h3, h4, h5, h6 { font-weight: 650; line-height: var(--lh-tight); letter-spacing: -0.011em; }

h1 { font-size: var(--fs-24); }
h2 { font-size: var(--fs-20); }
h3 { font-size: var(--fs-16); }
h4 { font-size: var(--fs-15); }

:focus { outline: none; }
:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--r-sm);
}

::selection { background: var(--blue-100); color: var(--blue-900); }
[data-theme="dark"] ::selection { background: var(--blue-700); color: #fff; }

/* Scrollbars, styled to match the surface rather than the OS. */
* { scrollbar-width: thin; scrollbar-color: var(--grey-300) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--grey-300);
    border-radius: var(--r-full);
    border: 3px solid transparent;
    background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--grey-400); background-clip: content-box; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--grey-700); background-clip: content-box; }

.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.ic-sm { width: 16px; height: 16px; }
.ic-lg { width: 24px; height: 24px; }

.sr-only {
    position: absolute; 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; inset-inline-start: var(--s-4); top: -100px;
    z-index: 999; padding: var(--s-3) var(--s-5);
    background: var(--brand); color: var(--brand-contrast);
    border-radius: var(--r-sm); box-shadow: var(--shadow-lg);
    transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: var(--s-4); text-decoration: none; }

/* ----------------------------------------------------------- 3. app layout */

.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    min-height: 100vh;
}
.app.is-collapsed { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }

/* ---- sidebar */

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border-inline-end: 1px solid var(--border);
    z-index: var(--z-sidebar);
    transition: width var(--dur) var(--ease);
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    height: var(--topbar-h);
    padding-inline: var(--s-5);
    border-bottom: 1px solid var(--border);
    flex: none;
}

.sidebar__logo {
    width: 34px; height: 34px; flex: none;
    display: grid; place-items: center;
    border-radius: var(--r-sm);
    background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
    color: #fff;
    font-weight: 700;
    font-size: var(--fs-14);
    letter-spacing: -0.02em;
    box-shadow: var(--shadow-brand);
}

.sidebar__title { display: flex; flex-direction: column; min-width: 0; }
.sidebar__name { font-weight: 650; font-size: var(--fs-15); letter-spacing: -0.01em; white-space: nowrap; }
.sidebar__edition { font-size: var(--fs-11); color: var(--text-muted); white-space: nowrap; }

.sidebar__scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--s-4) var(--s-3) var(--s-6);
}

.nav-group + .nav-group { margin-top: var(--s-5); }

.nav-group__label {
    padding: 0 var(--s-3) var(--s-2);
    font-size: var(--fs-11);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-2) var(--s-3);
    margin-bottom: 2px;
    border-radius: var(--r-sm);
    color: var(--text-secondary);
    font-size: var(--fs-14);
    font-weight: 500;
    white-space: nowrap;
    position: relative;
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }
.nav-item .ic { color: var(--text-muted); transition: color var(--dur-fast) var(--ease); }
.nav-item:hover .ic { color: var(--text-secondary); }

.nav-item.is-active {
    background: var(--bg-active);
    color: var(--text-brand);
    font-weight: 600;
}
.nav-item.is-active .ic { color: var(--brand); }
.nav-item.is-active::before {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    top: 50%;
    translate: 0 -50%;
    width: 3px;
    height: 18px;
    border-radius: var(--r-full);
    background: var(--brand);
}

.nav-item__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.nav-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    display: grid;
    place-items: center;
    border-radius: var(--r-full);
    background: var(--brand);
    color: var(--brand-contrast);
    font-size: var(--fs-11);
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}
.nav-badge--muted { background: var(--bg-sunken); color: var(--text-muted); }

.sidebar__footer {
    flex: none;
    padding: var(--s-3);
    border-top: 1px solid var(--border);
}

/* Collapsed rail keeps icons, drops labels. */
.app.is-collapsed .sidebar__title,
.app.is-collapsed .nav-group__label,
.app.is-collapsed .nav-item__label,
.app.is-collapsed .nav-badge,
.app.is-collapsed .sidebar__footer .user-chip__meta { display: none; }
.app.is-collapsed .sidebar__brand,
.app.is-collapsed .nav-item { justify-content: center; padding-inline: 0; }
.app.is-collapsed .nav-group + .nav-group { margin-top: var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--border); }

/* ---- topbar */

.topbar {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding-inline: var(--s-6);
    background: var(--bg-glass);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border);
}

.topbar__search {
    flex: 1;
    max-width: 460px;
    position: relative;
}
.topbar__search .ic {
    position: absolute;
    inset-inline-start: var(--s-3);
    top: 50%;
    translate: 0 -50%;
    color: var(--text-faint);
    pointer-events: none;
}
.topbar__search input {
    width: 100%;
    height: 38px;
    padding-inline: 40px var(--s-4);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--bg-surface);
    font-size: var(--fs-14);
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.topbar__search input::placeholder { color: var(--text-faint); }
.topbar__search input:focus { border-color: var(--brand); box-shadow: var(--focus-ring); }

.topbar__spacer { flex: 1; }
.topbar__actions { display: flex; align-items: center; gap: var(--s-2); }

.icon-btn {
    width: 38px; height: 38px;
    display: grid; place-items: center;
    border-radius: var(--r-sm);
    color: var(--text-secondary);
    position: relative;
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn.is-active { background: var(--bg-active); color: var(--brand); }

.icon-btn__dot {
    position: absolute;
    top: 7px;
    inset-inline-end: 7px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: var(--r-full);
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    border: 2px solid var(--bg-surface);
    font-variant-numeric: tabular-nums;
}

/* ---- main */

.main { display: flex; flex-direction: column; min-width: 0; }

.page {
    flex: 1;
    width: 100%;
    max-width: var(--content-max);
    margin-inline: auto;
    padding: var(--s-6) var(--s-6) var(--s-10);
}

.page__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--s-4);
    flex-wrap: wrap;
    margin-bottom: var(--s-6);
}
.page__title { font-size: var(--fs-24); letter-spacing: -0.02em; }
.page__subtitle { margin-top: var(--s-1); color: var(--text-muted); font-size: var(--fs-14); }
.page__actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }

.breadcrumb { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-13); color: var(--text-muted); margin-bottom: var(--s-2); }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text-brand); }
.breadcrumb__sep { color: var(--text-faint); }

.footer {
    padding: var(--s-5) var(--s-6);
    border-top: 1px solid var(--border);
    color: var(--text-faint);
    font-size: var(--fs-12);
    display: flex;
    justify-content: space-between;
    gap: var(--s-4);
    flex-wrap: wrap;
}

/* ------------------------------------------------------------ 4. primitives */

/* ---- buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    height: 38px;
    padding-inline: var(--s-4);
    border-radius: var(--r-sm);
    font-size: var(--fs-14);
    font-weight: 600;
    letter-spacing: -0.005em;
    white-space: nowrap;
    border: 1px solid transparent;
    transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
                color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), translate var(--dur-fast) var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:active { translate: 0 1px; }
.btn:disabled, .btn.is-loading { opacity: 0.6; pointer-events: none; }

.btn--primary { background: var(--brand); color: var(--brand-contrast); box-shadow: var(--shadow-brand); }
.btn--primary:hover { background: var(--brand-hover); }
.btn--primary:active { background: var(--brand-active); }

.btn--secondary { background: var(--bg-surface); color: var(--text-primary); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn--secondary:hover { background: var(--bg-hover); border-color: var(--grey-400); }

.btn--soft { background: var(--brand-soft); color: var(--text-brand); }
.btn--soft:hover { background: var(--blue-100); }
[data-theme="dark"] .btn--soft:hover { background: rgba(47, 101, 232, 0.24); }

.btn--ghost { color: var(--text-secondary); }
.btn--ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { filter: brightness(0.94); }

.btn--success { background: var(--success); color: #fff; }
.btn--success:hover { filter: brightness(0.94); }

.btn--sm { height: 32px; padding-inline: var(--s-3); font-size: var(--fs-13); }
.btn--lg { height: 46px; padding-inline: var(--s-6); font-size: var(--fs-15); border-radius: var(--r-md); }
.btn--block { width: 100%; }
.btn--icon { width: 38px; padding: 0; }
.btn--icon.btn--sm { width: 32px; }

.btn.is-loading { position: relative; color: transparent !important; }
.btn.is-loading::after {
    content: "";
    position: absolute;
    width: 16px; height: 16px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    color: var(--brand-contrast);
    animation: spin 640ms linear infinite;
}
.btn--secondary.is-loading::after, .btn--ghost.is-loading::after, .btn--soft.is-loading::after { color: var(--text-secondary); }

@keyframes spin { to { rotate: 360deg; } }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-start-start-radius: var(--r-sm); border-end-start-radius: var(--r-sm); }
.btn-group .btn:last-child { border-start-end-radius: var(--r-sm); border-end-end-radius: var(--r-sm); }
.btn-group .btn + .btn { margin-inline-start: -1px; }

/* ---- form controls */

.field { margin-bottom: var(--s-4); }
.field--inline { display: flex; align-items: center; gap: var(--s-3); }

.label {
    display: block;
    margin-bottom: var(--s-2);
    font-size: var(--fs-13);
    font-weight: 600;
    color: var(--text-secondary);
}
.label__req { color: var(--danger); margin-inline-start: 2px; }

.input, .select, .textarea {
    width: 100%;
    min-height: 40px;
    padding: var(--s-2) var(--s-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: var(--fs-14);
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--grey-400); }
.input:focus, .select:focus, .textarea:focus {
    border-color: var(--brand);
    box-shadow: var(--focus-ring);
}
.input:disabled, .select:disabled, .textarea:disabled { background: var(--bg-sunken); color: var(--text-muted); }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--danger); }

.textarea { min-height: 96px; resize: vertical; line-height: var(--lh-normal); }

.select {
    appearance: none;
    padding-inline-end: var(--s-8);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%236B7A92' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: 18px;
    background-position: right var(--s-3) center;
}
[dir="rtl"] .select { background-position: left var(--s-3) center; }

.input-group { position: relative; display: flex; align-items: center; }
.input-group .ic { position: absolute; inset-inline-start: var(--s-3); color: var(--text-faint); pointer-events: none; }
.input-group .input { padding-inline-start: 40px; }
.input-group__suffix {
    position: absolute;
    inset-inline-end: var(--s-3);
    font-size: var(--fs-13);
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.hint { margin-top: var(--s-2); font-size: var(--fs-12); color: var(--text-muted); }
.error-text { margin-top: var(--s-2); font-size: var(--fs-12); color: var(--danger); font-weight: 500; }

/* checkbox and radio */
.check {
    display: inline-flex;
    align-items: flex-start;
    gap: var(--s-2);
    cursor: pointer;
    font-size: var(--fs-14);
}
.check input[type="checkbox"], .check input[type="radio"] {
    appearance: none;
    width: 18px; height: 18px;
    flex: none;
    margin-top: 2px;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--r-xs);
    background: var(--bg-surface);
    transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.check input[type="radio"] { border-radius: 50%; }
.check input:checked {
    background: var(--brand);
    border-color: var(--brand);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8.5l3.2 3.2L13 5'/%3E%3C/svg%3E");
    background-size: 14px;
    background-position: center;
    background-repeat: no-repeat;
}
.check input[type="radio"]:checked { background-image: none; box-shadow: inset 0 0 0 4px var(--bg-surface); }
.check input:focus-visible { box-shadow: var(--focus-ring); }

/* switch */
.switch { display: inline-flex; align-items: center; gap: var(--s-3); cursor: pointer; }
.switch input { appearance: none; width: 42px; height: 24px; border-radius: var(--r-full); background: var(--grey-300); position: relative; transition: background var(--dur) var(--ease); flex: none; }
.switch input::after {
    content: "";
    position: absolute;
    top: 3px; inset-inline-start: 3px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: var(--shadow-sm);
    transition: translate var(--dur) var(--ease);
}
.switch input:checked { background: var(--brand); }
.switch input:checked::after { translate: 18px 0; }
[dir="rtl"] .switch input:checked::after { translate: -18px 0; }
.switch input:focus-visible { box-shadow: var(--focus-ring); }

/* segmented control */
.segment {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    background: var(--bg-sunken);
    border-radius: var(--r-sm);
}
.segment button {
    padding: var(--s-1) var(--s-3);
    border-radius: var(--r-xs);
    font-size: var(--fs-13);
    font-weight: 600;
    color: var(--text-muted);
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.segment button:hover { color: var(--text-primary); }
.segment button.is-active { background: var(--bg-surface); color: var(--text-brand); box-shadow: var(--shadow-xs); }

/* ------------------------------------------------------------ 5. components */

/* ---- card */

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card--flush { overflow: visible; }
.card--glass {
    background: var(--bg-glass);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
}

.card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    padding: var(--s-4) var(--s-5);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.card__title { font-size: var(--fs-15); font-weight: 650; }
.card__subtitle { font-size: var(--fs-12); color: var(--text-muted); margin-top: 2px; }
.card__body { padding: var(--s-5); }
.card__body--tight { padding: var(--s-4); }
.card__body--flush { padding: 0; }
.card__foot {
    padding: var(--s-3) var(--s-5);
    border-top: 1px solid var(--border);
    background: var(--bg-surface-alt);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    flex-wrap: wrap;
}

/* ---- stat tile */

.stats { display: grid; gap: var(--s-4); }
.stats--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stats--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.stat {
    position: relative;
    padding: var(--s-5);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow var(--dur) var(--ease), translate var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.stat:hover { box-shadow: var(--shadow-md); translate: 0 -2px; border-color: var(--border-brand); }

/* A whisper of brand colour along the top edge, not a whole coloured card. */
.stat::before {
    content: "";
    position: absolute;
    inset-inline: 0;
    top: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--blue-400), var(--blue-600));
    opacity: 0;
    transition: opacity var(--dur) var(--ease);
}
.stat:hover::before { opacity: 1; }

.stat__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-3); }
.stat__label { font-size: var(--fs-13); color: var(--text-muted); font-weight: 500; }
.stat__icon {
    width: 36px; height: 36px;
    display: grid; place-items: center;
    border-radius: var(--r-sm);
    background: var(--brand-soft);
    color: var(--brand);
    flex: none;
}
.stat__icon--success { background: var(--success-soft); color: var(--success); }
.stat__icon--warning { background: var(--warning-soft); color: var(--warning); }
.stat__icon--danger  { background: var(--danger-soft);  color: var(--danger); }
.stat__icon--info    { background: var(--info-soft);    color: var(--info); }

.stat__value {
    font-size: var(--fs-30);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.stat__value small { font-size: var(--fs-14); font-weight: 600; color: var(--text-muted); margin-inline-start: var(--s-1); }

.stat__foot { display: flex; align-items: center; gap: var(--s-2); margin-top: var(--s-3); font-size: var(--fs-12); color: var(--text-muted); }

.trend { display: inline-flex; align-items: center; gap: 3px; font-weight: 650; font-variant-numeric: tabular-nums; }
.trend--up { color: var(--success); }
.trend--down { color: var(--danger); }
.trend--flat { color: var(--text-muted); }
.trend .ic { width: 14px; height: 14px; }

.stat__spark { margin-top: var(--s-3); height: 40px; }

/* ---- badges and pills */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: var(--r-full);
    font-size: var(--fs-12);
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge--plain::before { display: none; }

.badge--ok    { background: var(--success-soft); color: var(--success); }
.badge--warn  { background: var(--warning-soft); color: var(--warning); }
.badge--bad   { background: var(--danger-soft);  color: var(--danger); }
.badge--info  { background: var(--info-soft);    color: var(--info); }
.badge--brand { background: var(--brand-soft);   color: var(--text-brand); }
.badge--muted { background: var(--bg-sunken);    color: var(--text-muted); }

.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    height: 28px;
    padding-inline: var(--s-3);
    border-radius: var(--r-full);
    background: var(--bg-sunken);
    font-size: var(--fs-12);
    font-weight: 550;
    color: var(--text-secondary);
}
.chip button { display: grid; place-items: center; color: var(--text-faint); }
.chip button:hover { color: var(--danger); }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot--ok { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.dot--warn { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }
.dot--bad { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.dot--live { background: var(--success); animation: pulse 2s var(--ease) infinite; }

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(14, 163, 106, 0.5); }
    50% { box-shadow: 0 0 0 6px rgba(14, 163, 106, 0); }
}

/* ---- avatar */

.avatar {
    width: 36px; height: 36px;
    border-radius: var(--r-full);
    display: grid; place-items: center;
    background: var(--brand-soft);
    color: var(--text-brand);
    font-weight: 650;
    font-size: var(--fs-13);
    flex: none;
    overflow: hidden;
    text-transform: uppercase;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--sm { width: 28px; height: 28px; font-size: var(--fs-11); }
.avatar--lg { width: 56px; height: 56px; font-size: var(--fs-18); }
.avatar--xl { width: 80px; height: 80px; font-size: var(--fs-24); }

.user-chip { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2); border-radius: var(--r-sm); width: 100%; transition: background var(--dur-fast) var(--ease); }
.user-chip:hover { background: var(--bg-hover); }
.user-chip__meta { min-width: 0; text-align: start; }
.user-chip__name { font-size: var(--fs-14); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip__role { font-size: var(--fs-12); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- table */

.table-wrap { overflow-x: auto; }

.table { width: 100%; font-size: var(--fs-14); }
.table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: var(--s-3) var(--s-4);
    text-align: start;
    font-size: var(--fs-12);
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background: var(--bg-surface-alt);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table tbody td {
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tbody tr { transition: background var(--dur-fast) var(--ease); }
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr.is-selected { background: var(--bg-active); }

.table th.is-sortable { cursor: pointer; user-select: none; }
.table th.is-sortable:hover { color: var(--text-primary); }
.table th .sort-ind { display: inline-block; margin-inline-start: 4px; opacity: 0.4; }
.table th.is-sorted .sort-ind { opacity: 1; color: var(--brand); }

.table .num { text-align: end; font-variant-numeric: tabular-nums; }
.table .mono { font-family: var(--font-mono); font-size: var(--fs-13); letter-spacing: -0.02em; }
.table .nowrap { white-space: nowrap; }
.table .actions { text-align: end; white-space: nowrap; }

.table--compact tbody td, .table--compact thead th { padding: var(--s-2) var(--s-3); }

.cell-primary { font-weight: 600; }
.cell-sub { font-size: var(--fs-12); color: var(--text-muted); }
.cell-stack { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cell-user { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }

/* ---- toolbar and filters */

.toolbar {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-3) var(--s-4);
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
}
.toolbar__search { flex: 1; min-width: 220px; max-width: 360px; }
.toolbar__spacer { flex: 1; }

.filter-bar { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }
.filter-bar .select, .filter-bar .input { min-height: 34px; height: 34px; font-size: var(--fs-13); width: auto; min-width: 130px; }

/* ---- pagination */

.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-4);
    padding: var(--s-3) var(--s-4);
    flex-wrap: wrap;
    font-size: var(--fs-13);
    color: var(--text-muted);
}
.pager__pages { display: flex; align-items: center; gap: 2px; }
.pager__btn {
    min-width: 32px; height: 32px;
    padding-inline: var(--s-2);
    display: grid; place-items: center;
    border-radius: var(--r-xs);
    font-size: var(--fs-13);
    font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.pager__btn:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }
.pager__btn.is-active { background: var(--brand); color: var(--brand-contrast); }
.pager__btn:disabled { opacity: 0.4; pointer-events: none; }
[dir="rtl"] .pager__btn .ic { scale: -1 1; }

/* ---- dropdown */

.dropdown { position: relative; }
.dropdown__menu {
    position: absolute;
    top: calc(100% + 6px);
    inset-inline-end: 0;
    min-width: 210px;
    padding: var(--s-2);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-dropdown);
    opacity: 0;
    visibility: hidden;
    translate: 0 -6px;
    transition: opacity var(--dur-fast) var(--ease), translate var(--dur-fast) var(--ease), visibility var(--dur-fast);
}
.dropdown.is-open .dropdown__menu { opacity: 1; visibility: visible; translate: 0 0; }
.dropdown__menu--start { inset-inline-end: auto; inset-inline-start: 0; }
.dropdown__menu--wide { min-width: 340px; }

.dropdown__item {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    width: 100%;
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r-xs);
    font-size: var(--fs-14);
    color: var(--text-secondary);
    text-align: start;
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.dropdown__item:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }
.dropdown__item.is-danger { color: var(--danger); }
.dropdown__item.is-danger:hover { background: var(--danger-soft); }
.dropdown__item .ic { color: var(--text-faint); }
.dropdown__item:hover .ic { color: inherit; }

.dropdown__sep { height: 1px; background: var(--border); margin: var(--s-2) 0; }
.dropdown__label { padding: var(--s-2) var(--s-3); font-size: var(--fs-11); font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); }

/* ---- modal and drawer */

.overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-scrim);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: var(--z-modal);
    display: grid;
    place-items: center;
    padding: var(--s-4);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--dur) var(--ease), visibility var(--dur);
}
.overlay.is-open { opacity: 1; visibility: visible; }

.modal {
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - var(--s-8));
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-xl);
    scale: 0.96;
    translate: 0 8px;
    transition: scale var(--dur) var(--ease-out), translate var(--dur) var(--ease-out);
}
.overlay.is-open .modal { scale: 1; translate: 0 0; }
.modal--lg { max-width: 820px; }
.modal--xl { max-width: 1100px; }

.modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-4);
    padding: var(--s-5);
    border-bottom: 1px solid var(--border);
    flex: none;
}
.modal__title { font-size: var(--fs-18); font-weight: 650; }
.modal__body { padding: var(--s-5); overflow-y: auto; flex: 1; }
.modal__foot {
    display: flex;
    justify-content: flex-end;
    gap: var(--s-2);
    padding: var(--s-4) var(--s-5);
    border-top: 1px solid var(--border);
    background: var(--bg-surface-alt);
    flex: none;
}

/* Side drawer, used for record detail. */
.drawer {
    position: fixed;
    inset-block: 0;
    inset-inline-end: 0;
    width: min(680px, 100%);
    background: var(--bg-surface);
    box-shadow: var(--shadow-xl);
    z-index: var(--z-modal);
    display: flex;
    flex-direction: column;
    translate: 100% 0;
    transition: translate var(--dur-slow) var(--ease-out);
}
[dir="rtl"] .drawer { translate: -100% 0; }
.drawer.is-open { translate: 0 0; }
.drawer__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); padding: var(--s-5); border-bottom: 1px solid var(--border); flex: none; }
.drawer__body { padding: var(--s-5); overflow-y: auto; flex: 1; }
.drawer__foot { padding: var(--s-4) var(--s-5); border-top: 1px solid var(--border); background: var(--bg-surface-alt); display: flex; gap: var(--s-2); justify-content: flex-end; flex: none; }

/* ---- tabs */

.tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
    padding: var(--s-3) var(--s-4);
    font-size: var(--fs-14);
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.tab:hover { color: var(--text-primary); text-decoration: none; }
.tab.is-active { color: var(--text-brand); border-bottom-color: var(--brand); }
.tab__count { margin-inline-start: var(--s-2); padding: 1px 6px; border-radius: var(--r-full); background: var(--bg-sunken); font-size: var(--fs-11); }

.tab-panel { display: none; padding-top: var(--s-5); }
.tab-panel.is-active { display: block; animation: fade-in var(--dur) var(--ease); }

@keyframes fade-in { from { opacity: 0; translate: 0 4px; } to { opacity: 1; translate: 0 0; } }

/* ---- alerts */

.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--s-3);
    padding: var(--s-4);
    border-radius: var(--r-md);
    font-size: var(--fs-14);
    border: 1px solid transparent;
}
.alert__body { flex: 1; min-width: 0; }
.alert__title { font-weight: 650; margin-bottom: 2px; }
.alert--info    { background: var(--info-soft);    color: var(--text-primary); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.alert--success { background: var(--success-soft); color: var(--text-primary); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.alert--warning { background: var(--warning-soft); color: var(--text-primary); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.alert--danger  { background: var(--danger-soft);  color: var(--text-primary); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert--info .ic    { color: var(--info); }
.alert--success .ic { color: var(--success); }
.alert--warning .ic { color: var(--warning); }
.alert--danger .ic  { color: var(--danger); }

/* ---- toasts */

.toasts {
    position: fixed;
    bottom: var(--s-5);
    inset-inline-end: var(--s-5);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    width: min(380px, calc(100vw - var(--s-8)));
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--s-3);
    padding: var(--s-4);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: toast-in var(--dur-slow) var(--ease-out);
}
.toast.is-leaving { animation: toast-out var(--dur) var(--ease) forwards; }
.toast__icon { width: 20px; height: 20px; flex: none; }
.toast--success .toast__icon { color: var(--success); }
.toast--error .toast__icon { color: var(--danger); }
.toast--warning .toast__icon { color: var(--warning); }
.toast--info .toast__icon { color: var(--info); }
.toast__body { flex: 1; font-size: var(--fs-14); min-width: 0; }
.toast__close { color: var(--text-faint); }
.toast__close:hover { color: var(--text-primary); }

@keyframes toast-in { from { opacity: 0; translate: 0 12px; scale: 0.98; } to { opacity: 1; translate: 0 0; scale: 1; } }
@keyframes toast-out { to { opacity: 0; translate: 0 8px; } }

/* ---- progress and meters */

.progress { height: 8px; border-radius: var(--r-full); background: var(--bg-sunken); overflow: hidden; }
.progress__bar { height: 100%; border-radius: var(--r-full); background: linear-gradient(90deg, var(--blue-400), var(--blue-600)); transition: width var(--dur-slow) var(--ease-out); }
.progress__bar--success { background: linear-gradient(90deg, var(--green-500), var(--green-700)); }
.progress__bar--warning { background: linear-gradient(90deg, var(--amber-500), var(--amber-600)); }
.progress__bar--danger  { background: linear-gradient(90deg, var(--red-500), var(--red-600)); }

.meter { display: flex; align-items: center; gap: var(--s-3); }
.meter__track { flex: 1; }
.meter__value { font-size: var(--fs-13); font-weight: 650; font-variant-numeric: tabular-nums; min-width: 42px; text-align: end; }

.gauge { position: relative; display: grid; place-items: center; }
.gauge__value { position: absolute; text-align: center; }
.gauge__number { font-size: var(--fs-30); font-weight: 700; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.gauge__caption { font-size: var(--fs-12); color: var(--text-muted); margin-top: 2px; }

/* ---- timeline */

.timeline { position: relative; padding-inline-start: var(--s-6); }
.timeline::before {
    content: "";
    position: absolute;
    inset-inline-start: 7px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: var(--border);
}
.timeline__item { position: relative; padding-bottom: var(--s-5); }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__dot {
    position: absolute;
    inset-inline-start: calc(var(--s-6) * -1);
    top: 4px;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--bg-surface);
    border: 3px solid var(--border-strong);
}
.timeline__item--ok .timeline__dot { border-color: var(--success); }
.timeline__item--bad .timeline__dot { border-color: var(--danger); }
.timeline__item--warn .timeline__dot { border-color: var(--warning); }
.timeline__item--brand .timeline__dot { border-color: var(--brand); }
.timeline__title { font-size: var(--fs-14); font-weight: 600; }
.timeline__meta { font-size: var(--fs-12); color: var(--text-muted); margin-top: 2px; }

/* ---- description list */

.dl { display: grid; grid-template-columns: minmax(120px, 200px) 1fr; gap: var(--s-3) var(--s-4); font-size: var(--fs-14); }
.dl dt { color: var(--text-muted); font-weight: 500; }
.dl dd { font-weight: 550; min-width: 0; overflow-wrap: anywhere; }
.dl--stacked { grid-template-columns: 1fr; gap: var(--s-1); }
.dl--stacked dt { font-size: var(--fs-12); }

/* ---- empty state */

.empty {
    padding: var(--s-9) var(--s-5);
    text-align: center;
    color: var(--text-muted);
}
.empty__icon {
    width: 56px; height: 56px;
    margin: 0 auto var(--s-4);
    display: grid; place-items: center;
    border-radius: var(--r-lg);
    background: var(--bg-sunken);
    color: var(--text-faint);
}
.empty__icon .ic { width: 26px; height: 26px; }
.empty__title { font-size: var(--fs-15); font-weight: 650; color: var(--text-primary); margin-bottom: var(--s-1); }
.empty__text { font-size: var(--fs-13); max-width: 42ch; margin-inline: auto; }
.empty__action { margin-top: var(--s-5); }

/* ---- skeleton */

.skeleton {
    background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--bg-hover) 37%, var(--bg-sunken) 63%);
    background-size: 400% 100%;
    border-radius: var(--r-xs);
    animation: shimmer 1.4s var(--ease) infinite;
}
@keyframes shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }
.skeleton--text { height: 12px; margin-bottom: var(--s-2); }
.skeleton--title { height: 20px; width: 40%; }
.skeleton--block { height: 120px; }

/* ---- code */

.code {
    font-family: var(--font-mono);
    font-size: var(--fs-13);
    background: var(--bg-sunken);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: var(--s-3) var(--s-4);
    overflow-x: auto;
    direction: ltr;
    text-align: left;
    line-height: 1.7;
    white-space: pre;
}
code.inline {
    font-family: var(--font-mono);
    font-size: 0.9em;
    padding: 2px 6px;
    border-radius: var(--r-xs);
    background: var(--bg-sunken);
    direction: ltr;
    display: inline-block;
}

.method {
    display: inline-block;
    min-width: 56px;
    padding: 2px 8px;
    border-radius: var(--r-xs);
    font-family: var(--font-mono);
    font-size: var(--fs-11);
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.02em;
}
.method--get    { background: var(--info-soft);    color: var(--info); }
.method--post   { background: var(--success-soft); color: var(--success); }
.method--put,
.method--patch  { background: var(--warning-soft); color: var(--warning); }
.method--delete { background: var(--danger-soft);  color: var(--danger); }

/* ---- charts */

.chart { position: relative; width: 100%; }
.chart--sm { height: 180px; }
.chart--md { height: 280px; }
.chart--lg { height: 360px; }
.chart__legend { display: flex; gap: var(--s-4); flex-wrap: wrap; font-size: var(--fs-12); color: var(--text-muted); margin-top: var(--s-3); }
.chart__legend span { display: inline-flex; align-items: center; gap: var(--s-2); }
.chart__swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* Heatmap grid for hour-of-week activity. */
.heatmap { display: grid; grid-template-columns: auto repeat(24, minmax(0, 1fr)); gap: 2px; font-size: var(--fs-11); }
.heatmap__label { color: var(--text-faint); padding-inline-end: var(--s-2); text-align: end; line-height: 18px; }
.heatmap__cell { height: 18px; border-radius: 3px; background: var(--bg-sunken); transition: scale var(--dur-fast) var(--ease); }
.heatmap__cell:hover { scale: 1.35; }
.heatmap__cell[data-level="1"] { background: var(--blue-100); }
.heatmap__cell[data-level="2"] { background: var(--blue-200); }
.heatmap__cell[data-level="3"] { background: var(--blue-400); }
.heatmap__cell[data-level="4"] { background: var(--blue-600); }
.heatmap__cell[data-level="5"] { background: var(--blue-800); }

/* Country volume bars, used instead of a heavy map library. */
.geo-row { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: var(--s-3); padding: var(--s-2) 0; }
.geo-row__code { font-family: var(--font-mono); font-size: var(--fs-12); font-weight: 650; color: var(--text-muted); }
.geo-row__bar { height: 8px; border-radius: var(--r-full); background: var(--bg-sunken); overflow: hidden; }
.geo-row__fill { height: 100%; border-radius: var(--r-full); background: linear-gradient(90deg, var(--blue-400), var(--blue-600)); }
.geo-row__value { font-size: var(--fs-13); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Funnel */
.funnel { display: flex; flex-direction: column; gap: var(--s-3); }
.funnel__step { display: grid; grid-template-columns: 1fr auto; gap: var(--s-2); align-items: baseline; }
.funnel__bar { grid-column: 1 / -1; height: 34px; border-radius: var(--r-sm); background: var(--bg-sunken); overflow: hidden; }
.funnel__fill { height: 100%; border-radius: var(--r-sm); background: linear-gradient(90deg, var(--blue-500), var(--blue-700)); display: flex; align-items: center; padding-inline: var(--s-3); color: #fff; font-size: var(--fs-13); font-weight: 650; transition: width var(--dur-slow) var(--ease-out); }
.funnel__label { font-size: var(--fs-13); font-weight: 600; }
.funnel__pct { font-size: var(--fs-12); color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* Cohort matrix */
.cohort { font-size: var(--fs-12); }
.cohort td, .cohort th { padding: var(--s-2); text-align: center; }
.cohort__cell { border-radius: var(--r-xs); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- security posture */

.posture { display: grid; gap: var(--s-3); }
.posture__item {
    display: flex;
    align-items: flex-start;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--bg-surface);
}
.posture__status { width: 28px; height: 28px; border-radius: var(--r-xs); display: grid; place-items: center; flex: none; }
.posture__status--pass { background: var(--success-soft); color: var(--success); }
.posture__status--warn { background: var(--warning-soft); color: var(--warning); }
.posture__status--fail { background: var(--danger-soft);  color: var(--danger); }
.posture__name { font-weight: 600; font-size: var(--fs-14); }
.posture__control { font-size: var(--fs-11); color: var(--text-faint); font-family: var(--font-mono); }
.posture__detail { font-size: var(--fs-13); color: var(--text-muted); margin-top: 2px; }

/* ---- permission matrix */

.matrix { width: 100%; font-size: var(--fs-13); }
.matrix th { text-align: start; padding: var(--s-3); font-weight: 650; color: var(--text-muted); font-size: var(--fs-12); text-transform: uppercase; letter-spacing: 0.04em; }
.matrix td { padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--border); }
.matrix__module { background: var(--bg-surface-alt); font-weight: 650; }
.matrix__perms { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); }

/* ---- auth screens */

.auth {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr;
    background: var(--bg-canvas);
}
@media (min-width: 1024px) {
    .auth { grid-template-columns: 1fr 1.05fr; }
}

.auth__aside {
    display: none;
    position: relative;
    padding: var(--s-10) var(--s-9);
    color: #fff;
    background:
        radial-gradient(1200px 600px at 15% 10%, rgba(255, 255, 255, 0.16), transparent 60%),
        radial-gradient(900px 500px at 90% 90%, rgba(14, 163, 106, 0.28), transparent 60%),
        linear-gradient(150deg, var(--blue-700) 0%, var(--blue-800) 45%, var(--blue-900) 100%);
    overflow: hidden;
    flex-direction: column;
    justify-content: space-between;
}
@media (min-width: 1024px) { .auth__aside { display: flex; } }

.auth__aside::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: radial-gradient(circle at 30% 30%, #000, transparent 72%);
    -webkit-mask-image: radial-gradient(circle at 30% 30%, #000, transparent 72%);
    pointer-events: none;
}

.auth__aside > * { position: relative; z-index: 1; }
.auth__headline { font-size: var(--fs-36); font-weight: 700; letter-spacing: -0.03em; line-height: 1.15; max-width: 16ch; }
.auth__lede { margin-top: var(--s-4); font-size: var(--fs-16); opacity: 0.86; max-width: 44ch; line-height: 1.7; }
.auth__points { margin-top: var(--s-7); display: grid; gap: var(--s-4); }
.auth__point { display: flex; gap: var(--s-3); align-items: flex-start; font-size: var(--fs-14); opacity: 0.92; }
.auth__point .ic { flex: none; opacity: 0.9; }
.auth__compliance { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.auth__compliance span {
    padding: 4px 10px;
    border-radius: var(--r-full);
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    font-size: var(--fs-11);
    font-weight: 600;
    letter-spacing: 0.02em;
}

.auth__main { display: grid; place-items: center; padding: var(--s-6); }
.auth__card { width: 100%; max-width: 420px; }
.auth__brand { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-7); }
.auth__title { font-size: var(--fs-24); letter-spacing: -0.02em; }
.auth__sub { color: var(--text-muted); margin-top: var(--s-2); font-size: var(--fs-14); }
.auth__form { margin-top: var(--s-6); }
.auth__foot { margin-top: var(--s-6); text-align: center; font-size: var(--fs-13); color: var(--text-muted); }
.auth__row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-5); }

/* One-time-code entry */
.otp { display: flex; gap: var(--s-2); justify-content: center; direction: ltr; }
.otp input {
    width: 48px; height: 56px;
    text-align: center;
    font-size: var(--fs-20);
    font-weight: 650;
    font-family: var(--font-mono);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--bg-surface);
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.otp input:focus { border-color: var(--brand); box-shadow: var(--focus-ring); }

.password-meter { display: flex; gap: 4px; margin-top: var(--s-2); }
.password-meter span { flex: 1; height: 4px; border-radius: var(--r-full); background: var(--bg-sunken); transition: background var(--dur) var(--ease); }
.password-meter[data-score="1"] span:nth-child(1) { background: var(--danger); }
.password-meter[data-score="2"] span:nth-child(-n+2) { background: var(--warning); }
.password-meter[data-score="3"] span:nth-child(-n+3) { background: var(--blue-500); }
.password-meter[data-score="4"] span { background: var(--success); }

/* ---- error and maintenance pages */

.state-page { min-height: 100vh; display: grid; place-items: center; padding: var(--s-6); text-align: center; }
.state-page__code { font-size: 6rem; font-weight: 700; letter-spacing: -0.05em; line-height: 1; background: linear-gradient(135deg, var(--blue-500), var(--blue-800)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.state-page__title { font-size: var(--fs-24); margin-top: var(--s-4); }
.state-page__text { color: var(--text-muted); margin-top: var(--s-3); max-width: 46ch; }
.state-page__actions { margin-top: var(--s-7); display: flex; gap: var(--s-3); justify-content: center; flex-wrap: wrap; }

/* --------------------------------------------------------------- 6. grid */

.grid { display: grid; gap: var(--s-4); }
.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--sidebar { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid--aside { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }

.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-full { grid-column: 1 / -1; }

/* ---------------------------------------------------------- 7. utilities */

.stack { display: flex; flex-direction: column; }
.stack-1 { gap: var(--s-1); } .stack-2 { gap: var(--s-2); } .stack-3 { gap: var(--s-3); }
.stack-4 { gap: var(--s-4); } .stack-5 { gap: var(--s-5); } .stack-6 { gap: var(--s-6); }

.row { display: flex; align-items: center; }
.row-1 { gap: var(--s-1); } .row-2 { gap: var(--s-2); } .row-3 { gap: var(--s-3); }
.row-4 { gap: var(--s-4); } .row-5 { gap: var(--s-5); }
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.row--center { justify-content: center; }
.row--top { align-items: flex-start; }
.row--wrap { flex-wrap: wrap; }

.flex-1 { flex: 1; min-width: 0; }

.mt-0 { margin-top: 0; } .mt-1 { margin-top: var(--s-1); } .mt-2 { margin-top: var(--s-2); }
.mt-3 { margin-top: var(--s-3); } .mt-4 { margin-top: var(--s-4); } .mt-5 { margin-top: var(--s-5); }
.mt-6 { margin-top: var(--s-6); } .mt-7 { margin-top: var(--s-7); }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: var(--s-2); } .mb-3 { margin-bottom: var(--s-3); }
.mb-4 { margin-bottom: var(--s-4); } .mb-5 { margin-bottom: var(--s-5); } .mb-6 { margin-bottom: var(--s-6); }

.p-0 { padding: 0; } .p-3 { padding: var(--s-3); } .p-4 { padding: var(--s-4); } .p-5 { padding: var(--s-5); }

.text-xs { font-size: var(--fs-12); } .text-sm { font-size: var(--fs-13); }
.text-base { font-size: var(--fs-14); } .text-lg { font-size: var(--fs-16); }
.text-xl { font-size: var(--fs-20); } .text-2xl { font-size: var(--fs-24); }

.text-muted { color: var(--text-muted); } .text-faint { color: var(--text-faint); }
.text-brand { color: var(--text-brand); } .text-success { color: var(--success); }
.text-warning { color: var(--warning); } .text-danger { color: var(--danger); }

.fw-500 { font-weight: 500; } .fw-600 { font-weight: 600; } .fw-700 { font-weight: 700; }
.mono { font-family: var(--font-mono); font-size: 0.95em; letter-spacing: -0.02em; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-start { text-align: start; } .text-end { text-align: end; } .text-center { text-align: center; }
.ltr { direction: ltr; }

.hidden { display: none !important; }
.invisible { visibility: hidden; }
.pointer { cursor: pointer; }
.divider { height: 1px; background: var(--border); border: none; margin: var(--s-4) 0; }
.divider--v { width: 1px; height: 24px; background: var(--border); }

.surface { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-md); }
.sunken { background: var(--bg-sunken); border-radius: var(--r-md); }
.rounded { border-radius: var(--r-md); }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }

/* ------------------------------------------------- 8. responsive behaviour */

.sidebar__scrim {
    position: fixed;
    inset: 0;
    background: var(--bg-scrim);
    z-index: calc(var(--z-sidebar) - 1);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--dur) var(--ease), visibility var(--dur);
}

@media (max-width: 1279px) {
    .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stats--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1023px) {
    .app, .app.is-collapsed { grid-template-columns: minmax(0, 1fr); }

    .sidebar {
        position: fixed;
        inset-block: 0;
        inset-inline-start: 0;
        width: var(--sidebar-w);
        translate: -100% 0;
        box-shadow: var(--shadow-xl);
        transition: translate var(--dur-slow) var(--ease-out);
    }
    [dir="rtl"] .sidebar { translate: 100% 0; }
    .sidebar.is-open { translate: 0 0; }
    .sidebar.is-open ~ .sidebar__scrim,
    .app.is-nav-open .sidebar__scrim { opacity: 1; visibility: visible; }

    .grid--3, .grid--sidebar, .grid--aside { grid-template-columns: minmax(0, 1fr); }
    .stats--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .page { padding: var(--s-5) var(--s-4) var(--s-9); }
    .topbar { padding-inline: var(--s-4); }
    .drawer { width: 100%; }
}

@media (max-width: 767px) {
    .grid--2, .grid--4, .stats--2, .stats--3, .stats--4 { grid-template-columns: minmax(0, 1fr); }
    .span-2, .span-3 { grid-column: span 1; }

    .page__head { flex-direction: column; align-items: stretch; }
    .page__actions .btn { flex: 1; }

    .topbar__search { display: none; }
    .dl { grid-template-columns: 1fr; gap: var(--s-1) 0; }
    .dl dd { margin-bottom: var(--s-3); }

    .modal { max-width: 100%; border-radius: var(--r-lg); }
    .toasts { inset-inline: var(--s-3); width: auto; bottom: var(--s-3); }

    /* Tables become stacked records; each cell carries its own label. */
    .table--responsive thead { display: none; }
    .table--responsive tbody tr {
        display: block;
        padding: var(--s-3) var(--s-4);
        border-bottom: 1px solid var(--border);
    }
    .table--responsive tbody td {
        display: flex;
        justify-content: space-between;
        gap: var(--s-4);
        padding: var(--s-1) 0;
        border: none;
        text-align: end;
    }
    .table--responsive tbody td::before {
        content: attr(data-label);
        font-size: var(--fs-12);
        font-weight: 600;
        color: var(--text-muted);
        text-align: start;
        flex: none;
    }
    .table--responsive .actions { justify-content: flex-end; padding-top: var(--s-3); }
}

/* ------------------------------------------------ 9. motion and print */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

.fade-in { animation: fade-in var(--dur-slow) var(--ease-out); }
.rise-in { animation: rise-in var(--dur-slow) var(--ease-out) both; }
@keyframes rise-in { from { opacity: 0; translate: 0 10px; } to { opacity: 1; translate: 0 0; } }

.rise-in:nth-child(1) { animation-delay: 0ms; }
.rise-in:nth-child(2) { animation-delay: 40ms; }
.rise-in:nth-child(3) { animation-delay: 80ms; }
.rise-in:nth-child(4) { animation-delay: 120ms; }
.rise-in:nth-child(5) { animation-delay: 160ms; }
.rise-in:nth-child(6) { animation-delay: 200ms; }

@media print {
    .sidebar, .topbar, .page__actions, .toolbar, .pager, .footer, .toasts { display: none !important; }
    .app { grid-template-columns: 1fr; }
    .page { padding: 0; max-width: 100%; }
    .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
    body { background: #fff; color: #000; }
}
