/* ============================================
   Portfolio Studio Sandbox — Design System
   Apple UI-inspired, Black & Gold theme
   ============================================ */

/* --- CSS Variables (Light Theme - Default) --- */
:root {
    /* Backgrounds */
    --bg-primary: #FFFFFF;
    --bg-secondary: #F5F5F7;
    --bg-card: #FFFFFF;
    --bg-nav: #FFFFFF;
    --bg-filter: #F5F5F7;
    --bg-input: #FFFFFF;
    --bg-hover: #F0F0F2;
    --bg-dropdown: #FFFFFF;
    --bg-table-alt: #FAFAFA;
    --bg-code: #F5F5F7;

    /* Text */
    --text-primary: #1D1D1F;
    --text-secondary: #6E6E73;
    --text-muted: #86868B;
    --text-inverse: #FFFFFF;

    /* Accent — Gold */
    --accent: #C9A84C;
    --accent-hover: #B8963E;
    --accent-light: rgba(201, 168, 76, 0.12);
    --accent-border: rgba(201, 168, 76, 0.3);

    /* Sentiment colours (charts only) */
    --positive: #34A853;
    --positive-light: rgba(52, 168, 83, 0.15);
    --negative: #D93025;
    --negative-light: rgba(217, 48, 37, 0.15);
    --neutral-color: #9AA0A6;
    --neutral-light: rgba(154, 160, 166, 0.15);

    /* Borders & Shadows */
    --border: #E5E5EA;
    --border-light: #F0F0F2;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.10);

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    /* Transitions */
    --transition: 0.2s ease;
    --transition-slow: 0.4s ease;

    /* Chart colours */
    --chart-1: #C9A84C;
    --chart-2: #1D1D1F;
    --chart-3: #2196F3;
    --chart-4: #D93025;
    --chart-5: #26A69A;
    --chart-6: #7B1FA2;
    --chart-7: #E67C34;
    --chart-8: #6E6E73;

    /* Plotly background */
    --plotly-bg: #FFFFFF;
    --plotly-grid: #F0F0F2;
    --plotly-text: #1D1D1F;
}

/* --- Dark Theme --- */
[data-theme="dark"] {
    --bg-primary: #1C1C1E;
    --bg-secondary: #2C2C2E;
    --bg-card: #2C2C2E;
    --bg-nav: #1C1C1E;
    --bg-filter: #2C2C2E;
    --bg-input: #3A3A3C;
    --bg-hover: #3A3A3C;
    --bg-dropdown: #2C2C2E;
    --bg-table-alt: #252528;
    --bg-code: #2C2C2E;

    --text-primary: #F5F5F7;
    --text-secondary: #A1A1A6;
    --text-muted: #86868B;
    --text-inverse: #1D1D1F;

    --positive: #81C995;
    --positive-light: rgba(129, 201, 149, 0.15);
    --negative: #F28B82;
    --negative-light: rgba(242, 139, 130, 0.15);
    --neutral-color: #9AA0A6;
    --neutral-light: rgba(154, 160, 166, 0.15);

    --border: #3A3A3C;
    --border-light: #48484A;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);

    --chart-1: #C9A84C;
    --chart-2: #F5F5F7;
    --chart-3: #64B5F6;
    --chart-4: #F28B82;
    --chart-5: #80CBC4;
    --chart-6: #CE93D8;
    --chart-7: #FF8A65;
    --chart-8: #A1A1A6;

    --plotly-bg: #2C2C2E;
    --plotly-grid: #3A3A3C;
    --plotly-text: #F5F5F7;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', system-ui, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.5;
    transition: background-color var(--transition-slow), color var(--transition-slow);
    min-height: 100vh;
}

/* --- Typography --- */
h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

p {
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--accent-hover);
}

