@charset "UTF-8";

/* ==========================================================================
   دایرکتوری تلفن برج — Design system
   Hand-written CSS, full RTL. Zero external dependencies, zero CDN.
   Order: tokens -> base -> shell -> nav -> buttons -> forms -> cards ->
          badges -> feedback (toast/modal) -> tables -> loading -> utilities.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Fonts — bundled locally so the demo works offline.
   Place the woff2 files in wwwroot/fonts/ (see fonts/README.md).
   If they are missing the stack below falls back to Tahoma/Segoe UI.
   -------------------------------------------------------------------------- */
@font-face {
    font-family: "Vazirmatn";
    src: url("../fonts/Vazirmatn-Regular.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Vazirmatn";
    src: url("../fonts/Vazirmatn-Medium.woff2") format("woff2");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Vazirmatn";
    src: url("../fonts/Vazirmatn-SemiBold.woff2") format("woff2");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Vazirmatn";
    src: url("../fonts/Vazirmatn-Bold.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* --------------------------------------------------------------------------
   2. Tokens
   -------------------------------------------------------------------------- */
:root {
    /* type scale: S / M / L is a single multiplier, set from Settings */
    --fs: 1;
    --font-ui: "Vazirmatn", "Vazir", Tahoma, "Segoe UI", system-ui, sans-serif;
    --font-num: "Vazirmatn", Tahoma, "Segoe UI", system-ui, sans-serif;

    /* palette — light */
    --bg: #f4f7f9;
    --bg-tint: radial-gradient(1200px 600px at 80% -10%, rgba(13, 107, 95, 0.07), transparent 60%),
               radial-gradient(900px 500px at 0% 0%, rgba(45, 122, 160, 0.05), transparent 55%);
    --surface: #ffffff;
    --surface-2: #f1f5f8;
    --surface-3: #e7eef4;
    --border: #e2e9f0;
    --border-strong: #cdd8e4;
    --text: #0f1c26;
    --text-2: #4a5b6a;
    --text-3: #788795;

    --brand: #0d6b5f;
    --brand-strong: #095449;
    --brand-soft: #e5f2ef;
    --brand-contrast: #ffffff;

    --ok: #12765a;
    --ok-soft: #e3f3ec;
    --warn: #946008;
    --warn-soft: #fbf0db;
    --danger: #b0392b;
    --danger-soft: #fcebe9;
    --star: #d59b0b;
    --star-soft: #fdf6e3;

    --shadow-1: 0 1px 2px rgba(15, 28, 38, 0.06);
    --shadow-2: 0 10px 24px -14px rgba(15, 28, 38, 0.22);
    --shadow-3: 0 32px 64px -34px rgba(15, 28, 38, 0.38);
    --ring: 0 0 0 3px rgba(13, 107, 95, 0.22);

    --r-1: 8px;
    --r-2: 12px;
    --r-3: 16px;
    --r-4: 22px;
    --r-pill: 999px;

    --s-1: 4px;
    --s-2: 8px;
    --s-3: 12px;
    --s-4: 16px;
    --s-5: 24px;
    --s-6: 32px;
    --s-7: 48px;

    --sidebar-w: 264px;
    --sidebar-w-slim: 78px;
    --topbar-h: 68px;

    --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
    --speed: 180ms;

    color-scheme: light;
}

/* dark palette, applied either by system preference or explicit choice */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0a1119;
        --bg-tint: radial-gradient(1100px 560px at 85% -10%, rgba(53, 194, 171, 0.10), transparent 62%),
                   radial-gradient(900px 520px at 0% 0%, rgba(80, 140, 200, 0.07), transparent 58%);
        --surface: #111a24;
        --surface-2: #16212d;
        --surface-3: #1d2a39;
        --border: #233241;
        --border-strong: #344a5f;
        --text: #e9f0f7;
        --text-2: #a6b6c6;
        --text-3: #7e8d9c;

        --brand: #35c2ab;
        --brand-strong: #63dcc8;
        --brand-soft: #0e2b28;
        --brand-contrast: #04211d;

        --ok: #45c79c;
        --ok-soft: #0f2a21;
        --warn: #e0ae55;
        --warn-soft: #2a2110;
        --danger: #f08076;
        --danger-soft: #2d1714;
        --star: #f0b73a;
        --star-soft: #2a2310;

        --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-2: 0 12px 28px -16px rgba(0, 0, 0, 0.75);
        --shadow-3: 0 34px 70px -34px rgba(0, 0, 0, 0.85);
        --ring: 0 0 0 3px rgba(53, 194, 171, 0.28);

        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #0a1119;
    --bg-tint: radial-gradient(1100px 560px at 85% -10%, rgba(53, 194, 171, 0.10), transparent 62%),
               radial-gradient(900px 520px at 0% 0%, rgba(80, 140, 200, 0.07), transparent 58%);
    --surface: #111a24;
    --surface-2: #16212d;
    --surface-3: #1d2a39;
    --border: #233241;
    --border-strong: #344a5f;
    --text: #e9f0f7;
    --text-2: #a6b6c6;
    --text-3: #7e8d9c;

    --brand: #35c2ab;
    --brand-strong: #63dcc8;
    --brand-soft: #0e2b28;
    --brand-contrast: #04211d;

    --ok: #45c79c;
    --ok-soft: #0f2a21;
    --warn: #e0ae55;
    --warn-soft: #2a2110;
    --danger: #f08076;
    --danger-soft: #2d1714;
    --star: #f0b73a;
    --star-soft: #2a2310;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 12px 28px -16px rgba(0, 0, 0, 0.75);
    --shadow-3: 0 34px 70px -34px rgba(0, 0, 0, 0.85);
    --ring: 0 0 0 3px rgba(53, 194, 171, 0.28);

    color-scheme: dark;
}

/* font size preference */
:root[data-font="sm"] { --fs: 0.92; }
:root[data-font="md"] { --fs: 1; }
:root[data-font="lg"] { --fs: 1.1; }

/* --------------------------------------------------------------------------
   3. Base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: calc(16px * var(--fs));
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background-color: var(--bg);
    background-image: var(--bg-tint);
    background-attachment: fixed;
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 1rem;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5 {
    margin: 0;
    font-weight: 700;
    line-height: 1.45;
    letter-spacing: -0.01em;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.28rem; }
h3 { font-size: 1.06rem; }

p { margin: 0; }

a {
    color: var(--brand);
    text-decoration: none;
    transition: color var(--speed) var(--ease);
}

a:hover { color: var(--brand-strong); }

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

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

ul, ol { margin: 0; padding: 0; list-style: none; }

::selection {
    background: var(--brand);
    color: var(--brand-contrast);
}

:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
    border-radius: 4px;
}

/* thin, theme-aware scrollbars */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: var(--r-pill);
    border: 3px solid transparent;
    background-clip: content-box;
}

/* --------------------------------------------------------------------------
   4. App shell, sidebar, top bar
   -------------------------------------------------------------------------- */
.app {
    display: flex;
    min-height: 100vh;
    align-items: stretch;
}

.app__body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
}

