/* ═══════════════════════════════════════════════════════════════════
   Klero Consumer Dashboard — editorial-fintech aesthetic
   White paper, cobalt accent, DM Sans + DM Mono. Restrained luxury.
   ═══════════════════════════════════════════════════════════════════ */

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

:root {
    /* paper */
    --paper:         #ffffff;
    --surface:       #f8f9fb;
    --surface-2:     #f0f2f6;
    --surface-3:     #e8ebf2;

    /* ink */
    --ink:           #0a0a0a;
    --ink-soft:      #1f2430;
    --muted:         #525866;
    --soft:          #8d94a4;
    --whisper:       #b0b6c3;

    /* rules */
    --rule:          #e5e7eb;
    --rule-strong:   #d4d7de;

    /* cobalt — used sparingly for primary actions only */
    --cobalt:        #1845ff;
    --cobalt-deep:   #0a2bb8;
    --cobalt-darker: #061d8a;
    --cobalt-tint:   #ecefff;
    --cobalt-glow:   rgba(24, 69, 255, 0.12);

    /* status */
    --success:       #0d9488;
    --success-bg:    #ecfdf5;
    --warning:       #b45309;
    --warning-bg:    #fffbeb;
    --danger:        #dc2626;
    --danger-bg:    #fef2f2;
    --info:          #1845ff;
    --info-bg:       #ecefff;

    /* typography */
    --body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --mono: 'DM Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

    /* depth */
    --shadow-sm:  0 1px 2px rgba(10, 12, 20, 0.04);
    --shadow:     0 1px 2px rgba(10, 12, 20, 0.04), 0 8px 24px rgba(10, 12, 20, 0.06);
    --shadow-lg:  0 2px 4px rgba(10, 12, 20, 0.06), 0 20px 48px rgba(10, 12, 20, 0.10);
    --shadow-cobalt: 0 1px 2px rgba(24, 69, 255, 0.16), 0 12px 32px rgba(24, 69, 255, 0.18);

    /* shape */
    --radius-xs:   4px;
    --radius-sm:   8px;
    --radius:      12px;
    --radius-lg:   16px;
    --radius-xl:   24px;
    --radius-pill: 999px;

    /* motion */
    --motion-fast: 140ms cubic-bezier(0.4, 0, 0.2, 1);
    --motion-base: 220ms cubic-bezier(0.4, 0, 0.2, 1);
    --motion-slow: 380ms cubic-bezier(0.4, 0, 0.2, 1);

    /* layout */
    --nav-width:    248px;
    --topbar-h:     60px;
    --content-max:  960px;
}

html, body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--body);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    min-height: 100dvh;
}

body { color-scheme: light only; }

a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--cobalt); }
img, svg { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
hr { border: none; border-top: 1px solid var(--rule); margin: 24px 0; }

/* ───── Typography scale ────────────────────────────────────── */

h1, .h1 { font-size: 28px; line-height: 1.2; letter-spacing: -0.02em; font-weight: 600; }
h2, .h2 { font-size: 20px; line-height: 1.3; letter-spacing: -0.015em; font-weight: 600; }
h3, .h3 { font-size: 16px; line-height: 1.35; letter-spacing: -0.005em; font-weight: 600; }

.eyebrow {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
}
.eyebrow-cobalt { color: var(--cobalt); }
.mono { font-family: var(--mono); font-feature-settings: "tnum" 1; }
.muted { color: var(--muted); }
.soft  { color: var(--soft); }

/* ───── Auth pages — centered card on gradient hero ────────── */

.auth-shell {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 32px 20px;
    background:
        radial-gradient(1100px 540px at 80% -10%, rgba(24,69,255,0.07), transparent 60%),
        radial-gradient(800px 400px at 10% 110%, rgba(24,69,255,0.04), transparent 50%),
        var(--paper);
    position: relative;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 36px 32px;
    position: relative;
}

.auth-brand {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 32px;
}
.auth-brand .logo {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: var(--ink);
}
.auth-brand .by {
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
}

.auth-card h1 {
    font-size: 22px;
    margin-bottom: 6px;
}
.auth-card .lede {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 28px;
}

.auth-foot {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--rule);
    font-size: 13px;
    color: var(--muted);
    text-align: center;
}
.auth-foot a {
    color: var(--cobalt);
    font-weight: 500;
}