/* Tabular numbers for data */
.num, .metric-value, td.num {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

/* --- Navigation --- */
.nav-bar {
    background-color: var(--bg-nav);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 52px;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: background-color var(--transition-slow), border-color var(--transition-slow);
}

.nav-brand {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0;
}

.nav-link {
    padding: 0 1rem;
    height: 52px;
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: color var(--transition), border-color var(--transition);
}

.nav-link:hover {
    color: var(--text-primary);
}

.nav-link.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.nav-right strong {
    color: var(--text-primary);
    font-weight: 600;
}

.nav-right a {
    color: var(--text-muted);
    font-weight: 500;
}

.nav-right a:hover {
    color: var(--accent);
}

/* Prominent Upload nav link */
.nav-link-upload {
    color: var(--accent) !important;
    font-weight: 700 !important;
    font-size: 0.88rem !important;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    border: none !important;
    background: none !important;
    transition: all var(--transition);
}
.nav-link-upload svg {
    flex-shrink: 0;
}
.nav-link-upload:hover {
    color: var(--accent) !important;
    opacity: 0.8;
}
.nav-link-upload.active {
    color: var(--accent) !important;
    border-bottom: 2px solid var(--accent) !important;
}

/* Theme Icon Button */
.theme-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.35rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: color var(--transition), background var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.theme-icon-btn:hover {
    color: var(--accent);
    background: var(--accent-light);
}

/* Light mode: show moon, hide sun */
.theme-icon-btn .icon-sun { display: none; }
.theme-icon-btn .icon-moon { display: block; }

/* Dark mode: show sun, hide moon */
[data-theme="dark"] .theme-icon-btn .icon-sun { display: block; }
[data-theme="dark"] .theme-icon-btn .icon-moon { display: none; }

/* --- Main Content --- */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 2rem 3rem;
}

.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    margin-bottom: 0.25rem;
}

.page-header p {
    font-size: 0.9rem;
}

.page-description {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0.5rem 0 0 0;
    max-width: 72rem;
}

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    padding: 1.25rem 1.5rem;
    transition: background-color var(--transition-slow), box-shadow var(--transition), border-color var(--transition-slow);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-gold-top {
    border-top: 2.5px solid var(--accent);
}

/* Score Cards Row */
.score-cards {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.score-card {
    text-align: center;
    padding: 1rem 0.75rem;
}

.score-card .card-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.score-card .card-value {
    font-size: 1.6rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    margin-bottom: 0.3rem;
}

.score-card .card-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* Colour helpers */
.text-positive { color: var(--positive); }
.text-negative { color: var(--negative); }
.text-neutral { color: var(--text-muted); }
.bg-positive-light { background-color: var(--positive-light); }
.bg-negative-light { background-color: var(--negative-light); }

/* --- Section containers --- */
.section {
    margin-bottom: 2rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.chart-container {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    padding: 1.25rem;
    transition: background-color var(--transition-slow), border-color var(--transition-slow);
}

.chart-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.chart-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

/* --- Filter Bar --- */
.filter-bar {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem;
    transition: background-color var(--transition-slow), border-color var(--transition-slow);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
}

.filter-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.filter-bar select,
.filter-bar input[type="date"],
.filter-bar input[type="number"],
.filter-bar input[type="text"] {
    font-family: inherit;
    font-size: 0.82rem;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    transition: border-color var(--transition), background-color var(--transition-slow);
    outline: none;
}

.filter-bar select:focus,
.filter-bar input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
}

/* Segmented Control */
.segmented-control {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-input);
}

.seg-btn {
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 500;
    font-family: inherit;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    border-right: 1px solid var(--border);
    white-space: nowrap;
}

.seg-btn:last-child {
    border-right: none;
}

.seg-btn:hover {
    background: var(--bg-hover);
}

.seg-btn.active {
    background: var(--accent);
    color: #FFFFFF;
}

/* Label Toggles */
.label-toggles {
    display: inline-flex;
    gap: 0.4rem;
}