.sidebar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    flex: 0 0 var(--sidebar-w);
    width: var(--sidebar-w);
    height: 100vh;
    padding: 18px 14px 16px;
    background: var(--surface);
    border-inline-end: 1px solid var(--border);
    transition: width var(--speed) var(--ease), flex-basis var(--speed) var(--ease),
                padding var(--speed) var(--ease);
}

/* The slim rail is a desktop-only affordance: on tablet/phone the sidebar is a
   drawer and must always show its labels. Scoping these rules keeps that true
   even when a slim preference is stored from an earlier desktop session. */
@media (min-width: 1025px) {
    .app[data-sidebar="slim"] .sidebar {
        flex-basis: var(--sidebar-w-slim);
        width: var(--sidebar-w-slim);
        padding-inline: 10px;
    }

    .app[data-sidebar="slim"] .hide-slim {
        display: none !important;
    }

    .app[data-sidebar="slim"] .nav__item {
        justify-content: center;
        padding-inline: 0;
        gap: 0;
    }

    .app[data-sidebar="slim"] .user-mini {
        justify-content: center;
        background: transparent;
        padding: 4px;
    }
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 4px 6px 2px;
    color: var(--text);
    min-height: 46px;
}

.sidebar__brand:hover { color: var(--text); }

.brand-mark {
    display: grid;
    place-items: center;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 13px;
    background: linear-gradient(145deg, var(--brand), var(--brand-strong));
    color: var(--brand-contrast);
    box-shadow: var(--shadow-1);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.brand-text strong { font-size: 0.98rem; font-weight: 700; white-space: nowrap; }
.brand-text small { font-size: 0.74rem; color: var(--text-3); white-space: nowrap; }

.sidebar__head {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 44px;
    padding: 0 4px;
}

/* the brand mark doubles as the collapse / expand control */
.brand-mark {
    border: 0;
    padding: 0;
    font: inherit;
    cursor: pointer;
    transition: transform var(--speed) var(--ease), background var(--speed) var(--ease);
}

.brand-mark:hover { transform: translateY(-1px); }

/* standalone login shell */
.auth {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: clamp(18px, 4vw, 48px) clamp(16px, 4vw, 24px);
}

.sidebar__collapse {
    margin-inline-start: auto;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 6px;
}

.nav__label-section {
    padding: 12px 12px 6px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text-3);
}

