/* ============================================================================
   FinBill · Личный кабинет — Design System
   Premium fintech, auto light/dark. Trust-first, restrained motion.
   Tokens → Base → Layout → Components → Motion → Responsive
   Шрифты: Golos Text (UI, кириллица) + JetBrains Mono (числа/счета).
   Денежная семантика: --pos (приход) / --neg (расход). Бренд-акцент отдельный.
   ============================================================================ */

/* ----------------------------------------------------------------------------
   0. Fonts (self-hosted, variable, subset-split)
   ---------------------------------------------------------------------------- */
@font-face {
    font-family: 'Golos Text';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('/assets/fonts/golos-cyrillic.woff2') format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116, U+20BD;
}
@font-face {
    font-family: 'Golos Text';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('/assets/fonts/golos-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
                   U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('/assets/fonts/jbmono-cyrillic.woff2') format('woff2');
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116, U+20BD;
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('/assets/fonts/jbmono-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2074, U+20AC, U+2122, U+2212, U+2215;
}

/* ----------------------------------------------------------------------------
   1. Design tokens — LIGHT (default)
   ---------------------------------------------------------------------------- */
:root {
    color-scheme: light;

    --bg:            #f5f7fb;
    --bg-elev:       #eef2f9;
    --surface:       #ffffff;
    --surface-2:     #f3f6fc;   /* hover / inset */
    --surface-3:     #e9eef7;
    --surface-inset: #f7f9fd;

    --border:        #e4e9f2;   /* hairline */
    --border-strong: #cfd8e8;

    --text:          #0f1729;   /* ink */
    --text-muted:    #545f76;   /* AA secondary */
    --text-subtle:   #767f95;   /* tertiary / decorative */

    --brand:         #2e47d4;   /* cobalt — trust, не зелёный */
    --brand-hover:   #2439b0;
    --brand-active:  #1e308f;
    --brand-text:    #2a42c9;   /* links/icons on light */
    --brand-soft:    #eaeeff;   /* tint surfaces */
    --brand-soft-2:  #dde3ff;
    --brand-contrast:#ffffff;
    --brand-line:    #c4cdf7;

    --pos:           #15924f;   /* приход */
    --pos-text:      #0f7d43;
    --pos-soft:      #e4f6ec;
    --neg:           #cf3b3b;   /* расход */
    --neg-text:      #c0322f;
    --neg-soft:      #fce8e7;
    --warn:          #9a6a12;
    --warn-soft:     #fbf0d9;
    --info-soft:     #e7eefb;

    --shadow-sm:  0 1px 2px rgba(15,23,42,.06);
    --shadow-md:  0 1px 2px rgba(15,23,42,.05), 0 6px 18px -6px rgba(15,23,42,.12);
    --shadow-lg:  0 12px 36px -10px rgba(15,23,42,.20), 0 4px 12px -6px rgba(15,23,42,.10);
    --shadow-brand: 0 8px 24px -8px rgba(46,71,212,.40);

    --ring:       0 0 0 3px rgba(46,71,212,.28);
    --ring-danger:0 0 0 3px rgba(207,59,59,.26);

    /* select arrow (адаптируется per-theme) */
    --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23767f95' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    --glow: radial-gradient(120% 120% at 100% 0%, rgba(46,71,212,.10), transparent 60%);

    --radius-sm: 8px;
    --radius:    12px;
    --radius-lg: 16px;
    --radius-xl: 22px;
    --radius-pill: 999px;

    --font-sans: 'Golos Text', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

    --ease-out:    cubic-bezier(0.23, 1, 0.32, 1);
    --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
    --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);

    --maxw: 1180px;
    --sidebar-w: 248px;
}

/* 1b. Tokens — DARK (explicit toggle) */
:root[data-theme="dark"] {
    color-scheme: dark;

    --bg:            #0b0e14;
    --bg-elev:       #0e121b;
    --surface:       #12161f;
    --surface-2:     #171c28;
    --surface-3:     #1e2533;
    --surface-inset: #0f131c;

    --border:        #242b3a;
    --border-strong: #333c50;

    --text:          #e7ebf3;
    --text-muted:    #a3adc2;
    --text-subtle:   #7e889e;

    --brand:         #3d5af0;
    --brand-hover:   #4f6bf7;
    --brand-active:  #6079ff;
    --brand-text:    #9db0ff;
    --brand-soft:    rgba(93,119,255,.14);
    --brand-soft-2:  rgba(93,119,255,.22);
    --brand-contrast:#ffffff;
    --brand-line:    rgba(93,119,255,.32);

    --pos:           #2fbf78;
    --pos-text:      #45d98c;
    --pos-soft:      rgba(47,191,120,.15);
    --neg:           #e8584f;
    --neg-text:      #ff7a72;
    --neg-soft:      rgba(232,88,79,.16);
    --warn:          #d9a23e;
    --warn-soft:     rgba(217,162,62,.15);
    --info-soft:     rgba(93,119,255,.12);

    --shadow-sm:  0 1px 2px rgba(0,0,0,.4);
    --shadow-md:  0 1px 2px rgba(0,0,0,.4), 0 8px 24px -8px rgba(0,0,0,.6);
    --shadow-lg:  0 16px 44px -12px rgba(0,0,0,.7), 0 4px 14px -6px rgba(0,0,0,.5);
    --shadow-brand: 0 10px 30px -10px rgba(61,90,240,.55);

    --ring:       0 0 0 3px rgba(93,119,255,.40);
    --ring-danger:0 0 0 3px rgba(232,88,79,.34);

    --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237e889e' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    --glow: radial-gradient(120% 120% at 100% 0%, rgba(93,119,255,.18), transparent 55%);
}

/* 1c. Tokens — DARK (system preference, when no explicit choice) */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;

        --bg:            #0b0e14;
        --bg-elev:       #0e121b;
        --surface:       #12161f;
        --surface-2:     #171c28;
        --surface-3:     #1e2533;
        --surface-inset: #0f131c;

        --border:        #242b3a;
        --border-strong: #333c50;

        --text:          #e7ebf3;
        --text-muted:    #a3adc2;
        --text-subtle:   #7e889e;

        --brand:         #3d5af0;
        --brand-hover:   #4f6bf7;
        --brand-active:  #6079ff;
        --brand-text:    #9db0ff;
        --brand-soft:    rgba(93,119,255,.14);
        --brand-soft-2:  rgba(93,119,255,.22);
        --brand-contrast:#ffffff;
        --brand-line:    rgba(93,119,255,.32);

        --pos:           #2fbf78;
        --pos-text:      #45d98c;
        --pos-soft:      rgba(47,191,120,.15);
        --neg:           #e8584f;
        --neg-text:      #ff7a72;
        --neg-soft:      rgba(232,88,79,.16);
        --warn:          #d9a23e;
        --warn-soft:     rgba(217,162,62,.15);
        --info-soft:     rgba(93,119,255,.12);

        --shadow-sm:  0 1px 2px rgba(0,0,0,.4);
        --shadow-md:  0 1px 2px rgba(0,0,0,.4), 0 8px 24px -8px rgba(0,0,0,.6);
        --shadow-lg:  0 16px 44px -12px rgba(0,0,0,.7), 0 4px 14px -6px rgba(0,0,0,.5);
        --shadow-brand: 0 10px 30px -10px rgba(61,90,240,.55);

        --ring:       0 0 0 3px rgba(93,119,255,.40);
        --ring-danger:0 0 0 3px rgba(232,88,79,.34);

        --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237e889e' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
        --glow: radial-gradient(120% 120% at 100% 0%, rgba(93,119,255,.18), transparent 55%);
    }
}

