/* ==========================================================================
   Components: controls, cards, pills, data table, war-log tiles, overlays
   ========================================================================== */

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--surface-2);
  color: var(--text-1); font-size: 13px; font-weight: 600; cursor: pointer;
  white-space: nowrap; transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { background: var(--surface-hover); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--text-1); color: var(--text-inverse); border-color: transparent; }
.btn-primary:hover { background: var(--text-1); opacity: 0.88; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text-1); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-icon { width: 32px; padding: 0; }
.btn svg { width: 16px; height: 16px; flex: 0 0 auto; }
.btn.is-busy svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Segmented control ────────────────────────────────────────────────── */
.seg {
  display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--radius);
  background: var(--surface-3); border: 1px solid var(--line);
}
.seg button {
  height: 26px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent;
  color: var(--text-2); font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.seg button:hover { color: var(--text-1); }
.seg button[aria-pressed="true"] { background: var(--surface-1); color: var(--text-1); box-shadow: var(--shadow-1); }

/* ── Clan switch (sub bar) ────────────────────────────────────────────── */
.clan-switch { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.clan-switch::-webkit-scrollbar { display: none; }
.clan-switch button {
  display: inline-flex; align-items: center; gap: 8px;
  height: 30px; padding: 0 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--text-2);
  font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}
.clan-switch button:hover { color: var(--text-1); border-color: var(--line-strong); }
.clan-switch button[aria-selected="true"] { background: var(--surface-3); color: var(--text-1); border-color: var(--line-strong); }
.clan-switch .count { font-size: 11px; color: var(--text-3); font-weight: 600; font-variant-numeric: tabular-nums; }
.clan-switch button.is-mine::after {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); flex-shrink: 0;
}
.clan-label-mobile { display: none; }

@media (max-width: 960px) {
  .clan-label-desktop { display: none; }
  .clan-label-mobile { display: inline; font-weight: 750; letter-spacing: 0.01em; }
  .clan-switch {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    width: 100%;
    overflow: visible;
    background: var(--surface-2);
    padding: 3px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
  }
  .clan-switch button {
    justify-content: center;
    gap: 5px;
    height: 30px;
    padding: 0 4px;
    border-radius: 6px;
    border: 1px solid transparent;
    font-size: 12.5px;
    min-width: 0;
  }
  .clan-switch button[aria-selected="true"] {
    background: var(--surface-1);
    color: var(--text-1);
    border-color: var(--accent);
    box-shadow: var(--shadow-1);
  }
  .clan-switch button.is-mine:not([aria-selected="true"]) {
    border-color: color-mix(in srgb, var(--brand) 38%, transparent);
    background: color-mix(in srgb, var(--brand) 8%, transparent);
  }
  .clan-switch button.is-mine::after {
    display: none;
  }
  .clan-switch .count {
    font-size: 10.5px;
    padding: 1px 4px;
    border-radius: 4px;
    background: var(--surface-3);
    color: var(--text-2);
  }
  .clan-switch button[aria-selected="true"] .count {
    background: var(--accent-soft);
    color: var(--accent);
  }
}

@media (max-width: 420px) {
  .clan-switch .count-unit { display: none; }
}

/* ── Toggle switch ────────────────────────────────────────────────────── */
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track {
  position: relative; width: 30px; height: 18px; border-radius: 999px;
  background: var(--surface-3); border: 1px solid var(--line-strong); transition: background 0.15s;
}
.toggle-thumb {
  position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--text-3); transition: transform 0.15s, background 0.15s;
}
.toggle input:checked + .toggle-track { background: var(--short-soft); border-color: var(--short); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(12px); background: var(--short); }
.toggle input:focus-visible + .toggle-track { box-shadow: var(--focus); }
.toggle-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }

