:root {
    --bg: #0b0f14;
    --bg-soft: #0f151d;
    --panel: #121a24;
    --panel-2: #16202c;
    --border: #223041;
    --text: #e6edf3;
    --muted: #8b98a5;
    --emerald: #34d399;
    --emerald-dim: #10795a;
    --amber: #fbbf24;
    --cyan: #22d3ee;
    --red: #f87171;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 10px 30px rgba(0, 0, 0, .35);
    font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--emerald); text-decoration: none; }
a:hover { text-decoration: none; opacity: .9; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

.muted { color: var(--muted); font-size: 13px; }
.unit { font-size: .55em; color: var(--muted); font-weight: 500; }

/* ------------------------------------------------------------------ brand */
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 17px;
    color: var(--text);
}
.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--emerald), var(--cyan));
    color: #04140f;
    font-weight: 800;
    font-size: 14px;
}
.brand-logo {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    object-fit: contain;
    display: block;
    flex: 0 0 auto;
}
.hero-logo {
    width: 88px;
    height: 88px;
    border-radius: 20px;
    display: block;
    margin: 0 auto 18px;
    object-fit: contain;
}

/* ------------------------------------------------------------- guest/landing */
.guest-body {
    min-height: 100vh;
    background:
        radial-gradient(900px 500px at 15% -10%, rgba(52, 211, 153, .13), transparent 60%),
        radial-gradient(800px 500px at 90% 0%, rgba(34, 211, 238, .10), transparent 55%),
        var(--bg);
}
.guest-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 1080px;
    margin: 0 auto;
    padding: 22px 22px 30px;
}
.guest-top { display: flex; align-items: center; justify-content: space-between; }
.guest-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 0; }
.guest-foot { text-align: center; color: var(--muted); font-size: 12.5px; }

.hero { max-width: 720px; text-align: center; }
.hero-badge {
    display: inline-block;
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(52, 211, 153, .07);
    color: var(--emerald);
    font-size: 12.5px;
    letter-spacing: .02em;
    margin-bottom: 20px;
}
.hero h1 { font-size: 42px; line-height: 1.12; margin-bottom: 16px; }
.hero-lead { color: var(--muted); font-size: 17px; max-width: 560px; margin: 0 auto 26px; }
.hero-actions { display: flex; justify-content: center; gap: 12px; margin-bottom: 34px; }
.hero-features {
    display: inline-flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
    color: var(--muted);
    font-size: 14.5px;
}
.hero-features li { display: flex; align-items: center; gap: 10px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-emerald { background: var(--emerald); }
.dot-amber { background: var(--amber); }
.dot-cyan { background: var(--cyan); }

/* ------------------------------------------------------------------ auth */
.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 30px;
    box-shadow: var(--shadow);
}
.auth-head { text-align: center; margin-bottom: 22px; }
.auth-head h1 { font-size: 24px; margin-bottom: 6px; }
.auth-head p { color: var(--muted); font-size: 13.5px; }
.auth-foot { margin-top: 18px; text-align: center; color: var(--muted); font-size: 12.5px; }

/* ------------------------------------------------------------------ forms */
.form { display: flex; flex-direction: column; gap: 15px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; color: var(--muted); }
input[type="email"], input[type="password"], input[type="text"], input[type="number"], input[type="date"], select, textarea {
    width: 100%;
    padding: 11px 13px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14.5px;
    font-family: inherit;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--emerald-dim);
    box-shadow: 0 0 0 3px rgba(52, 211, 153, .12);
}
.check { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13.5px; cursor: pointer; }
.check input { accent-color: var(--emerald); width: 16px; height: 16px; }