.label-toggle {
    padding: 0.3rem 0.7rem;
    font-size: 0.78rem;
    font-weight: 500;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.label-toggle:hover {
    border-color: var(--accent-border);
}

.label-toggle.active {
    background: var(--accent);
    color: #FFFFFF;
    border-color: var(--accent);
}

/* Weighting Panel */
.weighting-toggle-btn {
    padding: 0.35rem 0.8rem;
    font-size: 0.78rem;
    font-weight: 500;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}

.weighting-toggle-btn:hover {
    border-color: var(--accent-border);
}

.weighting-toggle-btn.has-custom::after {
    content: '';
    position: absolute;
    top: -3px;
    right: -3px;
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
}

.weighting-panel {
    display: none;
    width: 100%;
    padding-top: 0.75rem;
    margin-top: 0.25rem;
    border-top: 1px solid var(--border-light);
}

.weighting-panel.open {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.weight-section h4 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.weight-inputs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.weight-input-group {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.weight-input-group label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    min-width: 55px;
}

.weight-input-group input {
    width: 50px;
    text-align: center;
    font-size: 0.8rem;
    padding: 0.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
}

/* Multi-select dropdown */
.multi-select-wrapper {
    position: relative;
}

.multi-select-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    font-size: 0.82rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    cursor: pointer;
    min-width: 160px;
    transition: border-color var(--transition);
}

.multi-select-btn:hover,
.multi-select-btn.open {
    border-color: var(--accent);
}

.multi-select-btn .arrow {
    font-size: 0.6rem;
    color: var(--text-muted);
}

.multi-select-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 260px;
    max-height: 320px;
    overflow-y: auto;
    background: var(--bg-dropdown);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 500;
    margin-top: 4px;
}

.multi-select-dropdown.open {
    display: block;
}

.ms-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-light);
}

.ms-action-btn {
    font-size: 0.72rem;
    font-family: inherit;
    color: var(--accent);
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 500;
}

.ms-action-btn:hover {
    color: var(--accent-hover);
}

.ms-divider {
    padding: 0.35rem 0.75rem;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: var(--bg-secondary);
}

.ms-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background var(--transition);
}

.ms-option:hover {
    background: var(--bg-hover);
}

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

/* Source tier group */
.tier-group-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition);
    user-select: none;
}

.tier-group-header:hover {
    background: var(--bg-hover);
}

.tier-group-header .tier-arrow {
    font-size: 0.55rem;
    transition: transform var(--transition);
    color: var(--text-muted);
}

.tier-group-header .tier-arrow.expanded {
    transform: rotate(90deg);
}

.tier-sources {
    display: none;
    padding-left: 1.5rem;
}

.tier-sources.open {
    display: block;
}

/* --- Tables --- */
.data-table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.data-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    transition: color var(--transition);
}

.data-table th:hover {
    color: var(--accent);
}

.data-table th .sort-arrow {
    font-size: 0.6rem;
    margin-left: 0.25rem;
    opacity: 0.4;
}

.data-table th.sorted .sort-arrow {
    opacity: 1;
    color: var(--accent);
}

.data-table td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    transition: background-color var(--transition-slow);
}

.data-table tbody tr:nth-child(even) {
    background-color: var(--bg-table-alt);
}

.data-table tbody tr:hover {
    background-color: var(--bg-hover);
}

.data-table tbody tr.clickable {
    cursor: pointer;
}

/* Sentiment badge */
.sentiment-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.78rem;
    font-weight: 500;
}

.sentiment-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.sentiment-dot.positive { background: var(--positive); }
.sentiment-dot.negative { background: var(--negative); }
.sentiment-dot.neutral { background: var(--neutral-color); }

/* Layer tags */
.layer-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
}

.layer-tag {
    font-size: 0.68rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 500;
    white-space: nowrap;
}

