/* ============================================================================
   AI Financial Advisor — Style Guide & Theme
   ============================================================================

   Design Tokens (CSS Custom Properties)
   ────────────────────────────────────────────────
   See :root block below for the full token set.

   ============================================================================ */


/* ── Design Tokens ───────────────────────────────────────────────────────── */

:root {
    /* Backgrounds */
    --ink:       #0B0C0E;
    --ink-2:     #13151A;
    --ink-3:     #1C1F27;
    --surface:   #232730;
    --surface-2: #2C3040;

    /* Borders */
    --border:       rgba(255,255,255,0.07);
    --border-hover: rgba(255,255,255,0.14);

    /* Text */
    --text-primary:   #F0EDE8;
    --text-secondary: #9A95A0;
    --text-tertiary:  #5C5870;

    /* Gold / amber */
    --gold:      #C9A84C;
    --gold-dim:  #7A6430;
    --gold-glow: rgba(201,168,76,0.15);
    --gold-line: rgba(201,168,76,0.35);

    /* Wine / burgundy */
    --wine:      #9B3A5A;
    --wine-light:#C4607C;
    --wine-dim:  #5A2035;
    --wine-glow: rgba(155,58,90,0.18);
    --wine-line: rgba(196,96,124,0.35);

    /* Semantic up/down/neutral */
    --up:      #4CAF84;
    --down:    #E05A5A;
    --neutral: #7A8099;

    /* Typography */
    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-body:    'Instrument Sans', system-ui, sans-serif;
    --font-mono:    'DM Mono', monospace;

    /* Warn / amber semantic */
    --warn:      #E09A3A;
    --warn-glow: rgba(224,154,58,0.15);
    --warn-line: rgba(224,154,58,0.35);

    /* Radii */
    --r-xs:  6px;
    --r-sm:  8px;
    --r-md:  12px;
    --r-lg:  16px;
    --r-xl:  20px;
    --r-2xl: 28px;
}


/* ── Reset & Base ────────────────────────────────────────────────────────── */

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

body {
    font-family: var(--font-body);
    background: var(--ink);
    color: var(--text-primary);
    padding: 0;
    min-height: 100vh;
}


/* ── Layout ──────────────────────────────────────────────────────────────── */

.container { margin: 0 auto; padding: 20px; }

.header {
    background: var(--ink-3);
    border: 1px solid var(--border);
    border-left: 3px solid var(--gold);
    padding: 28px 32px;
    border-radius: var(--r-xl);
    margin-bottom: 20px;
}
.header h1 {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 300;
    letter-spacing: -0.01em;
    margin-bottom: 6px;
    color: var(--text-primary);
}
.header p { color: var(--text-secondary); font-size: 14px; }

.card {
    background: var(--ink-3);
    border: 1px solid var(--border);
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 20px;
}


/* ── Button Style Guide ──────────────────────────────────────────────────
   All buttons use the `.btn` base class. Variants control color/purpose.

   Sizes:
     .btn        — default (15px font, 12px/24px padding)
     .btn-sm     — compact  (13px font, 8px/16px padding)

   Variants:
     .btn-primary    — blue, standard actions (import, cancel, generic)
     .btn-accent     — purple→blue gradient, AI/special actions
     .btn-success    — green, positive actions (save, update)
     .btn-warning    — amber, caution actions (snapshot)
     .btn-danger     — red, destructive actions (clear, delete)
     .btn-key        — purple, API key management
     .btn-trade      — green gradient, trade ideas

   States:
     :disabled   — 50% opacity, not-allowed cursor
     :hover      — slight brightness boost (via filter)

   Usage:
     <button class="btn btn-primary">Import</button>
     <button class="btn btn-accent">Get AI Analysis</button>
     <button class="btn btn-danger btn-sm">Clear</button>

   ──────────────────────────────────────────────────────────────────────── */

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--r-sm);
    font-size: 15px;
    cursor: pointer;
    font-weight: 600;
    margin-right: 6px;
    margin-bottom: 6px;
    color: white;
    transition: filter 0.15s ease;
}

