:root {
    --bg: #131722;
    --bg-alt: #1e222d;
    --bg-card: #1e222d;
    --panel: rgba(30, 34, 45, 0.95);
    --panel-strong: rgba(19, 23, 34, 0.98);
    --text: #d1d4dc;
    --text-bright: #ffffff;
    --muted: #787b86;
    --line: rgba(42, 46, 57, 0.8);
    --accent: #2962ff;
    --accent-2: #26a69a;
    --accent-cyan: #00bcd4;
    --positive: #26a69a;
    --negative: #ef5350;
    --danger: #ef5350;
    --warning: #ff9800;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --sidebar-width: 52px;
    --sidebar-expanded: 180px;
    --header-height: 48px;
    --border-radius: 4px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Trebuchet MS", Roboto, Ubuntu, sans-serif;
    color: var(--text);
    background: var(--bg);
    overflow: hidden;
    font-size: 13px;
}

/* ============================================ */
/* APP MODE - DESKTOP APPLICATION LAYOUT       */
/* ============================================ */

body.app-mode {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: var(--header-height) 1fr;
    grid-template-areas:
        "sidebar header"
        "sidebar main";
    height: 100vh;
    overflow: hidden;
}

/* SIDEBAR */
.app-sidebar {
    grid-area: sidebar;
    background: var(--bg);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width 200ms ease;
}

.app-sidebar:hover {
    width: var(--sidebar-expanded);
}

.sidebar-logo {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--line);
}

.logo-icon {
    font-size: 1.5rem;
    color: var(--accent-cyan);
    font-weight: bold;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin: 0 6px;
    border-radius: var(--border-radius);
    background: transparent;
    border: none;
    color: var(--muted);
    cursor: pointer;
    transition: all 150ms ease;
    white-space: nowrap;
    overflow: hidden;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-item span {
    opacity: 0;
    font-size: 0.85rem;
    font-weight: 500;
    transition: opacity 150ms ease;
}

.app-sidebar:hover .nav-item span {
    opacity: 1;
}

.nav-item:hover {
    background: var(--bg-alt);
    color: var(--text);
}

.nav-item.active {
    background: var(--accent);
    color: #ffffff;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: center;
}

.sidebar-btn {
    padding: 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    color: var(--muted);
    cursor: pointer;
    transition: all 150ms ease;
}

.sidebar-btn:hover {
    background: rgba(255, 126, 107, 0.15);
    color: var(--danger);
}

.sidebar-btn svg {
    width: 20px;
    height: 20px;
}

/* HEADER */
.app-header {
    grid-area: header;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    gap: 16px;
    z-index: 90;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.header-left h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
}

.status-badge {
    padding: 3px 8px;
    border-radius: var(--border-radius);
    background: rgba(38, 166, 154, 0.15);
    color: var(--positive);
    font-size: 0.7rem;
    white-space: nowrap;
    font-weight: 500;
}

.mode-strip-inline {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--border-radius);
    margin-bottom: 16px;
    overflow: hidden;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    border-radius: var(--border-radius);
    background: transparent;
    border: 1px solid var(--line);
    color: var(--text);
    cursor: pointer;
    transition: all 150ms ease;
    font-weight: 500;
    font-size: 0.8rem;
}

.header-btn svg {
    width: 16px;
    height: 16px;
}

.header-btn:hover {
    background: var(--bg-alt);
    border-color: var(--muted);
}

.header-btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
}

.header-btn.primary:hover {
    background: #1e53e4;
    box-shadow: 0 2px 8px rgba(41, 98, 255, 0.3);
}