/* --- Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    margin-top: 1rem;
}

.page-btn {
    padding: 0.3rem 0.65rem;
    font-size: 0.8rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.page-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.page-btn.active {
    background: var(--accent);
    color: #FFFFFF;
    border-color: var(--accent);
}

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

.page-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0 0.5rem;
}

/* --- Toggle / Checkbox button --- */
.toggle-btn {
    padding: 0.3rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 500;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.toggle-btn:hover {
    border-color: var(--accent-border);
}

.toggle-btn.active {
    background: var(--accent-light);
    color: var(--accent);
    border-color: var(--accent-border);
}

/* --- Search input --- */
.search-input {
    font-family: inherit;
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
    padding-left: 2rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2386868B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat 0.6rem center;
    color: var(--text-primary);
    width: 280px;
    transition: border-color var(--transition), background-color var(--transition-slow);
    outline: none;
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
}

/* --- Buttons --- */
.btn {
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    padding: 0.45rem 1rem;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.btn-primary {
    background: var(--accent);
    color: #FFFFFF;
}

.btn-primary:hover {
    background: var(--accent-hover);
    color: #FFFFFF;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-danger {
    background: transparent;
    border: 1px solid var(--negative);
    color: var(--negative);
    font-size: 0.78rem;
    padding: 0.3rem 0.7rem;
}

.btn-danger:hover {
    background: var(--negative-light);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 0.78rem;
    padding: 0.3rem 0.7rem;
    text-decoration: none;
    display: inline-block;
}
.btn-secondary:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

/* --- Agent Selector --- */

.agent-selector {
    margin-bottom: 1.25rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.2rem;
}
.agent-section {
    margin-bottom: 0.75rem;
}
.agent-section:last-child {
    margin-bottom: 0;
}
.agent-section-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}
.agent-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.agent-btn {
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 0.38rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input, var(--card-bg));
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.agent-btn:hover:not(.disabled) {
    border-color: var(--accent);
    color: var(--text-primary);
}
.agent-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
}
.agent-divider {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-left: 0.25rem;
}
.agent-divider::before {
    content: '';
    width: 1px;
    height: 1.2rem;
    background: var(--border);
    flex-shrink: 0;
}
.coming-soon-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
    white-space: nowrap;
    flex-shrink: 0;
}
.agent-disabled-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}
.agent-btn.disabled {
    opacity: 0.5;
    cursor: default;
    pointer-events: none;
    font-size: 0.73rem;
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--border);
}

/* --- Upload Page --- */

.upload-section {
    margin-top: 2rem;
}

.upload-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}
@media (max-width: 900px) {
    .upload-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 500px) {
    .upload-grid { grid-template-columns: 1fr; }
}

.upload-grid-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.2rem;
}
.upload-grid-card h3 {
    font-size: 0.88rem;
    font-weight: 700;
    margin: 0 0 0.35rem;
    color: var(--text-primary);
}
.upload-grid-card p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.45;
}

.code-block {
    background: var(--bg-input, var(--card-bg));
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem 1.2rem;
    margin-top: 1rem;
    overflow-x: auto;
}
.code-block pre {
    margin: 0;
    font-family: 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre;
}

.guidance-box {
    margin-top: 2rem;
    padding: 1.25rem 1.5rem;
    border-left: 3px solid var(--accent);
    background: var(--card-bg);
    border-radius: 0 var(--radius) var(--radius) 0;
}
.guidance-box .section-title {
    margin-top: 0;
}
.guidance-box p {
    font-size: 0.84rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0.6rem 0;
}
.guidance-box p:last-child {
    margin-bottom: 0;
}

.sample-link {
    display: inline-block;
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.sample-link:hover {
    color: var(--accent);
}
.upload-info-note {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0.75rem 0 0 0;
}

.upload-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}
@media (max-width: 800px) {
    .upload-split { grid-template-columns: 1fr; }
}

.sample-panel {
    border-left: 3px solid var(--accent);
}