.btn:hover:not(:disabled) {
    filter: brightness(1.1);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Buttons inside action bars — let gap handle spacing */
.action-bar .btn,
.action-bar .btn-sm,
.action-buttons-row .btn,
.action-buttons-row .btn-sm {
    margin: 0;
}

.btn-sm {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    font-weight: 600;
    color: white;
    transition: filter 0.15s ease;
}

.btn-sm:hover:not(:disabled) {
    filter: brightness(1.1);
}

.btn-sm:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Variants — all mapped to design tokens */
.btn-primary   { background: var(--surface-2); border: 1px solid var(--border-hover); }
.btn-secondary { background: var(--surface-2); border: 1px solid var(--border-hover); }
.btn-accent    { background: linear-gradient(135deg, var(--gold-dim) 0%, var(--gold) 100%); }
.btn-success   { background: var(--up); }
.btn-warning   { background: var(--warn); }
.btn-danger    { background: var(--down); }
.btn-key       { background: var(--wine); }
.btn-trade     { background: linear-gradient(135deg, var(--up) 0%, #6BCF9E 100%); }
.btn-trade:hover:not(:disabled) {
    filter: brightness(1.1);
}

/* Legacy compat: .btn-add and .btn-analyze map to new system */
.btn-add     { background: var(--surface-2); border: 1px solid var(--border-hover); color: white; }
.btn-analyze { background: linear-gradient(135deg, var(--gold-dim) 0%, var(--gold) 100%); color: white; }


/* ── Currency Selector ───────────────────────────────────────────────────── */

.currency-selector {
    display: inline-flex;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-hover);
    margin-left: auto;
}
.currency-option {
    background: var(--surface);
    color: var(--text-secondary);
    border: none;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.currency-option:not(:last-child) { border-right: 1px solid var(--border-hover); }
.currency-option:hover { background: var(--surface-2); color: var(--text-primary); }
.currency-option.active {
    background: var(--gold);
    color: var(--ink);
}


/* ── Portfolio Header ────────────────────────────────────────────────────── */

.portfolio-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.total-value { text-align: right; }
.total-value div:first-child { color: var(--text-secondary); font-size: 12px; }
.total-value div:last-child  { color: var(--up); font-size: 24px; font-weight: bold; font-family: var(--font-mono); }


/* ── Portfolio Grid ──────────────────────────────────────────────────────── */

.positions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

/* Card-style position row — uses .pos-card-mobile base from Design System v2 */
.position {
    background: var(--ink-3);
    border: 1px solid var(--border);
    border-left: 2px solid var(--gold-dim);
    border-radius: var(--r-lg);
    padding: 12px 14px;
    display: grid;
    grid-template-columns: 40px 1fr auto;
    gap: 10px;
    align-items: start;
    transition: border-color 0.15s;
}
.position:hover { border-color: var(--border-hover); border-left-color: var(--gold); }

/* Inactive (closed) position */
.position.inactive {
    opacity: 0.45;
    border-left-color: var(--border);
}
.position.inactive:hover { opacity: 0.7; }

/* Middle column */
.pos-card-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.pos-card-body .position-actions {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}

/* Status dot inline with name */
.pos-status-dot {
    font-size: 11px;
    margin-right: 3px;
    vertical-align: middle;
}

/* Header row no longer needed but kept for JS compat — hidden */
.position-header-row { display: none; }

.position-symbol  { font-size: 15px; font-weight: bold; color: var(--text-primary); }
.position-details { color: var(--text-primary); }
.position-value   { color: var(--gold); font-weight: bold; font-family: var(--font-mono); }

/* Two-line cell helpers */
.pos-cell { min-width: 0; }
.pos-secondary { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pos-right { text-align: right; }


/* ── Analysis Section ────────────────────────────────────────────────────── */

.analysis-section { margin-top: 20px; }

.analysis-card {
    background: var(--surface);
    border: 1px solid var(--border-hover);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 15px;
}

.analysis-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.analysis-content { color: var(--text-primary); line-height: 1.6; }

.idea-item {
    background: var(--surface-2);
    padding: 15px;
    border-radius: var(--r-sm);
    margin-bottom: 10px;
}
.idea-title { font-weight: bold; margin-bottom: 8px; }
.idea-desc  { color: var(--text-primary); font-size: 14px; }

.disclaimer {
    background: var(--gold-glow);
    border: 1px solid var(--gold-line);
    color: var(--gold);
    padding: 15px;
    border-radius: var(--r-sm);
    font-size: 13px;
    margin-top: 15px;
}

.market-news-card { border-left: 3px solid var(--gold); }


/* ── Perspective Selector ────────────────────────────────────────────────── */

.perspective-selector {
    background: var(--ink-3);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 20px;
    margin-top: 15px;
}

.perspective-header { margin-bottom: 12px; }

.perspective-label {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.perspective-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.perspective-tab {
    padding: 8px 16px;
    border-radius: var(--r-sm);
    border: 2px solid var(--border-hover);
    background: var(--ink);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.perspective-tab:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
    background: var(--ink-3);
}
.perspective-tab.active {
    color: var(--text-primary);
    background: var(--ink-3);
}

.perspective-info {
    background: var(--ink);
    border-radius: var(--r-sm);
    padding: 12px 16px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.perspective-info-icon { font-size: 24px; }
.perspective-info-text { flex: 1; }
.perspective-info-name {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 2px;
}
.perspective-info-desc {
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 4px;
}
.perspective-info-figures {
    color: var(--text-secondary);
    font-size: 12px;
}

.perspective-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: white;
}

.perspective-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}


/* ── Trade Ideas ─────────────────────────────────────────────────────────── */

.trade-ideas-section { margin-top: 20px; }

.trade-idea-card {
    background: var(--surface);
    border-radius: var(--r-md);
    padding: 20px;
    margin-bottom: 15px;
    border-left: 4px solid;
}
.trade-idea-card.rebalance { border-left-color: var(--gold); }
.trade-idea-card.buy       { border-left-color: var(--up); }
.trade-idea-card.sell      { border-left-color: var(--down); }
.trade-idea-card.hold      { border-left-color: var(--neutral); }
.trade-idea-card.watch     { border-left-color: var(--neutral); }

.trade-idea-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.trade-idea-number {
    background: var(--ink-3);
    color: var(--text-primary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.trade-idea-title-section { flex: 1; }

.trade-idea-title {
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}

.trade-idea-subtitle {
    color: var(--text-secondary);
    font-size: 13px;
}

.trade-idea-context {
    background: var(--ink-3);
    border-radius: var(--r-sm);
    padding: 12px 15px;
    margin-bottom: 12px;
}
.trade-idea-context h4 {
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.trade-idea-context ul {
    margin: 0;
    padding-left: 18px;
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.6;
}

.trade-idea-action {
    background: var(--ink);
    border-radius: var(--r-sm);
    padding: 12px 15px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
}
.trade-idea-action h4 {
    color: var(--up);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.trade-idea-action p {
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    margin: 0;
}

.trade-idea-rationale {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
    font-style: italic;
}

.trade-ideas-summary {
    background: var(--ink-3);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 20px;
    margin-top: 15px;
}
.trade-ideas-summary h3 {
    color: var(--text-primary);
    font-size: 16px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.execution-step {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.execution-step:last-child { border-bottom: none; }

.execution-time {
    background: var(--surface);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.execution-action {
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.5;
}


/* ── Allocation Charts ───────────────────────────────────────────────────── */

.allocation-section {
    background: var(--ink-3);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 20px;
    margin-top: 15px;
}

.allocation-charts {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.allocation-chart-container {
    background: var(--ink);
    border-radius: var(--r-sm);
    padding: 15px;
}

.allocation-chart {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.allocation-bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.allocation-bar-label {
    width: 100px;
    font-size: 12px;
    color: var(--text-primary);
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.allocation-bar-track {
    flex: 1;
    height: 24px;
    background: var(--surface);
    border-radius: 4px;
    overflow: hidden;
}

.allocation-bar-fill {
    height: 100%;
    border-radius: 4px;
    display: flex;
    align-items: center;
    padding-left: 8px;
    font-size: 11px;
    font-weight: 600;
    color: white;
    transition: width 0.3s ease;
}

.allocation-bar-value {
    width: 60px;
    font-size: 12px;
    color: var(--text-secondary);
    text-align: right;
    font-family: var(--font-mono);
}

/* Sector slicer (interactive bars) */
.allocation-bar-row.slicer {
    cursor: pointer;
    border-radius: 4px;
    padding: 2px 4px;
    margin: -2px -4px;
    transition: background 0.15s ease;
}
.allocation-bar-row.slicer:hover       { background: rgba(255,255,255,0.05); }
.allocation-bar-row.slicer.active      { background: rgba(255,255,255,0.1); outline: 1px solid rgba(255,255,255,0.15); }
.allocation-bar-row.slicer.dimmed      { opacity: 0.35; }

.slicer-hint {
    font-size: 10px;
    color: var(--text-tertiary);
    margin-top: 6px;
    text-align: center;
}
.slicer-clear {
    display: inline-block;
    font-size: 11px;
    color: var(--gold);
    cursor: pointer;
    margin-left: 8px;
}
.slicer-clear:hover { color: var(--text-primary); text-decoration: underline; }


/* ── Legacy Trade Idea (old format) ──────────────────────────────────────── */

.trade-idea {
    background: var(--surface-2);
    padding: 15px;
    border-radius: var(--r-sm);
    margin-bottom: 10px;
}

.trade-ticker {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
    background: var(--ink-3);
    padding: 2px 8px;
    border-radius: 4px;
}

.trade-action {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 12px;
    letter-spacing: 0.5px;
}

.trade-title     { font-weight: bold; margin-bottom: 6px; color: var(--text-primary); }
.trade-rationale { color: var(--text-primary); font-size: 13px; line-height: 1.5; }


/* ── Position Management Dialogs ─────────────────────────────────────────── */

#positionDialog {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

#positionDialog .card {
    max-width: 520px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.position-form-group {
    margin-bottom: 16px;
}

.position-form-group label {
    display: block;
    color: var(--text-primary);
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
}

.position-form-group input,
.position-form-group select {
    width: 100%;
    padding: 10px 12px;
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border-hover);
    border-radius: var(--r-sm);
    font-size: 14px;
}

.position-form-group select {
    cursor: pointer;
    appearance: auto;
}

.position-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.position-calc-display {
    color: var(--gold);
    font-size: 13px;
    margin-top: 6px;
    min-height: 18px;
    font-family: var(--font-mono);
}

/* Search autocomplete */
.search-container {
    position: relative;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--ink-3);
    border: 1px solid var(--border-hover);
    border-radius: 0 0 var(--r-sm) var(--r-sm);
    max-height: 240px;
    overflow-y: auto;
    z-index: 1000;
}

.search-result-item {
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s ease;
}
.search-result-item:hover {
    background: var(--surface);
}
.search-result-item:last-child {
    border-bottom: none;
}

.search-result-symbol {
    font-weight: 700;
    color: var(--gold);
    font-size: 14px;
    min-width: 70px;
}
.search-result-name {
    color: var(--text-primary);
    font-size: 13px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.search-result-type {
    color: var(--text-secondary);
    font-size: 11px;
    background: var(--ink);
    padding: 2px 8px;
    border-radius: 4px;
}

.search-no-results {
    padding: 12px;
    color: var(--text-tertiary);
    font-size: 13px;
    text-align: center;
}

/* Sell info banner */
.position-sell-info {
    background: var(--ink);
    border: 1px solid var(--border-hover);
    border-radius: var(--r-sm);
    padding: 10px 14px;
    margin-bottom: 16px;
    color: var(--text-secondary);
    font-size: 13px;
}

/* Position action buttons in grid rows */
.position-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.position-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter 0.15s ease, opacity 0.15s ease;
    padding: 0;
    color: white;
}
.position-action-btn:hover {
    filter: brightness(1.2);
}
.position-action-btn.action-refresh { background: var(--gold-dim); }
.position-action-btn.action-buy  { background: var(--up); }
.position-action-btn.action-sell { background: var(--gold); }
.position-action-btn.action-del  { background: var(--down); }

/* Inactive toggle */
.inactive-toggle {
    font-size: 12px;
    color: var(--text-tertiary);
    cursor: pointer;
    user-select: none;
    margin-left: 12px;
}
.inactive-toggle:hover {
    color: var(--text-secondary);
}

/* Sales history section */
.sales-history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.sales-history-table th {
    text-align: left;
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-hover);
}
.sales-history-table td {
    padding: 8px 10px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    font-family: var(--font-mono);
}
.sales-history-table tr:last-child td {
    border-bottom: none;
}

/* ── Top Movers Section ──────────────────────────────────────────────────── */

.movers-section {
    background: var(--ink-3);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 16px 20px;
    margin-bottom: 16px;
}

.movers-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 8px;
}

.movers-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.movers-timestamp {
    font-size: 11px;
    color: var(--text-tertiary);
}

.movers-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 14px;
}

.movers-column-header {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 8px;
}

.movers-column-header.gainers { color: var(--up); }
.movers-column-header.losers  { color: var(--down); }

.mover-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 10px;
    border-radius: var(--r-sm);
    margin-bottom: 6px;
    font-size: 13px;
}

.mover-chip.gain {
    background: rgba(76, 175, 132, 0.08);
    border: 1px solid rgba(76, 175, 132, 0.2);
}

.mover-chip.loss {
    background: rgba(224, 90, 90, 0.08);
    border: 1px solid rgba(224, 90, 90, 0.2);
}

.mover-symbol {
    font-weight: 700;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-primary);
}

.mover-name {
    font-size: 11px;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    text-align: center;
}

.mover-pct {
    font-weight: 700;
    font-size: 13px;
    white-space: nowrap;
    font-family: var(--font-mono);
}

.mover-pct.gain { color: var(--up); }
.mover-pct.loss { color: var(--down); }

.movers-ai-section {
    border-top: 1px solid var(--border);
    padding-top: 12px;
    margin-top: 4px;
}

.movers-ai-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--wine);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.movers-ai-text {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.7;
}

.movers-ai-loading {
    font-size: 13px;
    color: var(--text-tertiary);
    font-style: italic;
}

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


/* ── States ──────────────────────────────────────────────────────────────── */

.loading     { text-align: center; padding: 40px; color: var(--text-secondary); }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-tertiary); }


/* ── Auth Bar ────────────────────────────────────────────────────────────── */

.auth-bar {
    background: var(--ink-3);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 12px 20px;
    margin-bottom: 20px;
    font-size: 13px;
}

.auth-logged-in {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.auth-login-panel {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.auth-sso-section {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.auth-email-section {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.auth-divider {
    color: var(--text-tertiary);
    font-size: 12px;
    display: flex;
    align-items: center;
}
.auth-divider span {
    white-space: nowrap;
}

/* SSO Buttons */
.btn-sso {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: 1px solid var(--border-hover);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s ease, background 0.15s ease;
    white-space: nowrap;
}
.btn-sso:hover {
    filter: brightness(1.1);
}

.btn-google {
    background: var(--ink-3);
    color: var(--text-primary);
}
.btn-google:hover {
    background: var(--surface);
}

.auth-bar input[type="email"],
.auth-bar input[type="password"] {
    padding: 8px 12px;
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border-hover);
    border-radius: 6px;
    font-size: 13px;
    width: 180px;
}


/* Forgot-password link inside the email section */
.auth-forgot-link {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 12px;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    white-space: nowrap;
    transition: color 0.15s ease;
}
.auth-forgot-link:hover {
    color: var(--text-secondary);
}


/* ── Role Badges ────────────────────────────────────────────────────────── */

.role-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}
.role-admin {
    background: linear-gradient(135deg, var(--wine-dim) 0%, var(--wine) 100%);
    color: #fff;
}
.role-user {
    background: var(--surface);
    color: var(--text-secondary);
}


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

@media (max-width: 768px) {
    .position, .position-header-row {
        grid-template-columns: 60px 1fr 80px 80px;
        gap: 6px;
        font-size: 12px;
        padding: 8px 10px;
    }
    .pos-hide-mobile { display: none; }
    .portfolio-header { flex-direction: column; align-items: flex-start; }
    .total-value { text-align: left; }

    .auth-login-panel {
        flex-direction: column;
        align-items: stretch;
    }
    .auth-sso-section {
        flex-direction: column;
    }
    .auth-email-section {
        flex-direction: column;
    }
    .auth-divider {
        justify-content: center;
    }
    .auth-bar input[type="email"],
    .auth-bar input[type="password"] {
        width: 100%;
    }
}


/* ═══════════════════════════════════════════════════════════════════════════
   App Navbar — persistent top bar shared across all pages
   ═══════════════════════════════════════════════════════════════════════════ */

.app-navbar {
    background: var(--ink);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    margin-bottom: 0;
}

.navbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 50px;
}

/* Brand / hub link */
.nav-brand {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary);
    text-decoration: none;
    white-space: nowrap;
    padding: 6px 10px 6px 0;
    margin-right: 8px;
    border-right: 1px solid var(--border);
    transition: color 0.15s;
}
.nav-brand:hover { color: var(--text-primary); }
.nav-brand.active { color: var(--gold); }

/* Page links */
.nav-links {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
}

.nav-link {
    color: var(--text-tertiary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
}
.nav-link:hover  { color: var(--text-primary); background: var(--ink-3); }
.nav-link.active { color: var(--gold); background: var(--ink-2); }

/* Right-side actions area */
.nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* Language toggle button */
.lang-toggle {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-tertiary);
    font-size: 12px;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.15s, color 0.15s;
}
.lang-toggle:hover {
    border-color: var(--gold);
    color: var(--gold);
}

/* Auth wrap (relative anchor for dropdown) */
.nav-auth-wrap {
    position: relative;
}

/* Auth toggle button */
.nav-auth-btn {
    background: var(--ink-3);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: border-color 0.15s, color 0.15s;
}
.nav-auth-btn:hover      { border-color: var(--border-hover); color: var(--text-primary); }
.nav-auth-btn.logged-in  { border-color: #166534; color: var(--up); }

/* Dropdown panel */
.nav-auth-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: var(--ink-3);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    min-width: 290px;
    z-index: 200;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.nav-dropdown-inner {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
}

/* Responsive: stack nav on narrow screens */
@media (max-width: 600px) {
    .navbar-inner {
        padding: 0 12px;
        gap: 2px;
        min-height: 46px;
        flex-wrap: wrap;
    }
    .nav-brand {
        font-size: 12px;
        padding-right: 8px;
        margin-right: 4px;
    }
    .nav-link {
        font-size: 12px;
        padding: 5px 8px;
    }
    .nav-auth-btn {
        font-size: 12px;
        padding: 5px 9px;
        max-width: 140px;
    }
    .nav-auth-dropdown {
        min-width: 250px;
        right: -8px;
    }
    .lang-toggle {
        font-size: 11px;
        padding: 4px 8px;
    }
}

/* ── Spacing: pages have the container below the sticky navbar ─────────────── */
body > #appNavbar + * {
    /* container sits directly after the navbar — keep existing margin-top */
}


/* ═══════════════════════════════════════════════════════════════════════════
   Design System v2 — Mobile-first premium components
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Hero Metric Section ────────────────────────────────────────────────── */

.hero-metric-section {
    padding: 20px 0 16px;
}

.hero-label {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}

.hero-value-display {
    font-family: var(--font-display);
    font-size: clamp(32px, 6vw, 44px);
    font-weight: 300;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1;
}

.hero-value-display.gold  { color: var(--gold); }
.hero-value-display.wine  { color: var(--wine-light); }

.hero-delta {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-mono);
    font-size: 12px;
    margin-top: 6px;
}
.hero-delta.up   { color: var(--up); }
.hero-delta.down { color: var(--down); }


/* ── Sparkline / Mini Chart ─────────────────────────────────────────────── */

.mini-chart {
    border-radius: var(--r-lg);
    background: var(--ink-3);
    overflow: hidden;
    margin-bottom: 6px;
}

.mini-chart svg { display: block; width: 100%; }

.mini-chart-labels {
    display: flex;
    justify-content: space-between;
    padding: 4px 10px 8px;
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-tertiary);
}


/* ── Hub Cards (premium) ────────────────────────────────────────────────── */

.hub-card-premium {
    border-radius: var(--r-xl);
    padding: 22px 24px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    text-decoration: none;
    display: block;
    transition: transform 0.15s, box-shadow 0.15s;
}
.hub-card-premium:hover {
    transform: translateY(-2px);
}
.hub-card-premium.stock-hub {
    background: linear-gradient(135deg, #1C1A10, #1E1C12);
    border: 1px solid var(--gold-line);
    box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}
.hub-card-premium.wine-hub {
    background: linear-gradient(135deg, #1A0F14, #1C1018);
    border: 1px solid var(--wine-line);
    box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}
.hub-card-premium:hover.stock-hub { box-shadow: 0 8px 32px rgba(201,168,76,0.15); }
.hub-card-premium:hover.wine-hub  { box-shadow: 0 8px 32px rgba(155,58,90,0.18); }

.hub-card-glow-bg {
    position: absolute;
    top: -24px; right: -24px;
    width: 100px; height: 100px;
    border-radius: 50%;
    filter: blur(28px);
    pointer-events: none;
}
.stock-hub .hub-card-glow-bg { background: var(--gold-glow); }
.wine-hub  .hub-card-glow-bg { background: var(--wine-glow); }

.hub-card-eyebrow {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 10px;
}
.stock-hub .hub-card-eyebrow { color: var(--gold-dim); }
.wine-hub  .hub-card-eyebrow { color: var(--wine-dim); }

.hub-card-name {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 300;
    letter-spacing: -0.01em;
    margin-bottom: 4px;
}
.stock-hub .hub-card-name { color: var(--gold); }
.wine-hub  .hub-card-name { color: var(--wine-light); }

.hub-card-sub {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 16px;
}

.hub-card-value-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.hub-card-amount {
    font-family: var(--font-mono);
    font-size: 20px;
    font-weight: 500;
    color: var(--text-primary);
}

.hub-card-delta {
    font-family: var(--font-mono);
    font-size: 11px;
}
.hub-card-delta.up   { color: var(--up); }
.hub-card-delta.down { color: var(--down); }


/* ── Mobile Position Cards ──────────────────────────────────────────────── */

.pos-card-mobile {
    background: var(--ink-3);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 12px 14px;
    display: grid;
    grid-template-columns: 40px 1fr auto;
    gap: 10px;
    align-items: center;
    transition: border-color 0.15s;
}
.pos-card-mobile:hover { border-color: var(--border-hover); }
.pos-card-mobile.stock { border-left: 2px solid var(--gold-dim); }
.pos-card-mobile.wine  { border-left: 2px solid var(--wine-dim); }

.pos-icon-badge {
    width: 40px; height: 40px;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-mono);
    letter-spacing: -0.02em;
    flex-shrink: 0;
}
.pos-icon-badge.stock { background: var(--gold-glow);  color: var(--gold); }
.pos-icon-badge.wine  { background: var(--wine-glow);  color: var(--wine-light); }

.pos-card-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pos-card-sub {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-tertiary);
}

.pos-card-right { text-align: right; flex-shrink: 0; }

.pos-card-value {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.pos-card-change {
    font-family: var(--font-mono);
    font-size: 10px;
}
.pos-card-change.up   { color: var(--up); }
.pos-card-change.down { color: var(--down); }


/* ── Chip / Filter Row ──────────────────────────────────────────────────── */

.chip-scroll-row {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
    margin-bottom: 14px;
}
.chip-scroll-row::-webkit-scrollbar { display: none; }

.chip-filter {
    flex-shrink: 0;
    padding: 5px 14px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    background: var(--ink-3);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}
.chip-filter:hover { border-color: var(--border-hover); color: var(--text-primary); }
.chip-filter.active-stock {
    border-color: var(--gold-line);
    color: var(--gold);
    background: var(--gold-glow);
}
.chip-filter.active-wine {
    border-color: var(--wine-line);
    color: var(--wine-light);
    background: var(--wine-glow);
}


/* ── AI Insight Card ────────────────────────────────────────────────────── */

.ai-insight-card {
    background: linear-gradient(135deg, var(--ink-3), var(--surface));
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 16px 18px;
    position: relative;
    overflow: hidden;
    margin-bottom: 16px;
}
.ai-insight-card::before {
    content: '';
    position: absolute;
    top: -30px; right: -30px;
    width: 100px; height: 100px;
    border-radius: 50%;
    background: var(--gold-glow);
    filter: blur(28px);
    pointer-events: none;
}
.ai-insight-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.ai-insight-badge {
    background: var(--gold-glow);
    border: 1px solid var(--gold-line);
    color: var(--gold);
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 3px 9px;
    border-radius: 100px;
}
.ai-insight-badge.wine-badge {
    background: var(--wine-glow);
    border-color: var(--wine-line);
    color: var(--wine-light);
}
.ai-insight-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.65;
    font-style: italic;
}


/* ── Segment Tabs ───────────────────────────────────────────────────────── */

.seg-tab-row {
    display: flex;
    background: var(--ink-3);
    border-radius: var(--r-lg);
    padding: 3px;
    gap: 2px;
    margin-bottom: 16px;
}
.seg-tab-item {
    flex: 1;
    padding: 7px 10px;
    border-radius: var(--r-md);
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    background: transparent;
}
.seg-tab-item.active-stock {
    background: linear-gradient(135deg, var(--gold-dim), #5A4820);
    color: var(--gold);
}
.seg-tab-item.active-wine {
    background: linear-gradient(135deg, var(--wine-dim), #3A1525);
    color: var(--wine-light);
}


/* ── Bottom Tab Nav (mobile) ────────────────────────────────────────────── */

.bottom-tab-nav {
    display: none; /* shown via media query */
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--ink-2);
    border-top: 1px solid var(--border);
    padding: 10px 0 env(safe-area-inset-bottom, 10px);
    z-index: 90;
    justify-content: space-around;
}
.btn-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.05em;
    padding: 4px 16px;
    text-decoration: none;
    transition: color 0.15s;
}
.btn-nav .bn-icon { font-size: 20px; line-height: 1; }
.btn-nav.active       { color: var(--gold); }
.btn-nav.active-wine  { color: var(--wine-light); }
.btn-nav:hover        { color: var(--text-secondary); }

@media (max-width: 640px) {
    .bottom-tab-nav { display: flex; }
    .container { padding-bottom: 68px; } /* clearance for fixed bottom nav */
}


/* ── Premium Button Variants ────────────────────────────────────────────── */

.btn-stock {
    background: linear-gradient(135deg, var(--gold), #A07830);
    color: var(--ink);
    font-weight: 700;
}
.btn-wine-primary {
    background: linear-gradient(135deg, var(--wine), var(--wine-dim));
    color: var(--text-primary);
}
.btn-ghost-stock {
    background: var(--gold-glow);
    color: var(--gold);
    border: 1px solid var(--gold-line);
}
.btn-ghost-wine {
    background: var(--wine-glow);
    color: var(--wine-light);
    border: 1px solid var(--wine-line);
}


/* ── Drink Window Badges (design system) ────────────────────────────────── */

.dw-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 500;
    font-family: var(--font-mono);
    letter-spacing: 0.02em;
}
.dw-ready { background: rgba(76,175,132,0.12); color: var(--up);       border: 1px solid rgba(76,175,132,0.3); }
.dw-peak  { background: rgba(201,168,76,0.12); color: var(--gold);     border: 1px solid var(--gold-line); }
.dw-hold  { background: rgba(92,88,112,0.15);  color: var(--neutral);  border: 1px solid rgba(92,88,112,0.35); }
.dw-past  { background: rgba(224,90,90,0.12);  color: var(--down);     border: 1px solid rgba(224,90,90,0.3); }


/* ═══════════════════════════════════════════════════════════════════════════
   Design System v3 — Full component library (Investment Hub)
   All pages must only reference classes defined here (or wine.css).
   No inline styles. No per-page <style> blocks.
   ═══════════════════════════════════════════════════════════════════════════ */


/* ── Container variants ──────────────────────────────────────────────────── */

/* Narrower hub / landing page container */
.container-hub { max-width: 680px; }


/* ── Header eyebrow & version tag ────────────────────────────────────────── */

.header-eyebrow {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 6px;
}
.header-eyebrow.wine-eyebrow { color: var(--wine); }

/* Small version/tag span inside an h1 */
.header-version {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 400;
    opacity: 0.4;
    margin-left: 8px;
}

/* Italic em inside a display heading */
.header h1 em { color: var(--gold); font-style: italic; }


/* ── Hub page layout ─────────────────────────────────────────────────────── */

.hub-layout        { display: flex; flex-direction: column; gap: 0; }
.hub-hero          { padding: 8px 0 20px; }

.hub-eyebrow {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}

.hub-total {
    font-family: var(--font-display);
    font-size: clamp(30px, 7vw, 46px);
    font-weight: 300;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1;
}

.hub-year-delta {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--up);
    margin-top: 6px;
}

/* Sparkline chart wrapper */
.hub-chart {
    background: var(--ink-3);
    border-radius: var(--r-lg);
    overflow: hidden;
    margin-bottom: 6px;
}
.hub-chart svg { display: block; width: 100%; }

.hub-chart-labels {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 4px 10px 8px;
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-tertiary);
    box-sizing: border-box;
}