/* ----------------------------------------------------------------------------
   2. Base / reset
   ---------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "ss01", "cv01";
    text-rendering: optimizeLegibility;
    transition: background-color .3s var(--ease-out), color .3s var(--ease-out);
}

h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.014em; line-height: 1.2; }

a { color: var(--brand-text); text-decoration: none; transition: color .14s ease; }
a:hover { color: var(--brand-hover); }
a:focus-visible { outline: none; border-radius: 4px; box-shadow: var(--ring); }

::selection { background: var(--brand-soft-2); color: var(--text); }

:where(button, [role="button"]) { font-family: inherit; }

/* Numerals: tabular everywhere money/figures live */
.tnum, .txn-amount, .money-widget__balance, .metric__value,
.data-table td, .kv dd { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }

/* 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: 999px; border: 3px solid var(--bg); }
*::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); }

/* Headings balance to avoid widows */
h1, h2, h3, .page-title, .auth-title, .section-title, .auth-aside__headline { text-wrap: balance; }

/* Touch / tap refinements */
a, .btn, .sidebar-link, .quick-card, .theme-toggle, .pagination__link, button { -webkit-tap-highlight-color: transparent; }
.btn, .sidebar-link, .quick-card, .theme-toggle, .pagination__link { touch-action: manipulation; }