.sample-securities {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.sample-security {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    font-size: 0.84rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--border-light, var(--border));
}
.sample-security strong {
    font-family: 'SF Mono', SFMono-Regular, Consolas, monospace;
    font-size: 0.82rem;
    color: var(--accent);
    min-width: 3rem;
}
.sample-security span {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.sample-freshness {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.upload-bottom-note {
    margin-top: 2rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* --- Forms (login, upload) --- */
.form-card {
    max-width: 400px;
    margin: 3rem auto;
    padding: 2rem;
}

.form-card h1 {
    text-align: center;
    margin-bottom: 0.3rem;
}

.form-card p {
    text-align: center;
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.form-group input[type="email"],
.form-group input[type="text"],
.form-group input[type="file"] {
    width: 100%;
    font-family: inherit;
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition), background-color var(--transition-slow);
}

.form-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
}

.form-card .btn {
    width: 100%;
    justify-content: center;
    padding: 0.55rem;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.form-error {
    color: var(--negative);
    font-size: 0.85rem;
    text-align: center;
    margin-bottom: 1rem;
}

/* --- Info box / format helper --- */
.info-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-top: 1.5rem;
}

.info-box h3 {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.info-box pre {
    font-family: 'SF Mono', SFMono-Regular, ui-monospace, Menlo, monospace;
    font-size: 0.8rem;
    background: var(--bg-code);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    color: var(--text-primary);
}

.info-box p {
    font-size: 0.82rem;
    margin-bottom: 0.4rem;
}

/* --- Loading --- */
.loading-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 0.5rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Flash messages --- */
.flash-success {
    background: var(--positive-light);
    color: var(--positive);
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.flash-error {
    background: var(--negative-light);
    color: var(--negative);
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

/* --- Summary page (index) --- */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.summary-card ul {
    list-style: none;
    padding: 0;
}

.summary-card li {
    padding: 0.35rem 0;
    font-size: 0.88rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-light);
}

.summary-card li:last-child {
    border-bottom: none;
}

.summary-card li strong {
    color: var(--text-primary);
}

/* --- Headline Explorer extras --- */
.explorer-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.headline-count {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.headline-text {
    max-width: 400px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.headline-text:hover {
    white-space: normal;
    word-wrap: break-word;
}

/* --- Extreme Headlines Tabs --- */
.view-tabs {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.view-tab {
    padding: 0.35rem 0.85rem;
    font-size: 0.78rem;
    font-weight: 500;
    font-family: inherit;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    border-right: 1px solid var(--border);
}

.view-tab:last-child {
    border-right: none;
}

.view-tab:hover {
    background: var(--bg-hover);
}

.view-tab.active {
    background: var(--accent);
    color: #FFFFFF;
}

/* --- Responsive --- */
@media (max-width: 1200px) {
    .score-cards {
        grid-template-columns: repeat(3, 1fr);
    }
    .chart-grid-3 {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 900px) {
    .score-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    .chart-grid-2, .chart-grid-3 {
        grid-template-columns: 1fr;
    }
    .nav-bar {
        padding: 0 1rem;
    }
    .main-content {
        padding: 1rem;
    }
    .filter-bar {
        padding: 0.75rem 1rem;
    }
    .search-input {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .nav-links {
        display: none;
    }
}


/* ============================================
   Portfolio Dashboard — Styles
   ============================================ */

/* Portfolio mode visibility */
.portfolio-mode-only {
    display: none !important;
}
body.portfolio-active .portfolio-mode-only {
    display: flex !important;
}
body.portfolio-active .score-cards.portfolio-mode-only {
    display: grid !important;
}
body.portfolio-active .section.portfolio-mode-only {
    display: block !important;
}
body.portfolio-active .portfolio-mode-only.section-block {
    display: block !important;
}
body.portfolio-active .portfolio-mode-only.chart-grid-2 {
    display: grid !important;
}

/* Benchmark-only visibility */
.benchmark-only {
    display: none !important;
}
body.benchmark-active .benchmark-only {
    display: block !important;
}

/* Portfolio Mode Banner */
.portfolio-mode-banner {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.75rem 1.25rem;
    margin-bottom: 0.75rem;
    transition: all 0.25s ease;
}
.portfolio-mode-banner.active {
    border-color: var(--accent);
    background: var(--accent-light);
}
.portfolio-banner-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.portfolio-banner-left {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.portfolio-banner-label {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}
.portfolio-banner-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.portfolio-mode-banner.active .portfolio-banner-desc {
    color: var(--accent-hover);
}
.portfolio-banner-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
}
.portfolio-banner-btn:hover {
    border-color: var(--accent-border);
    color: var(--accent);
}
.portfolio-banner-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.portfolio-banner-btn.active:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}
.portfolio-banner-btn-icon {
    font-size: 1.1rem;
    line-height: 1;
}

/* Weights panel */
.weights-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-top: 12px;
}
.weights-panel h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.weights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
}
.weight-item {
    display: flex;
    align-items: center;
    gap: 8px;
}
.weight-item label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 60px;
}
.weight-item input {
    width: 70px;
    padding: 4px 8px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    text-align: right;
}
.weight-item input:focus {
    outline: none;
    border-color: var(--accent);
}
.weights-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    align-items: center;
}
.weights-actions button {
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}
.weights-actions button:hover {
    background: var(--accent);
    color: var(--text-inverse);
    border-color: var(--accent);
}
.weights-total {
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: auto;
}
.weights-total.warning {
    color: var(--negative);
    font-weight: 600;
}

/* Chart grid layouts */
.chart-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.chart-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}
.chart-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

/* Sparkline cards */
.sparkline-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}
.sparkline-card:hover {
    box-shadow: var(--shadow-md);
}
.sparkline-card .spark-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.sparkline-card .spark-ticker {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.sparkline-card .spark-price {
    font-size: 13px;
    color: var(--text-secondary);
}
.sparkline-card .spark-return {
    font-size: 12px;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px;
}
.sparkline-card .spark-return.positive {
    background: var(--positive-light);
    color: var(--positive);
}
.sparkline-card .spark-return.negative {
    background: var(--negative-light);
    color: var(--negative);
}
.sparkline-card .spark-chart {
    height: 50px;
}
.sparkline-card .spark-weight {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Section block styling */
.section-block {
    margin-bottom: 24px;
}
.section-block h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

/* Chart controls row */
.chart-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.chart-controls select {
    padding: 6px 10px;
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
}
.chart-controls select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Comparison card */
.comparison-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
}
.comparison-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 12px;
    text-align: center;
}
.comparison-grid .comp-label {
    font-size: 12px;
    color: var(--text-muted);
    padding: 6px 0;
    border-bottom: 1px solid var(--border-light);
}
.comparison-grid .comp-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    padding: 6px 0;
    border-bottom: 1px solid var(--border-light);
}
.comparison-grid .comp-vs {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Score card row for portfolio */
.score-cards-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.score-cards-row .score-card {
    flex: 1;
    min-width: 150px;
}

/* Period comparison */
.period-picker {
    display: flex;
    gap: 8px;
    align-items: center;
}
.period-picker input[type="date"] {
    padding: 4px 8px;
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
}

/* Chart placeholder */
.chart-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: var(--text-muted);
    font-size: 14px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
}

/* Controls bar for portfolio */
.portfolio-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}
.portfolio-controls .control-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.portfolio-controls .control-group label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.portfolio-controls select,
.portfolio-controls input[type="date"] {
    padding: 6px 10px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
}
.portfolio-controls .control-group select:focus,
.portfolio-controls .control-group input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Responsive for portfolio grids */
@media (max-width: 1200px) {
    .chart-grid-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (max-width: 900px) {
    .chart-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    .chart-grid-2 {
        grid-template-columns: 1fr;
    }
    .chart-grid-3 {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 768px) {
    .chart-grid-4 {
        grid-template-columns: 1fr;
    }
    .portfolio-controls {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ============================================
   Signal Analysis Page — Specific Styles
   ============================================ */

/* Active series badge */
.active-series-badge {
    display: inline-block;
    padding: 0.3rem 0.75rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-light);
    border: 1px solid var(--accent-border);
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

/* Lead correlation card — prominent styling */
.lead-corr-card {
    position: relative;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 1px var(--accent-border), var(--shadow-sm);
}

/* KEY METRIC badge */
.key-metric-badge {
    position: absolute;
    top: 0.4rem;
    right: 0.5rem;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--accent);
    background: var(--accent-light);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
}

/* ============================================
   Reusable Tooltip Component
   ============================================ */
.info-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    font-size: 12px;
    font-weight: 700;
    font-family: inherit;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: 50%;
    cursor: help;
    vertical-align: middle;
    margin-left: 6px;
    flex-shrink: 0;
    line-height: 1;
    user-select: none;
    z-index: 1;
    box-shadow: 0 1px 4px rgba(201, 168, 76, 0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.info-tooltip:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(201, 168, 76, 0.5);
}
.info-tooltip .tooltip-text {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    max-width: 320px;
    padding: 0.65rem 0.8rem;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.5;
    color: #fff;
    background: rgba(30, 30, 32, 0.95);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    pointer-events: none;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    z-index: 9999;
    text-align: left;
    white-space: normal;
}
.info-tooltip .tooltip-text::before {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-bottom-color: rgba(30, 30, 32, 0.95);
}
.info-tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}
/* When tooltip would overflow right edge, anchor to right */
.info-tooltip.tooltip-left .tooltip-text {
    left: auto;
    right: -8px;
    transform: none;
}
.info-tooltip.tooltip-left .tooltip-text::before {
    left: auto;
    right: 12px;
    transform: none;
}
/* When tooltip should appear above */
.info-tooltip.tooltip-above .tooltip-text {
    top: auto;
    bottom: calc(100% + 8px);
}
.info-tooltip.tooltip-above .tooltip-text::before {
    bottom: auto;
    top: 100%;
    border-bottom-color: transparent;
    border-top-color: rgba(30, 30, 32, 0.95);
}
/* Dark theme adaptation */
[data-theme="dark"] .info-tooltip .tooltip-text {
    background: rgba(55, 55, 60, 0.97);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}
[data-theme="dark"] .info-tooltip .tooltip-text::before {
    border-bottom-color: rgba(55, 55, 60, 0.97);
}
[data-theme="dark"] .info-tooltip.tooltip-above .tooltip-text::before {
    border-bottom-color: transparent;
    border-top-color: rgba(55, 55, 60, 0.97);
}
/* Score card tooltip positioning */
.score-card .info-tooltip {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    margin-left: 0;
}
.score-card .info-tooltip .tooltip-text {
    left: auto;
    right: -4px;
    transform: none;
}
.score-card .info-tooltip .tooltip-text::before {
    left: auto;
    right: 10px;
    transform: none;
}
.score-card {
    position: relative;
}

/* ============================================
   Login Page — Split-Screen Layout
   ============================================ */

/* Keyframes */
@keyframes shimmer {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Fade-in utility */
.login-fade-in {
    opacity: 0;
    animation: fadeInUp 0.55s ease-out forwards;
}

/* Split container */
.login-split {
    display: flex;
    height: 100vh;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', system-ui, sans-serif;
}

/* ---- LEFT PANEL (Hero) ---- */
.login-hero {
    flex: 0 0 57%;
    position: relative;
    background: #141420;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Subtle grid pattern background */
.login-hero-bg {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(201, 168, 76, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(201, 168, 76, 0.04) 1px, transparent 1px);
    background-size: 48px 48px;
    pointer-events: none;
}
/* Subtle radial glow overlay on left panel */
.login-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 30% 40%, rgba(201, 168, 76, 0.06) 0%, transparent 60%),
                radial-gradient(ellipse at 80% 80%, rgba(201, 168, 76, 0.04) 0%, transparent 50%);
    pointer-events: none;
}

.login-hero-content {
    position: relative;
    z-index: 1;
    padding: 3rem 3.5rem;
    max-width: 560px;
    width: 100%;
}

/* Brand name with shimmer */
.login-brand {
    font-size: 2.4rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin: 0;
    line-height: 1.15;
    background: linear-gradient(
        105deg,
        #FFFFFF 0%,
        #FFFFFF 35%,
        #C9A84C 50%,
        #FFFFFF 65%,
        #FFFFFF 100%
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmer 6s linear infinite, fadeInUp 0.55s ease-out forwards;
}

/* Subtitle */
.login-subtitle {
    font-size: 1rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.45);
    margin: 0.6rem 0 0 0;
    letter-spacing: -0.005em;
}

/* Gold separator */
.login-separator {
    width: 60px;
    height: 2px;
    margin: 2rem 0 0 0;
    background: linear-gradient(90deg, #C9A84C, rgba(201, 168, 76, 0.2));
    border-radius: 1px;
}

/* Description paragraph */
.login-description {
    margin-top: 1.75rem;
    font-size: 0.88rem;
    font-weight: 400;
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.65);
    text-align: left;
    max-width: 500px;
}

/* Feature highlights */
.login-features {
    margin-top: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.login-feature {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}
.login-dot {
    width: 8px;
    height: 8px;
    min-width: 8px;
    border-radius: 50%;
    background: #C9A84C;
    box-shadow: 0 0 6px rgba(201, 168, 76, 0.6), 0 0 12px rgba(201, 168, 76, 0.3);
    margin-top: 0.45rem;
}
.login-feature-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
}
.login-feature-text {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.55);
    margin: 0.15rem 0 0 0;
    line-height: 1.5;
}

/* ---- RIGHT PANEL (Login) ---- */
.login-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #FAFAFA;
    position: relative;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.08);
}

