/* ------------------------------------------------------------------
   Design tokens — change colors and fonts here
   ------------------------------------------------------------------ */
:root {
    --ink: #17202a;
    --ink-soft: #4b5563;
    --ink-faint: #8a94a3;
    --paper: #f6f4ef;
    --surface: #ffffff;
    --line: #e7e3da;

    --play: #0f9d6b;          /* Google Play green */
    --play-soft: rgba(15, 157, 107, 0.12);
    --apple: #2f6bff;         /* App Store blue */
    --apple-soft: rgba(47, 107, 255, 0.12);
    --accent: #f2b33d;

    --radius: 14px;
    --shadow: 0 1px 2px rgba(23, 32, 42, 0.04), 0 8px 24px -12px rgba(23, 32, 42, 0.12);

    --font-display: "Bricolage Grotesque", Georgia, serif;
    --font-body: "Figtree", system-ui, sans-serif;

    --bs-body-font-family: var(--font-body);
    --bs-body-color: var(--ink);
    --bs-body-bg: var(--paper);
    --bs-border-color: var(--line);
}

body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
}

code {
    color: var(--ink);
    background: rgba(23, 32, 42, 0.06);
    padding: 1px 6px;
    border-radius: 5px;
}

/* ---------- Top bar ---------- */
.topbar {
    background: var(--ink);
    color: #fff;
    padding: 14px 0;
}
.eyebrow {
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
}
.brand-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 18px;
    line-height: 1.2;
}
.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
    padding: 8px;
}
.brand-mark span {
    width: 7px;
    border-radius: 3px;
    background: var(--play);
    height: 60%;
}
.brand-mark span + span {
    background: var(--apple);
    height: 100%;
}

/* ---------- Buttons ---------- */
.btn-ghost {
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: transparent;
    border-radius: 999px;
    padding: 6px 14px;
}
.btn-ghost:hover,
.btn-ghost:focus {
    color: var(--ink);
    background: #fff;
    border-color: #fff;
}
.panel .btn-ghost {
    color: var(--ink);
    border-color: var(--line);
}
.panel .btn-ghost:hover {
    background: var(--ink);
    color: #fff;
    border-color: var(--ink);
}
.btn-ink {
    background: var(--ink);
    color: #fff;
    border: none;
    border-radius: 10px;
}
.btn-ink:hover,
.btn-ink:focus {
    background: #000;
    color: #fff;
}

/* ---------- Headings ---------- */
.page-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(28px, 4vw, 40px);
    letter-spacing: -0.02em;
}
.text-muted-ink { color: var(--ink-soft); }
.panel-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 18px;
}

/* ---------- Segmented control ---------- */
.date-panel {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}
.date-fields {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px 14px;
    box-shadow: var(--shadow);
}
.date-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0;
}
.date-field span {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-faint);
}
.date-field input {
    border: 0;
    padding: 2px 0;
    font-weight: 600;
    font-size: 16px;
    color: var(--ink);
    background: transparent;
    box-shadow: none !important;
    cursor: pointer;
    min-width: 150px;
}
.date-field input::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.6;
}
.date-sep {
    color: var(--ink-faint);
    padding-bottom: 4px;
}
.quick-picks {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}
.quick-picks button {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-soft);
    font-weight: 600;
    font-size: 13px;
    padding: 5px 12px;
    border-radius: 999px;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.quick-picks button:hover {
    border-color: var(--ink-faint);
    color: var(--ink);
}
.quick-picks button.active {
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
}
@media (max-width: 991.98px) {
    .date-panel, .quick-picks { align-items: flex-start; justify-content: flex-start; }
}
@media (max-width: 575.98px) {
    .date-fields { width: 100%; }
    .date-field { flex: 1; }
    .date-field input { min-width: 0; width: 100%; }
}

/* ---------- Stat cards ---------- */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px 22px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    height: 100%;
}
.stat-card::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
}
.stat-play::after { background: var(--play); }
.stat-apple::after { background: var(--apple); }
.stat-total {
    background: var(--ink);
    color: #fff;
    border-color: var(--ink);
}
.stat-total::after { background: var(--accent); }
.stat-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-soft);
    display: flex;
    align-items: center;
    gap: 8px;
}
.stat-total .stat-label { color: rgba(255, 255, 255, 0.65); }
.stat-label .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.stat-play .dot { background: var(--play); }
.stat-apple .dot { background: var(--apple); }
.stat-value {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 38px;
    letter-spacing: -0.02em;
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
}
.stat-sub {
    font-size: 13px;
    color: var(--ink-faint);
}
.stat-total .stat-sub { color: rgba(255, 255, 255, 0.55); }

/* ---------- Panels ---------- */
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
}
.chart-wrap {
    position: relative;
    height: 360px;
}
.chart-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--ink-soft);
    background: rgba(255, 255, 255, 0.85);
    z-index: 2;
    font-size: 14px;
}
.chart-loading.d-none { display: none; }

.legend { display: flex; gap: 16px; }
.legend-item {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-soft);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.legend-item::before {
    content: "";
    width: 14px;
    height: 3px;
    border-radius: 2px;
}
.legend-play::before { background: var(--play); }
.legend-apple::before { background: var(--apple); }

/* ---------- Table ---------- */
.table-scroll { max-height: 420px; overflow-y: auto; }
.data-table { --bs-table-bg: transparent; }
.data-table thead th {
    position: sticky;
    top: 0;
    background: var(--surface);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-faint);
    font-weight: 600;
    border-bottom: 1px solid var(--line);
}
.data-table td {
    font-variant-numeric: tabular-nums;
    border-color: var(--line);
    padding-top: 10px;
    padding-bottom: 10px;
}
.data-table td.missing { color: var(--ink-faint); }
.data-table tbody tr:hover td { background: var(--paper); }

/* ---------- Notices ---------- */
.notice {
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
    border: 1px solid;
}
.notice-demo {
    background: #fff8e8;
    border-color: #f3dca6;
    color: #6b4e0f;
}
.notice-error {
    background: #fdeeee;
    border-color: #f2c4c4;
    color: #8a1f1f;
}
.notice-error ul { margin: 6px 0 0; padding-left: 18px; }

.footnote {
    font-size: 13px;
    color: var(--ink-faint);
}

/* ---------- Login ---------- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(600px 300px at 15% 10%, var(--play-soft), transparent 70%),
        radial-gradient(600px 300px at 85% 90%, var(--apple-soft), transparent 70%),
        var(--paper);
}
.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 32px;
    box-shadow: var(--shadow);
}
.login-card h1 { font-family: var(--font-display); font-weight: 700; }
.login-card .brand-mark { background: var(--ink); }

@media (max-width: 767px) {
    .chart-wrap { height: 280px; }
    .stat-value { font-size: 32px; }
}