/* Skip link (a11y) */
.skip-link {
    position: absolute; left: 12px; top: -56px; z-index: 100;
    padding: 9px 15px; border-radius: 10px; background: var(--brand); color: #fff;
    font-weight: 600; font-size: 13px; transition: top .18s var(--ease-out);
}
.skip-link:focus { top: 12px; outline: none; box-shadow: var(--ring); color: #fff; text-decoration: none; }

/* ----------------------------------------------------------------------------
   3a. Auth shell — split screen (brand panel + form)
   ---------------------------------------------------------------------------- */
.auth-body {
    min-height: 100dvh;
    background: var(--bg);
}
.auth-shell {
    min-height: 100dvh;
    display: grid;
    grid-template-columns: 1.05fr 1fr;
}

/* Left: brand / marketing panel */
.auth-aside {
    position: relative;
    overflow: hidden;
    padding: 48px 56px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    color: #f4f6ff;
    background:
        radial-gradient(110% 80% at 12% 8%, rgba(120,142,255,.34), transparent 55%),
        radial-gradient(120% 120% at 100% 100%, rgba(20,28,64,.55), transparent 60%),
        linear-gradient(155deg, #283ab8 0%, #1c2a86 46%, #131c54 100%);
    isolation: isolate;
}
.auth-aside::after {
    /* subtle grid texture for depth */
    content: "";
    position: absolute; inset: 0; z-index: -1;
    background-image:
        linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
    background-size: 46px 46px;
    mask-image: radial-gradient(120% 100% at 30% 20%, #000 30%, transparent 80%);
    -webkit-mask-image: radial-gradient(120% 100% at 30% 20%, #000 30%, transparent 80%);
}
.auth-aside__brand { display: inline-flex; align-items: center; gap: 11px; font-weight: 600; font-size: 19px; letter-spacing: -.02em; }
.auth-aside__brand .brand-mark { box-shadow: 0 6px 20px -6px rgba(0,0,0,.5); }
.auth-aside__headline {
    font-size: clamp(28px, 3.4vw, 42px);
    line-height: 1.08;
    letter-spacing: -0.03em;
    font-weight: 600;
    margin: 0 0 18px;
    max-width: 16ch;
}
.auth-aside__lead { color: rgba(232,236,255,.78); font-size: 15.5px; line-height: 1.6; max-width: 42ch; margin: 0; }
.auth-aside__points { list-style: none; margin: 26px 0 0; padding: 0; display: flex; flex-direction: column; gap: 13px; }
.auth-aside__points li { display: flex; align-items: center; gap: 12px; color: rgba(235,239,255,.92); font-size: 14.5px; }
.auth-aside__points svg { flex: none; color: #a9bbff; }
.auth-aside__foot { font-size: 12.5px; color: rgba(214,221,255,.6); }

/* Right: form panel */
.auth-main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    background: var(--bg);
}
.auth-card {
    width: 100%;
    max-width: 392px;
}
.auth-topbar { display: flex; justify-content: flex-end; margin-bottom: 18px; }
.auth-logo {   /* compact brand, shown when aside hidden / mobile */
    display: none;
    align-items: center; gap: 10px;
    font-size: 20px; font-weight: 600; letter-spacing: -.02em;
    color: var(--text); margin-bottom: 22px;
}
.auth-title { font-size: 25px; margin: 0 0 6px; font-weight: 600; letter-spacing: -.025em; }
.auth-sub { color: var(--text-muted); font-size: 14.5px; margin: 0 0 26px; }
.auth-form .form-field { margin-bottom: 16px; }
.auth-form button[type="submit"] { margin-top: 8px; }
.auth-links { margin-top: 22px; text-align: center; font-size: 14px; color: var(--text-muted); }
.auth-links a { font-weight: 500; }
.auth-divider {
    display: flex; align-items: center; gap: 14px;
    margin: 24px 0; color: var(--text-subtle); font-size: 12px; text-transform: uppercase; letter-spacing: .12em;
}
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-footer { font-size: 12px; color: var(--text-subtle); margin-top: 24px; text-align: center; }

/* ----------------------------------------------------------------------------
   3b. App shell
   ---------------------------------------------------------------------------- */
.app-body { min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); }

.app-header {
    position: sticky; top: 0; z-index: 40;
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    backdrop-filter: saturate(140%) blur(14px);
    -webkit-backdrop-filter: saturate(140%) blur(14px);
    border-bottom: 1px solid var(--border);
}
@supports not (backdrop-filter: blur(1px)) { .app-header { background: var(--surface); } }
.app-header__inner {
    max-width: var(--maxw); margin: 0 auto; padding: 0 24px;
    height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.app-logo { display: inline-flex; align-items: center; gap: 11px; font-weight: 600; font-size: 17px; letter-spacing: -.02em; color: var(--text); }
.app-logo:hover { color: var(--text); }
.app-header__right { display: flex; align-items: center; gap: 10px; }

/* brand mark (shared) */
.brand-mark {
    width: 30px; height: 30px; border-radius: 9px; flex: none;
    display: inline-grid; place-items: center;
    background: linear-gradient(150deg, var(--brand) 0%, var(--brand-active) 100%);
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.brand-mark svg { width: 17px; height: 17px; }

/* user chip */
.app-user {
    display: inline-flex; align-items: center; gap: 9px;
    padding: 5px 6px 5px 11px; border-radius: var(--radius-pill);
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text); font-size: 13.5px; font-weight: 500; max-width: 220px;
}
.app-user__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.avatar {
    width: 26px; height: 26px; border-radius: 50%; flex: none;
    display: inline-grid; place-items: center;
    font-size: 11.5px; font-weight: 600; letter-spacing: .02em;
    background: var(--brand-soft); color: var(--brand-text);
}
.logout-form { margin: 0; display: inline-flex; }

/* theme toggle */
.theme-toggle {
    width: 38px; height: 38px; border-radius: 10px; flex: none;
    display: inline-grid; place-items: center; cursor: pointer;
    border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
    transition: transform .16s var(--ease-out), background-color .16s ease, color .16s ease, border-color .16s ease;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
    :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}
.theme-toggle--ghost { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.18); color: #e9ecf7; }
.theme-toggle--ghost:hover { background: rgba(255,255,255,.16); color: #fff; }

.app-shell { display: flex; flex: 1; max-width: var(--maxw); width: 100%; margin: 0 auto; padding: 0 24px; gap: 28px; }

.app-sidebar { width: var(--sidebar-w); flex: none; padding: 26px 0 26px; }
.sidebar-sticky { position: sticky; top: 86px; }
.sidebar-group { margin-bottom: 22px; }
.sidebar-group__label {
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em;
    color: var(--text-subtle); padding: 0 12px; margin-bottom: 8px;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 3px; }
.sidebar-link {
    position: relative;
    display: flex; align-items: center; gap: 11px;
    padding: 9px 12px; border-radius: 10px; color: var(--text-muted);
    font-size: 14px; font-weight: 500;
    transition: background-color .15s var(--ease-out), color .15s var(--ease-out);
}
.sidebar-link svg { width: 18px; height: 18px; flex: none; color: var(--text-subtle); transition: color .15s ease; }
.sidebar-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar-link:hover svg { color: var(--text-muted); }
.sidebar-link.is-active { background: var(--brand-soft); color: var(--brand-text); font-weight: 600; }
.sidebar-link.is-active svg { color: var(--brand-text); }
.sidebar-link.is-active::before {
    content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
    width: 3px; height: 17px; border-radius: 0 3px 3px 0; background: var(--brand);
}
.sidebar-link:focus-visible { outline: none; box-shadow: var(--ring); }

.app-content { flex: 1; min-width: 0; padding: 30px 0 48px; }
.app-footer {
    border-top: 1px solid var(--border); color: var(--text-subtle); font-size: 12.5px;
    padding: 18px 24px; text-align: center;
}

/* page header */
.page-title { font-size: 26px; margin: 0 0 22px; font-weight: 600; letter-spacing: -.025em; }
.page-sub { color: var(--text-muted); font-size: 14.5px; margin: -16px 0 26px; max-width: 72ch; line-height: 1.5; }

/* ----------------------------------------------------------------------------
   4. Components
   ---------------------------------------------------------------------------- */

/* Cards */
.card,
.card-form,
.money-widget,
.ticket-meta,
.ticket-msg,
.metric,
.info-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.card { padding: 22px; box-shadow: var(--shadow-sm); }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
    font-family: inherit; font-size: 14px; font-weight: 600; letter-spacing: -.01em;
    cursor: pointer; white-space: nowrap; user-select: none;
    background: var(--surface-2); color: var(--text);
    transition: transform .16s var(--ease-out), background-color .16s ease, border-color .16s ease, box-shadow .16s ease, color .16s ease;
}
.btn svg { width: 17px; height: 17px; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:active { transform: scale(0.97); }
.btn[disabled], .btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }

.btn-primary { background: var(--brand); color: var(--brand-contrast); box-shadow: var(--shadow-sm); }
@media (hover: hover) { .btn-primary:hover { background: var(--brand-hover); box-shadow: var(--shadow-brand); color: #fff; text-decoration: none; } }
.btn-primary:active { background: var(--brand-active); }

.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
@media (hover: hover) { .btn-secondary:hover { border-color: var(--brand-line); background: var(--surface-2); color: var(--text); text-decoration: none; } }

.btn-ghost { background: transparent; color: var(--text-muted); }
@media (hover: hover) { .btn-ghost:hover { background: var(--surface-2); color: var(--text); } }

.btn-danger { background: var(--neg); color: #fff; }
@media (hover: hover) { .btn-danger:hover { background: color-mix(in srgb, var(--neg) 86%, #000); color:#fff; text-decoration:none; } }

.btn-link {
    background: none; border: none; color: var(--brand-text); padding: 6px 8px;
    font-weight: 600; display: inline-flex; align-items: center; gap: 6px;
}
.btn-link:hover { color: var(--brand-hover); text-decoration: none; }
.btn-sm { padding: 7px 13px; font-size: 13px; border-radius: 9px; }

/* Forms */
.form-field { display: block; margin-bottom: 16px; }
.form-field > span {
    display: block; margin-bottom: 7px; font-size: 13px; font-weight: 500; color: var(--text);
}
.form-field input,
.form-field select,
.form-field textarea {
    width: 100%; padding: 11px 13px;
    border: 1px solid var(--border-strong); border-radius: 10px;
    font: inherit; font-size: 14.5px; color: var(--text);
    background: var(--surface);
    transition: border-color .15s var(--ease-out), box-shadow .15s var(--ease-out), background-color .15s ease;
    -webkit-appearance: none; appearance: none;
}
.form-field textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
.form-field input::placeholder,
.form-field textarea::placeholder { color: var(--text-subtle); }
.form-field input:hover,
.form-field select:hover,
.form-field textarea:hover { border-color: var(--text-subtle); }
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    outline: none; border-color: var(--brand); box-shadow: var(--ring); background: var(--surface);
}
.form-field input[readonly] {
    background: var(--surface-inset); color: var(--text-muted); border-color: var(--border); cursor: default;
}
.form-field input[readonly]:hover { border-color: var(--border); }
.form-field input[aria-invalid="true"],
.form-field input.has-error { border-color: var(--neg); }
.form-field input[aria-invalid="true"]:focus { box-shadow: var(--ring-danger); }

/* select with custom arrow */
.form-field select {
    background-image: var(--select-arrow);
    background-repeat: no-repeat;
    background-position: right 13px center;
    padding-right: 38px;
    cursor: pointer;
}

.field-error { color: var(--neg-text); display: block; margin-top: 6px; font-size: 12.5px; font-weight: 500; }
.form-error {
    display: flex; align-items: flex-start; gap: 10px;
    background: var(--neg-soft); border: 1px solid color-mix(in srgb, var(--neg) 34%, transparent); color: var(--neg-text);
    padding: 12px 14px; border-radius: 10px; margin-bottom: 18px; font-size: 14px; line-height: 1.45;
}
.form-error::before {
    content: ""; flex: none; width: 18px; height: 18px; margin-top: 1px;
    background: currentColor;
    -webkit-mask: var(--icon-alert) center / contain no-repeat; mask: var(--icon-alert) center / contain no-repeat;
}
.form-actions { display: flex; align-items: center; gap: 14px; margin-top: 20px; flex-wrap: wrap; }
.form-status { font-size: 13.5px; font-weight: 500; transition: color .15s ease; }
.form-status.is-error { color: var(--neg-text); }
.form-status.is-success { color: var(--pos-text); }
.hint { color: var(--text-muted); font-size: 12.5px; display: block; margin-top: 6px; line-height: 1.45; }

/* Flash */
.flash {
    display: flex; align-items: flex-start; gap: 11px;
    padding: 12px 15px; border-radius: 11px; margin-bottom: 20px; font-size: 14px; line-height: 1.45;
    border: 1px solid var(--border);
}
.flash::before {
    content: ""; flex: none; width: 18px; height: 18px; margin-top: 1px; background: currentColor;
    -webkit-mask: var(--icon-info) center / contain no-repeat; mask: var(--icon-info) center / contain no-repeat;
}
.flash-success { background: var(--pos-soft); color: var(--pos-text); border-color: color-mix(in srgb, var(--pos) 32%, transparent); }
.flash-success::before { -webkit-mask: var(--icon-check) center / contain no-repeat; mask: var(--icon-check) center / contain no-repeat; }
.flash-error   { background: var(--neg-soft); color: var(--neg-text); border-color: color-mix(in srgb, var(--neg) 32%, transparent); }
.flash-error::before { -webkit-mask: var(--icon-alert) center / contain no-repeat; mask: var(--icon-alert) center / contain no-repeat; }
.flash-info    { background: var(--info-soft); color: var(--brand-text); border-color: var(--brand-line); }

/* Hero balance (money widget) */
.money-widget {
    position: relative; overflow: hidden;
    padding: 24px 26px; box-shadow: var(--shadow-md);
    background-image: var(--glow);
    max-width: 520px;
}
.money-widget__title {
    color: var(--text-muted); font-size: 13px; font-weight: 500;
    display: flex; align-items: center; gap: 8px;
}
.money-widget__title .badge { margin-left: auto; }
.money-widget__balance {
    font-size: 38px; font-weight: 600; letter-spacing: -.03em; margin: 10px 0 14px;
    line-height: 1; color: var(--text);
}
.money-widget__sub { font-size: 13.5px; color: var(--text-muted); display: flex; gap: 14px; flex-wrap: wrap; }
.money-widget__sub strong { color: var(--text); font-weight: 600; }
.money-widget__sub .dot { display: none; }
.money-widget__stat { display: inline-flex; flex-direction: column; gap: 1px; }
.money-widget__stat .lbl { font-size: 11.5px; color: var(--text-subtle); }
.money-widget__number {
    font-family: var(--font-mono); font-size: 12px; color: var(--text-muted);
    margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border);
    letter-spacing: .01em;
}

/* Metric cards (dashboard) */
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 8px; }
.metric { padding: 18px 20px; box-shadow: var(--shadow-sm); transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out), border-color .18s ease; }
@media (hover: hover) { .metric:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); } }
.metric__label { font-size: 12.5px; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.metric__label svg { width: 15px; height: 15px; color: var(--text-subtle); }
.metric__value { font-size: 24px; font-weight: 600; letter-spacing: -.02em; margin-top: 8px; }
.metric__delta { font-size: 12.5px; font-weight: 600; margin-top: 4px; }
.metric__delta.is-pos { color: var(--pos-text); }
.metric__delta.is-neg { color: var(--neg-text); }

/* Quick actions (dashboard) */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.quick-card {
    display: flex; align-items: center; gap: 13px;
    padding: 16px 18px; border-radius: var(--radius);
    background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
    color: var(--text);
    transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out), border-color .18s ease;
}
.quick-card:hover { text-decoration: none; color: var(--text); }
@media (hover: hover) { .quick-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--brand-line); } }
.quick-card:active { transform: scale(0.985); }
.quick-card:focus-visible { outline: none; box-shadow: var(--ring); }
.quick-card__icon {
    width: 40px; height: 40px; border-radius: 11px; flex: none; display: grid; place-items: center;
    background: var(--brand-soft); color: var(--brand-text);
}
.quick-card__icon svg { width: 20px; height: 20px; }
.quick-card__t { font-weight: 600; font-size: 14.5px; }
.quick-card__d { font-size: 12.5px; color: var(--text-muted); margin-top: 1px; }
.quick-card__arrow { margin-left: auto; color: var(--text-subtle); transition: transform .18s var(--ease-out), color .18s ease; }
@media (hover: hover) { .quick-card:hover .quick-card__arrow { transform: translateX(3px); color: var(--brand-text); } }

/* Sections */
.dash-section { margin-bottom: 34px; }
.dash-section:last-child { margin-bottom: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 14px; }
.section-title { font-size: 16px; margin: 0 0 14px; font-weight: 600; letter-spacing: -.01em; }
.section-head .section-title { margin: 0; }
.action-row { display: flex; gap: 10px; margin: 18px 0; flex-wrap: wrap; }
.dash-more { margin-top: 14px; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.table-wrap .data-table { border: none; box-shadow: none; border-radius: 0; }
.data-table {
    width: 100%; border-collapse: collapse; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm);
}
.data-table thead th {
    text-align: left; padding: 11px 16px; font-size: 11.5px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .06em; color: var(--text-subtle);
    background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: 14px; color: var(--text); vertical-align: middle; }
.data-table tbody tr { transition: background-color .12s ease; }
@media (hover: hover) { .data-table tbody tr:hover { background: var(--surface-2); } }
.data-table tr:last-child td { border-bottom: none; }
.txn-amount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.txn-amount.is-pos { color: var(--pos-text); }
.txn-amount.is-neg { color: var(--neg-text); }
.txn-status { white-space: nowrap; }
.txn-desc { color: var(--text-muted); overflow-wrap: anywhere; }
.cell-mono { font-family: var(--font-mono); font-size: 13px; }
.cell-right { text-align: right; }

/* Badges / status pills */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px 3px 8px; border-radius: var(--radius-pill);
    font-size: 12px; font-weight: 600; line-height: 1.5;
    background: var(--surface-3); color: var(--text-muted);
    border: 1px solid transparent; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge--success { background: var(--pos-soft); color: var(--pos-text); }
.badge--pending { background: var(--warn-soft); color: var(--warn); }
.badge--danger  { background: var(--neg-soft); color: var(--neg-text); }
.badge--info    { background: var(--brand-soft); color: var(--brand-text); }
.badge--neutral { background: var(--surface-3); color: var(--text-muted); }

/* Card form */
.card-form { padding: 24px; box-shadow: var(--shadow-sm); max-width: 560px; }
.card-form .form-field:last-of-type { margin-bottom: 0; }

/* Pagination */
.pagination { display: flex; align-items: center; gap: 10px; margin-top: 20px; }
.pagination__link {
    display: inline-grid; place-items: center; min-width: 36px; height: 36px; padding: 0 10px;
    border: 1px solid var(--border-strong); border-radius: 10px; color: var(--text); font-weight: 600;
    transition: background-color .14s ease, border-color .14s ease, transform .14s var(--ease-out);
}
.pagination__link:hover { background: var(--surface-2); border-color: var(--brand-line); text-decoration: none; }
.pagination__link:active { transform: scale(0.95); }
.pagination__link.is-disabled { color: var(--text-subtle); pointer-events: none; opacity: .5; }
.pagination__info { font-size: 13.5px; color: var(--text-muted); }

/* Tickets */
.ticket-meta { padding: 16px 18px; margin-bottom: 20px; box-shadow: var(--shadow-sm); display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 10px 24px; }
.ticket-meta > div { font-size: 14px; }
.ticket-meta strong { color: var(--text-subtle); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; display: block; margin-bottom: 2px; }
.ticket-thread { display: flex; flex-direction: column; gap: 14px; margin-bottom: 24px; }
.ticket-msg { padding: 14px 16px; box-shadow: var(--shadow-sm); border-left: 3px solid var(--border-strong); }
.ticket-msg--user { border-left-color: var(--brand); }
.ticket-msg--manager, .ticket-msg--superadmin, .ticket-msg--agent, .ticket-msg--support { border-left-color: var(--pos); background: var(--surface-2); }
.ticket-msg header { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--text-subtle); margin-bottom: 8px; }
.ticket-msg header span { font-weight: 600; color: var(--text-muted); text-transform: capitalize; }
.ticket-msg p { margin: 0; font-size: 14px; line-height: 1.55; }

/* Key-value */
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 12px 20px; font-size: 14px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; font-weight: 500; }