/* ───── Form controls ──────────────────────────────────────── */

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}
.field label, label.field-label {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
}
.input, input[type="text"], input[type="email"], input[type="password"], input[type="number"], textarea, select {
    width: 100%;
    padding: 12px 14px;
    background: var(--paper);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius-sm);
    font-size: 15px;
    color: var(--ink);
    transition: border-color var(--motion-fast), box-shadow var(--motion-fast), background var(--motion-fast);
}
.input:hover, input:hover { border-color: var(--soft); }
.input:focus, input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--cobalt);
    box-shadow: 0 0 0 4px var(--cobalt-glow);
}
.input::placeholder { color: var(--whisper); }
.input.mono { letter-spacing: 0.02em; }

.code-input {
    font-family: var(--mono);
    font-size: 28px;
    letter-spacing: 0.32em;
    text-align: center;
    padding: 16px;
    font-weight: 600;
}

.input-hint {
    font-size: 12px;
    color: var(--muted);
    margin-top: -2px;
}
.input-error {
    font-size: 12px;
    color: var(--danger);
    margin-top: 4px;
}

/* ───── Buttons ─────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    letter-spacing: -0.005em;
    transition: background var(--motion-fast), box-shadow var(--motion-fast), transform var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast);
    user-select: none;
    white-space: nowrap;
    text-decoration: none;
}
.btn:disabled, .btn[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none !important;
}

.btn-primary {
    background: var(--cobalt);
    color: #fff;
    box-shadow: var(--shadow-cobalt);
}
.btn-primary:hover:not(:disabled) {
    background: var(--cobalt-deep);
    transform: translateY(-1px);
}
.btn-primary:active:not(:disabled) {
    background: var(--cobalt-darker);
    transform: translateY(0);
}

.btn-secondary {
    background: var(--paper);
    color: var(--ink);
    border: 1px solid var(--rule-strong);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--surface);
    border-color: var(--soft);
}

.btn-ghost {
    background: transparent;
    color: var(--muted);
}
.btn-ghost:hover:not(:disabled) {
    color: var(--ink);
    background: var(--surface);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-block { width: 100%; }
.btn-lg { padding: 14px 22px; font-size: 15px; }
.btn-sm { padding: 8px 12px; font-size: 13px; }

/* ───── Dashboard shell ────────────────────────────────────── */

.dash-shell {
    display: grid;
    grid-template-columns: var(--nav-width) 1fr;
    min-height: 100dvh;
}

.dash-nav {
    border-right: 1px solid var(--rule);
    background: var(--paper);
    padding: 24px 18px;
    position: sticky;
    top: 0;
    height: 100dvh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.dash-nav .brand {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 4px 8px 24px;
}
.dash-nav .brand .logo {
    font-size: 19px;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: var(--ink);
}
.dash-nav .brand .by {
    font-size: 10px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--soft);
}

.dash-nav .nav-section {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.dash-nav .nav-section-label {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--soft);
    padding: 14px 8px 6px;
}
.dash-nav a.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    font-size: 14px;
    font-weight: 500;
    transition: background var(--motion-fast), color var(--motion-fast);
}
.dash-nav a.nav-link:hover {
    background: var(--surface);
    color: var(--ink);
}
.dash-nav a.nav-link.active {
    background: var(--cobalt-tint);
    color: var(--cobalt-deep);
}
.dash-nav a.nav-link .icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.85;
}

.dash-nav .nav-foot {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--rule);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.dash-nav .who {
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.dash-nav .who .who-email {
    font-size: 13px;
    color: var(--ink);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dash-nav .who .who-meta {
    font-size: 11px;
    color: var(--soft);
}

.dash-main {
    padding: 32px 40px 80px;
    max-width: calc(var(--content-max) + 80px);
    margin: 0 auto;
    width: 100%;
}

/* Top of each dashboard page */
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--rule);
    margin-bottom: 32px;
}
.page-head .title { display: flex; flex-direction: column; gap: 4px; }
.page-head h1 { font-size: 26px; }
.page-head .subtitle { color: var(--muted); font-size: 14px; }
.page-head .actions { display: flex; gap: 10px; }

/* ───── Cards ──────────────────────────────────────────────── */

