/* ===================================================================
   UBS Gold Monitor Dashboard - Styling v2
   Brand colors:
     Navy:       #142841
     Warm brown: #88775C
     Off-white:  #F8F6F1
   =================================================================== */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #1a1a1a;
    background: #F8F6F1;
    -webkit-font-smoothing: antialiased;
}

/* ===== LOGIN PAGE ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #142841 0%, #1f3a5f 100%);
    padding: 20px;
}
.login-container { width: 100%; max-width: 420px; }
.login-card {
    background: #fff;
    border-radius: 8px;
    padding: 40px 36px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-header h1 {
    color: #142841;
    font-size: 26px;
    font-weight: 600;
    margin-bottom: 4px;
    letter-spacing: -0.3px;
}
.login-header .subtitle {
    color: #88775C;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 500;
}
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #1a1a1a;
    font-size: 13px;
}
.form-group input, .form-group select {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid #d4d4d4;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: #142841;
    box-shadow: 0 0 0 3px rgba(20,40,65,0.1);
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.15s;
    line-height: 1.4;
    white-space: nowrap;
}
.btn-primary { background: #142841; color: #fff; border-color: #142841; }
.btn-primary:hover { background: #1f3a5f; border-color: #1f3a5f; }
.btn-secondary { background: #fff; color: #142841; border-color: #d4d4d4; }
.btn-secondary:hover { background: #F8F6F1; border-color: #88775C; }
.btn-block { display: block; width: 100%; padding: 11px 20px; font-size: 14px; }
.btn-link {
    background: transparent;
    color: #88775C;
    border: none;
    padding: 8px 6px;
    font-size: 13px;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.btn-link:hover { color: #142841; }
.badge-count {
    display: inline-block;
    background: #88775C;
    color: #fff;
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 4px;
}

/* ===== ALERTS ===== */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 13px;
}
.alert-error { background: #FEE; color: #A00; border: 1px solid #FBB; }
.alert-info  { background: #E6F0FB; color: #142841; border: 1px solid #B8D4F0; }
.alert-warn  { background: #FFF4E0; color: #8B5A00; border: 1px solid #F5D89C; }

.login-footer { margin-top: 24px; text-align: center; }
.text-muted { color: #888; font-size: 12px; }

/* ===== DASHBOARD LAYOUT ===== */
.dashboard-page { background: #F8F6F1; min-height: 100vh; }

.dashboard-header {
    background: #142841;
    color: #fff;
    padding: 14px 32px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.dashboard-header-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.dashboard-header h1 {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.2px;
}
.dashboard-header .accent {
    color: #88775C;
    font-weight: 400;
    margin-left: 8px;
}
.header-right { display: flex; align-items: center; gap: 16px; font-size: 13px; }
.last-update { color: #B5C5D8; }
.last-update strong { color: #fff; font-weight: 500; }
.logout-link {
    color: #fff;
    text-decoration: none;
    padding: 6px 12px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    font-size: 12px;
    transition: all 0.15s;
}
.logout-link:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.6);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 32px;
}

/* ===== KPI CARDS ===== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.kpi-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px 22px;
    border: 1px solid #ECE7DC;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: box-shadow 0.15s, transform 0.15s;
}
.kpi-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}
.kpi-card .label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    color: #666;
    margin-bottom: 14px;
}
.kpi-card .value {
    font-size: 30px;
    font-weight: 600;
    color: #142841;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.kpi-card .value.value-positive { color: #88775C; }
.kpi-card .value.value-warning  { color: #C04A2C; }
.kpi-card .value .unit {
    font-size: 18px;
    font-weight: 500;
    color: #88775C;
    margin-left: 2px;
}
.kpi-card .value .of {
    font-size: 14px;
    font-weight: 400;
    color: #888;
    margin-left: 8px;
    letter-spacing: 0;
}
.kpi-card .sub {
    font-size: 12px;
    color: #666;
    line-height: 1.4;
}
.kpi-card .sub strong { color: #142841; font-weight: 600; }

/* ===== SECTION ===== */
/* ===== STALE SNAPSHOT BANNER ===== */
.stale-banner {
    background: #FFF6E5;
    border: 1px solid #E8C97A;
    border-left: 4px solid #C08A2A;
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    font-size: 13px;
    color: #5C4A1A;
}
.stale-banner-text { line-height: 1.4; }
.stale-banner-text strong { color: #142841; }
.stale-banner-action {
    color: #142841;
    background: #fff;
    border: 1px solid #E8C97A;
    padding: 6px 12px;
    border-radius: 4px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s;
}
.stale-banner-action:hover { background: #F5E6C0; }

.section {
    background: #fff;
    border-radius: 8px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid #ECE7DC;
    overflow: hidden;
}
.section-header {
    padding: 16px 24px;
    border-bottom: 1px solid #ECE7DC;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.section-header h2 {
    font-size: 15px;
    font-weight: 600;
    color: #142841;
    margin: 0;
}
.section-header .meta { font-size: 12px; color: #666; }
.section-body { padding: 20px 24px; }
.section-body.no-padding { padding: 0; }
.section-subtitle { padding: 4px 24px 14px; font-size: 12px; color: #666; }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.data-table thead { background: #F8F6F1; }
table.data-table th {
    text-align: left;
    padding: 11px 16px;
    font-weight: 600;
    color: #142841;
    border-bottom: 2px solid #ECE7DC;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
table.data-table th.highlight-col { background: rgba(20,40,65,0.04); }
table.data-table td {
    padding: 13px 16px;
    border-bottom: 1px solid #F0EDE6;
    vertical-align: middle;
}
table.data-table td.highlight-col {
    background: rgba(20,40,65,0.03);
    font-weight: 600;
}
table.data-table tbody tr:hover { background: #FAFAF7; }
table.data-table tbody tr.ubs-row { background: rgba(20,40,65,0.06); }
table.data-table tbody tr.ubs-row:hover { background: rgba(20,40,65,0.09); }
table.data-table tbody tr.ubs-row td { border-bottom-color: rgba(20,40,65,0.15); }
table.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Combined spread cell: % primary + Rp secondary below */
.spread-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.2;
}
.spread-cell .spread-pct {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #142841;
    letter-spacing: -0.01em;
}
.spread-cell .spread-pct .pct-sym {
    font-size: 11px;
    font-weight: 500;
    color: #6b6b6b;
    margin-left: 1px;
}
.spread-cell .spread-rp {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: #8a8a8a;
    margin-top: 1px;
}

/* Rank badge */
.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    background: #888;
}
.rank-badge.rank-1 { background: #C9A227; }
.rank-badge.rank-2 { background: #9A9A9A; }
.rank-badge.rank-3 { background: #B17B47; }

/* Brand cell */
.brand-cell { display: flex; align-items: center; gap: 8px; }
.brand-name { font-weight: 500; color: #142841; }
.brand-name.is-focus { font-weight: 600; }
.you-tag {
    display: inline-block;
    background: #142841;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 3px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

/* Source pill */
.source-pill {
    display: inline-block;
    padding: 4px 11px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
}
.source-pill.src-galeri24     { background: #FFF1E0; color: #8B5A00; }
.source-pill.src-indogold     { background: #E0EFFD; color: #144A7C; }
.source-pill.src-hrtagold     { background: #E0F2E4; color: #2E6B33; }
.source-pill.src-logammulia   { background: #EDE5DB; color: #6B4E2E; }
.source-pill.src-ubslifestyle { background: #DCE3EE; color: #142841; }
.source-pill.src-default      { background: #ECE7DC; color: #6B6B6B; }

/* Other channels */
.other-channels {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 11px;
    color: #666;
}
.other-channel-row {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
}
.other-channel-row .ch-name { color: #888; }
.other-channel-row .ch-pct {
    color: #444;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}
.no-comparator {
    font-size: 11px;
    color: #aaa;
    font-style: italic;
}

/* Deltas */
.delta-positive { color: #C62828; font-weight: 500; }
.delta-negative { color: #2E7D32; font-weight: 500; }
.delta-neutral  { color: #666; }
.gap-positive { color: #C62828; }
.gap-negative { color: #2E7D32; }
.gap-zero     { color: #888; }

/* ===== FILTERS BAR ===== */
.filters-bar {
    background: #fff;
    border-radius: 8px;
    margin-bottom: 24px;
    border: 1px solid #ECE7DC;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.filters-primary {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    padding: 14px 20px;
}
.filters-primary .filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.filters-primary .filter-group label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    color: #666;
}
.filters-primary select,
.filters-primary input[type="date"] {
    padding: 7px 10px;
    border: 1px solid #d4d4d4;
    border-radius: 5px;
    font-size: 13px;
    background: #fff;
    font-family: inherit;
    min-width: 130px;
}
.filters-primary select:focus, .filters-primary input:focus {
    outline: none;
    border-color: #142841;
}
.filter-spacer { flex: 1; }
.filters-actions { display: flex; gap: 8px; align-items: flex-end; }

/* Collapsible secondary */
.filters-secondary {
    display: none;
    padding: 16px 20px;
    border-top: 1px solid #ECE7DC;
    background: #FAFAF7;
}
.filters-secondary.is-open { display: block; }
.filters-secondary-row {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: flex-start;
}
.filters-secondary-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.filters-secondary-col > label.col-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    color: #666;
}
.brand-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.brand-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border: 1px solid #d4d4d4;
    border-radius: 14px;
    background: #fff;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s;
    user-select: none;
}
.brand-pill input[type="checkbox"] {
    accent-color: #142841;
    margin: 0;
    cursor: pointer;
}
.brand-pill:has(input:checked) {
    background: #142841;
    color: #fff;
    border-color: #142841;
}
.brand-pill:hover { border-color: #88775C; }

.checkbox-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}
.checkbox-toggle input[type="checkbox"] { accent-color: #142841; cursor: pointer; }
.checkbox-toggle label { font-size: 13px; cursor: pointer; }

.compare-date-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 4px;
}
.compare-date-row input[type="date"] {
    padding: 6px 8px;
    border: 1px solid #d4d4d4;
    border-radius: 4px;
    font-size: 12px;
}
.compare-date-row span { color: #888; font-size: 12px; }

/* Active filters chips */
.active-filters-bar {
    padding: 10px 20px;
    border-top: 1px solid #ECE7DC;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    background: #FAFAF7;
}
.active-filters-bar .label {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-right: 4px;
}
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 5px 3px 10px;
    background: #142841;
    color: #fff;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    text-decoration: none;
}
.filter-chip .remove {
    background: rgba(255,255,255,0.2);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    text-decoration: none;
    padding: 0;
}
.filter-chip .remove:hover { background: rgba(255,255,255,0.4); }

/* ===== CHART ===== */
.chart-container {
    position: relative;
    height: 380px;
    padding: 8px;
}

/* ===== VOLATILITY ===== */
.volatility-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}
.volatility-card {
    padding: 16px;
    background: #FAFAF7;
    border-radius: 6px;
    border-left: 3px solid #88775C;
}
.volatility-card.highlight-bad { border-left-color: #C62828; }
.volatility-card.highlight-good { border-left-color: #2E7D32; }
.volatility-card .label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
    margin-bottom: 6px;
    font-weight: 600;
}
.volatility-card .value {
    font-size: 18px;
    font-weight: 600;
    color: #142841;
    margin-bottom: 4px;
}
.volatility-card .meta { font-size: 12px; color: #666; }

/* ===== STATUS ===== */
.status-row { display: flex; flex-wrap: wrap; gap: 12px; }
.status-card {
    flex: 1;
    min-width: 200px;
    padding: 12px 14px;
    border-radius: 6px;
    background: #FAFAF7;
    border: 1px solid #ECE7DC;
    font-size: 12px;
}
.status-card .source-name { font-weight: 600; color: #142841; margin-bottom: 4px; }
.status-card .status-fresh { color: #2E7D32; }
.status-card .status-stale { color: #C62828; }

/* ===== COLLAPSIBLE ===== */
.collapsible-toggle {
    background: transparent;
    border: none;
    color: #88775C;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.collapsible-toggle:hover { color: #142841; }
.collapsible-content { display: none; }
.collapsible-content.is-open { display: block; }

/* ===== EMPTY STATE ===== */
.empty-state {
    padding: 50px 24px;
    text-align: center;
    color: #888;
}
.empty-state p { margin-bottom: 8px; }

/* ===== UTILS ===== */
.mt-2 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.text-small { font-size: 12px; }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
    .container { padding: 16px; }
    .dashboard-header { padding: 12px 16px; }
    .dashboard-header h1 { font-size: 15px; }
    .header-right { font-size: 12px; gap: 8px; }
    .last-update { display: none; }
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .kpi-card { padding: 14px 16px; }
    .kpi-card .value { font-size: 24px; }
    .filters-primary { gap: 8px; padding: 12px 14px; }
    .filters-primary select, .filters-primary input[type="date"] { min-width: 110px; }
    .filter-spacer { display: none; }
    .filters-actions { width: 100%; margin-top: 8px; }
    .volatility-grid { grid-template-columns: 1fr; }
    .chart-container { height: 280px; }
    .section-body { padding: 16px; }
    .section-header { padding: 12px 16px; }
    table.data-table th, table.data-table td { padding: 9px 10px; font-size: 12px; }
    .filters-secondary-row { flex-direction: column; gap: 14px; }
}
@media (max-width: 600px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .dashboard-header .accent { display: none; }
}
@media print {
    .dashboard-header, .filters-bar, .logout-link, .filter-actions { display: none; }
    .container { padding: 0; }
    .section, .kpi-card { box-shadow: none; border: 1px solid #ccc; page-break-inside: avoid; }
    body { background: #fff; }
}