.nav__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--r-2);
    color: var(--text-2);
    font-size: 0.94rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}

.nav__item .icon { flex: 0 0 auto; opacity: 0.85; }

.nav__item:hover {
    background: var(--surface-2);
    color: var(--text);
}

.nav__item.active {
    background: var(--brand-soft);
    color: var(--brand-strong);
    font-weight: 600;
}

.nav__item.active .icon { opacity: 1; }

.nav__count {
    margin-inline-start: auto;
    font-size: 0.72rem;
    padding: 1px 7px;
    border-radius: var(--r-pill);
    background: var(--surface-3);
    color: var(--text-2);
}

.sidebar__foot {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-mini {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--r-2);
    background: var(--surface-2);
    min-width: 0;
}

.user-mini__meta { min-width: 0; line-height: 1.4; }
.user-mini__meta strong {
    display: block;
    font-size: 0.86rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-mini__meta small { font-size: 0.72rem; color: var(--text-3); }

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: var(--topbar-h);
    padding: 10px clamp(16px, 2.6vw, 36px);
    background: color-mix(in srgb, var(--bg) 78%, transparent);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    border-bottom: 1px solid var(--border);
}

.topbar__spacer { flex: 1 1 auto; }
.topbar__menu { display: none; }

.date-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border-radius: var(--r-pill);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-2);
    font-size: 0.83rem;
    white-space: nowrap;
}

.date-chip .icon { color: var(--text-3); }

.topbar__digits {
    padding: 6px 11px;
    font-weight: 700;
    color: var(--text-2);
}

.topbar__digits .num { font-size: 0.82rem; letter-spacing: 0.06em; }

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 5px 5px 5px 12px;
    border-radius: var(--r-pill);
    background: var(--surface);
    border: 1px solid var(--border);
    min-width: 0;
}

.user-chip__meta { line-height: 1.3; min-width: 0; }
.user-chip__meta strong { display: block; font-size: 0.84rem; font-weight: 600; white-space: nowrap; }
.user-chip__meta small { font-size: 0.71rem; color: var(--text-3); white-space: nowrap; }

.avatar {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand-strong);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.avatar--lg { width: 48px; height: 48px; font-size: 1rem; }

/* page container */
.page {
    flex: 1 1 auto;
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: clamp(20px, 2.6vw, 34px) clamp(16px, 2.6vw, 36px) 64px;
}

.page--wide { max-width: 1320px; }

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
    margin-bottom: var(--s-5);
}

.page-head__text { min-width: 0; }
.page-head__eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--brand);
    margin-bottom: 4px;
}
.page-head h1 { font-size: clamp(1.35rem, 2.4vw, 1.85rem); }
.page-head__sub {
    margin-top: 6px;
    color: var(--text-2);
    font-size: 0.93rem;
    max-width: 62ch;
}
.page-head__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* mobile drawer */
.sidebar-backdrop,
.sidebar__mobile-close { display: none; }

@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        inset-block: 0;
        inset-inline-end: 0;
        width: min(80vw, 300px);
        flex-basis: auto;
        height: 100vh;
        transform: translateX(100%);
        transition: transform 240ms var(--ease);
        box-shadow: var(--shadow-3);
        border-inline-end: none;
        border-inline-start: 1px solid var(--border);
    }

    .app[data-mobile="open"] .sidebar { transform: none; }

    .sidebar__mobile-close { display: inline-flex; }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 35;
        background: rgba(6, 12, 18, 0.45);
        backdrop-filter: blur(2px);
        opacity: 0;
        pointer-events: none;
        transition: opacity 200ms var(--ease);
    }

    .app[data-mobile="open"] .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .topbar__menu { display: inline-flex; }
    .date-chip span { display: none; }
}

