/* N50 Results — styles */
:root {
  --ink: #0f1b2d;
  --ink-2: #1c2b42;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #e3e8ef;
  --line-2: #d3dae4;
  --text: #142033;
  --muted: #627089;
  --accent: #ff5a36;
  --accent-ink: #d63d1b;
  --accent-soft: #fff0eb;
  --good: #16a34a;
  --good-soft: #e9f8ef;
  --gold: #e8b423;
  --silver: #9aa6b8;
  --bronze: #c27a45;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 27, 45, .06), 0 4px 16px rgba(15, 27, 45, .05);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
html.dark {
    --bg: #0b1320;
    --surface: #121c2c;
    --surface-2: #172234;
    --line: #223049;
    --line-2: #2c3c58;
    --text: #e6ecf5;
    --muted: #8e9cb3;
    --accent-soft: #3a1d17;
    --good-soft: #10291b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; min-height: 100vh; display: flex; flex-direction: column; }
a { color: inherit; }
a:hover { color: var(--accent-ink); }
html.dark a:hover { color: var(--accent); }
h1, h2, h3, h4 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
.container { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 20px; }
main.container { flex: 1; padding-top: 28px; padding-bottom: 56px; outline: none; }
.muted { color: var(--muted); }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- Top bar ---------- */
.topbar { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 50; box-shadow: 0 1px 0 rgba(255,255,255,.06); }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 0 20px; height: 64px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; font-weight: 800; font-size: 18px; letter-spacing: -.02em; white-space: nowrap; }
.brand:hover { color: #fff; }
.brand-mark { width: 28px; height: 28px; color: #fff; }
.brand-mark .bull { fill: var(--accent); }
.mainnav { display: flex; gap: 2px; flex: 1; }
.mainnav a { text-decoration: none; color: rgba(255,255,255,.72); padding: 8px 12px; border-radius: 8px; font-weight: 500; font-size: 14px; white-space: nowrap; }
.mainnav a:hover { color: #fff; background: rgba(255,255,255,.07); }
.mainnav a.active { color: #fff; background: rgba(255,255,255,.12); }
.topbar-tools { display: flex; align-items: center; gap: 10px; }
.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 10px; width: 16px; height: 16px; color: rgba(255,255,255,.55); pointer-events: none; }
.search input { width: 190px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.1); color: #fff; border-radius: 9px; padding: 7px 10px 7px 32px; font-size: 14px; outline: none; transition: width .2s, background .2s; }
.search input::placeholder { color: rgba(255,255,255,.5); }
.search input:focus { width: 240px; background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.25); }
.search-results { position: absolute; top: calc(100% + 8px); right: 0; width: 300px; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.search-results a { display: flex; justify-content: space-between; padding: 10px 14px; text-decoration: none; border-bottom: 1px solid var(--line); font-size: 14px; }
.search-results a:last-child { border-bottom: 0; }
.search-results a:hover, .search-results a.sel { background: var(--surface-2); color: var(--text); }
.search-results .empty { padding: 12px 14px; color: var(--muted); font-size: 14px; }
.topbar .btn-ghost { color: #fff; border-color: rgba(255,255,255,.2); }
.topbar .btn-ghost:hover { background: rgba(255,255,255,.1); color: #fff; }
.menu-btn { display: none; background: none; border: 0; width: 40px; height: 40px; padding: 10px 8px; cursor: pointer; }
.menu-btn span { display: block; height: 2px; background: #fff; margin: 4px 0; border-radius: 2px; }

/* ---------- Buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 10px; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { background: var(--ink-2); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-accent { background: var(--accent); }
.btn-accent:hover { background: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: transparent; color: #dc2626; border-color: #f3c4c4; }
.btn-danger:hover { background: #fdecec; color: #b91c1c; }
html.dark .btn { background: #2a3b57; }
html.dark .btn:hover { background: #34486a; }
html.dark .btn-accent { background: var(--accent); }
html.dark .btn-ghost, html.dark .btn-danger { background: transparent; }
html.dark .btn-danger { border-color: #5b2525; }
html.dark .btn-danger:hover { background: #2b1414; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-icon { padding: 6px 8px; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; padding: 9px 12px; font-size: 14px; color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,90,54,.15); }
.select-pill { appearance: none; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23627089' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 12px center; border: 1px solid var(--line-2); border-radius: 999px; padding: 7px 34px 7px 14px; font-weight: 600; font-size: 14px; cursor: pointer; outline: none; color: var(--text); }
.select-pill:focus { border-color: var(--accent); }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--text); }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.eyebrow { text-transform: uppercase; letter-spacing: .09em; font-size: 12px; font-weight: 700; color: var(--accent-ink); margin-bottom: 6px; }
html.dark .eyebrow { color: var(--accent); }
.page-head h1 { font-size: 30px; font-weight: 800; letter-spacing: -.025em; }
.page-head .sub { color: var(--muted); margin-top: 6px; font-size: 14px; }
.head-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- Cards / panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-head h2, .panel-head h3 { font-size: 16px; font-weight: 700; }
.panel-head .meta { font-size: 13px; color: var(--muted); }
.panel-body { padding: 18px 20px; }
.grid { display: grid; gap: 18px; }
.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)); }
.stack > * + * { margin-top: 18px; }

/* Stat tiles */
.stat { padding: 18px 20px; }
.stat .label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.stat .value { font-family: var(--mono); font-size: 30px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; }
.stat .hint { font-size: 13px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-stat { background: var(--ink); color: #fff; border-color: var(--ink); position: relative; overflow: hidden; }
.hero-stat .label, .hero-stat .hint { color: rgba(255,255,255,.65); }
.hero-stat .value { color: #fff; }
.hero-stat::after { content: ""; position: absolute; right: -40px; top: -40px; width: 150px; height: 150px; border-radius: 50%; border: 14px solid rgba(255,255,255,.05); box-shadow: 0 0 0 22px rgba(255,255,255,.03), inset 0 0 0 22px rgba(255,90,54,.18); }
.hero-stat a { color: #fff; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
table.data td { padding: 11px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .r { text-align: right; }
table.data .c { text-align: center; }
table.data td.num, table.data th.num { text-align: right; }
table.data td.x { color: var(--muted); font-size: 13px; }
table.data th.grp { border-left: 1px solid var(--line); }
table.data td.grp { border-left: 1px solid var(--line); }
table.data td.strong { font-weight: 700; }
table.data a { text-decoration: none; font-weight: 600; }
table.data a:hover { text-decoration: underline; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
.agg { font-family: var(--mono); font-weight: 700; font-size: 15px; }
.agg-x { font-family: var(--mono); color: var(--accent-ink); font-weight: 700; }
html.dark .agg-x { color: var(--accent); }
.subtle { font-size: 12.5px; color: var(--muted); }
.cell-name { display: flex; flex-direction: column; }
.cell-name .subtle { font-weight: 400; }

/* Rank badges */
.rank { display: inline-grid; place-items: center; min-width: 30px; height: 30px; border-radius: 50%; font-family: var(--mono); font-weight: 700; font-size: 13px; background: var(--surface-2); border: 1px solid var(--line); }
.rank.r1 { background: var(--gold); border-color: var(--gold); color: #3b2a00; }
.rank.r2 { background: var(--silver); border-color: var(--silver); color: #1d2533; }
.rank.r3 { background: var(--bronze); border-color: var(--bronze); color: #fff; }

/* Expandable card rows */
tr.detail > td { padding: 0; background: var(--surface-2); }
.cards-mini { padding: 10px 14px 14px 58px; }
.cards-mini table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cards-mini th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 8px; font-weight: 700; }
.cards-mini td { padding: 6px 8px; border-top: 1px dashed var(--line-2); font-family: var(--mono); font-size: 13px; }
.cards-mini td.txt { font-family: var(--font); }
.cards-mini tr.counts td { color: var(--text); }
.cards-mini tr:not(.counts) td { color: var(--muted); }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font-family: var(--font); white-space: nowrap; }
.tag.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.tag.accent { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.tag.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.chev { display: inline-block; transition: transform .15s; color: var(--muted); }
tr.open .chev { transform: rotate(90deg); }
.perfect { color: var(--good); font-weight: 700; }

/* Tabs / segmented */
.tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px; overflow-x: auto; }
.tabs a, .tabs button { border: 0; background: transparent; padding: 7px 14px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; text-decoration: none; white-space: nowrap; }
.tabs a:hover, .tabs button:hover { color: var(--text); background: var(--surface-2); }
.tabs .active { background: var(--ink) !important; color: #fff !important; }
html.dark .tabs .active { background: #2a3b57 !important; }
.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.filter-input { max-width: 260px; }

/* Leader cards (dashboard / top 5) */
.leader-list { list-style: none; margin: 0; padding: 0; }
.leader-list li { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; padding: 11px 20px; border-bottom: 1px solid var(--line); }
.leader-list li:last-child { border-bottom: 0; }
.leader-list .who { min-width: 0; }
.leader-list .who a { font-weight: 600; text-decoration: none; }
.leader-list .who .subtle { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leader-list .score { text-align: right; }
.leader-list .score .agg { display: block; }
.panel-foot { padding: 12px 20px; border-top: 1px solid var(--line); font-size: 13px; }
.panel-foot a { font-weight: 600; text-decoration: none; color: var(--accent-ink); }
html.dark .panel-foot a { color: var(--accent); }

/* Match list */
.match-list { list-style: none; margin: 0; padding: 0; }
.match-list li a, .match-list li .row { display: grid; grid-template-columns: 54px 1fr auto; gap: 14px; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--line); text-decoration: none; }
.match-list li:last-child a, .match-list li:last-child .row { border-bottom: 0; }
.match-list li a:hover { background: var(--surface-2); color: var(--text); }
.datebox { text-align: center; border: 1px solid var(--line); border-radius: 10px; padding: 4px 0; background: var(--surface-2); line-height: 1.1; }
.datebox .m { font-size: 10.5px; text-transform: uppercase; font-weight: 700; color: var(--accent-ink); letter-spacing: .06em; }
html.dark .datebox .m { color: var(--accent); }
.datebox .d { font-family: var(--mono); font-weight: 700; font-size: 18px; }
.match-list .title { font-weight: 600; }

/* Club schedule cards */
.club-card .panel-head { align-items: flex-start; }
.club-card h3 { font-size: 17px; }
.club-meta { font-size: 13px; color: var(--muted); margin-top: 3px; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.chip { border: 1px solid var(--line-2); background: var(--surface); padding: 6px 14px; border-radius: 999px; font-weight: 600; font-size: 13px; cursor: pointer; color: var(--muted); }
.chip:hover { color: var(--text); }
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
html.dark .chip.active { background: #2a3b57; border-color: #2a3b57; }

/* Champions */
.champ-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: 18px; }
.champ-row { display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.champ-row:last-child { border-bottom: 0; }

/* Match detail */
.info-strip { display: flex; gap: 28px; flex-wrap: wrap; padding: 16px 20px; }
.info-strip .k { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.info-strip .v { font-weight: 600; margin-top: 2px; }

/* Empty / loading */
.empty-state { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty-state svg { width: 56px; height: 56px; opacity: .35; margin-bottom: 10px; }
.empty-state h3 { color: var(--text); font-size: 17px; margin-bottom: 6px; }
.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--line) 0%, var(--surface-2) 50%, var(--line) 100%); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.loading { padding: 40px 0; display: grid; gap: 14px; }

/* Toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.25); font-weight: 600; font-size: 14px; z-index: 100; max-width: calc(100% - 40px); }
.toast.error { background: #b91c1c; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 22px 0; font-size: 13px; }
.footer-inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: center; }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--text); }

/* Login */
.auth-card { max-width: 400px; margin: 40px auto; }
.auth-card .panel-body { padding: 28px; }
.auth-card h1 { font-size: 24px; margin-bottom: 6px; }
.error-text { color: #dc2626; font-size: 14px; font-weight: 500; min-height: 20px; }

/* Shooter profile */
.profile-head { display: flex; gap: 18px; align-items: center; }
.avatar { width: 64px; height: 64px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 22px; flex-shrink: 0; }

/* Display (TV) mode */
body.tv .topbar, body.tv .site-footer, body.tv .head-tools, body.tv .toolbar .filter-input { display: none !important; }
body.tv main.container { max-width: none; padding: 24px 36px; }
body.tv { font-size: 18px; }
body.tv table.data { font-size: 20px; }
body.tv table.data td { padding: 14px 14px; }
body.tv .agg { font-size: 22px; }
body.tv .page-head h1 { font-size: 42px; }
.tv-exit { position: fixed; top: 14px; right: 14px; z-index: 60; }

/* Admin */
.admin-layout { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: start; }
.admin-nav { position: sticky; top: 88px; display: flex; flex-direction: column; gap: 2px; }
.admin-nav a { text-decoration: none; padding: 9px 12px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); }
.admin-nav a:hover { background: var(--surface); color: var(--text); }
.admin-nav a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); border: 1px solid var(--line); }
.admin-nav .who { padding: 4px 12px 12px; font-size: 13px; color: var(--muted); }
.admin-nav hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; width: 100%; }
.score-grid { width: 100%; border-collapse: collapse; font-size: 14px; }
.score-grid th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 4px; text-align: left; font-weight: 700; white-space: nowrap; }
.score-grid td { padding: 3px; }
.score-grid input, .score-grid select { width: 100%; border: 1px solid var(--line-2); background: var(--surface); border-radius: 7px; padding: 7px 8px; font-size: 14px; outline: none; color: var(--text); }
.score-grid input:focus, .score-grid select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255,90,54,.15); }
.score-grid input.sc { width: 56px; text-align: right; font-family: var(--mono); }
.score-grid input.xc { width: 44px; text-align: right; font-family: var(--mono); background: var(--surface-2); }
.score-grid input.bad { border-color: #dc2626; background: #fdecec; }
.score-grid .tot { font-family: var(--mono); font-weight: 700; text-align: right; padding: 0 10px; white-space: nowrap; }
.score-grid td.name-cell { min-width: 150px; }
.score-grid td.rifle-cell { min-width: 110px; }
.score-grid td.cal-cell input { width: 62px; }
.score-grid select[data-k="class_id"] { min-width: 112px; }
.score-grid tr.class-sep td { padding-top: 14px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.sticky-actions { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 12px 20px; display: flex; justify-content: space-between; gap: 10px; align-items: center; border-radius: 0 0 var(--radius) var(--radius); flex-wrap: wrap; }
dialog.modal { border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100% - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 30px 80px rgba(0,0,0,.35); }
dialog.modal::backdrop { background: rgba(10, 18, 30, .55); }
dialog.modal .panel-head { border-bottom: 1px solid var(--line); }
dialog.modal form { margin: 0; }
.multi-check { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; max-height: 200px; overflow: auto; border: 1px solid var(--line-2); border-radius: 10px; padding: 10px; }
.kbd { font-family: var(--mono); font-size: 12px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .mainnav { display: none; position: absolute; top: 64px; left: 0; right: 0; background: var(--ink); flex-direction: column; padding: 10px 16px 18px; box-shadow: 0 12px 24px rgba(0,0,0,.25); }
  .mainnav.open { display: flex; }
  .mainnav a { padding: 12px; font-size: 16px; }
  .menu-btn { display: block; }
  .topbar-inner { gap: 12px; justify-content: space-between; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-nav { position: static; flex-direction: row; flex-wrap: wrap; }
  .admin-nav .who, .admin-nav hr { display: none; }
  .hide-sm { display: none !important; }
}
@media (max-width: 600px) {
  .container, .topbar-inner { padding-left: 14px; padding-right: 14px; }
  /* Phone header: search box fills the space between the logo and the buttons (issue #1) */
  .topbar-tools { flex: 1; min-width: 0; }
  .search { flex: 1; min-width: 0; }
  .search input, .search input:focus { width: 100%; }
  .search-results { position: fixed; top: 64px; left: 10px; right: 10px; width: auto; }
  .brand-name { display: none; }
  .page-head h1 { font-size: 24px; }
  .stat .value { font-size: 24px; }
  .hide-xs { display: none !important; }
  .grid-4.leaders { grid-template-columns: 1fr; }
  .cards-mini { padding-left: 14px; }
  .champ-row { grid-template-columns: 84px 1fr auto; padding: 12px 14px; }
}
@media print {
  .topbar, .site-footer, .head-tools, .toolbar, .admin-nav { display: none !important; }
  body { background: #fff; }
  .panel { box-shadow: none; }
}

/* Schedule cards: keep every column inside the card */
.sched-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); }
.club-card table.data { table-layout: fixed; }
.club-card table.data th, .club-card table.data td { padding: 10px 10px; }
.club-card table.data th:nth-child(1), .club-card table.data td:nth-child(1) { width: 40%; }
.club-card table.data th:nth-child(2), .club-card table.data td:nth-child(2) { width: 16%; }
.club-card table.data th:nth-child(3), .club-card table.data td:nth-child(3) { width: 18%; }
.club-card table.data td:nth-child(4) { white-space: normal; }
.club-card .tag { font-size: 11px; padding: 2px 7px; }
.club-card .panel-head h3 { overflow-wrap: anywhere; }

/* Theme picker */
.theme-picker { display: inline-flex; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.theme-picker button { border: 0; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; padding: 5px 12px; border-radius: 999px; cursor: pointer; }
.theme-picker button:hover { color: var(--text); }
.theme-picker button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Version stamp (footer, bottom right) */
.version { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ---------- Phone layout for the admin area ---------- */
.admin-layout > div { min-width: 0; }            /* stop wide tables from widening the whole page */
@media (max-width: 1100px) {
  .admin-layout { grid-template-columns: 1fr; }
  .admin-nav { position: static; flex-direction: row; }
  .admin-nav .who, .admin-nav hr { display: none; }
  .admin-nav { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 4px; margin: 0 -14px; padding: 0 14px 4px; scrollbar-width: none; }
  .admin-nav::-webkit-scrollbar { display: none; }
  .admin-nav a { white-space: nowrap; flex-shrink: 0; }
  .admin-layout { gap: 14px; }
}
@media (max-width: 700px) {
  /* Admin lists become stacked cards: one row per card, each value labeled */
  table.data.stack thead { display: none; }
  table.data.stack, table.data.stack tbody, table.data.stack tr, table.data.stack td { display: block; width: 100%; }
  table.data.stack tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  table.data.stack tbody tr:last-child { border-bottom: 0; }
  table.data.stack td { border: 0; padding: 3px 0; white-space: normal; text-align: left !important; display: flex; gap: 12px; align-items: baseline; }
  table.data.stack td[data-label]::before { content: attr(data-label); flex: 0 0 92px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
  table.data.stack td:not([data-label]), table.data.stack td[data-label=""] { padding-top: 10px; flex-wrap: wrap; gap: 8px; }
  table.data.stack td:not([data-label])::before { display: none; }
  table.data.stack td.r { justify-content: flex-start; }

  .page-head .head-tools { width: 100%; }
}
@media (max-width: 900px) {
  /* Score entry: each shooter becomes a card */
  .score-grid thead { display: none; }
  .score-grid, .score-grid tbody { display: block; }
  .score-grid tr { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; padding: 12px 0; border-bottom: 1px dashed var(--line-2); }
  .score-grid td { padding: 0; min-width: 0 !important; }
  .score-grid .name-cell { grid-column: 1 / 6; grid-row: 1; }
  .score-grid .del-cell { grid-column: 6; grid-row: 1; display: flex; justify-content: flex-end; }
  .score-grid .class-cell, .score-grid .rifle-cell, .score-grid .cal-cell { grid-row: 2; }
  .score-grid [class^="t"][class$="-cell"], .score-grid [class^="x"][class$="-cell"] { grid-row: 3; }
  .score-grid .tot { grid-row: 4; }
  .score-grid .class-cell { grid-column: 1 / 3; }
  .score-grid .rifle-cell { grid-column: 3 / 6; }
  .score-grid tr.no-class .rifle-cell { grid-column: 1 / 6; }
  .score-grid .cal-cell { grid-column: 6; }
  .score-grid .tot { grid-column: 1 / -1; text-align: right; padding: 2px 4px 0; }
  .score-grid input, .score-grid select, .score-grid input.sc, .score-grid input.xc, .score-grid td.cal-cell input { width: 100%; font-size: 16px; padding: 9px 8px; } /* 16px stops iPhone auto-zoom */
  .score-grid select[data-k="class_id"] { min-width: 0; }
  .score-grid .del-cell .btn { width: 100%; height: 100%; }
  .sticky-actions { padding: 12px 14px; }
  .sticky-actions > div { width: 100%; justify-content: space-between; }
}
@media (max-width: 600px) {
  .input, select.input, textarea.input, .search input, .filter-input { font-size: 16px; } /* no iPhone zoom on focus */
}

/* Password rule checklist (issue #5) */
.pw-rules { display: flex; flex-wrap: wrap; gap: 6px; }
.pw-rules .tag.good::before { content: '✓'; }
