/* ==========================================================================
   BLUE REALM — THEME
   ==========================================================================
   ALL COLORS LIVE IN THIS ONE :root BLOCK. To change the accent color,
   background darkness, or contrast anywhere in the app, edit the values
   here — nothing else in any page needs to change.

   Text colors (--ink, --ink-muted, --ink-faint) are contrast-verified
   against WCAG AA/AAA. If you change them, re-check contrast before
   shipping — see the note above each one.
   ========================================================================== */

:root {
    /* ---- Backgrounds ---- */
    --bg: #0e1210;              /* page background */
    --surface: #171c19;         /* cards, sidebar */
    --surface-raised: #1d2320;  /* modals, elevated panels */
    --line: #3a443c;            /* visible borders (bolder than before) */
    --line-soft: #262e28;       /* subtle dividers */

    /* ---- Text — contrast-verified, see comments ---- */
    --ink: #f1efe9;             /* primary text — 16.4:1 on --bg (AAA) */
    --ink-muted: #a9b3aa;       /* secondary text — 8.7:1 on --bg (AAA) */
    --ink-faint: #7d867e;       /* tertiary/meta text — 5.0:1 on --bg (AA) — do not go darker than this */

    /* ---- Accent — the main "brand color" knob ---- */
    --brass: #c99a4e;           /* bolder/more saturated than before */
    --brass-bright: #e0b768;    /* text-on-dark use, hover states */
    --brass-glow: rgba(201, 154, 78, 0.45); /* shadow/glow color, keep alpha <0.5 */

    /* ---- Status colors — used for badges, positive/negative amounts ---- */
    --sage: #5c9a7e;            /* success / positive / completed */
    --sage-bright: #8fd1ae;
    --rust: #c96a4e;            /* danger / failed / rejected */
    --rust-bright: #e69679;
    --amber: #d9a441;           /* warning / pending */
    --amber-bright: #f0c26e;

    --serif: 'Fraunces', Georgia, serif;
    --sans: 'Inter', -apple-system, sans-serif;
    --mono: 'IBM Plex Mono', 'Courier New', monospace;

    --radius: 10px;
    --radius-lg: 16px;
}

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

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-tap-highlight-color: transparent; }
body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

.grain {
    position: fixed; inset: 0; pointer-events: none; z-index: 1; opacity: 0.025;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

a { color: inherit; text-decoration: none; }

:focus-visible { outline: 2.5px solid var(--brass-bright); outline-offset: 3px; border-radius: 2px; }
.btn:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
    box-shadow: 0 0 0 4px var(--brass-glow);
}

.skip-link {
    position: absolute; top: -60px; left: 12px; background: var(--brass); color: #14100a;
    padding: 12px 18px; border-radius: 8px; font-size: 13.5px; font-weight: 600; z-index: 100;
    transition: top 0.15s ease;
}
.skip-link:focus { top: 12px; }

h1, h2, h3, .serif { font-family: var(--serif); font-weight: 500; letter-spacing: -0.01em; }

.eyebrow {
    font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.12em;
    text-transform: uppercase; color: var(--ink-faint);
}

/* ============================== LAYOUT ============================== */

.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px; flex-shrink: 0; background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex; flex-direction: column;
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 40;
    transition: transform 0.3s ease;
}
.brand { padding: 28px 24px 22px; border-bottom: 1px solid var(--line-soft); }
.brand-mark { font-family: var(--serif); font-size: 20px; font-weight: 500; color: var(--ink); }
.brand-mark em { font-style: normal; color: var(--brass-bright); }
.brand-sub { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-faint); margin-top: 4px; }

.nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-group-label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); padding: 16px 12px 8px; }
.nav-item {
    display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 8px;
    color: var(--ink-muted); font-size: 14px; transition: background 0.15s ease, color 0.15s ease;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.9; }
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--ink); }
.nav-item.active {
    background: rgba(201, 154, 78, 0.14); color: var(--brass-bright);
    box-shadow: inset 3px 0 0 var(--brass);
    font-weight: 600;
}
.nav-item.cta { background: var(--brass); color: #14100a; font-weight: 700; margin-top: 8px; box-shadow: 0 4px 14px var(--brass-glow); }
.nav-item.cta:hover { background: var(--brass-bright); }

.sidebar-foot { padding: 16px; border-top: 1px solid var(--line-soft); }
.account-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: linear-gradient(160deg, var(--brass-bright), var(--brass) 60%, #8a6a3c);
    display: flex; align-items: center; justify-content: center; color: #14100a; font-weight: 700; font-size: 13px; flex-shrink: 0;
    box-shadow: 0 2px 8px var(--brass-glow);
}
.account-email { font-size: 12.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-role { font-size: 11px; color: var(--ink-faint); font-family: var(--mono); }
.logout-btn { display: flex; align-items: center; gap: 8px; width: 100%; margin-top: 6px; padding: 9px 8px; font-size: 12.5px; color: var(--ink-faint); border: none; background: none; cursor: pointer; border-radius: 8px; font-family: var(--sans); }
.logout-btn:hover { color: var(--rust-bright); background: rgba(201,106,78,0.08); }

.topbar {
    display: none; position: fixed; top: 0; left: 0; right: 0; height: 60px;
    background: rgba(14,18,16,0.94); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
    align-items: center; justify-content: space-between; padding: 0 16px; z-index: 45;
}
.menu-btn { width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; color: var(--ink); background: none; border: none; cursor: pointer; }
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 39; }
.overlay.show { display: block; }

.main { margin-left: 240px; flex: 1; min-width: 0; padding: 40px 48px 80px; position: relative; z-index: 2; }
.page-head { margin-bottom: 32px; }
.page-head h1 { font-size: 29px; color: var(--ink); margin-bottom: 6px; }
.page-head p { color: var(--ink-muted); font-size: 14.5px; }

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .topbar { display: flex; }
    .main { margin-left: 0; padding: 84px 20px 60px; }
}