/* Hub card stack: column on mobile, row on tablet+ */
.hub-cards-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 4px;
}
@media (min-width: 640px) {
    .hub-cards-stack           { flex-direction: row; }
    .hub-cards-stack .hub-card-premium { flex: 1; }
}

/* Feature list inside hub cards */
.hub-features-list {
    list-style: none;
    padding: 0;
    margin: 10px 0 16px;
}
.hub-features-list li {
    font-size: 12px;
    color: var(--text-tertiary);
    padding: 2px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}
.hub-features-list li::before {
    content: '—';
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-tertiary);
    opacity: 0.5;
}

/* CTA row at bottom of hub card */
.hub-card-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-mono);
    letter-spacing: 0.05em;
    padding: 7px 0 2px;
    border-top: 1px solid;
    width: 100%;
}
.stock-hub .hub-card-cta { color: var(--gold);       border-color: var(--gold-dim); }
.wine-hub  .hub-card-cta { color: var(--wine-light);  border-color: var(--wine-dim); }


/* ── Hero metric section ─────────────────────────────────────────────────── */

/* Wraps hero-label + hero-value-display + hero-delta on a page header */
.hero-metric { padding: 4px 0 20px; }


/* ── Wine card detail components ─────────────────────────────────────────── */

.wine-card-detail {
    background: var(--ink-3);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 16px;
    margin-bottom: 8px;
    border-left: 2px solid var(--wine-dim);
}