@media (max-width: 620px) {
    .topbar { gap: 8px; }
    .topbar .badge--brand { display: none; }
    .user-chip__meta { display: none; }
    .user-chip { padding: 4px; }
    .date-chip { display: none; }
    .page-head__actions { width: 100%; }
}

/* --------------------------------------------------------------------------
   5. Buttons
   -------------------------------------------------------------------------- */
.btn {
    --btn-bg: transparent;
    --btn-fg: var(--text);
    --btn-bd: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid var(--btn-bd);
    border-radius: var(--r-2);
    background: var(--btn-bg);
    color: var(--btn-fg);
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    transition: background var(--speed) var(--ease), color var(--speed) var(--ease),
                border-color var(--speed) var(--ease), transform 120ms var(--ease),
                box-shadow var(--speed) var(--ease);
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled,
.btn[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.btn--primary {
    --btn-bg: var(--brand);
    --btn-fg: var(--brand-contrast);
    --btn-bd: var(--brand);
    box-shadow: 0 6px 16px -10px color-mix(in srgb, var(--brand) 80%, transparent);
}
.btn--primary:hover { --btn-bg: var(--brand-strong); --btn-bd: var(--brand-strong); }

.btn--soft {
    --btn-bg: var(--brand-soft);
    --btn-fg: var(--brand-strong);
    --btn-bd: transparent;
}
.btn--soft:hover { --btn-bg: color-mix(in srgb, var(--brand) 16%, var(--surface)); }

.btn--ghost {
    --btn-bg: var(--surface);
    --btn-fg: var(--text-2);
    --btn-bd: var(--border);
}
.btn--ghost:hover { --btn-fg: var(--text); --btn-bd: var(--border-strong); --btn-bg: var(--surface-2); }

.btn--plain { --btn-bg: transparent; --btn-fg: var(--text-2); }
.btn--plain:hover { --btn-bg: var(--surface-2); --btn-fg: var(--text); }

.btn--danger { --btn-bg: var(--danger-soft); --btn-fg: var(--danger); }
.btn--danger:hover { --btn-bg: var(--danger); --btn-fg: #fff; }

.btn--icon {
    padding: 0;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border-radius: var(--r-2);
    background: transparent;
    color: var(--text-2);
}
.btn--icon:hover { background: var(--surface-2); color: var(--text); }

.btn--sm { padding: 7px 12px; font-size: 0.82rem; border-radius: var(--r-1); }
.btn--lg { padding: 13px 22px; font-size: 0.98rem; border-radius: var(--r-3); }
.btn--block { width: 100%; }

.btn.is-loading { pointer-events: none; opacity: 0.8; }

.icon-btn-group {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    border-radius: var(--r-2);
    background: var(--surface-2);
}

/* --------------------------------------------------------------------------
   6. Forms
   -------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 7px; }

.field__label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--text-2);
}

.field__label .req { color: var(--danger); }

.field__hint { font-size: 0.76rem; color: var(--text-3); }
.field__error { font-size: 0.78rem; color: var(--danger); display: flex; align-items: center; gap: 5px; }

.input,
.select,
.textarea {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--border);
    border-radius: var(--r-2);
    background: var(--surface);
    color: var(--text);
    font-size: 0.92rem;
    transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease),
                background var(--speed) var(--ease);
    appearance: none;
}

.input::placeholder,
.textarea::placeholder { color: var(--text-3); }

.input:hover,
.select:hover,
.textarea:hover { border-color: var(--border-strong); }

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: var(--ring);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
    background: var(--surface-2);
    color: var(--text-3);
    cursor: not-allowed;
}

.input--invalid,
.input--invalid:focus { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

.textarea { min-height: 96px; resize: vertical; line-height: 1.8; }

.select {
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                      linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position: calc(0% + 16px) calc(50% + 1px), calc(0% + 21px) calc(50% + 1px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-inline-start: 36px;
}

.input-group { position: relative; display: flex; align-items: center; }
.input-group .icon {
    position: absolute;
    inset-inline-start: 12px;
    color: var(--text-3);
    pointer-events: none;
}
.input-group .input { padding-inline-start: 40px; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 16px;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
    margin-top: var(--s-5);
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    font-size: 0.88rem;
    color: var(--text-2);
}

.checkbox input {
    width: 18px;
    height: 18px;
    accent-color: var(--brand);
    cursor: pointer;
}

/* segmented control */
.segmented {
    display: inline-flex;
    padding: 4px;
    gap: 2px;
    border-radius: var(--r-2);
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.segmented__item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    border: none;
    border-radius: var(--r-1);
    background: transparent;
    color: var(--text-2);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--speed) var(--ease), color var(--speed) var(--ease),
                box-shadow var(--speed) var(--ease);
}

.segmented__item:hover { color: var(--text); }

.segmented__item.active {
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    box-shadow: var(--shadow-1);
}

/* --------------------------------------------------------------------------
   7. Surfaces, cards, badges, chips
   -------------------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-3);
    box-shadow: var(--shadow-1);
}

.card--pad { padding: var(--s-5); }
.card--flat { box-shadow: none; }

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.card-head h2,
.card-head h3 { font-size: 1rem; }

.card-body { padding: 20px; }

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.96rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.tiny { font-size: 0.76rem; }
.small { font-size: 0.85rem; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.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); }
.stack { display: flex; flex-direction: column; gap: var(--s-3); }
.row { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.row--tight { gap: var(--s-2); }
.grow { flex: 1 1 auto; min-width: 0; }
.divider { height: 1px; background: var(--border); margin: var(--s-4) 0; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: var(--r-pill);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 0.74rem;
    font-weight: 600;
    line-height: 1.6;
    white-space: nowrap;
}

.badge--brand { background: var(--brand-soft); color: var(--brand-strong); }
.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--muted { background: var(--surface-3); color: var(--text-3); }
.badge--dot::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 13px;
    border-radius: var(--r-pill);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    font-size: 0.83rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color var(--speed) var(--ease), color var(--speed) var(--ease),
                background var(--speed) var(--ease), transform 120ms var(--ease);
}

.chip:hover {
    border-color: var(--brand);
    color: var(--brand-strong);
    transform: translateY(-1px);
}

.chip.is-active {
    background: var(--brand-soft);
    border-color: color-mix(in srgb, var(--brand) 30%, transparent);
    color: var(--brand-strong);
    font-weight: 600;
}

.kbd {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 6px;
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    background: var(--surface-2);
    color: var(--text-3);
    font-family: var(--font-ui);
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
}

.hl {
    background: color-mix(in srgb, var(--star) 26%, transparent);
    color: inherit;
    border-radius: 3px;
    padding: 0 2px;
}

/* numbers: always tabular, never reordered by bidi */
.num {
    font-family: var(--font-num);
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
    unicode-bidi: plaintext;
    letter-spacing: 0.01em;
}

.num--xl {
    font-size: clamp(1.6rem, 2.6vw, 2.1rem);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.02em;
}

.num--lg { font-size: 1.3rem; font-weight: 700; }
.num--md { font-size: 1.05rem; font-weight: 600; }

/* --------------------------------------------------------------------------
   8. Tables
   -------------------------------------------------------------------------- */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--r-3);
    border: 1px solid var(--border);
    background: var(--surface);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.table th {
    text-align: start;
    padding: 12px 16px;
    background: var(--surface-2);
    color: var(--text-3);
    font-size: 0.76rem;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--speed) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }

/* --------------------------------------------------------------------------
   9. Feedback: toasts, modal, callouts
   -------------------------------------------------------------------------- */
.toasts {
    position: fixed;
    inset-block-end: 22px;
    inset-inline-start: 22px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: min(92vw, 380px);
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--r-2);
    background: var(--surface);
    border: 1px solid var(--border);
    border-inline-start: 3px solid var(--brand);
    box-shadow: var(--shadow-2);
    pointer-events: auto;
    animation: toast-in 220ms var(--ease);
}

.toast__icon {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand-strong);
    flex: 0 0 auto;
}

.toast__body { min-width: 0; flex: 1 1 auto; }
.toast__title { font-size: 0.87rem; font-weight: 600; }
.toast__desc { font-size: 0.78rem; color: var(--text-2); margin-top: 1px; }

.toast--success { border-inline-start-color: var(--ok); }
.toast--success .toast__icon { background: var(--ok-soft); color: var(--ok); }
.toast--error { border-inline-start-color: var(--danger); }
.toast--error .toast__icon { background: var(--danger-soft); color: var(--danger); }
.toast--info { border-inline-start-color: var(--brand); }

.toast__close {
    border: none;
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    line-height: 0;
}
.toast__close:hover { color: var(--text); background: var(--surface-2); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(6, 12, 18, 0.5);
    backdrop-filter: blur(3px);
    animation: fade-in 160ms var(--ease);
}

