/* ==========================================================================
   OnBroker Afiliados — "Extrato" design system
   Cool paper, green-black ink, deep-green band for the neon logo, one green
   for money and primary actions. Archivo variable: condensed numerals.
   ========================================================================== */

@font-face {
    font-family: "Archivo";
    src: url("../fonts/archivo-variable.woff2") format("woff2");
    font-weight: 100 900;
    font-stretch: 62% 125%;
    font-style: normal;
    font-display: swap;
}

:root {
    /*
     * Palette C "Contraste" — light and dark in one place via light-dark().
     * The scheme follows the system by default; data-theme="light|dark" on <html>
     * (set by app.js from localStorage) forces one. Deep-green surfaces (band,
     * brand panel, link card) keep the same colors in both schemes.
     */
    color-scheme: light dark;
    /* Dark scheme: restrained greens — brand green for the primary action, a soft green
       for money, near-neutral surfaces; the neon stays only on the deep-green band. */
    --paper: light-dark(#EEF2EE, #0E1211);
    --paper-2: light-dark(#FFFFFF, #151B19);
    --ink: light-dark(#071410, #E9EEEB);
    --ink-2: light-dark(#2E3F37, #C7D0CB);
    --muted: light-dark(#4F5F57, #98A49E);
    --faint: light-dark(#75857D, #737E79);
    --rule: light-dark(#D3DCD6, #222A27);
    --rule-2: light-dark(#C9D4CE, #2A332F);
    --rule-3: light-dark(#AEBDB5, #3A453F);
    --mint: light-dark(#D2EADD, #1B2A24);
    --mint-2: #BFE5D0;
    --tint: light-dark(#E4F1E9, #152420);
    --deep: #0B3B2C;
    --deep-2: #0F4A38;
    --deep-3: #1F5A46;
    --on-deep: #F4F6F3;
    --primary: light-dark(#0B3B2C, #00A667);
    --primary-hover: light-dark(#0F4A38, #00B873);
    --primary-ink: light-dark(#FFFFFF, #04140D);
    --green: light-dark(#0F6B47, #5DC48F);
    --green-ink: light-dark(#0F6B47, #5DC48F);
    --neon: #00F584;
    --neon-btn: light-dark(#00F584, #00C97A);
    --link: light-dark(#0B3B2C, #5DC48F);
    --link-hover: light-dark(#0F6B47, #8ADBB0);
    --danger: light-dark(#B4531F, #F0956A);
    --danger-bg: light-dark(#FBEDE6, #3A2318);
    --avatar-bg: #D2EADD;   /* always on the deep band, which does not change with the scheme */
    --avatar-ink: #0B3B2C;
    --seg-on-bg: light-dark(#071410, #334640);
    --seg-on-ink: light-dark(#EEF2EE, #E9EEEB);
    --focus-ring: light-dark(rgba(15, 107, 71, 0.18), rgba(93, 196, 143, 0.28));
    --shadow-menu: light-dark(0 12px 32px rgba(15, 31, 25, 0.16), 0 12px 32px rgba(0, 0, 0, 0.55));
    --font: "Archivo", "Helvetica Neue", Arial, sans-serif;
    --radius: 10px;
    --radius-lg: 12px;
    --band: 64px;
    --rail: 224px;
    --tabs: 64px;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* ---- base ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); }
img, svg { display: block; max-width: 100%; }
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.num {
    font-variant-numeric: tabular-nums lining-nums;
    font-stretch: 78%;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.num--wide { font-stretch: 92%; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---- buttons ------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 22px;
    border-radius: var(--radius);
    font-weight: 700;
    font-size: 15px;
    line-height: 1;
    transition: background-color .15s ease, color .15s ease, transform .15s ease;
    white-space: nowrap;
}
.btn--primary { background: var(--primary); color: var(--primary-ink); }
.btn--primary:hover { background: var(--primary-hover); color: var(--primary-ink); }
.btn--neon { background: var(--neon-btn); color: #04140D; }
.btn--neon:hover { filter: brightness(1.08); color: #04140D; }
.btn--ghost { background: transparent; color: var(--ink); border: 1px solid var(--rule-2); }
.btn--ghost:hover { border-color: var(--ink); color: var(--ink); }
.btn--block { width: 100%; }
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn:active { transform: translateY(1px); }

/* ---- forms --------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 8px; }
.label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input-wrap { position: relative; }
.input {
    width: 100%;
    height: 50px;
    padding: 0 14px;
    border: 1px solid var(--rule-2);
    border-radius: var(--radius);
    background: var(--paper-2);
    color: var(--ink);
    font-size: 15px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.input::placeholder { color: var(--faint); }
.input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--focus-ring); }
.input.is-invalid { border-color: var(--danger); }
.input--code { font-size: 22px; letter-spacing: .3em; font-variant-numeric: tabular-nums; text-align: center; }
.input-wrap .input { padding-right: 48px; }
.toggle-eye {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    border-radius: 8px;
}
.toggle-eye:hover { color: var(--ink); background: var(--paper); }
.toggle-eye svg { width: 22px; height: 22px; }
.field__error { font-size: 13px; color: var(--danger); }
.form-status { display: flex; flex-direction: column; gap: 10px; }
.form-msg {
    min-height: 20px;
    font-size: 14px;
    color: var(--danger);
    text-align: center;
    margin: 0;
    font-weight: 500;
}
.form-msg.is-success { color: var(--green-ink); }
.spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--rule-2);
    border-top-color: var(--green-ink);
    border-radius: 50%;
    animation: spin .9s linear infinite;
    margin: 0 auto;
}
.spinner.is-active { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.link { color: var(--link); font-weight: 600; }
.link:hover { color: var(--link-hover); }
.link--small { font-size: 14px; }
.link.is-disabled { opacity: .5; pointer-events: none; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.legal { font-size: 12px; color: var(--muted); line-height: 1.5; padding-top: 12px; border-top: 1px solid var(--rule); }
.legal a { color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px; }

/* ---- auth layout --------------------------------------------------------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 44%) minmax(0, 1fr); }
.auth__brand {
    background: var(--deep);
    color: var(--on-deep);
    padding: 40px 48px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 32px;
}
.auth__logo { height: 44px; width: auto; align-self: flex-start; flex: none; }
.auth__claim { display: flex; flex-direction: column; gap: 16px; max-width: 440px; }
.auth__headline { font-size: clamp(30px, 3vw, 44px); line-height: 1.1; font-weight: 600; font-stretch: 90%; letter-spacing: -0.015em; text-wrap: pretty; }
.auth__sub { font-size: 16px; color: var(--mint-2); }
.auth__facts { display: flex; flex-wrap: wrap; gap: 12px 28px; font-size: 13px; color: #8CC9A9; }
.auth__panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth__form { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 22px; }
.auth__title { font-size: 30px; font-weight: 600; letter-spacing: -0.01em; }
.auth__lead { font-size: 15px; color: var(--muted); }
.auth__lead strong { color: var(--ink); font-weight: 600; }
.auth__actions { display: flex; flex-direction: column; gap: 14px; }

@media (max-width: 899px) {
    .auth { grid-template-columns: minmax(0, 1fr); }
    .auth__brand { padding: 20px 20px 24px; gap: 18px; justify-content: flex-start; }
    .auth__logo { height: 36px; }
    .auth__headline { font-size: 22px; }
    .auth__sub, .auth__facts { display: none; }
    .auth__panel { align-items: flex-start; padding: 28px 20px 40px; }
}

/* ---- app shell ----------------------------------------------------------- */
.band {
    position: sticky;
    top: 0;
    z-index: 40;
    height: var(--band);
    background: var(--deep);
    color: var(--on-deep);
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 0 24px;
}
.band__logo { height: 32px; width: auto; flex: none; }
.band > a { display: inline-flex; align-items: center; flex: none; }
.band__sep { width: 1px; height: 22px; background: var(--deep-3); }
.band__title { color: var(--mint-2); font-size: 14px; font-weight: 500; }
.band__spacer { flex: 1; }
.band__balance { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.band__balance-label { color: var(--mint-2); font-size: 12px; }
.band__balance-value { color: var(--neon); font-size: 15px; }
.user-menu { position: relative; }
.user-menu__btn { display: inline-flex; align-items: center; gap: 10px; padding: 4px; border-radius: 999px; color: var(--on-deep); }
.user-menu__btn:hover { background: var(--deep-2); }
.avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--avatar-bg); color: var(--avatar-ink);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; object-fit: cover; flex: none;
}
.user-menu__name { font-size: 14px; font-weight: 600; }
.user-menu__chev { color: var(--mint-2); }
.menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 220px;
    background: var(--paper-2);
    color: var(--ink);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-menu);
    padding: 6px;
    display: none;
    z-index: 50;
}
.menu.is-open { display: block; }
.menu__head { padding: 10px 12px 8px; border-bottom: 1px solid var(--rule); margin-bottom: 6px; }
.menu__head strong { display: block; font-size: 14px; }
.menu__head span { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.menu__item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--ink); }
.menu__item:hover { background: var(--paper); color: var(--ink); }
.menu__item svg { width: 18px; height: 18px; color: var(--muted); }
.menu__theme { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 8px; border-top: 1px solid var(--rule); margin-top: 6px; }
.menu__theme-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.seg--small { display: flex; }
.seg--small .seg__btn { flex: 1; min-height: 32px; padding: 4px 10px; font-size: 12px; }
@media (pointer: coarse) { .seg--small .seg__btn { min-height: 40px; } }

.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: calc(100vh - var(--band)); }
.rail { border-right: 1px solid var(--rule); padding: 24px 16px; display: flex; flex-direction: column; gap: 4px; }
.rail__spacer { flex: 1; }
.nav-item { display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 14px; border-radius: 8px; color: var(--ink-2); font-weight: 500; }
.nav-item svg { width: 20px; height: 20px; flex: none; }
.nav-item:hover { background: var(--paper-2); color: var(--ink); }
.nav-item.is-active { background: var(--mint); color: var(--ink); font-weight: 600; }
.nav-item--quiet { color: var(--muted); }
.content { padding: 32px 48px 48px 40px; display: flex; flex-direction: column; gap: 28px; min-width: 0; }
.tabs { display: none; }

@media (max-width: 1023px) {
    .shell { grid-template-columns: minmax(0, 1fr); }
    .rail { display: none; }
    .content { padding: 20px 20px calc(var(--tabs) + 28px); gap: 22px; }
    .band { padding: 0 16px; gap: 12px; }
    .band__title, .band__sep, .user-menu__name, .user-menu__chev { display: none; }
    .tabs {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
        height: var(--tabs);
        background: var(--paper-2);
        border-top: 1px solid var(--rule);
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        padding-bottom: env(safe-area-inset-bottom);
    }
    .tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; font-weight: 500; color: var(--muted); min-height: 44px; }
    .tab svg { width: 22px; height: 22px; }
    .tab.is-active { color: var(--green-ink); font-weight: 600; }
}

/* ---- page pieces --------------------------------------------------------- */
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; }
.card { background: var(--paper-2); border: 1px solid var(--rule-2); border-radius: var(--radius-lg); padding: 20px 24px; }
.card--deep { background: var(--deep); border-color: var(--deep); color: var(--on-deep); }
.card__title { font-size: 16px; font-weight: 600; }
.card__sub { font-size: 13px; color: var(--muted); }
.card--deep .card__sub { color: var(--mint-2); }
.card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

.statement { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; padding-bottom: 24px; border-bottom: 1px solid var(--rule-3); flex-wrap: wrap; }
.statement__main { display: flex; flex-direction: column; gap: 4px; }
.statement__label { font-size: 14px; color: var(--muted); font-weight: 500; }
.statement__value { font-size: clamp(40px, 5vw, 64px); line-height: 1; }
.statement__aside { display: flex; gap: 40px; align-items: flex-end; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat__label { font-size: 13px; color: var(--muted); }
.stat__value { font-size: 22px; }
.stat__value--green { color: var(--green-ink); }

.funnel-section { display: flex; flex-direction: column; gap: 12px; }
.funnel { display: flex; align-items: stretch; background: var(--paper-2); border: 1px solid var(--rule-2); border-radius: var(--radius-lg); padding: 20px 24px; gap: 0; overflow: hidden; }
.funnel__cell { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.funnel__cell--wide { flex: 1.4; }
.funnel__cell--result { flex: 1.2; margin: -20px -24px -20px 0; padding: 20px 24px; background: var(--tint); border-left: 1px solid var(--rule-2); }
.funnel__label { font-size: 13px; color: var(--muted); font-weight: 500; display: flex; flex-direction: column; gap: 2px; }
.funnel__hint { display: none; font-size: 12px; font-weight: 400; color: var(--faint); }
.funnel__value { font-size: 34px; line-height: 1; margin-top: auto; }
.funnel__cell--result .funnel__label, .funnel__cell--result .funnel__value { color: var(--green-ink); }
.funnel__rate { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); font-size: 12px; font-weight: 500; width: 76px; flex: none; }
.funnel__rate svg { width: 28px; height: 12px; color: #9BB0A6; }

.grid-12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 24px; }
.span-8 { grid-column: span 8; }
.span-4 { grid-column: span 4; }
.stack { display: flex; flex-direction: column; gap: 24px; }
.chart-card { display: flex; flex-direction: column; gap: 14px; }
.chart-box { position: relative; height: 260px; }
.seg { display: inline-flex; border: 1px solid var(--rule-2); border-radius: 8px; overflow: hidden; }
.seg__btn { padding: 8px 14px; font-size: 13px; font-weight: 500; color: var(--ink-2); background: var(--paper-2); min-height: 40px; }
@media (pointer: coarse) { .seg__btn { min-height: 44px; } }
.seg__btn + .seg__btn { border-left: 1px solid var(--rule-2); }
.seg__btn:hover { background: var(--paper); }
.seg__btn.is-on { background: var(--seg-on-bg); color: var(--seg-on-ink); }
.stats-row { display: flex; gap: 32px; padding-top: 12px; border-top: 1px solid var(--rule); font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.stats-row strong { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.link-box { display: flex; align-items: center; gap: 8px; background: var(--deep-2); border: 1px solid var(--deep-3); border-radius: var(--radius); padding: 12px; font-size: 14px; color: var(--on-deep); min-width: 0; }
/* One click selects the whole URL, for whoever copies by hand instead of using the button. */
.link-box span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; user-select: all; -webkit-user-select: all; cursor: text; }
.contact { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--rule); color: var(--ink); font-size: 14px; }
.contact:hover { color: var(--green-ink); }
.contact svg { width: 20px; height: 20px; flex: none; color: var(--green-ink); }
.contact span { color: var(--muted); }

.notice { display: flex; flex-direction: column; gap: 12px; max-width: 640px; }
.notice p { color: var(--muted); }

@media (max-width: 1023px) {
    .span-8, .span-6, .span-4 { grid-column: span 12; }
    .content > .page-head { display: none; }
    .funnel { padding: 18px; }
    .funnel__value { font-size: 28px; white-space: nowrap; }
    .funnel__rate { width: 52px; }
    .funnel__rate svg { width: 22px; }
    .funnel__cell--result { padding: 18px; margin: -18px -18px -18px 0; }
}
@media (max-width: 759px) {
    .statement { flex-direction: column; align-items: stretch; gap: 20px; }
    .statement__aside { gap: 24px; }
    .statement .btn { width: 100%; }
    /* Compact ledger rows: label (+ rate hint) left, value right; the arrow cells go away. */
    .funnel { flex-direction: column; gap: 0; padding: 4px 18px; }
    .funnel__rate { display: none; }
    .funnel__cell { flex-direction: row; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--rule); }
    .funnel__cell:first-child { border-top: 0; }
    .funnel__cell--result { margin: 4px -18px -4px; padding: 14px 18px; border-left: 0; border-top: 1px solid var(--rule-2); }
    .funnel__hint { display: block; }
    .funnel__value { font-size: 26px; margin-top: 0; white-space: nowrap; }
    .chart-box { height: 200px; }
    .card { padding: 18px; }
    .stats-row { gap: 16px 24px; }
    .grid-12 { gap: 16px; }
}

/* ---- reports ------------------------------------------------------------- */
.filters { display: flex; align-items: center; gap: 14px 20px; flex-wrap: wrap; }
.filters .seg a.seg__btn { display: inline-flex; align-items: center; color: var(--ink-2); }
.filters .seg a.seg__btn.is-on { color: var(--seg-on-ink); }
.filters__range { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.filters__field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 500; color: var(--muted); }
.input--date { height: 40px; width: 152px; padding: 0 10px; font-size: 14px; font-variant-numeric: tabular-nums; }
.input--link { height: 40px; width: 200px; padding: 0 36px 0 10px; font-size: 14px; background-position: right 10px center; }
.filters .btn { min-height: 40px; padding: 0 16px; font-size: 14px; }
.filters__current { margin-left: auto; }
.filters__current strong { color: var(--ink); font-weight: 600; }

.balances { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px 32px; padding-bottom: 22px; border-bottom: 1px solid var(--rule-3); }
.balance { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.balance__value { font-size: 30px; line-height: 1; white-space: nowrap; }
.balance--main .balance__value { color: var(--green-ink); }
.balance__hint { font-size: 12px; color: var(--faint); }
.balance .link { font-size: 13px; margin-top: 2px; }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--paper-2); border: 1px solid var(--rule-2); border-radius: var(--radius-lg); overflow: hidden; }
.tile { display: flex; flex-direction: column; gap: 6px; padding: 18px 22px; min-width: 0; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.tile:nth-child(4n) { border-right: 0; }
.tile:nth-last-child(-n+4) { border-bottom: 0; }
.tile__label { font-size: 13px; color: var(--muted); font-weight: 500; }
.tile__value { font-size: 28px; line-height: 1; white-space: nowrap; margin-top: 4px; }
.tile__hint { font-size: 12px; color: var(--faint); }
.tile--result { background: var(--tint); }
.tile--result .tile__label, .tile--result .tile__value, .tile--result .tile__hint { color: var(--green-ink); }
.is-neg { color: var(--danger) !important; }
.is-pos { color: var(--green-ink); }

.legend { display: flex; gap: 8px 16px; font-size: 13px; color: var(--muted); align-items: center; flex-wrap: wrap; }
.legend__item { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.legend__swatch { width: 16px; height: 3px; border-radius: 2px; background: var(--green-ink); }
.legend__swatch--sub { background: var(--rule-3); }

.report-tabs { display: flex; flex-direction: column; gap: 14px; }
.tabbar { display: flex; align-items: flex-end; gap: 4px; border-bottom: 1px solid var(--rule-3); }
.tabbar__tab { padding: 10px 14px; min-height: 44px; font-size: 15px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabbar__tab:hover { color: var(--ink); }
.tabbar__tab.is-on { color: var(--ink); font-weight: 600; border-bottom-color: var(--green-ink); }
.tabbar__export { margin-left: auto; padding: 10px 0; white-space: nowrap; }
.panel { display: flex; flex-direction: column; gap: 12px; }
.panel__bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel__bar strong { color: var(--ink); font-weight: 600; }

.table-wrap { overflow-x: auto; background: var(--paper-2); border: 1px solid var(--rule-2); border-radius: var(--radius-lg); -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 760px; }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--rule); white-space: nowrap; vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; }
.table thead th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--paper-2); }
.table .is-num { text-align: right; font-variant-numeric: tabular-nums; }
.table .is-action { width: 48px; text-align: right; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot th { font-size: 14px; font-weight: 600; color: var(--ink); background: var(--paper); border-top: 1px solid var(--rule-2); border-bottom: 0; }
.table tfoot th small { font-size: 11px; font-weight: 400; margin-left: 2px; }
.table .is-dim { color: var(--faint); }
.table--leads tbody tr[data-lead] { cursor: pointer; }
.table--leads tbody tr[data-lead]:hover td { background: var(--paper); }
.cell-user { display: flex; flex-direction: column; gap: 1px; line-height: 1.25; }
.cell-user strong { font-weight: 600; }
.cell-user span { font-size: 12px; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--rule-2); background: var(--paper); font-size: 11px; font-weight: 600; color: var(--muted); line-height: 1.5; vertical-align: middle; }
.pill--ok { background: var(--mint); border-color: transparent; color: var(--green-ink); }
.pill--warn { background: var(--danger-bg); border-color: transparent; color: var(--danger); }
.sort { display: inline-flex; align-items: center; gap: 5px; font: inherit; color: inherit; font-weight: inherit; }
.sort::after { content: ""; width: 0; height: 0; border: 4px solid transparent; border-top-color: currentColor; margin-top: 4px; opacity: 0; }
.sort.is-desc::after { opacity: 1; }
.sort.is-asc::after { border-top-color: transparent; border-bottom-color: currentColor; margin-top: -4px; opacity: 1; }
.sort:hover { color: var(--ink); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.pager__btns { display: flex; align-items: center; gap: 8px; }
.pager__pos { font-size: 13px; color: var(--muted); min-width: 48px; text-align: center; }
.pager .btn, .subrow .btn { min-height: 36px; padding: 0 12px; font-size: 13px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--rule-2); background: var(--paper-2); font-size: 13px; font-weight: 500; color: var(--ink-2); }
.chip b { font-weight: 600; color: var(--muted); }
.chip:hover { border-color: var(--rule-3); color: var(--ink); }
.chip.is-on { background: var(--seg-on-bg); border-color: var(--seg-on-bg); color: var(--seg-on-ink); }
.chip.is-on b { color: inherit; opacity: .7; }
.search { position: relative; flex: 1; min-width: 200px; max-width: 320px; }
.search .input { height: 40px; padding-left: 36px; font-size: 14px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.expand { width: 32px; height: 32px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.expand:hover { background: var(--paper); color: var(--ink); }
.expand svg { width: 16px; height: 16px; transition: transform .15s ease; }
.expand.is-open svg { transform: rotate(180deg); }
.subrow td { background: var(--paper); padding: 12px 20px 16px; white-space: normal; border-bottom: 1px solid var(--rule-2); }
.subrow__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.subrow__head strong { color: var(--ink); font-weight: 600; }
.subtable-wrap { overflow-x: auto; }
.subtable { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--paper-2); border: 1px solid var(--rule); border-radius: var(--radius); }
.subtable th, .subtable td { padding: 7px 10px; border-bottom: 1px solid var(--rule); white-space: nowrap; text-align: left; }
.subtable thead th { font-size: 11px; font-weight: 600; color: var(--muted); }
.subtable tbody tr:last-child td { border-bottom: 0; }
.subtable .is-num { text-align: right; font-variant-numeric: tabular-nums; }
.subtable .is-dim td { color: var(--faint); }
.trend { display: inline-flex; align-items: center; gap: 5px; }
.trend svg { width: 10px; height: 10px; }
.trend--up { color: var(--green-ink); }
.trend--down { color: var(--danger); }
.empty { padding: 44px 20px; text-align: center; display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 14px; white-space: normal; }
.empty strong { color: var(--ink); font-size: 15px; font-weight: 600; }
.loading-row td { color: var(--muted); text-align: center; padding: 28px; }

@media (max-width: 1023px) {
    .balances { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 24px; }
    .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tile:nth-child(4n) { border-right: 1px solid var(--rule); }
    .tile:nth-last-child(-n+4) { border-bottom: 1px solid var(--rule); }
    .tile:nth-child(2n) { border-right: 0; }
    .tile:nth-last-child(-n+2) { border-bottom: 0; }
    .filters__current { margin-left: 0; width: 100%; }
}
@media (max-width: 759px) {
    .balance__value { font-size: 24px; }
    .tile { padding: 14px 16px; }
    .tile__value { font-size: 22px; }
    .filters__range { width: 100%; }
    .filters__field { flex: 1; }
    .input--date { width: 100%; min-width: 0; }
    .tabbar { overflow-x: auto; }
    .tabbar__tab { padding: 10px 10px; font-size: 14px; flex: none; }
    .tabbar__export { padding-left: 10px; }
    .table { font-size: 13px; }
    .table th, .table td { padding: 10px 12px; }
    .search { max-width: none; }
    .panel__bar { align-items: stretch; }
}

/* ---- referrals ----------------------------------------------------------- */
.tiles--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tiles--3 .tile { border-bottom: 0; }
.tiles--3 .tile:nth-child(4n) { border-right: 1px solid var(--rule); }
.tiles--3 .tile:nth-child(3n) { border-right: 0; }
.tiles--4 .tile { border-bottom: 0; }
.tile--button { font: inherit; text-align: left; cursor: pointer; color: inherit; transition: background-color .15s ease; }
.tile--button:hover { background: var(--paper); }
.tile--button.is-on { background: var(--tint); box-shadow: inset 0 -3px 0 var(--green-ink); }
.tile--button.is-on .tile__label, .tile--button.is-on .tile__value { color: var(--green-ink); }
.tile--button:focus-visible { outline-offset: -3px; }

.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.who__name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.who__mail { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); min-width: 0; }
.who__mail-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.avatar--sm { width: 34px; height: 34px; font-size: 12px; position: relative; }
.avatar--lead { width: 56px; height: 56px; font-size: 20px; position: relative; }
.avatar__dot { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: var(--rule-3); border: 2px solid var(--paper-2); }
.avatar--lead .avatar__dot { width: 14px; height: 14px; }
.avatar__dot--ftd { background: light-dark(#0F6B47, #00C97A); }
.copy-btn { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; color: var(--faint); flex: none; }
.copy-btn:hover { color: var(--ink); background: var(--paper); }
.copy-btn.is-done { color: var(--green-ink); }
.copy-btn svg { width: 13px; height: 13px; }
.phone { font-variant-numeric: tabular-nums; }
.wa-link { display: inline-flex; width: 28px; height: 28px; align-items: center; justify-content: center; border-radius: 8px; background: var(--mint); color: var(--green-ink); vertical-align: middle; margin-left: 4px; }
.wa-link:hover { filter: brightness(.96); color: var(--green-ink); }
.wa-link svg { width: 15px; height: 15px; }
.pill--sub { background: light-dark(#E3ECF7, #1C2A3A); border-color: transparent; color: light-dark(#2B5C9B, #8FB8EA); }
.table--referrals { font-size: 13px; }
.table--referrals th, .table--referrals td { padding: 10px 12px; }
@media (max-width: 1540px) { .table--referrals .col-bonus { display: none; } }
.table--referrals tbody tr[data-lead] { cursor: pointer; }
.table--referrals tbody tr[data-lead]:hover td, .table--referrals tbody tr[data-lead]:focus-visible td { background: var(--paper); }

.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--muted); align-self: flex-start; }
.back-link:hover { color: var(--ink); }
.back-link svg { width: 16px; height: 16px; }
.content > .back-link { margin-bottom: -12px; }
.lead-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.lead-head__text { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.lead-head__title { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lead-head__meta { display: flex; align-items: center; gap: 6px 14px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.lead-head__phone { display: inline-flex; align-items: center; }

.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--paper-2); border: 1px solid var(--rule-2); border-radius: var(--radius-lg); padding: 8px 10px; }
.month-nav__label { font-size: 16px; font-weight: 600; }
.month-nav__label::first-letter { text-transform: uppercase; }
.month-nav .btn { min-height: 36px; padding: 0 10px; }
.calendar { background: var(--paper-2); border: 1px solid var(--rule-2); border-radius: var(--radius-lg); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.calendar__head, .calendar__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.calendar__head span { text-align: center; font-size: 11px; font-weight: 600; color: var(--muted); }
.calendar__day { min-height: 74px; border-radius: 8px; padding: 6px 8px; display: flex; flex-direction: column; gap: 1px; background: var(--paper); border: 1px solid var(--rule); font: inherit; font-size: 12px; color: var(--muted); text-align: left; line-height: 1.3; min-width: 0; }
.calendar__day--empty { background: transparent; border-color: transparent; }
.calendar__day--future { opacity: .45; }
.calendar__day--active { background: var(--tint); border-color: light-dark(#BFE5D0, #2A4A3A); cursor: pointer; transition: transform .1s ease, border-color .15s ease; }
.calendar__day--active:hover { transform: translateY(-1px); border-color: var(--green-ink); }
.calendar__day.is-selected { border-color: var(--green-ink); box-shadow: 0 0 0 2px var(--focus-ring); }
.calendar__num { font-weight: 600; color: var(--ink-2); display: flex; align-items: baseline; gap: 4px; }
.calendar__num small { font-size: 9px; font-weight: 600; color: var(--green-ink); text-transform: uppercase; letter-spacing: .04em; }
.calendar__day.is-today .calendar__num { color: var(--green-ink); }
.calendar__pnl { margin-top: auto; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.calendar__rev { font-size: 11px; color: var(--green-ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.calendar__dep { font-size: 10px; color: var(--faint); }
.calendar__loading { grid-column: 1 / -1; padding: 28px; text-align: center; color: var(--muted); font-size: 14px; }
.calendar__legend { padding-top: 6px; }
.legend__box { width: 12px; height: 12px; border-radius: 3px; background: var(--paper); border: 1px solid var(--rule); }
.legend__box--active { background: var(--tint); border-color: light-dark(#BFE5D0, #2A4A3A); }
.day-panel { display: flex; flex-direction: column; gap: 12px; }
.day-panel .btn { min-height: 36px; padding: 0 12px; font-size: 13px; }
.day-panel .subtable { border: 0; }

@media (max-width: 1023px) {
    .tiles--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .tiles--3 .tile:nth-child(2n) { border-right: 1px solid var(--rule); }
    .tiles--3 .tile:nth-child(3n) { border-right: 0; }
    .tiles--3 .tile, .tiles--4 .tile { border-bottom: 0; }
    .tiles--4 .tile:nth-child(-n+2) { border-bottom: 1px solid var(--rule); }
}
@media (max-width: 759px) {
    .tiles--3 { grid-template-columns: minmax(0, 1fr); }
    .tiles--3 .tile { border-right: 0 !important; border-bottom: 1px solid var(--rule); flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; }
    .tiles--3 .tile:last-child { border-bottom: 0; }
    .tiles--3 .tile__value { font-size: 22px; margin-top: 0; }
    .tiles--3 .tile__hint { width: 100%; }
    .lead-head__title { font-size: 20px; }
    .calendar { padding: 10px; }
    .calendar__head, .calendar__grid { gap: 4px; }
    .calendar__day { min-height: 58px; padding: 4px 5px; font-size: 11px; }
    .calendar__pnl, .calendar__rev { font-size: 10px; }
    .calendar__num small { display: none; }
    .who__name { max-width: 150px; }
    .who__mail-text { max-width: 140px; }
}

/* ---- links --------------------------------------------------------------- */
.link-main { display: flex; flex-direction: column; gap: 16px; }
.link-url { display: flex; align-items: center; gap: 10px; min-width: 0; }
.link-url .link-box { flex: 1; min-width: 0; }
.link-url .btn { flex: none; }
.link-url .link-box { min-height: 48px; }
/* Same box as the general link (padding, height, type), on the light card palette. */
.link-box--light { background: var(--paper); border-color: var(--rule-2); color: var(--ink-2); }
.link-metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px 16px; }
.link-metric { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.link-metric__label { font-size: 12px; color: var(--muted); }
.link-metric__value { font-size: 20px; line-height: 1.1; white-space: nowrap; }
.card--deep .link-metric__label { color: var(--mint-2); }
.card--deep .link-metric__value { color: var(--on-deep); }
.card--deep .link-metric__value.is-neg { color: #F6B08D !important; }
.create-link { border-color: var(--green-ink); }
.create-link form { display: flex; flex-direction: column; gap: 16px; }
.create-link__actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.link-card { display: flex; flex-direction: column; gap: 14px; }
.link-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.link-card__name { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.link-card__code { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.link-card__actions { display: flex; gap: 8px; flex: none; }
.link-card__foot { display: flex; gap: 8px 20px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--rule); font-size: 13px; color: var(--muted); }
.link-card__foot strong { color: var(--ink); font-weight: 600; }
.link-card__title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
/* link category badge: neutral pill with the channel's brand colour as a dot */
.link-cat { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--rule-2); background: var(--paper-2); font-size: 11px; font-weight: 600; line-height: 1.5; color: var(--ink-2); white-space: nowrap; }
.link-cat::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.link-cat[data-cat="google"]::before { background: #4285F4; }
.link-cat[data-cat="instagram"]::before { background: #E1306C; }
.link-cat[data-cat="youtube"]::before { background: #FF0000; }
.link-cat[data-cat="facebook"]::before { background: #1877F2; }
.link-cat[data-cat="tiktok"]::before { background: #69C9D0; }
.link-cat[data-cat="whatsapp"]::before { background: #25D366; }
.link-cat[data-cat="telegram"]::before { background: #229ED9; }
.link-cat[data-cat="website"]::before { background: #7C5CFF; }
.link-cat[data-cat="email"]::before { background: #F59E0B; }
.rename-form select.input { width: auto; min-width: 160px; }
.btn--small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn--danger { color: var(--danger); }
.btn--danger:hover { color: var(--danger); border-color: var(--danger); }
.rename-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rename-form .input { height: 40px; flex: 1; min-width: 200px; max-width: 420px; }
.rename-form .field__error { width: 100%; }

@media (max-width: 1023px) {
    .link-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 759px) {
    .link-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .link-metric__value { font-size: 18px; }
    .link-url { flex-direction: column; align-items: stretch; }
    .link-card__actions { width: 100%; }
    .link-card__actions .btn { flex: 1; }
}

/* ---- payments ------------------------------------------------------------ */
.tile__value--text { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.tile__value--text::first-letter { text-transform: uppercase; }
.notice-box { display: flex; flex-direction: column; gap: 2px; padding: 14px 18px; border-radius: var(--radius-lg); border: 1px solid var(--rule-2); background: var(--paper-2); font-size: 14px; color: var(--ink-2); }
.notice-box strong { font-weight: 600; color: var(--ink); }
.notice-box--warn { border-color: light-dark(#EAC9B6, #5A3A28); background: var(--danger-bg); }
.notice-box--warn strong { color: var(--danger); }
.pay-form { display: flex; flex-direction: column; gap: 18px; }
.pay-form form { display: flex; flex-direction: column; gap: 16px; }
.pay-form__grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 16px 20px; }
.pay-form__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 4px; }
.pay-form__summary strong { color: var(--ink); font-weight: 600; }
.pay-form [data-disabled] .input, .pay-form .input:disabled { opacity: .6; }
.amount { display: flex; align-items: stretch; border: 1px solid var(--rule-2); border-radius: var(--radius); background: var(--paper-2); overflow: hidden; transition: border-color .15s ease, box-shadow .15s ease; }
.amount:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px var(--focus-ring); }
.amount__prefix { display: flex; align-items: center; padding: 0 0 0 14px; color: var(--muted); font-weight: 600; }
.amount .input.amount__input { border: 0; background: transparent; box-shadow: none; height: 50px; font-size: 22px; padding-left: 8px; }
.amount .input.amount__input:focus { box-shadow: none; }
.amount__max { padding: 0 14px; font-size: 13px; font-weight: 600; color: var(--green-ink); border-left: 1px solid var(--rule); }
.amount__max:hover { background: var(--paper); }
.amount__max:disabled { color: var(--faint); cursor: not-allowed; }
select.input { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234F5F57' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; padding-right: 40px; }
.pill--wait { background: light-dark(#FBF1DE, #3B3220); border-color: transparent; color: light-dark(#8A5A12, #EBC27A); }
.table--payments { font-size: 13px; min-width: 620px; }
.table--payments .cell-user span { font-size: 11px; }
.table--payments th, .table--payments td { padding: 10px 12px; }
.table--payments td .pill { vertical-align: middle; }
.pay-grid { align-items: start; }
.releases { display: flex; flex-direction: column; }
.release { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 12px 18px; border-bottom: 1px solid var(--rule); font-size: 14px; }
.release:last-child { border-bottom: 0; }
.release__date { font-weight: 600; }
.release__amount { font-size: 16px; text-align: right; white-space: nowrap; }
.release__meta { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }

/* saved PIX keys (withdrawal_wallets) */
.wallets { display: flex; flex-direction: column; gap: 14px; }
.wallet-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; border: 1px solid var(--rule-2); border-radius: var(--radius-lg); overflow: hidden; }
/* badge + title (ellipsis) on the first row; meta below it; actions right-aligned, dropping to their own row when they do not fit */
.wallet { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 12px 14px; border-bottom: 1px solid var(--rule); font-size: 14px; }
.wallet:last-child { border-bottom: 0; }
.wallet.is-off .wallet__title { color: var(--muted); }
.wallet__type { flex: none; width: 46px; padding: 3px 0; border-radius: 6px; border: 1px solid var(--rule-2); background: var(--paper-2); font-size: 10px; font-weight: 700; letter-spacing: .04em; text-align: center; color: var(--ink-2); }
.wallet__title { flex: 1 1 calc(100% - 58px); min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wallet__meta { flex: 0 0 auto; max-width: calc(100% - 58px); margin-left: 58px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wallet__meta.is-neg { color: var(--danger); white-space: normal; }
.wallet__actions { flex: none; margin-left: auto; display: flex; align-items: center; gap: 6px; }
.wallet__actions:empty { display: none; }
.wallet-form { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px; border: 1px solid var(--green-ink); border-radius: var(--radius-lg); }
.wallet-form__title { font-weight: 600; }
.wallet-form .field--actions { flex-direction: row; flex-wrap: wrap; gap: 8px; }
.wallet-form .field--actions .btn { flex: 1 1 auto; }
.wallet-form .input--code { height: 48px; }
.wallets .form-msg:empty { display: none; }
.pager .btn.is-disabled { opacity: .45; pointer-events: none; }

@media (max-width: 759px) {
    .pay-form__grid { grid-template-columns: minmax(0, 1fr); }
    .pay-form__foot { flex-direction: column; align-items: stretch; }
    .pay-form__foot .btn { width: 100%; }
    .tile__value--text { font-size: 18px; }
}

/* ---- account ------------------------------------------------------------- */
.acc-card { display: flex; flex-direction: column; gap: 18px; }
.acc-card form { display: flex; flex-direction: column; gap: 16px; }
.acc-card__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.acc-card__foot .form-msg { text-align: left; flex: 1; min-height: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; }
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid--1 { grid-template-columns: minmax(0, 1fr); }
.form-grid__wide { grid-column: 1 / -1; }
.span-6 { grid-column: span 6; }
.acc-grid { align-items: start; }
/* Password + two-factor share the narrow column: everything inside stacks. */
.acc-side .acc-card__foot { flex-direction: column-reverse; align-items: stretch; }
.acc-side .acc-card__foot .btn { width: 100%; }
.acc-side .acc-card__foot .form-msg { text-align: center; }
.acc-side .twofa-options { grid-template-columns: minmax(0, 1fr); }
.acc-side .twofa-option .btn { align-self: stretch; }
.acc-side .totp-setup { grid-template-columns: minmax(0, 1fr); justify-items: center; }
.acc-side .totp-setup > .stack { width: 100%; }
.acc-side .twofa-confirm .input--code { flex: 1; min-width: 120px; }
.acc-side .field--actions .btn { flex: 1; }
.input[readonly] { background: var(--paper); color: var(--muted); }
.field--actions { display: flex; flex-direction: row; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.btn--danger-solid { background: var(--danger); color: #fff; }
.btn--danger-solid:hover { background: var(--danger); color: #fff; filter: brightness(.95); }
.twofa-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.twofa-option { display: flex; flex-direction: column; gap: 8px; padding: 16px 18px; border: 1px solid var(--rule-2); border-radius: var(--radius-lg); background: var(--paper); }
.twofa-option strong { font-weight: 600; }
.twofa-option .btn { align-self: flex-start; margin-top: 4px; }
.twofa-panel { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; border: 1px solid var(--green-ink); border-radius: var(--radius-lg); }
.twofa-confirm { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.twofa-confirm .input--code { width: 160px; height: 48px; font-size: 20px; }
.totp-setup { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 20px; align-items: start; }
.totp-setup__qr { width: 200px; height: 200px; background: #fff; border: 1px solid var(--rule-2); border-radius: var(--radius); padding: 8px; display: flex; align-items: center; justify-content: center; font-size: 12px; color: #4F5F57; text-align: center; }
.totp-setup__qr svg { width: 100%; height: 100%; display: block; }
.secret { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.secret code { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 15px; letter-spacing: .06em; padding: 8px 12px; border: 1px dashed var(--rule-3); border-radius: 8px; background: var(--paper); color: var(--ink); overflow-wrap: anywhere; }

@media (max-width: 759px) {
    .form-grid, .form-grid--3, .twofa-options { grid-template-columns: minmax(0, 1fr); }
    .totp-setup { grid-template-columns: minmax(0, 1fr); }
    .totp-setup__qr { margin: 0 auto; }
    .acc-card__foot { flex-direction: column-reverse; align-items: stretch; }
    .acc-card__foot .btn { width: 100%; }
}

/* ---- error pages --------------------------------------------------------- */
.error-page { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); }
.error-page__body { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.error-page__box { width: 100%; max-width: 480px; display: flex; flex-direction: column; gap: 14px; }
.error-page__code { font-size: 13px; color: var(--green-ink); font-weight: 600; letter-spacing: .08em; }
.error-page__title { font-size: 30px; font-weight: 600; letter-spacing: -0.01em; }
.error-page__text { color: var(--muted); }

/* ---- motion -------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