.wine-name {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 400;
    font-style: italic;
    color: var(--text-primary);
    margin-bottom: 2px;
    line-height: 1.2;
}

.wine-vintage {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--wine-light);
    letter-spacing: 0.1em;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.wine-meta-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.wine-meta-item {
    flex: 1;
    min-width: 64px;
    background: var(--ink-2);
    border-radius: var(--r-md);
    padding: 8px 10px;
}

.wm-label {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 3px;
}

.wm-value {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}
.wm-value.wine-accent { color: var(--wine-light); }
.wm-value.up-color    { color: var(--up); }


/* ── Section & chart heading helpers ─────────────────────────────────────── */

/* Generic h3 inside a card */
.section-heading     { color: var(--text-primary); margin-bottom: 15px; }

/* Small uppercase chart/section label */
.chart-label {
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    margin-bottom: 10px;
}

/* Cellar/Portfolio card header row (title left, stats right) */
.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
}

/* Row of action buttons below a card header */
.action-buttons-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}


/* ── Form utilities ──────────────────────────────────────────────────────── */

/* Bold label used in dialogs (API keys, etc.) */
.form-label-bold {
    display: block;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-weight: bold;
}

/* Helper text below form inputs */
.form-helper {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.6;
    margin-top: 4px;
}
.form-helper a { color: var(--gold); text-decoration: none; }
.form-helper a:hover { text-decoration: underline; }