.card {
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card-head {
    padding: 18px 22px;
    border-bottom: 1px solid var(--rule);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card-head h2, .card-head h3 {
    margin: 0;
}
.card-body { padding: 22px; }
.card-foot {
    padding: 14px 22px;
    border-top: 1px solid var(--rule);
    background: var(--surface);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.stack { display: flex; flex-direction: column; }
.stack-sm > * + * { margin-top: 8px; }
.stack-md > * + * { margin-top: 16px; }
.stack-lg > * + * { margin-top: 24px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { justify-content: space-between; }

/* ───── Stat tiles ────────────────────────────────────────── */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}
.stat {
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 18px 20px;
}
.stat .label {
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 8px;
}
.stat .value {
    font-family: var(--mono);
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--ink);
    line-height: 1.1;
}
.stat .delta {
    font-size: 12px;
    color: var(--muted);
    margin-top: 6px;
}

/* ───── Status pills ──────────────────────────────────────── */

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: var(--surface);
    color: var(--muted);
    border: 1px solid var(--rule);
}
.pill::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.pill-success { color: var(--success); background: var(--success-bg); border-color: rgba(13,148,136,0.18); }
.pill-warn    { color: var(--warning); background: var(--warning-bg); border-color: rgba(180,83,9,0.18); }
.pill-danger  { color: var(--danger); background: var(--danger-bg); border-color: rgba(220,38,38,0.18); }
.pill-info    { color: var(--cobalt); background: var(--cobalt-tint); border-color: rgba(24,69,255,0.18); }

/* ───── Tables ─────────────────────────────────────────────── */

.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--rule);
    background: var(--paper);
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
table th {
    text-align: left;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 12px 18px;
    border-bottom: 1px solid var(--rule);
    background: var(--surface);
}
table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--rule);
    color: var(--ink-soft);
    vertical-align: middle;
}
table tr:last-child td { border-bottom: none; }
table tr:hover td { background: rgba(248, 249, 251, 0.6); }

.addr-mono {
    font-family: var(--mono);
    font-size: 13px;
    color: var(--ink-soft);
    background: var(--surface);
    padding: 4px 8px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--rule);
}
.addr-short {
    font-family: var(--mono);
    font-size: 13px;
}

/* ───── Empty states ──────────────────────────────────────── */

.empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--muted);
}
.empty .empty-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--rule);
    display: grid;
    place-items: center;
    color: var(--soft);
}
.empty h3 {
    color: var(--ink);
    margin-bottom: 6px;
}
.empty p { font-size: 14px; margin-bottom: 18px; }

/* ───── Alerts / inline messages ──────────────────────────── */

.alert {
    border: 1px solid;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.5;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 16px;
}
.alert-info    { background: var(--info-bg);    border-color: rgba(24,69,255,0.22);  color: var(--cobalt-deep); }
.alert-success { background: var(--success-bg); border-color: rgba(13,148,136,0.22); color: #115e59; }
.alert-warn    { background: var(--warning-bg); border-color: rgba(180,83,9,0.22);   color: #7c2d12; }
.alert-danger  { background: var(--danger-bg);  border-color: rgba(220,38,38,0.22);  color: #991b1b; }
.alert .alert-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
    margin-top: 6px;
}

/* ───── Modal / dialog ─────────────────────────────────────── */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10, 12, 20, 0.32);
    backdrop-filter: blur(2px);
    display: grid;
    place-items: center;
    padding: 20px;
    z-index: 50;
    animation: fade-in 160ms ease-out;
}
.modal {
    background: var(--paper);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 460px;
    width: 100%;
    padding: 28px;
    animation: pop-in 180ms cubic-bezier(0.4, 0, 0.2, 1);
}
.modal h2 { margin-bottom: 8px; }
.modal .lede { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes pop-in {
    from { opacity: 0; transform: translateY(6px) scale(0.985); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ───── Toast ──────────────────────────────────────────────── */

.toast-root {
    position: fixed;
    right: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 60;
}
.toast {
    background: var(--ink);
    color: var(--paper);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 13px;
    box-shadow: var(--shadow-lg);
    animation: pop-in 200ms ease-out;
}
.toast.ok    { background: var(--ink); }
.toast.err   { background: var(--danger); }

/* ───── Tiny helpers ──────────────────────────────────────── */

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.spacer { flex: 1; }
.cluster { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ───── Responsive ─────────────────────────────────────────── */

@media (max-width: 900px) {
    .dash-shell { grid-template-columns: 1fr; }
    .dash-nav {
        position: static;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--rule);
        flex-direction: row;
        align-items: center;
        padding: 14px 20px;
        overflow-x: auto;
        gap: 8px;
    }
    .dash-nav .brand { padding: 0 8px 0 0; }
    .dash-nav .nav-section { flex-direction: row; gap: 4px; }
    .dash-nav .nav-section-label { display: none; }
    .dash-nav .nav-foot {
        margin: 0 0 0 auto;
        border: none;
        padding: 0;
        flex-direction: row;
    }
    .dash-nav .who { display: none; }
    .dash-main { padding: 24px 20px 60px; }
    .page-head { flex-direction: column; align-items: stretch; gap: 12px; }
    .page-head .actions { width: 100%; }
    .auth-card { padding: 28px 22px; }
}