.header-btn.accent {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

.header-btn.accent:hover {
    background: rgba(0, 188, 212, 0.1);
}

/* MAIN CONTENT */
.app-main {
    grid-area: main;
    overflow: hidden;
    position: relative;
    background: var(--bg);
}

.app-view {
    position: absolute;
    inset: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 200ms ease, visibility 200ms ease;
    overflow: hidden;
}

.app-view.active {
    opacity: 1;
    visibility: visible;
}

.view-content {
    height: 100%;
    padding: 16px 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.view-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
}

.toolbar-right {
    display: flex;
    gap: 8px;
}

/* METRICS STRIP */
.metrics-strip {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.metric-tile {
    flex: 1;
    min-width: 90px;
    padding: 10px 12px;
    border-radius: var(--border-radius);
    background: var(--bg-alt);
    border: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.metric-tile.accent {
    border-left: 3px solid var(--accent-cyan);
}

.metric-tile.positive {
    border-left: 3px solid var(--positive);
}

.metric-tile.positive .metric-value {
    color: var(--positive);
}

.metric-tile.negative {
    border-left: 3px solid var(--negative);
}

.metric-tile.negative .metric-value {
    color: var(--negative);
}

.metric-label {
    color: var(--muted);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-value {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-bright);
}

/* CARDS */
.card {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.card-header {
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
    background: rgba(42, 46, 57, 0.3);
}

.card-header h3 {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text);
}

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

.card-meta {
    color: var(--muted);
    font-size: 0.75rem;
}

.card-body {
    padding: 12px 14px;
    flex: 1;
    min-height: 0;
}

.card-body.scrollable {
    overflow-y: auto;
}

.small-btn {
    padding: 6px 12px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--line);
    color: var(--text);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 150ms ease;
}

.small-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Collapsible card headers */
.card-header.collapsible {
    cursor: pointer;
}

.card-header.collapsible:hover {
    background: rgba(255, 255, 255, 0.02);
}

.collapse-icon {
    font-size: 0.7rem;
    transition: transform 200ms ease;
}

.card-header.collapsible.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.sub-header {
    margin: 16px 0 10px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

/* GRID LAYOUTS */
.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1.15fr) minmax(280px, 0.7fr);
    grid-template-rows: auto auto auto;
    gap: 12px;
}

.dashboard-grid .agent-card { grid-column: 1; grid-row: 1; }
.dashboard-grid .finance-card { grid-column: 2; grid-row: 1; }
.dashboard-grid .watchlist-card { grid-column: 3; grid-row: 1 / span 2; }
.dashboard-grid .summary-card { grid-column: 1; grid-row: 2; }
.dashboard-grid .positions-card { grid-column: 2; grid-row: 2; }
.dashboard-grid .private-learning-card { grid-column: 1 / span 2; grid-row: 3; }
.dashboard-grid .trade-ranking-card { grid-column: 3; grid-row: 3; }

.market-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 16px;
    flex: 1;
    min-height: 0;
}

.market-table-card {
    overflow: auto;
}

.positions-sidebar {
    max-height: 100%;
}

.charts-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 16px;
    flex: 1;
    min-height: 0;
}

.chart-card {
    overflow: auto;
}

.learning-card {
    max-height: 100%;
}

.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    flex: 1;
    min-height: 0;
}

.activity-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    flex: 1;
    min-height: 0;
}

.ai-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 16px;
    flex: 1;
    min-height: 0;
}

.ai-card {
    display: flex;
    flex-direction: column;
}

.ai-message {
    font-size: 1.05rem;
    line-height: 1.7;
    margin: 0;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.watchlist {
    display: grid;
    gap: 8px;
}

.watchlist-row {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--border-radius);
    background: var(--bg-alt);
    color: var(--text);
    cursor: pointer;
    transition: background 150ms ease, border-color 150ms ease;
}

.watchlist-row:hover,
.watchlist-row.active {
    background: rgba(41, 98, 255, 0.12);
    border-color: rgba(41, 98, 255, 0.4);
}

.watchlist-symbol {
    font-weight: 700;
    color: var(--text-bright);
}

