/* Driver Analytics - shared UI styles for the Log and Stats pages. */
:root {
    --brand: #2C3E50;
    --accent: #3498DB;
    --accent-strong: #1f6fb2;
    --page: #F4F6F8;
    --surface: #ffffff;
    --ink: #1F2D3A;
    --ink-2: #5F6B76;
    --ink-3: #8A949C;
    --line: #E5E8EB;
    --field: #F8FAFB;
    --good: #006c10;
    --bad: #c0392b;
    --good-bg: #E8F5EA;
    --bad-bg: #FBEAEA;
    /* Chart colours (validated colour-blind safe per chart) */
    --series-income: #257de0;
    --series-expense: #f47230;
    --series-loss: #ec4647;
    --grid: #E7E7E7;
    --baseline: #C2C2C2;
    --radius: 14px;
}

* { box-sizing: border-box; }

body.ui {
    margin: 0;
    background: var(--page);
    color: var(--ink);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
}

.page {
    max-width: 800px;
    margin: 0 auto;
    padding: 4px 16px 16px;
}

/* ---------- Page header ---------- */
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin: 8px 0 16px;
}
.page-head h1 {
    margin: 0;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--brand);
}
.page-sub {
    margin: 4px 0 0;
    color: var(--ink-2);
    font-size: 14px;
}
.text-link {
    color: var(--accent-strong);
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    white-space: nowrap;
}

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.04);
    padding: 18px 16px;
    margin-bottom: 14px;
}
.card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.card-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
}
.card-meta {
    font-size: 14px;
    white-space: nowrap;
    color: var(--ink-2);
    font-variant-numeric: tabular-nums;
}
.card-meta strong { color: var(--ink); }

/* ---------- Form fields ---------- */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.span-2 { grid-column: 1 / -1; }

.field label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-2);
}
.field .hint { font-weight: 400; color: var(--ink-3); }

.field input,
.field textarea {
    width: 100%;
    min-height: 46px;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--field);
    color: var(--ink);
    font: inherit;
    font-size: 16px; /* 16px stops iOS zooming into the field */
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.field textarea { min-height: 80px; resize: vertical; }
/* iPhone Safari centres date text and lets the field grow past its box: reset both */
.field input[type="date"] {
    -webkit-appearance: none;
    appearance: none;
    display: block;
    min-width: 0;
    max-width: 100%;
    text-align: left;
    line-height: 22px;
}
.field input[type="date"]::-webkit-date-and-time-value { text-align: left; margin: 0; }
.field input[type="date"]::-webkit-datetime-edit { padding: 0; }
/* Hide desktop spinner arrows on number fields (phones never show them) */
.field input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.field input[type="number"]::-webkit-inner-spin-button,
.field input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.field input:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.18);
}
.field input::placeholder,
.field textarea::placeholder { color: var(--ink-3); }

.money { position: relative; }
.money span {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ink-3);
    font-weight: 600;
    pointer-events: none;
}
.money input { padding-left: 30px; font-variant-numeric: tabular-nums; }

.unit { position: relative; }
.unit span {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ink-3);
    font-size: 14px;
    pointer-events: none;
}
.unit input { padding-right: 42px; }