/* ============================== FLASH MESSAGES ============================== */
.flash {
    padding: 14px 18px; border-radius: 10px; font-size: 13.5px; margin-bottom: 20px;
    border: 1px solid; display: flex; align-items: center; gap: 10px;
}
.flash-success { background: rgba(92,154,126,0.12); border-color: rgba(143,209,174,0.35); color: var(--sage-bright); }
.flash-error { background: rgba(201,106,78,0.12); border-color: rgba(230,150,121,0.35); color: var(--rust-bright); }

/* ============================== COMPONENTS ============================== */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px; }

.ledger { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.ledger-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 24px; border-bottom: 1px solid var(--line-soft); }
.ledger-row {
    display: grid; grid-template-columns: 1fr auto; align-items: center;
    padding: 16px 24px; border-bottom: 1px solid var(--line-soft); gap: 12px;
    border-left: 3px solid transparent;
}
.ledger-row:last-child { border-bottom: none; }
.ledger-row.type-credit { border-left-color: var(--sage); }
.ledger-row.type-debit { border-left-color: var(--line); }
.ledger-row.type-failed { border-left-color: var(--rust); }
.ledger-row.type-pending { border-left-color: var(--amber); }
.ledger-row .desc { font-size: 14px; color: var(--ink); }
.ledger-row .meta { font-size: 12.5px; color: var(--ink-faint); margin-top: 3px; }
.ledger-row .amount { font-family: var(--mono); font-size: 14.5px; text-align: right; font-weight: 500; }
.amount.pos { color: var(--sage-bright); }
.amount.neg { color: var(--ink); }

.balance-display { font-family: var(--serif); font-weight: 500; font-size: 56px; letter-spacing: -0.02em; line-height: 1; color: var(--ink); text-shadow: 0 0 40px var(--brass-glow); }
.balance-display .cents { font-size: 28px; color: var(--ink-faint); text-shadow: none; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 13px 22px; border-radius: 8px; font-size: 13.5px; font-weight: 600;
    letter-spacing: 0.01em; border: 1px solid transparent; cursor: pointer; transition: all 0.15s ease;
    font-family: var(--sans);
}
.btn-primary { background: var(--brass); color: #14100a; box-shadow: 0 4px 16px var(--brass-glow); }
.btn-primary:hover { background: var(--brass-bright); box-shadow: 0 6px 22px var(--brass-glow); transform: translateY(-1px); }
.btn-secondary { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-secondary:hover { border-color: var(--brass); color: var(--brass-bright); }
.btn-ghost { background: transparent; color: var(--ink-muted); padding: 10px 14px; border: none; cursor: pointer; font-family: var(--sans); }
.btn-ghost:hover { color: var(--ink); }
.btn-danger { background: rgba(201,106,78,0.12); color: var(--rust-bright); border: 1px solid rgba(230,150,121,0.3); }
.btn-danger:hover { background: rgba(201,106,78,0.2); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

.badge {
    display: inline-flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 11.5px;
    letter-spacing: 0.04em; text-transform: uppercase; padding: 4px 10px; border-radius: 20px; border: 1px solid;
}
.badge-sage { background: rgba(92,154,126,0.18); color: var(--sage-bright); border-color: rgba(143,209,174,0.35); }
.badge-brass { background: rgba(201,154,78,0.18); color: var(--brass-bright); border-color: rgba(224,183,104,0.35); }
.badge-rust { background: rgba(201,106,78,0.18); color: var(--rust-bright); border-color: rgba(230,150,121,0.35); }
.badge-amber { background: rgba(217,164,65,0.18); color: var(--amber-bright); border-color: rgba(240,194,110,0.35); }
.badge-muted { background: rgba(169,179,170,0.15); color: var(--ink-muted); border-color: rgba(169,179,170,0.3); }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 700px) { .stat-grid { grid-template-columns: 1fr; } }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; }
.stat-card .stat-value { font-family: var(--serif); font-size: 29px; color: var(--ink); margin: 6px 0 4px; }
.stat-card .stat-label { font-size: 13px; color: var(--ink-muted); }

input, textarea, select {
    width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
    padding: 12px 14px; color: var(--ink); font-family: var(--sans); font-size: 14.5px;
}
input::placeholder, textarea::placeholder { color: var(--ink-faint); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brass); }
label { display: block; font-size: 13px; color: var(--ink-muted); margin-bottom: 7px; }

.divider { height: 1px; background: var(--line-soft); margin: 24px 0; }
.hairline-list > * + * { border-top: 1px solid var(--line-soft); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 60; }
.modal { background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 28px; max-width: 420px; width: 100%; animation: modalIn 0.25s ease-out; }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.hidden { display: none !important; }
.method-card.is-selected { border-color: var(--brass) !important; background: rgba(201,154,78,0.08); box-shadow: 0 0 0 1px var(--brass); }

.copy-field { display: flex; align-items: center; gap: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.copy-field code { flex: 1; font-family: var(--mono); font-size: 13.5px; color: var(--brass-bright); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.upload-box { border: 2px dashed var(--line); border-radius: 12px; padding: 24px; text-align: center; cursor: pointer; transition: border-color 0.15s ease; }
.upload-box:hover { border-color: var(--brass); }