/* Info box */
.info-box { padding: 14px 16px; margin-bottom: 20px; font-size: 14px; background: var(--info-soft); border-color: var(--brand-line); color: var(--text); line-height: 1.5; }
.info-box p { margin: 0; }

/* Error trace */
.error-trace {
    background: var(--surface-inset); color: var(--text-muted); padding: 14px; border-radius: 10px;
    border: 1px solid var(--border); overflow: auto; font-family: var(--font-mono); font-size: 12px; line-height: 1.5;
}

/* Filter bar */
.filter-bar { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.filter-bar .form-field { flex: 1 1 200px; margin-bottom: 0; }
.filter-bar .form-field > span { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-subtle); }

/* Empty state */
.empty-state {
    text-align: center; padding: 44px 24px; border: 1px dashed var(--border-strong); border-radius: var(--radius);
    background: var(--surface); color: var(--text-muted);
}
.empty-state__icon {
    width: 46px; height: 46px; border-radius: 13px; margin: 0 auto 14px; display: grid; place-items: center;
    background: var(--brand-soft); color: var(--brand-text);
}
.empty-state__icon svg { width: 23px; height: 23px; }
.empty-state h3 { margin: 0 0 6px; font-size: 16px; color: var(--text); }
.empty-state p { margin: 0 0 18px; font-size: 14px; }