.watchlist-price {
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.watchlist-change {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.private-learning-card .stack-item {
    background: linear-gradient(180deg, rgba(30, 34, 45, 0.98), rgba(25, 28, 38, 0.98));
}

.private-learning-card .badge {
    justify-self: end;
}

.trade-ranking-card .stack-item {
    background: linear-gradient(180deg, rgba(30, 34, 45, 0.98), rgba(25, 28, 38, 0.98));
}

.trade-ranking-row {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 8px;
    align-items: center;
    padding: 8px 10px;
    border-radius: var(--border-radius);
    background: var(--bg-alt);
    border: 1px solid var(--line);
    font-size: 0.8rem;
}

.trade-ranking-rank {
    font-weight: 700;
    color: var(--muted);
    min-width: 20px;
    text-align: center;
}

.trade-ranking-symbol {
    font-weight: 700;
    color: var(--text-bright);
}

.trade-ranking-count {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.trade-ranking-pnl {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Finance grid */
.finance-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

/* ============================================ */
/* MOBILE HERO (hidden on desktop)             */
/* ============================================ */

.mobile-hero {
    display: none;
}

.mobile-actions {
    display: none;
}

.sched-label { /* visible on desktop header only */ }

/* ============================================ */
/* APP MODE - MOBILE LAYOUT                    */
/* ============================================ */

/* Mobile bottom navigation */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(6, 16, 22, 0.98);
    border-top: 1px solid var(--line);
    padding: 6px 0;
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    z-index: 100;
    backdrop-filter: blur(10px);
}

.mobile-nav-items {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    border-radius: 8px;
    transition: all 150ms ease;
}

.mobile-nav-item svg {
    width: 22px;
    height: 22px;
}

.mobile-nav-item span {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.mobile-nav-item.active {
    color: var(--accent);
}

.mobile-nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* ============================================ */
/* MOBILE BREAKPOINT                           */
/* ============================================ */

@media (max-width: 768px) {
    /* Base font bump for readability */
    body {
        font-size: 15px;
    }
    
    body.app-mode {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        grid-template-areas:
            "header"
            "main"
            "mobilenav";
    }
    
    .app-sidebar {
        display: none;
    }
    
    .mobile-nav {
        display: block;
        grid-area: mobilenav;
    }
    
    /* ---- HEADER: clean, minimal on mobile ---- */
    .app-header {
        padding: 0 16px;
        height: 52px;
        min-height: 52px;
    }
    
    .header-left h1 {
        font-size: 1.2rem;
        font-weight: 700;
    }
    
    .status-badge {
        display: none;
    }
    
    .mode-strip-inline {
        display: none;
    }
    
    /* On mobile: hide text labels & some buttons from header */
    .header-btn span,
    .header-btn .sched-label {
        display: none;
    }
    
    #scheduler-button,
    #run-cycle-button {
        display: none;
    }
    
    .header-btn {
        padding: 8px;
        min-height: 40px;
        min-width: 40px;
        justify-content: center;
        border-radius: 10px;
    }
    
    .header-btn svg {
        width: 22px;
        height: 22px;
    }
    
    .header-right {
        gap: 6px;
    }
    
    /* ---- MAIN CONTENT ---- */
    .app-main {
        padding-bottom: 0;
        overflow: hidden;
    }
    
    .view-content {
        padding: 16px;
        padding-bottom: calc(16px + 68px);
        gap: 16px;
    }
    
    /* ---- MOBILE HERO: big balance card ---- */
    .mobile-hero {
        display: flex;
        flex-direction: column;
        gap: 14px;
        padding: 20px;
        background: linear-gradient(135deg, rgba(41, 98, 255, 0.12), rgba(0, 188, 212, 0.08));
        border: 1px solid rgba(41, 98, 255, 0.25);
        border-radius: 16px;
    }
    
    .mobile-hero-main {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
    
    .mobile-hero-label {
        font-size: 0.8rem;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: var(--muted);
        font-weight: 600;
    }
    
    .mobile-hero-value {
        font-size: 2rem;
        font-weight: 800;
        color: var(--text-bright);
        letter-spacing: -0.02em;
    }
    
    .mobile-hero-row {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }
    
    .mobile-hero-stat {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }
    
    .mobile-hero-stat span {
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        color: var(--muted);
        font-weight: 600;
    }
    
    .mobile-hero-stat strong {
        font-size: 1.1rem;
        font-weight: 700;
        color: var(--text-bright);
    }
    
    .mobile-hero-stat.positive strong { color: var(--positive); }
    .mobile-hero-stat.negative strong { color: var(--negative); }
    
    /* ---- MOBILE ACTIONS: cycle + scheduler buttons ---- */
    .mobile-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .mobile-action-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 14px 16px;
        border-radius: 12px;
        border: 1px solid var(--line);
        background: var(--bg-alt);
        color: var(--text);
        font-size: 0.9rem;
        font-weight: 600;
        cursor: pointer;
        transition: all 150ms ease;
        min-height: 50px;
    }
    
    .mobile-action-btn svg {
        width: 20px;
        height: 20px;
        flex-shrink: 0;
    }
    
    .mobile-action-btn.primary {
        background: var(--accent);
        border-color: var(--accent);
        color: #fff;
    }
    
    .mobile-action-btn.primary:active {
        background: #1e53e4;
    }
    
    .mobile-action-btn:active {
        background: rgba(255, 255, 255, 0.08);
    }
    
    /* ---- METRICS: hide on mobile (hero replaces them) ---- */
    .metrics-strip {
        display: none;
    }
    
    /* ---- GRIDS: single column ---- */
    .dashboard-grid,
    .market-layout,
    .charts-layout,
    .portfolio-grid,
    .activity-grid,
    .ai-layout,
    .settings-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .dashboard-grid .agent-card,
    .dashboard-grid .finance-card,
    .dashboard-grid .summary-card,
    .dashboard-grid .positions-card,
    .dashboard-grid .watchlist-card,
    .dashboard-grid .private-learning-card,
    .dashboard-grid .trade-ranking-card {
        grid-column: 1;
        grid-row: auto;
    }
    
    .finance-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .view-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .toolbar-right {
        flex-wrap: wrap;
    }
    
    /* ---- CARDS: clean, spacious, readable ---- */
    .card {
        border-radius: 14px;
        border: 1px solid rgba(42, 46, 57, 0.6);
        overflow: hidden;
    }
    
    .card-header {
        padding: 16px 18px;
        background: rgba(42, 46, 57, 0.25);
        border-bottom: 1px solid rgba(42, 46, 57, 0.5);
    }
    
    .card-header h3 {
        font-size: 0.9rem;
        font-weight: 700;
        letter-spacing: 0.04em;
        color: var(--text-bright);
    }
    
    .card-body {
        padding: 16px 18px;
    }
    
    /* ---- MOBILE ACCORDION for dashboard cards ---- */
    .dashboard-grid .card > .card-header {
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        user-select: none;
        min-height: 54px;
        transition: background 150ms ease;
        display: flex;
        align-items: center;
    }
    
    .dashboard-grid .card > .card-header:active {
        background: rgba(41, 98, 255, 0.1);
    }
    
    /* Chevron indicator */
    .dashboard-grid .card > .card-header::after {
        content: '';
        width: 9px;
        height: 9px;
        border-right: 2px solid var(--muted);
        border-bottom: 2px solid var(--muted);
        transform: rotate(45deg);
        transition: transform 250ms ease;
        flex-shrink: 0;
        margin-left: auto;
    }
    
    .dashboard-grid .card > .card-header.m-collapsed::after {
        transform: rotate(-45deg);
    }
    
    .dashboard-grid .card > .card-body.m-hidden {
        display: none;
    }
    
    /* Agent mode card — always visible, first card */
    .dashboard-grid .agent-card {
        order: -1;
    }
    
    /* ---- SWITCHER buttons (agent modes etc) ---- */
    .switcher {
        gap: 8px;
    }
    
    .switcher-button {
        padding: 12px 16px;
        font-size: 0.85rem;
        min-height: 48px;
        border-radius: 10px;
        font-weight: 600;
    }
    
    /* ---- STACK LIST items ---- */
    .stack-item {
        padding: 14px 16px;
        font-size: 0.9rem;
        border-radius: 10px;
    }
    
    /* ---- TABLE ---- */
    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .market-table {
        min-width: 800px;
    }
    
    /* ---- CHART ---- */
    .chart-stage {
        min-height: 350px;
    }
    
    .chart-svg {
        height: 330px;
    }
    
    /* ---- WATCHLIST rows more spacious ---- */
    .watchlist-row {
        padding: 12px 14px;
        border-radius: 10px;
        font-size: 0.9rem;
    }
    
    .watchlist-symbol {
        font-size: 0.95rem;
    }
    
    /* ---- TRADE RANKING rows ---- */
    .trade-ranking-row {
        padding: 12px 14px;
        border-radius: 10px;
        font-size: 0.85rem;
    }
    
    /* ---- QUICK SUMMARY ---- */
    .quick-summary-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }
    
    .quick-card {
        padding: 14px;
        border-radius: 10px;
    }
    
    .quick-card span {
        font-size: 0.75rem;
    }
    
    .quick-card strong {
        font-size: 1.05rem;
    }
    
    /* ---- AI message ---- */
    .ai-message {
        font-size: 1rem;
        line-height: 1.7;
    }
}

/* Extra small screens (iPhone SE, etc) */
@media (max-width: 380px) {
    .header-left h1 {
        font-size: 1.05rem;
    }
    
    .mobile-hero {
        padding: 16px;
    }
    
    .mobile-hero-value {
        font-size: 1.7rem;
    }
    
    .mobile-hero-stat strong {
        font-size: 1rem;
    }
    
    .mobile-hero-row {
        gap: 8px;
    }
    
    .mobile-action-btn {
        padding: 12px 12px;
        font-size: 0.82rem;
    }
    
    .mobile-nav-item {
        padding: 6px 8px;
    }
    
    .mobile-nav-item svg {
        width: 20px;
        height: 20px;
    }
    
    .mobile-nav-item span {
        font-size: 0.55rem;
    }
}

/* iPhone safe areas */
@supports (padding: env(safe-area-inset-bottom)) {
    body.app-mode {
        padding-top: env(safe-area-inset-top);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    
    .app-header {
        padding-top: env(safe-area-inset-top);
        height: calc(52px + env(safe-area-inset-top));
    }
    
    @media (max-width: 768px) {
        .view-content {
            padding-bottom: calc(16px + 68px + env(safe-area-inset-bottom));
        }
    }
}

/* PWA Standalone mode on mobile */
@media (display-mode: standalone) and (max-width: 768px) {
    body.app-mode {
        height: 100vh;
        height: -webkit-fill-available;
    }
    
    .app-main {
        height: calc(100vh - 52px - 68px);
        height: calc(-webkit-fill-available - 52px - 68px);
    }
}

/* ============================================ */
/* END APP MODE STYLES                         */
/* ============================================ */

.shell {
    position: relative;
    width: min(1280px, calc(100% - 32px));
    margin: 24px auto 40px;
    display: grid;
    gap: 18px;
}

.menu-toggle-button {
    position: fixed;
    top: 18px;
    left: 18px;
    z-index: 30;
    padding-inline: 18px;
}

.page-menu {
    position: fixed;
    top: 16px;
    left: 16px;
    width: min(320px, calc(100vw - 32px));
    padding: 18px;
    z-index: 40;
    transform: translateX(calc(-100% - 24px));
    transition: transform 180ms ease;
}

body.menu-open .page-menu {
    transform: translateX(0);
}

body.menu-open .menu-toggle-button {
    opacity: 0;
    pointer-events: none;
}

.page-menu-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.menu-close-button {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    border: 1px solid var(--line);
}

.page-menu-links {
    display: grid;
    gap: 8px;
}

.page-menu-links a {
    display: block;
    padding: 12px 14px;
    border-radius: 14px;
    color: var(--text);
    text-decoration: none;
    background: var(--panel-strong);
    border: 1px solid var(--line);
}

.page-menu-links a:hover {
    background: rgba(79, 209, 166, 0.12);
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: var(--shadow);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
}

.hero {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 20px;
    padding: 28px;
}

.eyebrow {
    margin: 0 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.72rem;
    color: var(--accent);
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: clamp(2rem, 4vw, 3.6rem);
    line-height: 0.96;
}

h2 {
    font-size: 1rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.hero-copy {
    max-width: 700px;
    margin-top: 12px;
    color: var(--muted);
    line-height: 1.6;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.chart-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

button {
    appearance: none;
    border: 0;
    cursor: pointer;
    border-radius: 999px;
    padding: 12px 20px;
    font-weight: 700;
    transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

button:hover {
    transform: translateY(-1px);
}

.primary-button {
    background: linear-gradient(135deg, var(--accent), #ffd07a);
    color: #1e1a13;
}

.secondary-button {
    background: rgba(79, 209, 166, 0.16);
    color: var(--text);
    border: 1px solid rgba(79, 209, 166, 0.28);
}

.ghost-button {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--line);
}

.metrics-grid,
.secondary-grid {
    display: grid;
    gap: 16px;
}

.metrics-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.quick-grid {
    display: grid;
    gap: 16px;
}

.overview-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: 1.1fr 1fr 1fr;
}

.control-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.4fr);
}

.metric-card {
    padding: 22px;
    display: grid;
    gap: 8px;
}

.metric-card span {
    color: var(--muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.metric-card strong {
    font-size: clamp(1.35rem, 3vw, 2.15rem);
}

.metric-card.accent {
    background: linear-gradient(160deg, rgba(240, 180, 74, 0.14), rgba(79, 209, 166, 0.08));
}

.mode-strip {
    padding: 18px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
}

.mode-chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.08);
}

.status-pill.buy {
    background: rgba(79, 209, 166, 0.16);
    color: #8ef7d0;
}

.status-pill.sell {
    background: rgba(255, 126, 107, 0.16);
    color: #ffb4a8;
}

.status-pill.hold {
    background: rgba(240, 180, 74, 0.16);
    color: #ffd98c;
}

.status-pill.neutral {
    background: rgba(141, 185, 255, 0.16);
    color: #b8d1ff;
}

.status-pill.live-pulse {
    background: rgba(240, 180, 74, 0.18);
    color: #ffe1a5;
    box-shadow: 0 0 0 1px rgba(240, 180, 74, 0.12), 0 0 18px rgba(240, 180, 74, 0.16);
    animation: pulse-pill 1.6s ease-in-out infinite;
}

@keyframes pulse-pill {
    0%,
    100% {
        transform: translateY(0);
        box-shadow: 0 0 0 1px rgba(240, 180, 74, 0.12), 0 0 18px rgba(240, 180, 74, 0.12);
    }
    50% {
        transform: translateY(-1px);
        box-shadow: 0 0 0 1px rgba(240, 180, 74, 0.22), 0 0 22px rgba(240, 180, 74, 0.24);
    }
}

.mode-strip-copy {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.mode-strip-copy strong {
    font-size: 0.98rem;
}

.mode-strip-copy span {
    color: var(--muted);
    font-size: 0.9rem;
}

.mode-live-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 6px;
}

.quick-summary-panel {
    padding: 22px;
}

.quick-summary-grid {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.quick-card {
    padding: 12px;
    border-radius: var(--border-radius);
    background: var(--bg-alt);
    border: 1px solid var(--line);
    display: grid;
    gap: 6px;
}

.quick-card span {
    color: var(--muted);
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.quick-card strong {
    font-size: 0.98rem;
    color: var(--text-bright);
}

.quick-card small {
    color: var(--muted);
    line-height: 1.35;
    font-size: 0.76rem;
}

.control-panel {
    padding: 22px;
}

.finance-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.finance-api-list {
    margin-top: 14px;
}

.overview-panel {
    padding: 22px;
}

.coin-menu {
    display: grid;
    gap: 12px;
}

.coin-menu-item {
    padding: 16px;
    border-radius: 18px;
    background: var(--panel-strong);
    border: 1px solid var(--line);
    display: grid;
    gap: 8px;
}

.coin-menu-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.coin-menu-meta {
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.4;
}

.main-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1.8fr) minmax(320px, 0.9fr);
}

.analytics-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr);
}

.operations-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.secondary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.section-head-sub {
    margin-top: 20px;
    margin-bottom: 12px;
}

.inline-meta,
.status-line {
    color: var(--muted);
    font-size: 0.9rem;
}

.table-wrap {
    overflow-x: auto;
}

.market-row {
    cursor: pointer;
    transition: background 160ms ease;
}

.market-row:hover,
.market-row.active {
    background: rgba(42, 46, 57, 0.6);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    font-size: 0.82rem;
}

th {
    color: var(--muted);
    font-weight: 600;
    background: rgba(42, 46, 57, 0.3);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stack-list {
    display: grid;
    gap: 8px;
}

.stack-list.compact {
    gap: 6px;
}

.stack-item {
    padding: 12px;
    border-radius: var(--border-radius);
    background: var(--bg-alt);
    border: 1px solid var(--line);
    display: grid;
    gap: 6px;
}

.stack-item-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 0.85rem;
}

.stack-item-meta {
    color: var(--muted);
    line-height: 1.4;
    font-size: 0.8rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: var(--border-radius);
    font-size: 0.7rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    font-weight: 600;
}

.badge.buy {
    background: rgba(38, 166, 154, 0.2);
    color: var(--positive);
}

.badge.sell {
    background: rgba(239, 83, 80, 0.2);
    color: var(--negative);
}

.badge.hold {
    background: rgba(255, 152, 0, 0.2);
    color: var(--warning);
}

.badge.neutral {
    background: rgba(120, 123, 134, 0.2);
    color: var(--muted);
}

.positive {
    color: #85efc6;
}

.negative {
    color: #ffae9e;
}

.insight-panel {
    padding: 22px;
}

.ai-message {
    margin-top: 12px;
    font-size: 1.05rem;
    line-height: 1.7;
    color: #f5faf7;
}

.chart-panel,
.learning-panel,
.articles-panel {
    overflow: hidden;
}

.disclosure-panel {
    padding: 0;
}

.disclosure-summary {
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 20px 22px;
    cursor: pointer;
}

.disclosure-summary::-webkit-details-marker {
    display: none;
}

.disclosure-summary strong {
    display: block;
    font-size: 1rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.disclosure-summary small {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.88rem;
}

.disclosure-body {
    padding: 0 22px 22px;
}

.switcher {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.switcher-tight .switcher-button {
    padding: 6px 10px;
    font-size: 0.72rem;
}

.chart-symbol-switcher,
.market-filter {
    margin-bottom: 10px;
}

.switcher-button {
    padding: 6px 12px;
    border-radius: var(--border-radius);
    background: transparent;
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 150ms ease;
}

.switcher-button:hover {
    color: var(--text);
    background: var(--bg-alt);
}

.switcher-button.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
}

.chart-stage {
    position: relative;
    min-height: 500px;
    border-radius: var(--border-radius);
    border: 1px solid var(--line);
    background: var(--bg-alt);
    padding: 8px;
}

.chart-svg {
    width: 100%;
    height: 480px;
    display: block;
}

.chart-overlay {
    position: absolute;
    inset: 10px;
    pointer-events: none;
}

.chart-hover-panel {
    position: absolute;
    top: 12px;
    left: 12px;
    min-width: 220px;
    max-width: min(280px, calc(100% - 24px));
    padding: 10px 12px;
    border-radius: var(--border-radius);
    background: rgba(30, 34, 45, 0.96);
    border: 1px solid var(--line);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    display: none;
    gap: 6px;
    z-index: 3;
}

.chart-hover-panel.visible {
    display: grid;
}

.chart-hover-panel.right {
    left: auto;
    right: 12px;
}

.chart-hover-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-weight: 700;
}

.chart-hover-date {
    color: var(--muted);
    font-size: 0.8rem;
}

.chart-hover-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
}