/* ------------------------------------------------------------------ buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 14.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform .08s, filter .15s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(135deg, var(--emerald), #10b981); color: #04140f; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: #33465c; }
.btn-block { width: 100%; }
.btn-lg { padding: 13px 24px; font-size: 15.5px; }

/* ------------------------------------------------------------------ alerts */
.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 16px; }
.alert-error { background: rgba(248, 113, 113, .1); border: 1px solid rgba(248, 113, 113, .3); color: #fca5a5; }

/* ------------------------------------------------------------------ app shell */
.app-body { background: var(--bg); }
.app-shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
    background: var(--bg-soft);
    border-right: 1px solid var(--border);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 11px;
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-size: 14px;
    transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.is-active { background: var(--panel-2); color: var(--text); box-shadow: inset 2px 0 0 var(--emerald); }
.nav-item.is-soon { opacity: .55; cursor: not-allowed; }
.nav-icon { width: 20px; text-align: center; opacity: .85; }
.nav-soon {
    margin-left: auto;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 1px 5px;
}
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 14px; }
.risk-badge { font-size: 12.5px; color: var(--muted); }
.risk-badge strong { color: var(--text); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 15px 26px;
    border-bottom: 1px solid var(--border);
    background: rgba(11, 15, 20, .75);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 5;
}
.page-title { font-size: 17px; font-weight: 650; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user-chip {
    font-size: 13px;
    color: var(--muted);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 5px 12px;
}
.content { padding: 24px 26px 50px; }

/* ------------------------------------------------------------------ cards */
.page { display: flex; flex-direction: column; gap: 18px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.kpi {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
}
.kpi-label { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 27px; font-weight: 700; margin: 8px 0 6px; }
.kpi-value-sm { font-size: 21px; }
.kpi-hint { color: var(--muted); font-size: 12px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { font-size: 15.5px; }

.stat-rows { display: flex; flex-direction: column; gap: 2px; }
.stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 2px;
    border-bottom: 1px solid rgba(34, 48, 65, .6);
    font-size: 14px;
}
.stat-row:last-child { border-bottom: none; }
.stat-row span { color: var(--muted); }
.stat-row strong { font-size: 15px; }

.checklist { display: flex; flex-direction: column; gap: 9px; }
.checklist li { display: flex; align-items: center; gap: 11px; font-size: 14px; }
.checklist .mark {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 1px solid var(--border);
    display: inline-grid;
    place-items: center;
    font-size: 12px;
    flex: 0 0 auto;
}
.checklist .is-done { color: var(--text); }
.checklist .is-done .mark { background: var(--emerald); border-color: var(--emerald); color: #04140f; font-weight: 700; }
.checklist .is-todo { color: var(--muted); }

.roadmap { display: flex; flex-direction: column; gap: 11px; }
.roadmap-item { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--text); }
.pill {
    flex: 0 0 auto;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid transparent;
}
.pill-emerald { background: rgba(52, 211, 153, .12); color: var(--emerald); border-color: rgba(52, 211, 153, .3); }
.pill-amber { background: rgba(251, 191, 36, .1); color: var(--amber); border-color: rgba(251, 191, 36, .3); }
.pill-slate { background: rgba(139, 152, 165, .1); color: var(--muted); border-color: var(--border); }

/* ------------------------------------------------------------------ error */
.error-page { text-align: center; padding: 60px 20px; }
.error-code { font-size: 64px; font-weight: 800; color: var(--emerald); opacity: .85; }
.error-page h1 { margin: 8px 0 10px; }
.error-page p { color: var(--muted); margin-bottom: 22px; }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
    text-align: left;
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td { padding: 11px 12px; border-bottom: 1px solid rgba(34, 48, 65, .6); vertical-align: middle; }
.data-table tbody tr:hover { background: rgba(22, 32, 44, .5); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .nowrap { white-space: nowrap; }

.pos { color: var(--emerald); }
.neg { color: var(--red); }
.flat { color: var(--muted); }

/* ------------------------------------------------------------------ badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11.5px;
    border: 1px solid var(--border);
    color: var(--muted);
    white-space: nowrap;
}
.badge-class { background: rgba(34, 211, 238, .1); color: var(--cyan); border-color: rgba(34, 211, 238, .25); }
.badge-warn { background: rgba(251, 191, 36, .1); color: var(--amber); border-color: rgba(251, 191, 36, .3); }
.badge-kind { background: rgba(52, 211, 153, .1); color: var(--emerald); border-color: rgba(52, 211, 153, .25); }
.badge-buy { background: rgba(52, 211, 153, .12); color: var(--emerald); border-color: rgba(52, 211, 153, .3); }
.badge-sell { background: rgba(248, 113, 113, .12); color: var(--red); border-color: rgba(248, 113, 113, .3); }
.badge-deposit { background: rgba(34, 211, 238, .12); color: var(--cyan); border-color: rgba(34, 211, 238, .3); }
.badge-withdrawal, .badge-fee { background: rgba(251, 191, 36, .12); color: var(--amber); border-color: rgba(251, 191, 36, .3); }
.badge-dividend, .badge-interest { background: rgba(52, 211, 153, .1); color: var(--emerald); border-color: rgba(52, 211, 153, .25); }
.badge-hold { background: rgba(139, 152, 165, .12); color: var(--muted); border-color: var(--border); }
.badge-avoid { background: rgba(139, 152, 165, .1); color: #94a3b8; border-color: var(--border); }
.badge-reduce { background: rgba(251, 191, 36, .12); color: var(--amber); border-color: rgba(251, 191, 36, .3); }
.badge-rebalance { background: rgba(34, 211, 238, .12); color: var(--cyan); border-color: rgba(34, 211, 238, .3); }

/* ------------------------------------------------------------------ signals */
.signals { display: flex; flex-direction: column; gap: 12px; }
.signal { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; background: var(--bg-soft); }
.signal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.signal-levels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
}
.signal-levels div { display: flex; flex-direction: column; gap: 2px; }
.signal-levels span { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; }
.signal-levels b { font-size: 14px; font-variant-numeric: tabular-nums; }
.reasons { display: flex; flex-direction: column; gap: 5px; margin-top: 10px; padding-left: 16px; list-style: disc; }
.reasons li { color: #cbd5e1; font-size: 13.5px; }

/* ------------------------------------------------------------------ flags & alerts */
.flag-list { display: flex; flex-direction: column; gap: 12px; }
.flag { display: flex; align-items: flex-start; gap: 11px; }
.flag strong { display: block; font-size: 14px; }
.flag.is-read { opacity: .55; }
.pill-danger { background: rgba(248, 113, 113, .12); color: var(--red); border-color: rgba(248, 113, 113, .3); }
.btn-primary.btn-sm, .btn-ghost.btn-sm { padding: 4px 10px; font-size: 13px; }

/* ------------------------------------------------------------------ advisor chat */
.chat {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 10px 0 18px;
    max-height: 540px;
    overflow-y: auto;
}
.chat-msg { display: flex; flex-direction: column; gap: 4px; max-width: 82%; }
.chat-user { align-self: flex-end; align-items: flex-end; }
.chat-assistant { align-self: flex-start; }
.chat-bubble { padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.55; }
.chat-user .chat-bubble {
    background: linear-gradient(135deg, rgba(52, 211, 153, .16), rgba(34, 211, 238, .12));
    border: 1px solid rgba(52, 211, 153, .3);
}
.chat-assistant .chat-bubble { background: var(--bg-soft); border: 1px solid var(--border); }
.chat-time { font-size: 11px; }
.chat-form { display: flex; gap: 10px; align-items: flex-end; }
.chat-form textarea { flex: 1; }
.ai-text { font-size: 14px; line-height: 1.6; color: #e6edf3; }

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(4, 20, 15, .3);
    border-top-color: #04140f;
    border-radius: 50%;
    animation: fp-spin .75s linear infinite;
    vertical-align: -2px;
    margin-right: 8px;
}
.spinner-light {
    border-color: rgba(139, 152, 165, .35);
    border-top-color: var(--emerald);
    margin-right: 0;
}
@keyframes fp-spin {
    to { transform: rotate(360deg); }
}
.chat-status {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    color: var(--muted);
    font-size: 13.5px;
}
.chat-status[hidden] { display: none; }

@media (max-width: 640px) {
    .chat-msg { max-width: 100%; }
    .chat-form { flex-direction: column; align-items: stretch; }
}

/* ------------------------------------------------------------------ forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.field-wide { grid-column: 1 / -1; }
.form-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.form-inline { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.form-inline .field { min-width: 120px; }
.filter-bar { display: flex; align-items: center; gap: 8px; }
.filter-bar select, .filter-bar input { width: auto; padding: 8px 10px; font-size: 13.5px; }
textarea { resize: vertical; min-height: 80px; }
.btn-danger { background: transparent; border-color: rgba(248, 113, 113, .4); color: var(--red); }
.btn-danger:hover { background: rgba(248, 113, 113, .12); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-primary.btn-sm { color: #04140f; }

.alert-success { background: rgba(52, 211, 153, .1); border: 1px solid rgba(52, 211, 153, .3); color: #6ee7b7; }

/* ------------------------------------------------------------------ charts & holdings */
.chart { width: 100%; max-height: 260px; }
.legend { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.legend li { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--muted); }
.legend li strong { color: var(--text); }

.holdings { display: flex; flex-direction: column; gap: 12px; }
.holding { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; background: var(--bg-soft); }
.holding-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.holding-title { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.holding-title strong { font-size: 15.5px; }
.holding-value { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.holding-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 10px;
    margin-bottom: 10px;
}
.holding-grid div { display: flex; flex-direction: column; gap: 2px; }
.holding-grid span { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; }
.holding-grid b { font-size: 14px; font-variant-numeric: tabular-nums; }
.holding-plan summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 6px 0; }
.holding-plan summary:hover { color: var(--text); }
.holding-plan .form-inline { margin-top: 10px; }

.empty {
    padding: 26px 18px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

/* ------------------------------------------------------------------ timeline */
.timeline { display: flex; flex-direction: column; gap: 14px; }
.timeline-item { border-left: 2px solid var(--border); padding: 2px 0 2px 16px; }
.timeline-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 6px; }
.timeline-head .muted { margin-left: auto; font-size: 12px; }
.timeline-body { color: #cbd5e1; font-size: 14px; }
.timeline-meta { display: flex; gap: 14px; margin-top: 7px; color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------------ integrations */
.integration-list { display: flex; flex-direction: column; gap: 12px; }
.integration { display: flex; align-items: flex-start; gap: 11px; }
.integration strong { display: block; font-size: 14px; font-weight: 600; }
.integration .muted { font-size: 12.5px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex: 0 0 auto; }
.status-dot.is-ok { background: var(--emerald); box-shadow: 0 0 0 3px rgba(52, 211, 153, .16); }
.status-dot.is-off { background: var(--red); box-shadow: 0 0 0 3px rgba(248, 113, 113, .14); }

code { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; font-size: 12.5px; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 860px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: static;
        height: auto;
        flex-direction: row;
        align-items: center;
        overflow-x: auto;
        gap: 12px;
        padding: 12px 14px;
    }
    .nav { flex-direction: row; gap: 4px; }
    .nav-soon, .sidebar-foot { display: none; }
    .content { padding: 18px 14px 40px; }
    .topbar { padding: 12px 14px; }
    .hero h1 { font-size: 31px; }
    .hero-lead { font-size: 15px; }
}