/* Utilities */
.muted { color: var(--text-muted); }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }

/* Error pages */
.error-page { text-align: center; padding: 24px 0; }
.error-page__code {
    font-size: 72px; font-weight: 600; letter-spacing: -.04em; line-height: 1;
    background: linear-gradient(160deg, var(--brand) 0%, var(--brand-active) 90%);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
    margin-bottom: 12px;
}
.error-page h1 { font-size: 22px; margin: 0 0 10px; }
.error-page p { color: var(--text-muted); margin: 0 0 24px; font-size: 15px; }

/* icon masks for ::before glyphs */
:root {
    --icon-info:  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='16' x2='12' y2='12'/%3E%3Cline x1='12' y1='8' x2='12.01' y2='8'/%3E%3C/svg%3E");
    --icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21.5 5.5 9 18 3.5 12.5'/%3E%3C/svg%3E");
    --icon-alert: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.3 3.3 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.3a2 2 0 0 0-3.4 0z'/%3E%3Cline x1='12' y1='9' x2='12' y2='13'/%3E%3Cline x1='12' y1='17' x2='12.01' y2='17'/%3E%3C/svg%3E");
}

/* ----------------------------------------------------------------------------
   5. Motion — page-load stagger + reveal
   ---------------------------------------------------------------------------- */
