/* ═══════════════════════════════════════════════════
   PDGA Ratings — Shared Design System
   ═══════════════════════════════════════════════════ */

/* Fonts loaded via <link> in layout.ejs for parallel loading */

:root {
    /* ── New design tokens ─────────────────────────── */
    --bg:        oklch(0.985 0.005 250);
    --paper:     #ffffff;
    --paper-2:   oklch(0.975 0.006 250);
    --ink:       oklch(0.22 0.02 260);
    --ink-2:     oklch(0.42 0.015 260);
    --ink-3:     oklch(0.60 0.012 260);
    --line:      oklch(0.93 0.008 260);
    --line-2:    oklch(0.88 0.010 260);
    --hover:     oklch(0.965 0.012 260);

    --accent:      #4f5fd8;
    --accent-soft: color-mix(in oklab, var(--accent) 12%, white);
    --accent-text: color-mix(in oklab, var(--accent) 92%, black);

    --up:        oklch(0.55 0.15 150);
    --up-soft:   oklch(0.94 0.04 150);
    --down:      oklch(0.58 0.18 25);
    --down-soft: oklch(0.95 0.04 25);

    --radius:    14px;
    --radius-sm: 10px;

    --shadow-card: 0 1px 0 oklch(0.92 0.01 260), 0 1px 2px oklch(0.85 0.01 260 / 0.30);
    --shadow-pop:  0 1px 2px oklch(0.80 0.01 260 / 0.18), 0 14px 40px -10px oklch(0.50 0.02 260 / 0.18);

    --font-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;

    /* ── Rating tier tokens ───────────────────────── */
    --rating-tier-high:   oklch(0.55 0.15 150);
    --rating-tier-mid:    oklch(0.55 0.12 100);
    --rating-tier-low:    oklch(0.55 0.10 50);

    /* legacy token aliases — remove as components migrate */
    --surface-0: var(--bg);
    --surface-1: var(--paper);
    --surface-2: var(--paper-2);
    --surface-3: var(--paper-2);

    --text-primary:   var(--ink);
    --text-secondary: var(--ink-2);
    --text-muted:     var(--ink-3);
    --text-inverse:   var(--paper);

    --navy-900: var(--ink);
    --navy-800: var(--ink);
    --navy-700: var(--ink-2);
    --navy-600: var(--ink-2);

    --border:       var(--line);
    --border-light: var(--line-2);

    --green:        var(--up);
    --green-subtle: var(--up-soft);
    --red:          var(--down);
    --red-subtle:   var(--down-soft);

    --accent-hover:   color-mix(in oklab, var(--accent) 85%, black);
    --accent-subtle:  var(--accent-soft);
    --accent-border:  color-mix(in oklab, var(--accent) 40%, transparent);

    --radius-md: var(--radius-sm);
    --radius-lg: var(--radius);
    --radius-xl: 20px;

    --shadow-sm:      0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md:      var(--shadow-card);
    --shadow-lg:      var(--shadow-pop);
    --shadow-overlay: 0 20px 60px rgba(15, 23, 42, 0.15), 0 4px 12px rgba(15, 23, 42, 0.08);

    --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Topbar dimensions (used by sticky thead) */
    --topbar-height: 64px;
}

/* ── Reset & Base ─────────────────────────────── */

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.45;
    font-feature-settings: "ss01", "cv11";
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.mono {
    font-family: var(--font-mono);
    font-feature-settings: "tnum", "zero";
}

/* ── Topbar ───────────────────────────────────── */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: color-mix(in oklab, var(--paper) 92%, transparent);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}

.topbar__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 32px;
    max-width: 1400px;
    margin: 0 auto;
}

.topbar__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.topbar__brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), color-mix(in oklab, var(--accent) 70%, black));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}

.topbar__brand-mark svg {
    width: 24px;
    height: 24px;
}

.topbar__brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.topbar__brand-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink);
}

.topbar__brand-sub {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-3);
}