/* ── Week History Window Slider ───────────────────────────────────────── */
.week-slider-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 3px 10px;
  border-radius: 999px;
  margin-left: auto;
  user-select: none;
}
.week-slider-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  white-space: nowrap;
}
.week-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 90px;
  height: 5px;
  border-radius: 999px;
  background: var(--line-strong);
  outline: none;
  cursor: pointer;
  transition: background 0.15s;
}
.week-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  cursor: pointer;
  transition: transform 0.1s;
}
.week-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}
.week-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  cursor: pointer;
}
.week-slider-val {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.week-quick-btns {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.week-quick-btn {
  height: 22px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  border: none;
  color: var(--text-3);
  background: transparent;
}
.week-quick-btn:hover {
  color: var(--text-1);
  background: var(--surface-3);
}
.week-quick-btn[aria-pressed="true"] {
  background: var(--surface-3);
  color: var(--accent);
  font-weight: 800;
}

/* ── Inputs ───────────────────────────────────────────────────────────── */
.input {
  height: 32px; padding: 0 11px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--surface-1); color: var(--text-1);
  font: inherit; font-size: 13.5px; min-width: 0;
}
.input::placeholder { color: var(--text-3); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.input-search { width: 240px; padding-left: 32px; background-repeat: no-repeat; background-position: 10px center; background-size: 14px; }

/* ── Toolbar (per view) ───────────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .spacer { flex: 1 1 auto; }
.search-wrap { position: relative; display: inline-flex; }
.search-wrap svg { position: absolute; left: 10px; top: 50%; width: 14px; height: 14px; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }

/* ── Cards ────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 16px;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-title { font-size: 13px; font-weight: 650; letter-spacing: 0; }
.card-kicker {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3);
}
.card-sub { font-size: var(--fs-sm); color: var(--text-2); }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } }

/* ── KPI tiles ────────────────────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 8px; margin-bottom: 14px; }
.kpi {
  position: relative; padding: 10px 12px; border-radius: var(--radius);
  background: var(--surface-1); border: 1px solid var(--line); text-align: left;
}
button.kpi { cursor: pointer; font: inherit; color: inherit; }
button.kpi:hover { border-color: var(--line-strong); }
.kpi[aria-pressed="true"] { border-color: var(--kpi-tone, var(--accent)); box-shadow: inset 0 0 0 1px var(--kpi-tone, var(--accent)); }
.kpi-label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-3); }
.kpi-value { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-note { font-size: 11.5px; color: var(--text-2); }
.kpi::before {
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px; border-radius: 2px;
  background: var(--kpi-tone, transparent);
}
.tone-pos { --kpi-tone: var(--pos); }
.tone-warn { --kpi-tone: var(--warn); }
.tone-neg { --kpi-tone: var(--neg); }
.tone-info { --kpi-tone: var(--info); }
.tone-muted { --kpi-tone: var(--line-strong); }
.tone-short { --kpi-tone: var(--short); }

/* ── Pills ────────────────────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 650; white-space: nowrap; border: 1px solid transparent;
}
.pill-pos { color: var(--pos); background: var(--pos-soft); }
.pill-warn { color: var(--warn); background: var(--warn-soft); }
.pill-neg { color: var(--neg); background: var(--neg-soft); }
.pill-info { color: var(--info); background: var(--info-soft); }
.pill-muted { color: var(--text-2); background: var(--surface-3); }
.pill-short { color: var(--short); background: var(--short-soft); }
.pill-outline { color: var(--text-2); border-color: var(--line-strong); }
.tag-chip {
  display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: var(--radius-sm);
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; background: var(--surface-3); color: var(--text-2);
}
.you-chip { background: var(--brand); color: var(--text-inverse); }

/* ── Data table ───────────────────────────────────────────────────────── */
.table-shell {
  border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface-1);
  overflow: auto; max-height: calc(100vh - 230px); min-height: 280px;
}
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2);
  padding: 8px 10px; text-align: left; white-space: nowrap;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3);
  border-bottom: 1px solid var(--line);
}
.table th.is-sortable { cursor: pointer; user-select: none; }
.table th.is-sortable:hover { color: var(--text-1); }
.table th[aria-sort="ascending"], .table th[aria-sort="descending"] { color: var(--text-1); }
.table th .sort-ind { display: inline-block; width: 8px; margin-left: 4px; color: var(--accent); }
.table td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.row { cursor: pointer; }
.table tbody tr.row:hover td { background: var(--surface-2); }
.table tbody tr.row.is-open td { background: var(--surface-2); border-bottom-color: transparent; }
.table tbody tr.row.is-me td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
.table .r { text-align: right; }
.table .c { text-align: center; }
.table .idx { color: var(--text-3); width: 36px; font-size: 12px; }
.table .sticky-col { position: sticky; left: 0; z-index: 1; background: var(--surface-1); }
.table th.sticky-col { z-index: 3; background: var(--surface-2); }
.table tbody tr.row:hover .sticky-col, .table tbody tr.row.is-open .sticky-col { background: var(--surface-2); }
.table .detail-row td { padding: 0 10px 14px; background: var(--surface-2); }
.table .empty-row td { padding: 40px; text-align: center; color: var(--text-3); cursor: default; }