.login-panel-content {
    width: 100%;
    max-width: 340px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.login-welcome {
    font-size: 1.8rem;
    font-weight: 600;
    color: #1D1D1F;
    margin: 0;
    letter-spacing: -0.02em;
}
.login-welcome-sub {
    font-size: 0.9rem;
    color: #86868B;
    margin: 0.4rem 0 0 0;
}

/* Form */
.login-form {
    width: 100%;
    margin-top: 2.25rem;
    display: flex;
    flex-direction: column;
}
.login-input {
    width: 100%;
    padding: 0.85rem 1rem;
    font-family: inherit;
    font-size: 0.92rem;
    color: #1D1D1F;
    background: #FFFFFF;
    border: 1.5px solid #E5E5EA;
    border-radius: 10px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}
.login-input::placeholder {
    color: #86868B;
}
.login-input:focus {
    border-color: #C9A84C;
    box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.15);
}
.login-error {
    font-size: 0.8rem;
    color: #D93025;
    margin-top: 0.5rem;
    text-align: left;
    min-height: 0;
}
.login-btn {
    width: 100%;
    padding: 0.85rem 1rem;
    margin-top: 0.75rem;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    color: #1D1D1F;
    background: #C9A84C;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(201, 168, 76, 0.25);
    transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
    box-sizing: border-box;
}
.login-btn:hover {
    background: #B8963E;
    box-shadow: 0 4px 20px rgba(201, 168, 76, 0.4);
}
.login-btn:active {
    transform: scale(0.985);
}