@keyframes fb-rise {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.app-content > *,
.auth-card > * {
    animation: fb-rise .5s var(--ease-out) both;
}
.app-content > *:nth-child(1) { animation-delay: .02s; }
.app-content > *:nth-child(2) { animation-delay: .07s; }
.app-content > *:nth-child(3) { animation-delay: .12s; }
.app-content > *:nth-child(4) { animation-delay: .17s; }
.app-content > *:nth-child(5) { animation-delay: .22s; }
.app-content > *:nth-child(n+6) { animation-delay: .26s; }
.auth-card > *:nth-child(1) { animation-delay: .02s; }
.auth-card > *:nth-child(2) { animation-delay: .07s; }
.auth-card > *:nth-child(3) { animation-delay: .12s; }
.auth-card > *:nth-child(4) { animation-delay: .17s; }
.auth-card > *:nth-child(n+5) { animation-delay: .2s; }

.auth-aside > * { animation: fb-rise .6s var(--ease-out) both; }
.auth-aside > *:nth-child(2) { animation-delay: .08s; }
.auth-aside > *:nth-child(3) { animation-delay: .14s; }

/* Respect reduced motion: keep opacity, drop movement (Emil) */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
    .app-content > *, .auth-card > *, .auth-aside > * { animation: fb-fade .3s ease both; }
    @keyframes fb-fade { from { opacity: 0; } to { opacity: 1; } }
}