.player-cell { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.player-name { font-weight: 650; color: var(--text-1); display: inline-flex; align-items: center; gap: 6px; }
.player-name:hover { text-decoration: none; color: var(--accent); }
.player-meta { font-size: 11.5px; color: var(--text-3); }
.metric-main { font-weight: 650; }
.metric-sub { display: block; font-size: 11px; color: var(--text-3); font-weight: 500; }

/* ── War-log tiles ────────────────────────────────────────────────────────
   One number per tile (the selected metric), a 3px battle-completion bar
   along the bottom, and orthogonal markers for the two facts that used to
   be blended into gradients: a violet corner for a shortened (3-day) war,
   and a blue left edge for a mid-week join. Tone is ONLY attendance. */
.wl { display: grid; grid-auto-flow: column; grid-auto-columns: var(--wl-w); gap: var(--wl-gap); }
.wl-head { align-items: end; }
.wl-head-cell {
  display: flex; flex-direction: column; align-items: center; gap: 1px; cursor: pointer;
  font-size: 10px; font-weight: 650; letter-spacing: 0; text-transform: none; color: var(--text-3);
  border-radius: var(--radius-sm); padding: 2px 0;
}
.wl-head-cell:hover { color: var(--text-1); background: var(--surface-3); }
.wl-head-cell.is-sorted { color: var(--accent); }
.wl-head-cell .d { width: 14px; height: 2px; border-radius: 1px; background: transparent; }
.wl-head-cell.is-short .d { background: var(--short); }

.wt {
  position: relative; height: var(--wl-h); border-radius: var(--radius-sm); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-3); color: var(--text-1);
  font-size: 11px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
}
.wt::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 3px;
  width: calc(var(--fill, 0) * 100%); background: var(--wt-bar, var(--line-strong));
}
.wt.t-full { --wt-bar: color-mix(in srgb, var(--pos) 70%, transparent); }
.wt.t-join { background: var(--info-soft); color: var(--info); --wt-bar: var(--info); }
.wt.t-miss { background: var(--warn-soft); color: var(--warn); --wt-bar: var(--warn); }
.wt.t-zero { 
  background: color-mix(in srgb, var(--neg) 24%, var(--surface-2)); 
  color: #ff5252; 
  --wt-bar: var(--neg); 
  box-shadow: inset 0 0 0 1.5px var(--neg); 
  font-weight: 800; 
}
.wt.t-zero::before {
  content: ""; position: absolute; top: 1px; right: 1px;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--neg);
}
.wt.t-absent { background: transparent; color: var(--text-3); box-shadow: inset 0 0 0 1px var(--line); font-weight: 500; }
.wt.t-absent::after { display: none; }

/* Weekly breakdown table row highlights */
tr.week-row-missed {
  background: color-mix(in srgb, var(--neg) 15%, transparent) !important;
}
tr.week-row-missed td:first-child {
  border-left: 3px solid var(--neg) !important;
}
tr.week-row-partial {
  background: color-mix(in srgb, var(--warn) 7%, transparent) !important;
}
tr.week-row-partial td:first-child {
  border-left: 3px solid var(--warn) !important;
}
.wt.m-ext { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--text-2); }
.wt.m-short::before {
  content: ""; position: absolute; top: 0; right: 0;
  border-style: solid; border-width: 0 7px 7px 0; border-color: transparent var(--short) transparent transparent;
}
.wt.m-joined { box-shadow: inset 2px 0 0 var(--info); }
.wt.m-ext.m-joined { box-shadow: inset 2px 0 0 var(--info), inset 0 0 0 1px var(--line-strong); }

.wl-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 11.5px; color: var(--text-2); }
.wl-legend .item { display: inline-flex; align-items: center; gap: 6px; }
.wl-legend .wt { --wl-h: 14px; width: 18px; font-size: 0; }

/* Week-detail grid (row drawer, profile, compare) */
.wk-grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.wk-grid th, .wk-grid td { padding: 5px 8px; text-align: center; white-space: nowrap; border-bottom: 1px solid var(--line); }
.wk-grid th { font-size: 10.5px; font-weight: 650; color: var(--text-3); text-transform: none; letter-spacing: 0; background: transparent; position: static; }
.wk-grid th:first-child, .wk-grid td:first-child { text-align: left; color: var(--text-3); font-weight: 650; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; }
.wk-grid th.is-short { color: var(--short); }
.wk-grid td.t-miss { color: var(--warn); }
.wk-grid td.t-zero { color: var(--neg); }
.wk-grid td.t-join { color: var(--info); }
.wk-grid td.t-absent { color: var(--text-3); }
.wk-grid .note { white-space: normal; font-size: 11px; color: var(--text-2); max-width: 110px; line-height: 1.3; text-align: center; }
.wk-scroll { overflow-x: auto; }