.topbar__nav {
    display: flex;
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 4px;
    gap: 2px;
}

.topbar__nav a {
    display: inline-flex;
    align-items: center;
    height: 28px;
    padding: 0 14px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-2);
    text-decoration: none;
    transition: color 120ms ease, background 120ms ease;
}

.topbar__nav a:hover {
    color: var(--ink);
}

.topbar__nav a.active {
    background: var(--paper);
    color: var(--ink);
    box-shadow: var(--shadow-card);
}

.topbar__meta {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar__meta-item {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.topbar__meta-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-3);
}

.topbar__meta-value {
    font-family: var(--font-mono);
    font-feature-settings: "tnum", "zero";
    font-size: 12px;
    font-weight: 500;
    color: var(--ink);
}

.topbar__divider {
    width: 1px;
    height: 22px;
    background: var(--line);
}

.topbar__refresh {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--paper);
    color: var(--ink);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease;
}

.topbar__refresh:hover:not(:disabled) {
    background: var(--hover);
    border-color: color-mix(in oklab, var(--line) 60%, var(--ink-3));
}

.topbar__refresh:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.topbar__refresh-spinner {
    display: none;
    width: 12px;
    height: 12px;
    border: 2px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: topbar-spin 0.7s linear infinite;
}

.topbar__refresh.htmx-request .topbar__refresh-spinner {
    display: inline-block;
}

.topbar__refresh.htmx-request .topbar__refresh-icon {
    display: none;
}

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

@media (max-width: 880px) {
    :root { --topbar-height: 56px; }
    .topbar__inner { padding: 10px 16px; gap: 10px; }
    .topbar__meta-item, .topbar__divider { display: none; }
    .topbar__refresh-label { display: none; }
    .topbar__nav a { padding: 0 10px; font-size: 12px; }
    .topbar__brand-sub { display: none; }
}

/* ── Container ────────────────────────────────── */

.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 28px 32px 60px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.page-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    margin: 0;
}

/* ── Tables ───────────────────────────────────── */

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

th {
    padding: 0 16px;
    height: 48px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-3);
    background: var(--paper-2);
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