.chart-hover-item {
    display: grid;
    gap: 2px;
}

.chart-hover-item span {
    color: var(--muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.chart-hover-item strong {
    font-size: 0.95rem;
}

.summary-grid {
    margin-top: 12px;
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
}

.summary-card {
    padding: 10px 12px;
    border-radius: var(--border-radius);
    background: var(--bg-alt);
    border: 1px solid var(--line);
    display: grid;
    gap: 4px;
}

.summary-card span {
    color: var(--muted);
    font-size: 0.68rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.summary-card strong {
    font-size: 1rem;
}

.empty-state {
    padding: 16px;
    border-radius: 16px;
    border: 1px dashed var(--line);
    color: var(--muted);
}

.article-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.article-card {
    padding: 18px;
    border-radius: 18px;
    background: var(--panel-strong);
    border: 1px solid var(--line);
    display: grid;
    gap: 10px;
}

.article-card h3 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.35;
}

.article-card p {
    color: var(--muted);
    line-height: 1.55;
}

.article-meta {
    color: var(--accent);
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.article-link {
    color: var(--accent-2);
    text-decoration: none;
    font-weight: 700;
}

.article-link:hover {
    text-decoration: underline;
}

.compact-mono {
    font-variant-numeric: tabular-nums;
}

.panel:not(.hero):not(.insight-panel) {
    padding: 22px;
}

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

    .metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .analytics-grid,
    .control-grid,
    .overview-grid,
    .operations-grid,
    .main-grid,
    .secondary-grid {
        grid-template-columns: 1fr;
    }

    .article-grid,
    .summary-grid,
    .quick-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .finance-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .shell {
        width: min(100% - 18px, 100%);
        margin-top: 12px;
    }

    .hero {
        padding: 20px;
        flex-direction: column;
        align-items: stretch;
    }

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

    .article-grid,
    .summary-grid,
    .quick-summary-grid {
        grid-template-columns: 1fr;
    }

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

    .chart-hover-panel {
        min-width: 0;
        max-width: calc(100% - 24px);
        top: 12px;
        left: 12px;
    }

    .chart-hover-panel.right {
        right: 12px;
    }

    th,
    td {
        padding: 12px 8px;
        font-size: 0.85rem;
    }
}

/* ==================== */
/* MOBILE PHONE STYLES  */
/* ==================== */

@media (max-width: 480px) {
    .shell {
        width: 100%;
        margin: 8px auto 20px;
        gap: 12px;
    }

    .panel {
        border-radius: 18px;
    }

    .panel:not(.hero):not(.insight-panel) {
        padding: 16px;
    }

    .hero {
        padding: 16px;
        border-radius: 0 0 18px 18px;
        margin-top: -8px;
    }

    h1 {
        font-size: 1.8rem;
    }

    .hero-copy {
        font-size: 0.9rem;
    }

    .hero-actions {
        gap: 8px;
    }

    .hero-actions button {
        flex: 1 1 calc(50% - 4px);
        padding: 10px 14px;
        font-size: 0.82rem;
    }

    .menu-toggle-button {
        top: 12px;
        left: 12px;
        padding: 10px 14px;
        font-size: 0.8rem;
    }

    .page-menu {
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        padding: 16px;
    }

    .page-menu-links a {
        padding: 14px 16px;
        font-size: 1rem;
    }

    .mode-strip {
        padding: 14px 16px;
        gap: 12px;
    }

    .status-pill {
        padding: 6px 10px;
        font-size: 0.72rem;
    }

    .metric-card {
        padding: 16px;
    }

    .metric-card span {
        font-size: 0.75rem;
    }

    .metric-card strong {
        font-size: 1.2rem;
    }

    .section-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        margin-bottom: 14px;
    }

    .section-head h2 {
        font-size: 0.9rem;
    }

    .switcher {
        gap: 6px;
    }

    .switcher-button {
        padding: 8px 12px;
        font-size: 0.75rem;
    }

    .stack-item {
        padding: 14px;
    }

    .chart-stage {
        min-height: 400px;
        padding: 6px;
    }

    .chart-svg {
        height: 380px;
    }

    .chart-toolbar {
        gap: 6px;
    }

    .chart-toolbar button {
        padding: 8px 12px;
        font-size: 0.75rem;
    }

    table {
        font-size: 0.8rem;
    }

    th, td {
        padding: 10px 6px;
    }

    .disclosure-summary {
        padding: 16px;
    }

    .disclosure-body {
        padding: 0 16px 16px;
    }

    .ai-message {
        font-size: 0.95rem;
        line-height: 1.6;
    }

    .quick-card {
        padding: 14px;
    }

    .quick-card span {
        font-size: 0.7rem;
    }

    .quick-card strong {
        font-size: 1rem;
    }

    .badge {
        padding: 5px 8px;
        font-size: 0.7rem;
    }
}

/* PWA Standalone Mode Adjustments */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .menu-toggle-button {
        top: calc(12px + env(safe-area-inset-top));
    }

    .hero {
        margin-top: 0;
        padding-top: calc(16px + env(safe-area-inset-top));
    }
}