/* ── Popover (column menu) ────────────────────────────────────────────── */
.popover-anchor { position: relative; display: inline-flex; }
.popover {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 20; min-width: 220px;
  background: var(--surface-1); border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-pop); padding: 6px;
}
.popover[hidden] { display: none; }
.popover-section { padding: 6px 8px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-3); }
.check-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.check-row:hover { background: var(--surface-3); }
.check-row input { accent-color: var(--accent); }

/* ── Modal ────────────────────────────────────────────────────────────── */
dialog.modal {
  width: min(980px, calc(100% - 24px)); max-height: calc(100vh - 32px);
  padding: 0; border: 1px solid var(--line-strong); border-radius: var(--radius-lg);
  background: var(--surface-1); color: var(--text-1); box-shadow: var(--shadow-pop);
  box-sizing: border-box; overflow-x: hidden;
}
dialog.modal.modal-md {
  width: min(600px, calc(100% - 24px));
}
dialog.modal::backdrop { background: var(--scrim); }
.modal-head {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; background: var(--surface-1); border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: var(--fs-lg); }
.modal-head .btn-icon { margin-left: auto; }
.modal-body { padding: 18px; }
@media (max-width: 720px) {
  dialog.modal,
  dialog.modal.modal-md {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 100dvh;
    height: 100dvh;
    margin: 0;
    border-radius: 0;
    border: 0;
  }
  .modal-head { padding: 12px 14px; }
  .modal-body { padding: 14px; }
}

/* ── Tooltip ──────────────────────────────────────────────────────────── */
.tooltip {
  position: fixed; z-index: 1000; max-width: 300px; pointer-events: none;
  padding: 8px 10px; border-radius: var(--radius); background: var(--surface-1);
  border: 1px solid var(--line-strong); box-shadow: var(--shadow-pop);
  font-size: 12px; line-height: 1.45; color: var(--text-2);
}
.tooltip strong { display: block; color: var(--text-1); font-weight: 650; margin-bottom: 2px; }

/* ── Toast ────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 20px; z-index: 1001; transform: translateX(-50%);
  padding: 9px 14px; border-radius: var(--radius); background: var(--text-1); color: var(--text-inverse);
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow-pop);
}

/* ── States ───────────────────────────────────────────────────────────── */
.empty { padding: 48px 16px; text-align: center; color: var(--text-3); font-size: 13.5px; }
.empty h3 { color: var(--text-1); font-size: 15px; margin-bottom: 4px; }
.error-box {
  padding: 12px 14px; border-radius: var(--radius); background: var(--neg-soft);
  border: 1px solid color-mix(in srgb, var(--neg) 40%, transparent); color: var(--neg); font-size: 13px;
}
.notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; margin-bottom: 12px;
  border-radius: var(--radius); background: var(--short-soft); color: var(--text-1); font-size: 12.5px;
  border: 1px solid color-mix(in srgb, var(--short) 35%, transparent);
}
.notice strong { color: var(--short); }
.skeleton {
  border-radius: var(--radius); background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2));
  background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ── Ranked list (leaderboards) ───────────────────────────────────────── */
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-list li {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 7px 0; border-bottom: 1px solid var(--line);
}
.rank-list li:last-child { border-bottom: 0; }
.rank-pos { font-size: 12px; font-weight: 700; color: var(--text-3); text-align: right; font-variant-numeric: tabular-nums; }
.rank-pos.p1 { color: var(--gold); }
.rank-pos.p2 { color: var(--silver); }
.rank-pos.p3 { color: var(--bronze); }
.rank-val { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.rank-val small { display: block; font-size: 11px; color: var(--text-3); font-weight: 500; }

/* ── Bars ─────────────────────────────────────────────────────────────── */
.bar { position: relative; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > span { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--bar-tone, var(--accent)); }

/* ── Charts ───────────────────────────────────────────────────────────── */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--text-3); font-size: 10px; font-family: var(--font-sans); font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-strong { stroke: var(--line-strong); }

.btn-xs { height: 24px; padding: 0 8px; font-size: 11.5px; border-radius: 6px; }