/* Security / warning notice (amber tint) */
.security-notice {
    color: var(--warn);
    font-size: 12px;
    margin-top: 6px;
    background: var(--warn-glow);
    border: 1px solid var(--warn-line);
    border-radius: 6px;
    padding: 8px;
    line-height: 1.5;
}

/* Horizontal rule styled for dark theme */
.hr-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

/* Textarea — same look as position-form-group inputs */
.position-form-group textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border-hover);
    border-radius: var(--r-sm);
    font-size: 14px;
    font-family: var(--font-body);
    resize: vertical;
}


/* ── API strategy info block ─────────────────────────────────────────────── */

.api-info-block {
    background: var(--surface);
    padding: 15px;
    border-radius: var(--r-sm);
    margin-bottom: 20px;
}

.api-info-title {
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 16px;
    font-weight: 600;
}

.api-tier-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.8;
}
.api-tier-status-primary  { color: var(--up); font-weight: 600; }
.api-tier-status-fallback { color: var(--gold); font-weight: 600; }

.api-info-detail {
    margin-top: 10px;
    padding: 10px;
    background: var(--ink-2);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Form field section (label + input + helper) */
.form-field-section { margin-bottom: 20px; }

/* Inline security/info card with amber background (legacy artifact warning) */
.info-card-amber {
    background: #fef3c7;
    border: 2px solid #f59e0b;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
}
.info-card-amber-title { font-weight: bold; color: #92400e; margin-bottom: 5px; }
.info-card-amber-body  { color: #78350f; font-size: 14px; margin-bottom: 10px; }
.info-card-amber-code  {
    color: #78350f;
    font-size: 13px;
    background: white;
    padding: 10px;
    border-radius: 5px;
    line-height: 1.6;
}

/* Radio group row */
.radio-group-row {
    display: flex;
    gap: 16px;
    padding: 10px 14px;
    background: var(--ink-2);
    border-radius: var(--r-sm);
    font-size: 13px;
    flex-wrap: wrap;
}
.radio-group-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: var(--text-primary);
}


/* ── Button: secondary (outlined) ────────────────────────────────────────── */

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-hover);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    padding: 10px 20px;
    border-radius: var(--r-md);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}