td {
    padding: 0 16px;
    height: 64px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

/* Column widths */
.col-rank    { width: 56px; text-align: center; }
.col-player  { min-width: 200px; }
.col-rating  { min-width: 220px; }
.col-predicted { min-width: 180px; }
.col-actions { width: 72px; }

/* Rank number */
.rank-num {
    font-size: 13px;
    color: var(--ink-3);
    font-weight: 500;
}

/* Player name cell */
.cell-name {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.player-name a {
    font-weight: 600;
    font-size: 14px;
    letter-spacing: -0.005em;
    color: var(--ink);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

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

/* The name links to pdga.com (PDGA attribution, #54); the icon next to it opens the dashboard. */
.player-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.player-name-row .player-name,
.player-name-row .m-player-name {
    min-width: 0;
}

.dashboard-link {
    flex-shrink: 0;
    font-size: 11px;
    color: var(--ink-3);
    text-decoration: none;
}

.dashboard-link:hover {
    color: var(--accent);
}

.pdga-num {
    font-size: 11px;
    color: var(--ink-3);
}

/* Rating cell stack */
.cell-rating {
    vertical-align: middle;
}

.rating-stack {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rating-big {
    font-size: 20px;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.02em;
    line-height: 1;
}

.rating-pending {
    font-size: 12px;
    font-style: italic;
    color: var(--ink-3);
}

/* Predicted cell stack */
.pred-stack {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pred-num {
    font-size: 20px;
    font-weight: 600;
    color: var(--ink-2);
    letter-spacing: -0.02em;
    line-height: 1;
}

/* Actions cell */
.cell-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

/* Chevron rotation when row open */
tr.row-open .icon-chev i {
    transform: rotate(180deg);
}

.icon-chev i {
    transition: transform 180ms ease;
}

.expandable-row {
    cursor: pointer;
    transition: background 120ms ease;
    outline: none;
    position: relative;
}

.expandable-row:hover {
    background: var(--hover);
}

.expanded-content {
    display: none;
}

@keyframes expandIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.expanded-content.is-open {
    animation: expandIn 0.2s ease;
}

.expanded-content td {
    padding: 0;
    background: color-mix(in oklab, var(--accent) 4%, var(--paper-2));
    border-bottom: 1px solid var(--line);
}

.expanded-cell {
    padding: 22px 28px 28px !important;
}

tr.row-open {
    box-shadow: inset 3px 0 0 var(--accent);
}

/* ── Expanded Row Detail Grid ─────────────────── */

.player-detail {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 28px;
    align-items: start;
}

@media (max-width: 880px) {
    .player-detail {
        grid-template-columns: 1fr;
    }
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    margin: 0;
    padding: 0;
    list-style: none;
}

.detail-grid > div {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--line);
}

.detail-grid > div:last-child {
    border-bottom: none;
}

.detail-grid dt {
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 400;
    flex-shrink: 0;
}

.detail-grid dd {
    color: var(--ink);
    font-size: 13px;
    font-family: var(--font-mono);
    font-feature-settings: "tnum", "zero";
    margin: 0;
    text-align: right;
}

.player-chart {
    width: 100%;
    max-width: 880px;
}

.link-btn {
    background: none;
    border: none;
    padding: 0;
    font-family: var(--font-sans);
    font-size: 13px;
    cursor: pointer;
    color: var(--accent);
}

.link-btn:disabled {
    color: var(--ink-3);
    cursor: default;
}

/* ── Links ────────────────────────────────────── */

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

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

/* ── Buttons ──────────────────────────────────── */

.btn {
    padding: 8px 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-sans);
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1.4;
}

.btn:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow-sm);
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ── Search Bar ───────────────────────────── */

.search-bar {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    box-shadow: var(--shadow-card);
}

.search-bar-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.search-bar-kicker {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.01em;
    color: var(--ink);
}

.search-bar-hint {
    font-size: 12px;
    color: var(--ink-3);
}

.search-bar-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--paper-2);
    border: 1px solid var(--line-2);
    border-radius: 10px;
    height: 40px;
    width: 220px;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.input-wrap:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px color-mix(in oklab, var(--accent) 14%, transparent);
}

.input-prefix {
    padding: 0 0 0 14px;
    color: var(--ink-3);
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 500;
    flex-shrink: 0;
}

.input-wrap input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    padding: 0 14px 0 6px;
    height: 100%;
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--ink);
    font-feature-settings: "tnum";
}

.input-wrap input::placeholder {
    color: var(--ink-3);
    opacity: 0.7;
}

/* htmx sets .htmx-request on #search-input-wrap (hx-indicator) while a search runs */
.search-bar-spinner {
    display: none;
    width: 12px;
    height: 12px;
    border: 2px solid color-mix(in oklab, currentColor 35%, transparent);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: topbar-spin 0.7s linear infinite;
}

.input-wrap.htmx-request .search-bar-spinner {
    display: inline-block;
}

.input-wrap.htmx-request .search-bar-icon {
    display: none;
}

/* ── Search Results ───────────────────────── */

.search-results {
    margin-top: 12px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.search-results:empty {
    display: none;
}

.search-results-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.search-result {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: baseline;
    gap: 2px 16px;
    min-height: 44px;
    padding: 12px 16px;
    border-top: 1px solid var(--line);
    color: inherit;
    text-decoration: none;
}

.search-results-list li:first-child .search-result {
    border-top: none;
}

.search-results-list li.is-active .search-result,
.search-result:hover,
.search-result:focus-visible {
    background: var(--hover);
}

.search-result:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.search-result-name {
    font-weight: 600;
    color: var(--ink);
    overflow-wrap: anywhere;
    min-width: 0;
}

.search-result-number {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--ink-3);
}

