:root {
    color-scheme: dark;
    --background: #0b0d12;
    --surface: #141821;
    --surface-soft: #191e28;
    --border: #272d39;
    --text: #f2f4f8;
    --muted: #929aaa;
    --positive: #46d79a;
    --negative: #f2f4f8;
    --accent: #8ea7ff;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(142,167,255,.08), transparent 34rem),
        var(--background);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
                 "Segoe UI", sans-serif;
}

.container {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 42px 0;
}

.topbar, .section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.top-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

h1, h2, p { margin-top: 0; }

h1 {
    margin-bottom: 8px;
    font-size: clamp(2rem, 5vw, 3.4rem);
    letter-spacing: -.05em;
}

h2 {
    margin-bottom: 0;
    font-size: 1.45rem;
}

.eyebrow {
    margin-bottom: 8px;
    color: var(--accent);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .16em;
}

.subtitle, .stat-detail, .stock-ticker, .small, footer {
    color: var(--muted);
}

.button {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: 0 18px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
}

.button.secondary { background: transparent; }
.button:hover { background: var(--surface-soft); }

.error-box, .login-error {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-soft);
    color: var(--text);
}

.error-box {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 24px;
    padding: 16px 18px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
    margin-top: 32px;
}

.stat-card, .portfolio-section {
    border: 1px solid var(--border);
    background: rgba(20,24,33,.92);
}

.stat-card {
    min-width: 0;
    padding: 20px;
    border-radius: 16px;
}

.stat-label {
    display: block;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: .85rem;
}

.stat-value {
    display: block;
    overflow-wrap: anywhere;
    font-size: clamp(1.25rem, 3vw, 1.8rem);
    letter-spacing: -.04em;
}

.stat-detail {
    display: block;
    margin-top: 4px;
    font-size: .86rem;
}

.positive { color: var(--positive); }
.negative { color: var(--negative); }

.portfolio-section {
    margin-top: 18px;
    padding: 22px;
    border-radius: 18px;
}

.position-count {
    padding: 7px 10px;
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--muted);
    font-size: .8rem;
}

.table-wrap {
    margin-top: 20px;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 820px;
}

th, td {
    padding: 15px 12px;
    border-bottom: 1px solid var(--border);
    text-align: right;
}

th:first-child, td:first-child {
    padding-left: 0;
    text-align: left;
}

th:last-child, td:last-child { padding-right: 0; }

th {
    color: var(--muted);
    font-size: .73rem;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

td { font-size: .93rem; }

.stock-name {
    max-width: 260px;
    font-weight: 750;
}

.stock-ticker {
    margin-top: 4px;
    font-size: .76rem;
}

.small {
    margin-top: 4px;
    font-size: .78rem;
}

.empty-cell {
    padding: 28px 0;
    color: var(--muted);
    text-align: center !important;
}

footer {
    padding: 22px 4px 0;
    font-size: .78rem;
}

/* LOGIN */

.login-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
}

.login-panel {
    width: min(430px, 100%);
    padding: 30px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
}

.login-title {
    margin-bottom: 8px;
    font-size: 2.2rem;
}

.login-subtitle {
    margin-bottom: 24px;
    color: var(--muted);
    line-height: 1.6;
}

.login-error {
    margin-bottom: 18px;
    padding: 12px 14px;
}

.login-form {
    display: grid;
    gap: 10px;
}

.login-form label {
    margin-top: 8px;
    color: var(--muted);
    font-size: .85rem;
    font-weight: 700;
}

.login-form input {
    width: 100%;
    min-height: 46px;
    padding: 0 13px;
    border: 1px solid var(--border);
    border-radius: 10px;
    outline: none;
    background: var(--background);
    color: var(--text);
    font: inherit;
}

.login-form input:focus { border-color: var(--accent); }

.login-form button {
    min-height: 46px;
    margin-top: 12px;
    border: 0;
    border-radius: 10px;
    background: var(--text);
    color: var(--background);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

@media (max-width: 1100px) {
    .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 800px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
    .container {
        width: min(100% - 22px, 1180px);
        padding: 24px 0;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .stats-grid { grid-template-columns: 1fr; }

    .top-actions { width: 100%; }
    .button { flex: 1; }

    .portfolio-section { padding: 16px; }
    .login-panel { padding: 22px; }
}
