:root {
    --bg: #f4f7f8;
    --surface: #ffffff;
    --surface-soft: #fbf8fa;
    --text: #2b1626;
    --muted: #7a6479;
    --border: #dce5e8;
    --teal: #632469;
    --teal-dark: #431647;
    --teal-soft: #f2e5ef;
    --pink: #b84e78;
    --pink-soft: #f7e7ee;
    --blue: #376f9d;
    --blue-soft: #e7f0f7;
    --purple: #7656a7;
    --positive: #a43e68;
    --negative: #2f6f8f;
    --neutral: #64737a;
    --shadow: 0 18px 45px rgba(71, 22, 56, 0.08);
    --radius: 20px;
    --sidebar: 258px;
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar) minmax(0, 1fr);
    align-items: start;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
}
button, input, select { font: inherit; }
a { color: inherit; }

/* Sidebar */
.sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    width: 100%;
    height: 100vh;
    min-height: 100vh;
    padding: 24px 18px 20px;
    display: flex;
    flex-direction: column;
    align-self: start;
    color: white;
    background: linear-gradient(180deg, #6b1f66 0%, #a238ac 58%, #e160e6 100%);
    overflow-y: auto;
}
.sidebar-brand { padding: 6px 10px 24px; }
.sidebar-brand .eyebrow {
    margin: 0 0 6px;
    color: #cfe4e7;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}
.sidebar-brand h1 { margin: 0; font-size: 1.35rem; line-height: 1.2; }
.sidebar-brand p { margin: 9px 0 0; color: #d8e8ea; font-size: .86rem; line-height: 1.5; }
.sidebar-nav { display: grid; gap: 7px; flex: 0 0 auto; }
.sidebar-nav a {
    display: grid;
    grid-template-columns: 30px 1fr;
    gap: 9px;
    align-items: center;
    padding: 11px 12px;
    color: #e9f3f4;
    border-radius: 11px;
    text-decoration: none;
    font-size: .91rem;
    line-height: 1.25;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.10); }
.sidebar-nav a.active { color: #d04cd4; background: white; font-weight: 800; }
.nav-number {
    display: inline-grid;
    place-items: center;
    width: 25px;
    height: 25px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.12);
    font-size: .78rem;
    font-weight: 800;
}
.sidebar-nav a.active .nav-number { color: white; background: var(--teal); }
.sidebar-divider { height: 1px; margin: 13px 8px; background: rgba(255, 255, 255, 0.18); }
.sidebar-note { margin: auto 10px 0; padding-top: 22px; color: #ddcae3; font-size: .78rem; line-height: 1.5; }

/* Main shell */
.app-main { grid-column: 2; min-width: 0; min-height: 100vh; margin: 0; align-self: start; }
.page-shell { width: min(1180px, calc(100% - 52px)); margin: 0 auto; }
.hero {
    padding: 55px 0 42px;
    color: white;
    background: linear-gradient(180deg, #6b1f66 0%, #a238ac 58%, #e160e6 100%);
}
.hero .kicker, .section-kicker {
    margin: 0 0 8px;
    font-size: .76rem;
    font-weight: 850;
    letter-spacing: .11em;
    text-transform: uppercase;
}
.hero .kicker { color: #e3cbe5; }
.hero h2 { margin: 0; max-width: 930px; font-size: clamp(2rem, 4.7vw, 3.6rem); line-height: 1.06; letter-spacing: -.04em; }
.hero .question {
    max-width: 910px;
    margin: 18px 0 0;
    color: #f0e4f1;
    font-size: 1.06rem;
    line-height: 1.65;
}
.hero .question strong { color: white; }
.content { padding: 30px 0 70px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.overview-card { padding: 24px 26px; margin-bottom: 20px; }
.section-kicker { color: var(--teal); }
.card h3, .card h2 { margin-top: 0; letter-spacing: -.02em; }
.method-note {
    margin: 13px 0 0;
    padding: 12px 14px;
    color: #6d5268;
    background: var(--teal-soft);
    border-radius: 11px;
    font-size: .87rem;
    line-height: 1.55;
}
.status { min-height: 24px; color: var(--muted); font-size: .9rem; }
.status.error { color: #8b3333; }

.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 15px;
    margin: 20px 0;
}
.metric-card {
    min-width: 0;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 15px;
    box-shadow: 0 8px 24px rgba(71, 22, 67, 0.05);
}
.metric-card span { display: block; color: var(--muted); font-size: .82rem; font-weight: 750; }
.metric-card strong { display: block; margin: 7px 0 3px; font-size: clamp(1.45rem, 3vw, 2rem); letter-spacing: -.035em; }
.metric-card small { color: var(--muted); }

.chart-card { padding: 24px; margin-top: 20px; }
.chart-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 18px; }
.chart-heading p { margin: 4px 0 0; color: var(--muted); line-height: 1.5; }

/* RQ1 lollipop */
.lollipop-chart { display: grid; gap: 12px; }
.lollipop-row { display: grid; grid-template-columns: minmax(150px, 230px) 1fr 86px; gap: 14px; align-items: center; }
.lollipop-label { font-weight: 700; font-size: .9rem; }
.lollipop-track { position: relative; height: 28px; background: #f3edf4; border-radius: 999px; overflow: visible; }
.lollipop-zero { position: absolute; left: 50%; top: -4px; bottom: -4px; width: 1px; background: #8fa0a7; }
.lollipop-fill { position: absolute; top: 10px; height: 8px; border-radius: 999px; }
.lollipop-dot { position: absolute; top: 50%; width: 15px; height: 15px; margin: -7.5px 0 0 -7.5px; border-radius: 50%; border: 2px solid white; box-shadow: 0 2px 5px rgba(0,0,0,.18); }
.positive-fill, .positive-dot { background: var(--pink); }
.negative-fill, .negative-dot { background: var(--blue); }
.value-positive { color: var(--positive); }
.value-negative { color: var(--negative); }
.lollipop-value { text-align: right; font-weight: 850; font-variant-numeric: tabular-nums; }

/* RQ2 dumbbells */
.dumbbell-list { display: grid; gap: 15px; }
.dumbbell-row { display: grid; grid-template-columns: minmax(160px, 230px) 1fr 150px; gap: 14px; align-items: center; }
.dumbbell-label strong { display: block; font-size: .9rem; }
.dumbbell-label small { color: var(--muted); }
.dumbbell-track { position: relative; height: 34px; background: #f5f0f5; border-radius: 10px; }
.dumbbell-zero { position:absolute; left:50%; top:0; bottom:0; width:1px; background:#a6b4b9; }
.dumbbell-line { position:absolute; top:15px; height:4px; border-radius:999px; background:#b8c5ca; }
.dumbbell-dot { position:absolute; top:9px; width:16px; height:16px; margin-left:-8px; border-radius:50%; border:2px solid white; box-shadow:0 2px 5px rgba(0,0,0,.15); }
.dot-brand { background: var(--purple); }
.dot-store { background: var(--blue); }
.dumbbell-values { text-align:right; font-size:.82rem; line-height:1.5; }
.dumbbell-values .brand { color:var(--purple); font-weight:800; }
.dumbbell-values .store { color:var(--blue); font-weight:800; }
.legend-row { display:flex; flex-wrap:wrap; gap:14px; color:var(--muted); font-size:.84rem; }
.legend-item { display:inline-flex; align-items:center; gap:7px; }
.legend-dot { width:10px; height:10px; border-radius:50%; }

/* Heatmap tables for RQ3/RQ4 */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 700px; }
.data-table th, .data-table td { padding: 12px 13px; border-bottom: 1px solid var(--border); text-align: left; }
.data-table th { color: var(--muted); background: var(--surface-soft); font-size: .8rem; text-transform: uppercase; letter-spacing: .045em; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table td.number { text-align: right; font-variant-numeric: tabular-nums; }
.heat-cell { text-align:center !important; font-weight:850; border-radius:8px; background: var(--heat-bg, #f6f2f6); color: var(--heat-text, var(--text)); }
.na-cell { color:#9aa7ac; text-align:center !important; }

.segment-cards { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; margin-top:18px; }
.segment-card { padding:18px; border:1px solid var(--border); border-radius:14px; background:var(--surface-soft); }
.segment-card strong { display:block; margin-top:7px; font-size:1.55rem; }

/* RQ5 position plot */
.position-list { display:grid; gap:16px; }
.position-row { display:grid; grid-template-columns:minmax(150px,220px) 1fr 115px; gap:16px; align-items:center; }
.position-label strong { display:block; font-size:.9rem; }
.position-label small { color:var(--muted); }
.position-track { position:relative; height:34px; margin:0 16px; }
.position-axis { position:absolute; left:0; right:0; top:16px; height:3px; background:#c6d1d5; border-radius:999px; }
.position-male, .position-female { position:absolute; top:8px; width:18px; height:18px; border-radius:50%; border:2px solid white; box-shadow:0 2px 5px rgba(0,0,0,.15); }
.position-male { left:0; margin-left:-9px; background:var(--blue); }
.position-female { left:100%; margin-left:-9px; background:var(--pink); }
.position-neutral { position:absolute; top:5px; width:24px; height:24px; margin-left:-12px; border-radius:7px; transform:rotate(45deg); background:var(--teal); border:2px solid white; box-shadow:0 2px 6px rgba(0,0,0,.18); }
.position-mid { position:absolute; left:50%; top:9px; height:16px; width:1px; border-left:1px dashed #86979e; }
.position-result { text-align:right; font-weight:800; font-size:.87rem; }

/* Custom analysis form */
.analysis-form-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:18px; }
.form-field { display:grid; gap:7px; }
.form-field label { font-weight:750; font-size:.9rem; }
.form-field select, .form-field input { width:100%; min-height:48px; padding:0 13px; border:1px solid var(--border); border-radius:10px; background:var(--surface-soft); color:var(--text); }
.form-field select:focus, .form-field input:focus { outline:none; border-color:var(--teal); box-shadow:0 0 0 4px rgba(105, 36, 82, 0.12); }
.form-field input[readonly] { color:var(--muted); background:#edf1f2; }
.range-preview { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:13px; margin-top:20px; }
.range-card { padding:15px; text-align:center; background:var(--surface-soft); border:1px solid var(--border); border-radius:13px; }
.range-card strong { display:block; margin-bottom:4px; }
.analysis-button { width:100%; margin-top:20px; padding:14px; border:0; border-radius:11px; color:white; background: #e160e6; font-weight:800; cursor:pointer; }
.analysis-button:disabled { opacity:.55; cursor:wait; }
.error-box { display:none; margin-top:16px; padding:13px; border-radius:10px; color:#8b3333; background:#f9e8e8; }
#analysis-results { display:none; }
.pink-tax-value { display:block; margin:7px 0; font-size:1.6rem; font-weight:850; }
.positive { color:var(--positive); }
.negative { color:var(--negative); }
.neutral { color:var(--neutral); }
.tax-chart { display:grid; gap:14px; margin-top:18px; }
.tax-row { display:grid; grid-template-columns:95px 1fr 75px; gap:12px; align-items:center; }
.tax-track { height:24px; background:#edf2f4; border-radius:999px; overflow:hidden; }
.tax-bar { height:100%; min-width:3px; background:var(--pink); border-radius:999px; }
.tax-bar.negative-bar { background:var(--blue); }
.tax-number { text-align:right; font-weight:800; }
.price-comparison { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; margin-top:18px; }
.price-chart-card { padding:16px; background:var(--surface-soft); border:1px solid var(--border); border-radius:13px; }
.gender-bar-row { display:grid; grid-template-columns:60px 1fr 72px; gap:8px; align-items:center; margin:8px 0; }
.gender-track { height:17px; background:#e5ebed; border-radius:999px; overflow:hidden; }
.gender-fill { height:100%; border-radius:999px; }
.gender-fill.female { background:var(--pink); }
.gender-fill.male { background:var(--blue); }
.result-table { width:100%; border-collapse:collapse; margin-top:18px; }
.result-table th,.result-table td { padding:10px; border-bottom:1px solid var(--border); text-align:center; }
.result-table th { background:var(--surface-soft); color:var(--muted); font-size:.8rem; }

.empty-state { padding:32px; text-align:center; color:var(--muted); background:var(--surface-soft); border-radius:14px; }
.footer-note { margin-top:24px; color:var(--muted); font-size:.8rem; line-height:1.55; }

@media (max-width: 980px) {
    :root { --sidebar: 218px; }
    .summary-grid { grid-template-columns: 1fr 1fr; }
    .lollipop-row, .dumbbell-row, .position-row { grid-template-columns: 150px 1fr 100px; }
}

@media (max-width: 760px) {
    :root { --sidebar: 184px; }
    .sidebar { padding:16px 12px; }
    .sidebar-brand { padding:2px 7px 14px; }
    .sidebar-brand p { display:none; }
    .sidebar-brand h1 { font-size:1.05rem; }
    .sidebar-nav a { grid-template-columns:26px 1fr; padding:9px 8px; font-size:.82rem; gap:6px; }
    .nav-number { width:22px; height:22px; border-radius:7px; }
    .sidebar-note { font-size:.7rem; margin-left:7px; margin-right:7px; }
    .page-shell { width:min(100% - 28px,1180px); }
    .hero { padding:38px 0 30px; }
    .content { padding-top:18px; }
    .summary-grid, .segment-cards, .analysis-form-grid, .range-preview, .price-comparison { grid-template-columns:1fr; }
    .lollipop-row, .dumbbell-row, .position-row { grid-template-columns:1fr; gap:7px; }
    .lollipop-value, .dumbbell-values, .position-result { text-align:left; }
    .chart-card, .overview-card { padding:18px; }
}

@media (max-width: 560px) {
    body { display:block; }
    .sidebar {
        position: sticky;
        top: 0;
        width: 100%;
        height: auto;
        min-height: 0;
        padding: 10px 12px;
        overflow-x: auto;
        overflow-y: hidden;
        box-shadow: 0 8px 20px rgba(67, 22, 71, 0.16);
    }
    .sidebar-brand, .sidebar-divider, .sidebar-note { display:none; }
    .sidebar-nav {
        display:flex;
        gap:7px;
        min-width:max-content;
    }
    .sidebar-nav a {
        display:inline-flex;
        grid-template-columns:none;
        white-space:nowrap;
        padding:8px 10px;
    }
    .app-main { min-width:0; }
    .hero { padding-top:32px; }
}

/* RQ3 interactive custom ranges */
.custom-analysis-card { scroll-margin-top: 22px; }
.form-help { color: var(--muted); font-size: .78rem; line-height: 1.45; }
.custom-results { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--border); }
.custom-results[hidden] { display: none !important; }
.result-heading p { color: var(--muted); line-height: 1.55; }