/* ---------- Alerts ---------- */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 14px;
    font-size: 15px;
    font-weight: 500;
}
.alert svg { flex-shrink: 0; width: 20px; height: 20px; }
.alert a { margin-left: auto; color: inherit; font-weight: 700; white-space: nowrap; }
.alert-success { background: var(--good-bg); color: var(--good); }
.alert-error { background: var(--bad-bg); color: var(--bad); }
.alert-info { background: #EAF3FB; color: var(--accent-strong); }

/* ---------- Sticky save bar (Log page) ---------- */
.save-bar {
    position: sticky;
    bottom: calc(var(--tabbar-space, 0px) + 8px);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 4px;
    padding: 10px 10px 10px 16px;
    background: var(--brand);
    color: #fff;
    border-radius: var(--radius);
    box-shadow: 0 6px 20px rgba(16, 24, 40, 0.18);
}
.save-bar .sb-label { font-size: 12px; opacity: 0.75; display: block; }
.save-bar .sb-value {
    font-size: 20px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.save-bar .sb-sub { font-size: 12px; opacity: 0.75; margin-left: 6px; }
.btn-primary {
    flex-shrink: 0;
    min-height: 46px;
    padding: 0 22px;
    border: none;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}
.btn-primary:active { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.6; }
.btn-secondary {
    display: inline-block;
    padding: 10px 18px;
    border-radius: 10px;
    background: #EAF3FB;
    color: var(--accent-strong);
    font-weight: 700;
    font-size: 15px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

/* ---------- Period filter (Stats page) ---------- */
.filters {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}
.segmented {
    display: inline-flex;
    padding: 3px;
    background: #E6EAEE;
    border-radius: 10px;
}
.segmented button {
    min-height: 36px;
    padding: 0 16px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--ink-2);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.segmented button[aria-pressed="true"] {
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.12);
}
.stepper {
    display: flex;
    flex: 1;
    justify-content: flex-end;
    align-items: center;
    gap: 2px;
    min-width: 0;
}
.stepper button {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--ink);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}
.stepper button:disabled { color: #C9CFD4; cursor: default; }
.stepper button:not(:disabled):active { background: #E6EAEE; }
.stepper .period-label {
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

/* ---------- Hero + stat tiles ---------- */
.hero { padding: 20px 18px; }
.hero-label { font-size: 14px; color: var(--ink-2); font-weight: 600; }
.hero-value {
    font-size: 48px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin: 4px 0 8px;
}
.hero-value.negative { color: var(--bad); }
.delta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    font-weight: 600;
}
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--ink-2); font-weight: 500; }

.tiles {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}
@media (min-width: 600px) {
    .tiles { grid-template-columns: repeat(3, 1fr); }
}
.tile {
    background: var(--surface);
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}
.tile-label { font-size: 13px; color: var(--ink-2); }
.tile-value { font-size: 20px; font-weight: 700; margin-top: 2px; }

/* ---------- Column chart (daily profit) ---------- */
.colchart { position: relative; }
.colchart-plot {
    position: relative;
    height: 170px;
    margin-left: 44px;
}
.colchart-grid {
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--grid);
}
.colchart-grid.zero { background: var(--baseline); }
.colchart-tick {
    position: absolute;
    left: -44px;
    width: 38px;
    text-align: right;
    font-size: 11px;
    color: var(--ink-2);
    transform: translateY(-50%);
    font-variant-numeric: tabular-nums;
}
.colchart-cols {
    position: absolute;
    inset: 0;
    display: flex;
}
.col {
    position: relative;
    flex: 1;
    min-width: 0;
    height: 100%;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    font: inherit;
}
.col:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }
.col:hover .bar, .col:focus .bar, .col.active .bar { filter: brightness(1.12); }
.col.active { background: rgba(37, 125, 224, 0.06); border-radius: 6px; }
.bar {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: min(24px, 62%);
    background: var(--series-income);
}
.bar.pos { border-radius: 4px 4px 0 0; }
.bar.neg { border-radius: 0 0 4px 4px; background: var(--series-loss); }
.bar-label {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
    pointer-events: none;
}
.colchart-x {
    display: flex;
    margin-left: 44px;
    margin-top: 6px;
}
.colchart-x span {
    flex: 1;
    min-width: 0;
    text-align: center;
    font-size: 11px;
    color: var(--ink-2);
    white-space: nowrap;
}
.chart-tip {
    position: absolute;
    z-index: 5;
    min-width: 150px;
    padding: 10px 12px;
    background: var(--surface);
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(16, 24, 40, 0.16);
    font-size: 13px;
    pointer-events: none;
}
.chart-tip[hidden] { display: none; }
.chart-tip .tip-title { color: var(--ink-2); margin-bottom: 4px; }
.chart-tip .tip-row { display: flex; align-items: center; gap: 8px; }
.chart-tip .tip-row strong { font-variant-numeric: tabular-nums; }
.chart-tip .tip-row span { color: var(--ink-2); }
.chart-tip .key { width: 12px; height: 2px; border-radius: 1px; flex-shrink: 0; }
.legend {
    display: flex;
    gap: 14px;
    font-size: 12px;
    color: var(--ink-2);
}
.legend i {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 5px;
    vertical-align: -1px;
}

/* ---------- Ranked bars (part-to-whole) ---------- */
.ranked { list-style: none; margin: 0; padding: 0; }
.ranked li {
    display: grid;
    grid-template-columns: 92px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    font-size: 14px;
}
.ranked .r-name { color: var(--ink); }
.ranked .r-track { height: 12px; }
.ranked .r-bar {
    height: 12px;
    min-width: 2px;
    border-radius: 0 4px 4px 0;
}
.ranked .r-value {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    white-space: nowrap;
}
.ranked .r-value small { color: var(--ink-2); font-weight: 500; margin-left: 4px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.data-table th {
    text-align: right;
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-2);
    padding: 8px 8px;
    border-bottom: 1px solid var(--line);
}
.data-table td {
    text-align: right;
    padding: 10px 8px;
    border-bottom: 1px solid var(--line);
}
.data-table th:first-child, .data-table td:first-child { text-align: left; padding-left: 0; }
.data-table th:last-child, .data-table td:last-child { padding-right: 0; }
@media (max-width: 420px) {
    .data-table { font-size: 13px; }
    .data-table th, .data-table td { padding-left: 5px; padding-right: 5px; }
}
.data-table tfoot td { font-weight: 700; border-bottom: none; }
.data-table .neg { color: var(--bad); }