/* Touch-friendly buttons */
@media (pointer: coarse) {
    button {
        min-height: 44px;
    }

    .switcher-button {
        min-height: 40px;
    }

    .page-menu-links a {
        min-height: 48px;
        display: flex;
        align-items: center;
    }
}

/* Prevent text selection on mobile for better UX */
@media (max-width: 720px) {
    .metric-card,
    .status-pill,
    .badge,
    .switcher-button {
        -webkit-user-select: none;
        user-select: none;
    }
}

/* Dark mode adjustments for OLED screens */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #000000;
    }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        padding: 12px 16px;
    }

    h1 {
        font-size: 1.5rem;
    }

    .hero-copy {
        display: none;
    }

    .chart-stage {
        min-height: 280px;
    }

    .chart-svg {
        height: 260px;
    }
}

/* Pull to refresh indicator placeholder */
.pull-to-refresh {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--panel);
    transform: translateY(-100%);
    transition: transform 200ms ease;
    z-index: 100;
}

.pull-to-refresh.visible {
    transform: translateY(0);
}

/* ============================================ */
/* LOGIN SCREEN                                */
/* ============================================ */

.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(160deg, #061017 0%, #091b23 48%, #0f2731 100%);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-overlay.hidden {
    display: none;
}

.login-container {
    width: 100%;
    max-width: 400px;
    background: var(--panel-strong);
    border-radius: 20px;
    padding: 40px 32px;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.logo-icon.large {
    font-size: 3rem;
    display: block;
    margin-bottom: 12px;
}

.login-logo h1 {
    font-size: 1.8rem;
    margin: 0;
    color: var(--text);
}

.login-subtitle {
    color: var(--muted);
    font-size: 0.9rem;
    margin: 8px 0 0 0;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-form.hidden {
    display: none;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 500;
}

.form-group input {
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--bg-alt);
    color: var(--text);
    font-size: 1rem;
    transition: all 150ms ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(240, 180, 74, 0.15);
}

.form-group input::placeholder {
    color: var(--muted);
    opacity: 0.6;
}

.btn-primary {
    padding: 14px 24px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, var(--accent) 0%, #d99b3a 100%);
    color: #0a1a22;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 150ms ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(240, 180, 74, 0.3);
}

.btn-ghost {
    padding: 12px 24px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--muted);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 150ms ease;
}