/* Panel footer */
.login-panel-footer {
    position: absolute;
    bottom: 1.25rem;
    font-size: 0.72rem;
    color: #86868B;
    letter-spacing: 0.01em;
}

/* ---- Dark Theme Overrides ---- */
[data-theme="dark"] .login-hero {
    background: #0E0E18;
}
[data-theme="dark"] .login-hero-bg {
    background-image:
        linear-gradient(rgba(201, 168, 76, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(201, 168, 76, 0.06) 1px, transparent 1px);
}
[data-theme="dark"] .login-panel {
    background: #1C1C1E;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.25);
}
[data-theme="dark"] .login-welcome {
    color: #F5F5F7;
}
[data-theme="dark"] .login-welcome-sub {
    color: #86868B;
}
[data-theme="dark"] .login-input {
    color: #F5F5F7;
    background: #2C2C2E;
    border-color: #3A3A3C;
}
[data-theme="dark"] .login-input::placeholder {
    color: #6E6E73;
}
[data-theme="dark"] .login-input:focus {
    border-color: #C9A84C;
    box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.2);
}
[data-theme="dark"] .login-btn {
    color: #1C1C1E;
    background: #C9A84C;
    box-shadow: 0 2px 16px rgba(201, 168, 76, 0.3);
}
[data-theme="dark"] .login-btn:hover {
    background: #B8963E;
    box-shadow: 0 4px 24px rgba(201, 168, 76, 0.5);
}
[data-theme="dark"] .login-panel-footer {
    color: #6E6E73;
}
[data-theme="dark"] .login-error {
    color: #FF6B6B;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .login-split {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }
    .login-hero {
        flex: none;
        padding: 2.5rem 1.5rem;
    }
    .login-hero-content {
        padding: 0;
        max-width: 100%;
    }
    .login-brand {
        font-size: 1.6rem;
    }
    .login-subtitle {
        font-size: 0.88rem;
    }
    .login-separator {
        margin-top: 1.25rem;
    }
    .login-features {
        margin-top: 1.25rem;
        gap: 0.75rem;
    }
    .login-description {
        font-size: 0.8rem;
    }
    .login-panel {
        flex: 1;
        min-height: 50vh;
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.08);
    }
}
@media (max-width: 480px) {
    .login-brand {
        font-size: 1.4rem;
    }
    .login-panel-content {
        padding: 1.5rem;
    }
    .login-welcome {
        font-size: 1.5rem;
    }
}