.btn-secondary:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

/* Primary gold-gradient button (stock / AI actions) */
.btn-primary-stock {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 20px;
    border-radius: var(--r-md);
    background: linear-gradient(135deg, var(--gold), #A07830);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: filter 0.15s;
}
.btn-primary-stock:hover { filter: brightness(1.08); }

/* Primary wine-gradient button (cellar / sommelier actions) */
.btn-primary-wine {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 20px;
    border-radius: var(--r-md);
    background: linear-gradient(135deg, var(--wine), var(--wine-dim));
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: filter 0.15s;
}
.btn-primary-wine:hover { filter: brightness(1.1); }


/* ── Misc utilities ────────────────────────────────────────────────────────── */

/* Push a flex child to the far end */
.btn-push-right { margin-left: auto; }

/* Uppercase text input (ticker symbols) */
.input-uppercase { text-transform: uppercase; }

/* Monospace code/paste textarea */
.textarea-code {
    height: 200px;
    font-family: var(--font-mono);
    font-size: 12px;
}

/* ── Info card amber: inner flex layout ──────────────────────────────────── */

.info-card-amber-inner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.info-card-amber-icon {
    font-size: 24px;
    flex-shrink: 0;
}
/* Last body element inside amber card needs no bottom margin */
.info-card-amber-body:last-child { margin-bottom: 0; }

/* ── Radio group spacing ──────────────────────────────────────────────────── */
.radio-group-row { margin-bottom: 12px; }

/* ── Ticker picker modal ─────────────────────────────────────────────────── */

.ticker-picker-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}
.ticker-picker-dialog {
    background: var(--ink);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 24px;
    max-width: 480px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.ticker-picker-dialog h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.ticker-picker-dialog p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}
.ticker-picker-options { margin-bottom: 16px; }
.ticker-picker-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin-bottom: 6px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--r-md);
    cursor: pointer;
    transition: border-color 0.15s;
}
.ticker-picker-option:hover,
.ticker-picker-option:focus-within { border-color: var(--gold); }
.ticker-picker-option.is-first {
    background: var(--gold-glow);
    border-color: var(--gold);
}
.ticker-picker-option input[type="radio"] {
    accent-color: var(--gold);
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
.ticker-option-content {
    flex: 1;
    min-width: 0;
}
.ticker-option-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.ticker-option-ticker {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 15px;
}
.ticker-option-badge {
    color: var(--gold);
    font-size: 12px;
    background: var(--gold-glow);
    padding: 1px 8px;
    border-radius: var(--r-sm);
}
.ticker-option-badge.type-badge {
    font-size: 11px;
    background: var(--wine-glow);
    padding: 1px 6px;
}
.ticker-option-name {
    color: var(--text-secondary);
    font-size: 12px;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ticker-picker-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ── Icon button with danger hover ───────────────────────────────────────── */

.btn-icon-hover-danger {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
    padding: 2px 4px;
    border-radius: var(--r-sm);
    transition: color 0.2s;
}
.btn-icon-hover-danger:hover { color: var(--down); }


/* ═══════════════════════════════════════════════════════════════════════════
   Design System v2 — Aliases & New Components
   Multi-selectors alias existing names so both old and new class names work.
   New components have no existing equivalent and are added fresh.
   ═══════════════════════════════════════════════════════════════════════════ */


/* ── Navigation aliases ──────────────────────────────────────────────────── */

/* DS: .bottom-nav → existing: .bottom-tab-nav */
.bottom-nav,
.bottom-tab-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--ink-2);
    border-top: 1px solid var(--border);
    padding: 10px 0 env(safe-area-inset-bottom, 10px);
    z-index: 90;
    justify-content: space-around;
}
@media (max-width: 640px) {
    .bottom-nav, .bottom-tab-nav { display: flex; }
}

/* DS: .bn-item → existing: .btn-nav (btn-nav already styled; just alias states) */
.bn-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.05em;
    padding: 4px 16px;
    text-decoration: none;
    transition: color 0.15s;
}
.bn-item .bn-icon { font-size: 20px; line-height: 1; }
.bn-item.active-hub   { color: var(--text-primary); }
.bn-item.active-stock { color: var(--gold); }
.bn-item.active-wine  { color: var(--wine-light); }
.bn-item:hover        { color: var(--text-secondary); }


/* ── Page header aliases ─────────────────────────────────────────────────── */

/* DS: .page-header → existing: .header */
.page-header,
.header {
    background: var(--ink-3);
    border: 1px solid var(--border);
    border-left: 3px solid var(--gold);
    padding: 28px 32px;
    border-radius: var(--r-xl);
    margin-bottom: 20px;
}

/* DS: .ph-eyebrow → existing: .header-eyebrow */
.ph-eyebrow { /* inherits .header-eyebrow styles via shared styling below */
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 6px;
}

/* DS: .ph-title */
.ph-title {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 300;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.ph-title.stock { color: var(--gold); }
.ph-title.wine  { color: var(--wine-light); }

/* DS: .ph-sub */
.ph-sub {
    font-size: 12px;
    color: var(--text-secondary);
}

/* DS: .ph-version → existing: .header-version */
.ph-version {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-tertiary);
    margin-top: 6px;
}


/* ── Action bar alias ────────────────────────────────────────────────────── */

/* DS: .action-bar → existing: .action-buttons-row */
.action-bar,
.action-buttons-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}


/* ── Currency toggle aliases ─────────────────────────────────────────────── */

/* DS: .currency-toggle → existing: .currency-selector */
.currency-toggle,
.currency-selector {
    display: inline-flex;
    border-radius: 100px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--ink-3);
    padding: 3px;
    gap: 2px;
    margin-left: auto;
}