.search-result-rating {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-2);
    text-align: right;
}

.search-result-location {
    grid-column: 1 / -1;
    font-size: 12px;
    color: var(--ink-3);
    overflow-wrap: anywhere;
}

.search-results-message {
    margin: 0;
    padding: 14px 16px;
    font-size: 13px;
    color: var(--ink-2);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--accent);
    color: white;
    border: none;
    height: 40px;
    padding: 0 18px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 13px;
    font-family: var(--font-sans);
    cursor: pointer;
    box-shadow: 0 1px 0 color-mix(in oklab, var(--accent) 50%, black), 0 1px 3px color-mix(in oklab, var(--accent) 40%, transparent);
    transition: transform 80ms ease, box-shadow 150ms ease, background 150ms ease;
}

.btn-primary:hover {
    background: color-mix(in oklab, var(--accent) 92%, black);
}

.btn-primary:active {
    transform: translateY(1px);
}

@media (max-width: 880px) {
    .search-bar { flex-direction: column; align-items: stretch; gap: 14px; padding: 16px; }
    .search-bar-controls { flex-shrink: 1; }
    .search-bar .input-wrap { flex: 1; width: auto; min-width: 0; }
    .search-result { column-gap: 10px; padding: 12px; }
}

/* ── Inputs ───────────────────────────────────── */

.input {
    padding: 9px 14px;
    font-size: 14px;
    font-family: var(--font-sans);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    background: var(--surface-1);
    color: var(--text-primary);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.input::placeholder {
    color: var(--text-muted);
}

/* ── Refresh Icons ────────────────────────────── */

.refresh-icon {
    cursor: pointer;
    opacity: 0.4;
    margin-left: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    transition: all var(--transition);
    padding: 4px;
    border-radius: var(--radius-sm);
}

.refresh-icon:hover {
    opacity: 1;
    color: var(--accent);
    background: var(--accent-subtle);
}

.refresh-icon.spinning {
    animation: spin 0.8s linear infinite;
    color: var(--accent);
    opacity: 1;
}

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

/* ── Responsive ───────────────────────────────── */

/* Responsive table/container tweaks handled by mobile.css (≤880px) */

@media (max-width: 880px) {
    .mobile-hide {
        display: none;
    }
}

/* ── Delta Pills ──────────────────────────────── */

.delta-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px 3px 6px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}

.delta-glyph {
    font-size: 9px;
    display: inline-block;
    line-height: 1;
    position: relative;
    top: -0.5px;
}

.delta-num {
    font-family: var(--font-mono);
    font-feature-settings: "tnum", "zero";
    letter-spacing: 0;
}

.delta-pill.up {
    background: var(--up-soft);
    color: var(--up);
}

.delta-pill.down {
    background: var(--down-soft);
    color: var(--down);
}

.delta-pill.flat {
    background: var(--paper-2);
    color: var(--ink-3);
    border: 1px solid var(--line);
}

/* ── Round Breakdown Table ─────────────────────── */

.round-breakdown {
    margin-top: 22px;
    padding-top: 22px;
    border-top: 1px dashed var(--line);
}

.round-breakdown-title {
    margin: 0 0 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-2);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.round-breakdown-empty {
    margin: 0;
    font-size: 13px;
    color: var(--ink-3);
}

.round-breakdown-scroll {
    overflow-x: auto;
}

.round-breakdown-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.round-breakdown-table th {
    padding: 0 12px;
    height: 34px;
    text-align: left;
    font-weight: 600;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-3);
    background: var(--paper-2);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.round-breakdown-table td {
    padding: 8px 12px;
    /* Overrides the global `td { height: 64px }` rule above — without this the
       row height doesn't shrink to fit its content and a player with many
       rounds gets an unnecessarily tall table. Do not remove. */
    height: auto;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
    white-space: nowrap;
}

.round-breakdown-table tr:last-child td {
    border-bottom: none;
}

.round-breakdown-summary {
    margin: 10px 0 0;
    font-size: 13px;
    color: var(--ink-3);
}