.btn-ghost:hover {
    border-color: var(--muted);
    color: var(--text);
}

.btn-full {
    width: 100%;
}

.auth-switch {
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    margin: 8px 0;
}

.auth-switch a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.auth-switch a:hover {
    text-decoration: underline;
}

.auth-error {
    background: rgba(255, 126, 107, 0.15);
    border: 1px solid var(--danger);
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--danger);
    font-size: 0.9rem;
    text-align: center;
}

.auth-error.hidden {
    display: none;
}

#skip-login {
    margin-top: 24px;
    border-top: 1px solid var(--line);
    padding-top: 24px;
}

/* ============================================ */
/* USER MENU                                   */
/* ============================================ */

.user-menu-container {
    position: relative;
}

.user-btn {
    gap: 6px;
}

.user-btn span {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    min-width: 200px;
    background: var(--panel-strong);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    z-index: 200;
}

.user-dropdown.hidden {
    display: none;
}

.dropdown-header {
    padding: 16px;
    background: var(--bg-alt);
    border-bottom: 1px solid var(--line);
}

.user-email {
    color: var(--muted);
    font-size: 0.85rem;
}

.dropdown-divider {
    height: 1px;
    background: var(--line);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 150ms ease;
    text-align: left;
}

.dropdown-item:hover {
    background: var(--bg-alt);
}