/* ── Personal Standing Banner (Find Me & Onboarding) ──────────────────── */
.my-standing-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  flex-wrap: wrap;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--surface-1);
  padding: 8px 12px;
  box-shadow: var(--shadow-1);
}
.my-standing-bar.is-prompt {
  border-style: dashed;
  border-left: 3px solid var(--accent);
}
.my-standing-bar.tone-pos {
  border-left: 4px solid var(--pos);
  background: color-mix(in srgb, var(--pos) 6%, var(--surface-1));
}
.my-standing-bar.tone-warn {
  border-left: 4px solid var(--warn);
  background: color-mix(in srgb, var(--warn) 7%, var(--surface-1));
}
.my-standing-bar.tone-neg {
  border-left: 4px solid var(--neg);
  background: color-mix(in srgb, var(--neg) 8%, var(--surface-1));
}
.my-standing-bar.tone-info {
  border-left: 4px solid var(--info);
  background: color-mix(in srgb, var(--info) 6%, var(--surface-1));
}
.my-standing-main {
  display: flex;
  align-items: center;
  gap: 6px 10px;
  flex-wrap: wrap;
  flex: 1 1 240px;
  min-width: 0;
  font-size: 12.5px;
}
.my-standing-icon {
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}
.my-standing-metrics {
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}
.my-standing-advice {
  font-size: 12px;
  color: var(--text-2);
}
.my-standing-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}

@keyframes rowFlashPulse {
  0%, 100% { box-shadow: inset 0 0 0 2px var(--pos); }
  50% { background: var(--pos-soft); box-shadow: inset 0 0 0 3px var(--pos); }
}
tr.row-flash td {
  animation: rowFlashPulse 1.1s ease 2;
}

/* ── Plain-English Contextual Help Callout ────────────────────────────── */
.help-callout {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-left: 3px solid var(--info);
  border-radius: var(--radius);
  padding: 7px 12px;
  margin-bottom: 12px;
}
.help-callout-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  flex-wrap: wrap;
  cursor: pointer;
}
.help-callout-title {
  display: flex;
  align-items: center;
  gap: 6px 8px;
  flex-wrap: wrap;
  font-size: 12.5px;
  min-width: 0;
  flex: 1 1 200px;
}
.help-q-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--info-soft);
  color: var(--info);
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
}
.help-callout-body {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--text-2);
}
.help-callout-body ul {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ── 1-Click Smart Preset Chips ───────────────────────────────────────── */
.preset-strip {
  display: flex;
  align-items: center;
  gap: 6px 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.preset-strip-lbl {
  font-size: 10.5px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-right: 4px;
}
.preset-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text-1);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  transition: all 0.14s ease;
}
.preset-chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.preset-chip.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

/* ── Mobile Responsive Refinements (< 640px) ──────────────────────────── */
@media (max-width: 640px) {
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
  }
  .kpi {
    padding: 8px 10px;
  }
  .kpi-value {
    font-size: 18px;
  }
  .kpi-note {
    font-size: 10.5px;
  }
  .toolbar {
    gap: 6px;
  }
  .toolbar .spacer {
    display: none;
  }
  .search-wrap {
    flex: 1 1 100%;
    width: 100%;
  }
  .input-search {
    width: 100%;
  }
  .table-shell {
    max-height: none;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table {
    font-size: 12.5px;
  }
  .table th, .table td {
    padding: 6px 8px;
  }
  .table .sticky-col {
    max-width: 132px;
  }
  .player-name {
    max-width: 118px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .help-callout-title .muted {
    display: none;
  }
}



/* RoyaleAPI quick lookup in topbar */
.rapi-lookup {
  display: inline-flex;
  align-items: center;
  background: var(--surface-2, rgba(255, 255, 255, 0.05));
  border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
  border-radius: var(--radius-sm, 6px);
  padding: 2px 4px 2px 8px;
  gap: 4px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.rapi-lookup:focus-within {
  border-color: var(--accent, #6366f1);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}
.rapi-input {
  background: transparent;
  border: none;
  color: var(--text-1, #f8fafc);
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  width: 130px;
  outline: none;
}
.rapi-input::placeholder {
  color: var(--text-3, #94a3b8);
  font-family: var(--font-sans, inherit);
}
.rapi-btn {
  padding: 2px 6px !important;
  font-size: 11px !important;
  height: 24px !important;
  min-height: 24px !important;
  line-height: 1 !important;
  border-radius: 4px !important;
}
@media (max-width: 768px) {
  .rapi-input {
    width: 95px;
  }
}
@media (max-width: 540px) {
  .rapi-lookup {
    display: none;
  }
}