.modal {
    width: 100%;
    max-width: 540px;
    max-height: 92vh;
    overflow: auto;
    background: var(--surface);
    border-radius: var(--r-4);
    box-shadow: var(--shadow-3);
    animation: modal-in 200ms var(--ease);
}

.modal--wide { max-width: 720px; }

.modal__head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 20px 22px 0;
}

.modal__title { font-size: 1.05rem; font-weight: 700; }
.modal__sub { font-size: 0.84rem; color: var(--text-2); margin-top: 3px; }
.modal__body { padding: 18px 22px; }
.modal__foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 0 22px 20px;
    flex-wrap: wrap;
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(12px) scale(0.985); }
    to { opacity: 1; transform: none; }
}

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

.callout {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--r-2);
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-2);
}

.callout--brand { background: var(--brand-soft); border-color: transparent; color: var(--brand-strong); }
.callout--warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.callout--danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }

/* --------------------------------------------------------------------------
   10. Loading skeletons & empty states
   -------------------------------------------------------------------------- */
.skeleton {
    display: block;
    border-radius: var(--r-1);
    background: linear-gradient(90deg,
        var(--surface-2) 0%,
        var(--surface-3) 40%,
        var(--surface-2) 80%);
    background-size: 220% 100%;
    animation: shimmer 1.4s var(--ease) infinite;
}

.skeleton--text { height: 12px; }
.skeleton--title { height: 18px; }
.skeleton--circle { border-radius: 50%; }

@keyframes shimmer {
    from { background-position: 120% 0; }
    to { background-position: -60% 0; }
}

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: var(--s-7) var(--s-4);
    color: var(--text-2);
}

.empty--page { min-height: 55vh; justify-content: center; }

.empty__icon {
    display: grid;
    place-items: center;
    width: 62px;
    height: 62px;
    border-radius: 20px;
    background: var(--surface-2);
    color: var(--text-3);
    margin-bottom: 6px;
}

.empty__title { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.empty__text { font-size: 0.88rem; max-width: 42ch; }
.empty .btn { margin-top: 12px; }

/* --------------------------------------------------------------------------
   11. Motion & print
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

@media print {
    .sidebar, .topbar, .toasts { display: none !important; }
    .page { max-width: none; padding: 0; }
    body { background: #fff; }
}

/* --------------------------------------------------------------------------
   13. Login card (Step B)
   The `.auth` shell in section 4 already centers whatever sits inside it.
   -------------------------------------------------------------------------- */

.login-card {
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-3);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.login-brand .brand-mark {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
}

.login-brand strong { display: block; font-size: 0.95rem; }
.login-brand small { display: block; font-size: 0.76rem; line-height: 1.5; }

.login-title {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.5;
}

.login-hint { gap: var(--s-2); }

.demo-account {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--r-2);
    background: var(--surface-2);
    color: inherit;
    font: inherit;
    text-align: start;
    cursor: pointer;
    transition: border-color var(--speed) var(--ease), background var(--speed) var(--ease);
}

.demo-account:hover:not(:disabled) {
    border-color: var(--brand);
    background: var(--brand-soft);
}

.demo-account:disabled { cursor: not-allowed; opacity: 0.65; }

.demo-account__meta { min-width: 0; line-height: 1.55; }
.demo-account__meta strong { display: block; font-size: 0.84rem; }
.demo-account__meta small { display: block; font-size: 0.76rem; color: var(--text-3); }

.topbar__logout { flex: 0 0 auto; }