/* ---------- Empty / loading states ---------- */
.empty {
    text-align: center;
    padding: 28px 12px;
    color: var(--ink-2);
}
.empty h3 { margin: 0 0 6px; color: var(--ink); font-size: 17px; }
.empty p { margin: 0 0 16px; font-size: 14px; }
.empty .actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.muted { color: var(--ink-2); font-size: 14px; }
.is-loading { opacity: 0.55; transition: opacity 0.2s; }

@media (max-width: 400px) {
    .filters { flex-direction: column; align-items: stretch; }
    .segmented button { flex: 1; }
    .stepper { justify-content: space-between; }
}

@media (max-width: 360px) {
    .grid-2 { grid-template-columns: 1fr; }
    .hero-value { font-size: 40px; }
    .ranked li { grid-template-columns: 78px 1fr auto; }
    .segmented button { padding: 0 12px; }
}

/* =====================================================================
   Auth pages (login / register)
   ===================================================================== */
body.auth {
    min-height: 100vh;
    background: var(--page);
}
.auth-hero {
    background: linear-gradient(160deg, #2C3E50 0%, #22313f 60%, #1b2833 100%);
    color: #fff;
    padding: 44px 24px 84px;
    text-align: center;
}
.auth-hero .brand-tile {
    width: 76px;
    height: 76px;
    margin: 0 auto 14px;
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.auth-hero .brand-tile img { width: 100%; height: 100%; }
.auth-hero h1 {
    margin: 0;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.02em;
}
.auth-hero h1 span { color: #5DADE2; }
.auth-hero p { margin: 6px 0 0; color: rgba(255, 255, 255, 0.72); font-size: 15px; }
.auth-card {
    position: relative;
    max-width: 420px;
    margin: -56px auto 0;
    padding: 24px 20px;
}
.auth-card h2 { margin: 0 0 4px; font-size: 21px; }
.auth-card .page-sub { margin: 0 0 18px; }
.auth-card .field { margin-bottom: 14px; }
.field-error { margin-top: 6px; font-size: 13px; color: var(--bad); font-weight: 500; }
.field input.invalid { border-color: var(--bad); background: #fff; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 64px; }
.pw-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: var(--accent-strong);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    padding: 8px;
    cursor: pointer;
}
.btn-block { width: 100%; margin-top: 6px; }
.auth-switch { text-align: center; margin: 18px 0 0; font-size: 15px; color: var(--ink-2); }
.auth-switch a { color: var(--accent-strong); font-weight: 700; text-decoration: none; }
.auth-foot { text-align: center; color: var(--ink-3); font-size: 12px; padding: 24px 16px 32px; }
.perks { list-style: none; margin: 18px auto 0; padding: 0; display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; font-size: 13px; color: rgba(255,255,255,0.8); }
.perks li::before { content: '✓ '; color: #5DADE2; font-weight: 700; }

/* =====================================================================
   Shift list (All shifts / history)
   ===================================================================== */
.month-group { margin-bottom: 18px; }
.month-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0 4px 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--ink-2);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.month-head span { text-transform: none; letter-spacing: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.shift {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
    margin-bottom: 8px;
    overflow: hidden;
}
.shift summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    cursor: pointer;
}
.shift summary::-webkit-details-marker { display: none; }
.shift-date {
    width: 44px;
    flex-shrink: 0;
    text-align: center;
    border-radius: 10px;
    background: #EEF4FA;
    padding: 5px 0;
    line-height: 1.1;
}
.shift-date b { display: block; font-size: 18px; color: var(--brand); }
.shift-date small { font-size: 11px; color: var(--ink-2); text-transform: uppercase; }
.shift-main { flex: 1; min-width: 0; }
.shift-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shift-sub { font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shift-profit { text-align: right; flex-shrink: 0; }
.shift-profit b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }
.shift-profit b.neg { color: var(--bad); }
.shift-profit small { font-size: 12px; color: var(--ink-2); }
.chev { color: var(--ink-3); transition: transform 0.2s; flex-shrink: 0; }
.shift[open] .chev { transform: rotate(90deg); }
.shift-body { padding: 2px 14px 14px; border-top: 1px solid var(--line); }
.kv-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 20px; }
.kv-cols h4 { margin: 12px 0 4px; font-size: 12px; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.04em; }
.kv { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; padding: 3px 0; }
.kv span { color: var(--ink-2); }
.kv b { font-weight: 600; font-variant-numeric: tabular-nums; }
.shift-note { margin-top: 10px; font-size: 14px; color: var(--ink); background: var(--field); border-radius: 8px; padding: 8px 10px; }

/* =====================================================================
   Community feed
   ===================================================================== */
.composer textarea {
    width: 100%;
    min-height: 84px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--field);
    font: inherit;
    font-size: 16px;
    color: var(--ink);
    resize: vertical;
}
.composer textarea:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(52,152,219,0.18); }
.composer-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.composer-foot .muted { font-size: 13px; }
.post {
    display: flex;
    gap: 12px;
    background: var(--surface);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}