/* DS: .ct-opt → existing: .currency-option */
.ct-opt,
.currency-option {
    background: transparent;
    color: var(--text-tertiary);
    border: none;
    padding: 5px 14px;
    border-radius: 100px;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.ct-opt:not(:last-child)       { border-right: none; }
.currency-option:not(:last-child) { border-right: 1px solid var(--border-hover); }
.ct-opt:hover,
.currency-option:hover { background: var(--surface-2); color: var(--text-primary); }
.ct-opt.active,
.currency-option.active {
    background: var(--surface-2);
    color: var(--gold);
    border: 1px solid var(--gold-line);
}


/* ── Perspective chips alias ─────────────────────────────────────────────── */

/* DS: .persp-chip → existing: .perspective-tab */
.persp-chip,
.perspective-tab {
    padding: 6px 12px;
    border-radius: var(--r-md);
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
    background: var(--ink-3);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.persp-chip:hover,
.perspective-tab:hover {
    border-color: var(--border-hover);
    color: var(--text-secondary);
}
.persp-chip.active,
.perspective-tab.active {
    background: var(--gold-glow);
    color: var(--gold);
    border-color: var(--gold-line);
}


/* ── Allocation section alias ────────────────────────────────────────────── */

/* DS: .alloc-section → existing: .allocation-section */
.alloc-section,
.allocation-section {
    background: var(--ink-3);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 20px;
    margin-top: 15px;
}


/* ── Position card aliases ───────────────────────────────────────────────── */

/* DS: .pos-card → existing: .position */
.pos-card,
.position {
    background: var(--ink-3);
    border: 1px solid var(--border);
    border-left: 2px solid var(--gold-dim);
    border-radius: var(--r-lg);
    padding: 12px 14px;
    display: grid;
    grid-template-columns: 40px 1fr auto;
    gap: 10px;
    align-items: start;
    transition: border-color 0.15s;
}
.pos-card:hover,
.position:hover { border-color: var(--border-hover); }

/* Inactive state */
.pos-card.inactive,
.position.inactive { opacity: 0.45; border-left-color: var(--border); }
.pos-card.inactive:hover,
.position.inactive:hover { opacity: 0.7; }

/* Asset-type left-border variants (resting) */
.pos-card.stock  { border-left-color: var(--gold-dim); }
.pos-card.etf    { border-left-color: #4A7A6A; }
.pos-card.crypto { border-left-color: #5A6AAA; }
.pos-card.wine   { border-left-color: var(--wine-dim); }

/* Asset-type hover accents */
.pos-card.stock:hover  { border-left-color: var(--gold); }
.pos-card.etf:hover    { border-left-color: #6AAA92; }
.pos-card.crypto:hover { border-left-color: #8A9ACA; }
.pos-card.wine:hover   { border-left-color: var(--wine); }
.position:hover        { border-left-color: var(--gold); }

/* DS: .pos-icon → existing: .pos-icon-badge */
.pos-icon,
.pos-icon-badge {
    width: 40px; height: 40px;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-mono);
    letter-spacing: -0.02em;
    flex-shrink: 0;
}
.pos-icon.stock,  .pos-icon-badge.stock  { background: var(--gold-glow);  color: var(--gold); }
.pos-icon.etf                            { background: rgba(74,122,106,0.15); color: #6AAA92; }
.pos-icon.crypto                         { background: rgba(90,106,170,0.15); color: #8A9ACA; }
.pos-icon.wine,   .pos-icon-badge.wine   { background: var(--wine-glow);  color: var(--wine-light); }

/* DS: .pos-name → existing: .pos-card-name */
.pos-name,
.pos-card-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* DS: .pos-sub → existing: .pos-card-sub */
.pos-sub,
.pos-card-sub {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-tertiary);
}

/* DS: .pos-platform — new element for platform badge */
.pos-platform {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 9px;
    padding: 1px 6px;
    border-radius: var(--r-xs);
    background: var(--surface);
    color: var(--text-tertiary);
    margin-top: 3px;
}

/* DS: .pos-value → existing: .pos-card-value */
.pos-value,
.pos-card-value {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
}

/* DS: .pos-change → existing: .pos-card-change */
.pos-change,
.pos-card-change {
    font-family: var(--font-mono);
    font-size: 10px;
}
.pos-change.up,   .pos-card-change.up   { color: var(--up); }
.pos-change.down, .pos-card-change.down { color: var(--down); }


/* ── Form aliases ────────────────────────────────────────────────────────── */

/* DS: .form-group → existing: .position-form-group */
.form-group,
.position-form-group { margin-bottom: 16px; }

/* DS: .form-label → existing: .form-label-bold */
.form-label,
.form-label-bold {
    display: block;
    color: var(--text-primary);
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
}
.form-label .req { color: var(--down); margin-left: 2px; }

/* DS: .form-input — standalone input style */
.form-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--ink-3);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    font-family: var(--font-body);
    font-size: 14px;
    transition: border-color 0.15s;
    outline: none;
}
.form-input::placeholder { color: var(--text-tertiary); }
.form-input:focus { border-color: var(--border-hover); background: var(--surface); }
.form-input.stock:focus { border-color: var(--gold-line); }
.form-input.wine:focus  { border-color: var(--wine-line); }

/* DS: .form-select */
.form-select {
    width: 100%;
    padding: 10px 32px 10px 12px;
    background: var(--ink-3);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    font-family: var(--font-body);
    font-size: 14px;
    cursor: pointer;
    outline: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%235C5870'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: border-color 0.15s;
}
.form-select:focus { border-color: var(--border-hover); }

/* DS: .form-textarea */
.form-textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--ink-3);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    font-family: var(--font-body);
    font-size: 14px;
    resize: vertical;
    min-height: 80px;
    outline: none;
    transition: border-color 0.15s;
}
.form-textarea:focus { border-color: var(--border-hover); }

/* DS: .form-hint → existing: .form-helper */
.form-hint,
.form-helper {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.6;
    margin-top: 4px;
}
.form-hint a,
.form-helper a { color: var(--gold); text-decoration: none; }
.form-hint a:hover,
.form-helper a:hover { text-decoration: underline; }

/* DS: .form-error */
.form-error {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--down);
    margin-top: 2px;
}

/* DS: .import-area → existing: .textarea-code */
.import-area,
.textarea-code {
    width: 100%;
    background: var(--ink-3);
    border: 1px dashed var(--border-hover);
    border-radius: var(--r-lg);
    padding: 16px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 12px;
    min-height: 120px;
    resize: vertical;
    outline: none;
    transition: border-color 0.15s;
}
.import-area:focus,
.textarea-code:focus { border-color: var(--gold-line); }


/* ── AI card aliases ─────────────────────────────────────────────────────── */

/* DS: .ai-card → existing: .analysis-card */
.ai-card,
.analysis-card {
    background: var(--ink-3);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 16px;
    margin-bottom: 15px;
    position: relative;
    overflow: hidden;
}
.ai-card::after {
    content: '';
    position: absolute;
    top: -24px; right: -24px;
    width: 80px; height: 80px;
    border-radius: 50%;
    background: var(--gold-glow);
    filter: blur(28px);
    pointer-events: none;
}

/* DS: .ai-header */
.ai-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

/* DS: .ai-badge → existing: .perspective-badge */
.ai-badge,
.perspective-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border-radius: 100px;
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: var(--gold-glow);
    border: 1px solid var(--gold-line);
    color: var(--gold);
    font-weight: 500;
}
.ai-badge.wine {
    background: var(--wine-glow);
    border-color: var(--wine-line);
    color: var(--wine-light);
}

/* DS: .ai-perspective */
.ai-perspective {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-tertiary);
}