.dropdown-item svg {
    width: 18px;
    height: 18px;
    stroke: var(--muted);
}

/* ============================================ */
/* API KEYS MANAGEMENT                         */
/* ============================================ */

.api-keys-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.api-key-form {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-alt);
    border-radius: 12px;
    border: 1px solid var(--line);
}

.api-key-form.hidden {
    display: none;
}

.form-row {
    margin-bottom: 12px;
}

.form-row.inline {
    display: flex;
    align-items: center;
    gap: 16px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 0.9rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.small-select {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--bg);
    color: var(--text);
    font-size: 0.85rem;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 16px;
}

.api-key-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-alt);
    border-radius: 10px;
    margin-bottom: 8px;
}

.api-key-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.api-key-name {
    font-weight: 500;
    color: var(--text);
}

.api-key-meta {
    font-size: 0.8rem;
    color: var(--muted);
    display: flex;
    gap: 8px;
}

.api-key-actions {
    display: flex;
    gap: 8px;
}

.api-key-actions button {
    padding: 6px 12px;
    border-radius: 6px;
    border: none;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 150ms ease;
}

.btn-test {
    background: var(--accent-2);
    color: #0a1a22;
}

.btn-delete {
    background: rgba(255, 126, 107, 0.2);
    color: var(--danger);
}