.avatar {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    background: var(--brand);
    text-transform: uppercase;
}
.post-body { min-width: 0; flex: 1; }
.post-meta { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.post-author { font-weight: 700; font-size: 15px; }
.post-you { font-size: 11px; font-weight: 700; color: var(--accent-strong); background: #EAF3FB; padding: 1px 6px; border-radius: 6px; }
.post-time { font-size: 12px; color: var(--ink-3); }
.post-text { margin-top: 4px; font-size: 15px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.section-label { font-size: 13px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.04em; margin: 18px 4px 10px; }

/* =====================================================================
   Leaderboard
   ===================================================================== */
.seg-links { display: flex; padding: 3px; background: #E6EAEE; border-radius: 10px; margin-bottom: 16px; }
.seg-links a {
    flex: 1;
    text-align: center;
    padding: 8px 0;
    border-radius: 8px;
    color: var(--ink-2);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}
.seg-links a.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(16, 24, 40, 0.12); }
.podium {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: end;
    gap: 8px;
    padding: 18px 12px 0;
}
.podium-spot { text-align: center; min-width: 0; }
.podium-spot .avatar { width: 52px; height: 52px; margin: 0 auto 6px; font-size: 20px; position: relative; }
.podium-spot.first .avatar { width: 64px; height: 64px; font-size: 24px; }
.medal {
    position: absolute;
    right: -4px;
    bottom: -4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid #fff;
    font-size: 11px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1F2D3A;
}
.medal.gold { background: #F5C542; }
.medal.silver { background: #C9D1D9; }
.medal.bronze { background: #E0A46E; }
.podium-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.podium-amount { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; margin-bottom: 8px; }
.podium-step { border-radius: 10px 10px 0 0; background: #EEF4FA; color: var(--brand); font-weight: 800; font-size: 18px; display: flex; align-items: flex-start; justify-content: center; padding-top: 8px; }
.podium-spot.first .podium-step { height: 84px; background: #DCEBF8; }
.podium-spot.second .podium-step { height: 60px; }
.podium-spot.third .podium-step { height: 44px; }
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}
.rank-list li:last-child { border-bottom: none; }
.rank-list .pos { width: 24px; text-align: center; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.rank-list .avatar { width: 34px; height: 34px; font-size: 14px; }
.rank-list .who { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-list .amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.rank-list li.me { background: #EAF3FB; margin: 0 -16px; padding-left: 16px; padding-right: 16px; border-radius: 8px; }

/* =====================================================================
   Zazi chat
   ===================================================================== */
body.chat-page { overflow: hidden; }
.chat-wrapper {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--userbar-height, 0px));
    max-width: 800px;
    margin: 0 auto;
}
.chat-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.chat-head .avatar { background: linear-gradient(135deg, #3498DB, #2C3E50); width: 42px; height: 42px; font-size: 18px; }
.chat-head b { display: block; font-size: 16px; }
.chat-head small { color: var(--good); font-size: 12px; font-weight: 600; }
.chat-log {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    -webkit-overflow-scrolling: touch;
}
.bubble {
    max-width: 84%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.bubble.zazi { align-self: flex-start; background: var(--surface); border-bottom-left-radius: 4px; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06); }
.bubble.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.bubble.error { background: var(--bad-bg); color: var(--bad); }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); animation: blink 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.suggestions { display: flex; gap: 8px; overflow-x: auto; padding: 0 16px 10px; -webkit-overflow-scrolling: touch; }
.suggestions button {
    flex-shrink: 0;
    border: 1px solid #CFE3F5;
    background: #fff;
    color: var(--accent-strong);
    border-radius: 18px;
    padding: 8px 14px;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.chat-input {
    display: flex;
    gap: 10px;
    padding: 10px 16px 12px;
    background: var(--surface);
    border-top: 1px solid var(--line);
}
.chat-input input {
    flex: 1;
    min-width: 0;
    min-height: 46px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 23px;
    background: var(--field);
    font: inherit;
    font-size: 16px;
}
.chat-input input:focus { outline: none; border-color: var(--accent); background: #fff; }
.send-btn {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.send-btn:disabled { opacity: 0.5; }