/* ----------------------------------------------------------------------------
   6. Responsive
   ---------------------------------------------------------------------------- */
@media (max-width: 900px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
    .auth-logo { display: inline-flex; }
    .auth-main { padding: 32px 20px; }
}

@media (max-width: 860px) {
    .app-shell { flex-direction: column; gap: 0; padding: 0; }
    .app-sidebar {
        width: 100%; padding: 10px 16px;
        border-bottom: 1px solid var(--border); background: var(--surface);
        position: sticky; top: 62px; z-index: 30;
        overflow-x: auto;
    }
    .sidebar-sticky { position: static; }
    .sidebar-group { margin-bottom: 0; }
    .sidebar-group__label { display: none; }
    .sidebar-nav { flex-direction: row; gap: 4px; }
    .sidebar-link { white-space: nowrap; padding: 8px 13px; }
    .sidebar-link.is-active::before { display: none; }
    .app-content { padding: 22px 16px 40px; }
    .app-header__inner { padding: 0 16px; }
    .app-user__name { display: none; }
    .app-user { padding: 5px; }
}

@media (max-width: 560px) {
    .money-widget__balance { font-size: 32px; }
    .page-title { font-size: 22px; }
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .kv { grid-template-columns: 1fr; gap: 2px 0; }
    .kv dt { margin-top: 10px; }
    .form-actions { flex-direction: column; align-items: stretch; }
    .form-actions .btn { width: 100%; }
}