.btn-delete:hover {
    background: var(--danger);
    color: white;
}

/* Binance Balances */
.binance-balances {
    max-height: 300px;
    overflow-y: auto;
}

.balance-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.balance-item:last-child {
    border-bottom: none;
}

.balance-asset {
    font-weight: 500;
}

.balance-amount {
    color: var(--accent);
}

.portfolio-value-display {
    margin-top: 16px;
    padding: 16px;
    background: linear-gradient(135deg, rgba(79, 209, 166, 0.15) 0%, rgba(240, 180, 74, 0.15) 100%);
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.portfolio-value-display.hidden {
    display: none;
}

.portfolio-value-display .label {
    color: var(--muted);
}

.portfolio-value-display .value {
    font-size: 1.4rem;
    color: var(--accent);
}

.empty-state {
    text-align: center;
    color: var(--muted);
    padding: 24px;
    font-size: 0.9rem;
}

.small-btn {
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--accent);
    background: transparent;
    color: var(--accent);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 150ms ease;
}

.small-btn:hover {
    background: var(--accent);
    color: #0a1a22;
}

/* Mobile adjustments for login */
@media (max-width: 480px) {
    .login-container {
        padding: 32px 24px;
    }
    
    .logo-icon.large {
        font-size: 2.5rem;
    }
    
    .login-logo h1 {
        font-size: 1.5rem;
    }
    
    .user-btn span {
        display: none;
    }
}

/* Install PWA prompt */
.install-prompt {
    position: fixed;
    bottom: 20px;
    left: 16px;
    right: 16px;
    padding: 16px;
    background: var(--panel-strong);
    border: 1px solid var(--accent);
    border-radius: 16px;
    display: none;
    gap: 12px;
    z-index: 50;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.install-prompt.visible {
    display: grid;
}

.install-prompt-text {
    font-size: 0.9rem;
    line-height: 1.5;
}

.install-prompt-actions {
    display: flex;
    gap: 8px;
}

.install-prompt-actions button {
    flex: 1;
}