/* DS: .ai-text → existing: .analysis-content */
.ai-text,
.analysis-content {
    color: var(--text-primary);
    line-height: 1.65;
    font-size: 13px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   Design System v2 — New Components (no existing equivalent)
   ═══════════════════════════════════════════════════════════════════════════ */


/* ── Ghost button ────────────────────────────────────────────────────────── */

.btn-ghost {
    background: var(--ink-3);
    color: var(--text-secondary);
    border: 1px solid var(--border-hover);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    padding: 9px 16px;
    border-radius: var(--r-md);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.btn-ghost:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}


/* ── Alert family ────────────────────────────────────────────────────────── */

.alert {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    border-radius: var(--r-lg);
    padding: 12px 14px;
    border: 1px solid;
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 16px;
}
.alert-icon  { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-title { font-weight: 600; margin-bottom: 4px; }

.alert-warn  { background: var(--warn-glow);  border-color: var(--warn-line);  color: var(--warn); }
.alert-info  { background: rgba(92,88,112,0.15); border-color: rgba(92,88,112,0.3); color: var(--text-secondary); }
.alert-error { background: rgba(224,90,90,0.1);  border-color: rgba(224,90,90,0.25); color: var(--down); }


/* ── Stale warning ───────────────────────────────────────────────────────── */

.stale-warning {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--warn-glow);
    border: 1px solid var(--warn-line);
    border-radius: var(--r-md);
    padding: 8px 12px;
    color: var(--warn);
    font-family: var(--font-mono);
    font-size: 11px;
}


/* ── Confidence badges ───────────────────────────────────────────────────── */

.conf-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    border-radius: 100px;
    font-family: var(--font-mono);
    font-size: 9px;
}
.conf-high { background: rgba(76,175,132,0.1);  color: var(--up);   border: 1px solid rgba(76,175,132,0.25); }
.conf-med  { background: rgba(224,154,58,0.1);  color: var(--warn); border: 1px solid var(--warn-line); }
.conf-low  { background: rgba(224,90,90,0.1);   color: var(--down); border: 1px solid rgba(224,90,90,0.25); }


/* ── Import mode toggle ──────────────────────────────────────────────────── */

.import-mode {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}
.im-option {
    flex: 1;
    padding: 10px 14px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: var(--ink-3);
    cursor: pointer;
    transition: all 0.15s;
}
.im-option.active {
    border-color: var(--gold-line);
    background: var(--gold-glow);
}
.im-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.im-option.active .im-title { color: var(--gold); }
.im-desc { font-size: 11px; color: var(--text-tertiary); }


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

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(11,12,14,0.85);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}
.modal {
    background: var(--ink-2);
    border: 1px solid var(--border-hover);
    border-radius: var(--r-xl);
    padding: 24px;
    max-width: 480px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.modal-title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 300;
    color: var(--text-primary);
}
.modal-title.stock { color: var(--gold); }
.modal-title.wine  { color: var(--wine-light); }
.modal-close {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--ink-3);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
}
.modal-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}


/* ── API Tier cards (redesigned) ─────────────────────────────────────────── */

.api-tier {
    background: var(--ink-3);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 12px 14px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
}
.api-tier-badge {
    flex-shrink: 0;
    padding: 3px 8px;
    border-radius: var(--r-xs);
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.08em;
    font-weight: 500;
}
.tier-primary  { background: rgba(76,175,132,0.15); color: var(--up);             border: 1px solid rgba(76,175,132,0.3); }
.tier-fallback { background: var(--gold-glow);       color: var(--gold);           border: 1px solid var(--gold-line); }
.tier-last     { background: var(--surface);         color: var(--text-secondary); border: 1px solid var(--border-hover); }
.tier-ai       { background: rgba(130,100,200,0.12); color: #A080E0;               border: 1px solid rgba(130,100,200,0.3); }
.api-tier-body { flex: 1; }
.api-tier-name { font-size: 13px; font-weight: 500; color: var(--text-primary); margin-bottom: 2px; }
.api-tier-desc { font-size: 11px; color: var(--text-tertiary); }
.api-tier-input { margin-top: 8px; }


/* ── Hero metric (DS naming) ─────────────────────────────────────────────── */

.hero-metric {
    background: var(--ink-2);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 20px 22px;
}
.hm-label {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 6px;
}
.hm-value {
    font-family: var(--font-display);
    font-size: 42px;
    font-weight: 300;
    letter-spacing: -0.02em;
    line-height: 1;
    margin-bottom: 8px;
    color: var(--text-primary);
}
.hm-value.stock   { color: var(--gold); }
.hm-value.wine    { color: var(--wine-light); }
.hm-value.neutral { color: var(--text-primary); }
.hm-delta {
    font-family: var(--font-mono);
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.hm-delta.up   { color: var(--up); }
.hm-delta.down { color: var(--down); }


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

.stat-tiles {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
@media (max-width: 600px) {
    .stat-tiles { grid-template-columns: 1fr 1fr; }
}
.stat-tile {
    background: var(--ink-3);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 12px 14px;
}
.st-label {
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}
.st-value {
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: 500;
    color: var(--text-primary);
}
.st-value.up   { color: var(--up); }
.st-value.down { color: var(--down); }
.st-value.wine { color: var(--wine-light); }
.st-value.gold { color: var(--gold); }


/* ── History chart container ─────────────────────────────────────────────── */

.chart-container {
    background: var(--ink-2);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 16px;
}
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.chart-area-box {
    height: 80px;
    background: var(--ink-3);
    border-radius: var(--r-md);
    overflow: hidden;
    position: relative;
}
.chart-area-box svg { width: 100%; height: 100%; }
.chart-time-labels {
    display: flex;
    justify-content: space-between;
    padding: 5px 4px 0;
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-tertiary);
}


/* ── Toast (DS naming, portfolio uses JS injection) ──────────────────────── */

.toast {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border-hover);
    border-radius: 100px;
    padding: 8px 16px;
    font-size: 13px;
    color: var(--text-primary);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.toast.success { border-color: rgba(76,175,132,0.4); }
.toast-icon { flex-shrink: 0; }
.toast-undo,
.toast-undo-btn {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--gold);
    cursor: pointer;
    padding-left: 8px;
    border-left: 1px solid var(--border-hover);
    background: none;
    border-top: none;
    border-right: none;
    border-bottom: none;
}


/* ── Ticker option (DS naming) ───────────────────────────────────────────── */

.ticker-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--ink-3);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: 6px;
}
.ticker-option:hover  { border-color: var(--gold-line); background: var(--gold-glow); }
.ticker-option.selected { border-color: var(--gold); background: var(--gold-glow); }
.to-ticker   { font-family: var(--font-mono); font-size: 14px; font-weight: 500; color: var(--gold); }
.to-exchange { font-size: 11px; color: var(--text-tertiary); margin-top: 1px; }
.to-check    { color: var(--gold); font-size: 16px; opacity: 0; }
.ticker-option.selected .to-check { opacity: 1; }


/* ── Scan area (shared, was wine-only) ───────────────────────────────────── */

.scan-area {
    background: var(--ink-3);
    border: 1px dashed var(--wine-line);
    border-radius: var(--r-xl);
    padding: 28px 20px;
    text-align: center;
}
.scan-icon  { font-size: 36px; margin-bottom: 10px; }
.scan-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-style: italic;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.scan-sub     { font-size: 12px; color: var(--text-tertiary); margin-bottom: 16px; }
.scan-actions { display: flex; gap: 8px; justify-content: center; }