.round-status-pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    background: var(--paper-2);
    color: var(--ink-3);
    border: 1px solid var(--line);
}

.round-status-pill--counted,
.round-status-pill--counted-double {
    background: var(--up-soft);
    color: var(--up);
    border-color: transparent;
}

.round-status-pill--extended {
    background: var(--accent-soft);
    color: var(--accent-text);
    border-color: transparent;
}

.round-status-pill--outlier-stddev,
.round-status-pill--outlier-100 {
    background: var(--down-soft);
    color: var(--down);
    border-color: transparent;
}

/* These three statuses render the same as the base .round-status-pill — the
   declarations below are redundant but kept to document that this is deliberate
   (a neutral "didn't count" look), not an omission. */
.round-status-pill--out-of-window,
.round-status-pill--after-cutoff,
.round-status-pill--invalid {
    background: var(--paper-2);
    color: var(--ink-3);
    border: 1px solid var(--line);
}

/* ── Table Header Hints ───────────────────────── */

.th-hint {
    display: block;
    font-size: 9.5px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--ink-3);
    margin-top: 2px;
}

/* ── KPI Tiles ────────────────────────────────── */

.kpi-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.kpi-tile {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    gap: 12px;
    box-shadow: var(--shadow-card);
}

.kpi-rail {
    width: 3px;
    align-self: stretch;
    border-radius: 2px;
    background: var(--ink-3);
    flex-shrink: 0;
}

.kpi-rail.up {
    background: var(--up);
}

.kpi-rail.down {
    background: var(--down);
}

.kpi-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.kpi-value {
    font-family: var(--font-mono);
    font-feature-settings: "tnum", "zero";
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--ink);
    line-height: 1;
}

.kpi-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
}

.kpi-sub {
    font-size: 12px;
    color: var(--ink-3);
}

@media (max-width: 880px) {
    .kpi-strip {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ── Table Card + Toolbar ─────────────────────── */

.table-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.kicker {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.10em;
    color: var(--ink-3);
}

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--line);
}

.toolbar-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* ── Icon Buttons ─────────────────────────────── */

.icon-btn {
    background: transparent;
    border: 1px solid transparent;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: var(--ink-3);
    cursor: pointer;
    font-size: 12px;
    transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}

.icon-btn:hover {
    background: var(--hover);
    color: var(--ink);
    border-color: var(--line);
}

/* ── Table Pill Toggle ────────────────────────── */

.pill-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px 5px 10px;
    border-radius: 999px;
    border: 1px solid var(--line-2);
    background: var(--paper-2);
    color: var(--ink-2);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.pill-toggle:hover {
    background: var(--hover);
    border-color: var(--line);
}

.pill-toggle[aria-pressed="true"] {
    background: color-mix(in oklab, var(--accent) 10%, white);
    border-color: color-mix(in oklab, var(--accent) 35%, var(--line-2));
    color: var(--accent-text);
}

.pill-icon {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.pill-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ink-3);
    opacity: 0.4;
    transition: background 150ms ease, opacity 150ms ease, box-shadow 150ms ease;
}

.pill-toggle[aria-pressed="true"] .pill-dot {
    background: var(--accent);
    opacity: 1;
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 20%, transparent);
}

/* ── Sparklines ───────────────────────────────── */

.sparkline {
    display: block;
    line-height: 0;
    flex-shrink: 0;
}

.spark {
    display: block;
    overflow: visible;
}

body[data-sparklines="off"] .sparkline,
body[data-sparklines="off"] .spark {
    display: none;
}

/* ── PDGA attribution ─────────────────────────── */

.pdga-attribution {
    font-size: 11.5px;
    color: var(--ink-3);
    text-align: center;
    max-width: 640px;
    margin: 0 auto;
    line-height: 1.6;
    padding: 0 16px;
}

.pdga-attribution a {
    color: inherit;
    text-decoration: underline;
}
