/* ============================================================
   VAR DASHBOARD — SHARED STYLES v4 (RESPONSIVE)
   Sidebar: drawer on mobile, fixed on desktop
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

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

:root {
  --primary: #2563eb;
  --primary-light: #dbeafe;
  --primary-dark: #1d4ed8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-2: #f1f5f9;
  --text-1: #0f172a;
  --text-2: #334155;
  --text-3: #64748b;
  --text-4: #94a3b8;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --indigo: #6366f1;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
  --shadow-xl: 0 20px 60px rgba(0,0,0,.18);
  --sidebar-w: 224px;
  --topbar-h: 56px;
}

html, body {
  height: 100%;
  font-family: 'DM Sans', sans-serif;
  background: var(--surface-2);
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.5;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

/* ══════════════════════════════════════
   LAYOUT
══════════════════════════════════════ */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* ══════════════════════════════════════
   SIDEBAR — Desktop: fixed left panel
             Mobile: off-canvas drawer
══════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 10px;
  overflow-y: auto;
  flex-shrink: 0;
  /* smooth slide transition for mobile */
  transition: transform .28s cubic-bezier(.4,0,.2,1), box-shadow .28s;
  z-index: 50;
}

/* ── Sidebar Brand ── */
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; margin-bottom: 20px; }
.sidebar-brand-icon { width: 34px; height: 34px; background: var(--primary); border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sidebar-brand-name { font-size: 13.5px; font-weight: 700; color: var(--text-1); line-height: 1.2; }
.sidebar-brand-sub { font-size: 10px; color: var(--text-4); }

/* ── Nav ── */
.sidebar-section-label { font-size: 10px; font-weight: 700; color: var(--text-4); letter-spacing: .08em; text-transform: uppercase; padding: 0 8px; margin-bottom: 5px; margin-top: 6px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; color: var(--text-3); cursor: pointer; text-decoration: none; transition: all .15s; white-space: nowrap; }
.nav-link:hover { background: var(--primary-light); color: var(--primary-dark); }
.nav-link.active { background: #dbeafe; color: var(--primary-dark); font-weight: 600; }
.nav-icon { width: 16px; height: 16px; flex-shrink: 0; }

/* ── Sidebar Footer ── */
.sidebar-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border-2); }
.sidebar-user { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--radius-sm); }
.sidebar-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--primary-light); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--primary-dark); flex-shrink: 0; }
.logout-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border-radius: var(--radius-sm); border: none; background: transparent; cursor: pointer; font-size: 12px; font-weight: 500; color: var(--text-4); font-family: 'DM Sans', sans-serif; transition: all .15s; }
.logout-btn:hover { background: #fee2e2; color: #dc2626; }

/* ── Overlay backdrop (mobile) ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  z-index: 49;
  backdrop-filter: blur(1px);
  opacity: 0;
  transition: opacity .28s;
}
.sidebar-overlay.show {
  display: block;
  opacity: 1;
}

/* ══════════════════════════════════════
   TOPBAR
══════════════════════════════════════ */
.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 12px;
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.topbar-title { font-size: 14.5px; font-weight: 700; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-sub { font-size: 11px; color: var(--text-4); margin-top: 1px; white-space: nowrap; }
.topbar-controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Secondary page toolbar: filters, search, and exports live below the topbar */
.page-toolbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.page-toolbar .filter-pill select { max-width: 150px; }
.page-toolbar .search-wrap.push-right,
.page-toolbar .toolbar-spacer { margin-left: auto; }
.page-toolbar .toolbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── Hamburger toggle — hidden on desktop, shown on mobile ── */
.menu-toggle {
  display: none;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-2);
  flex-shrink: 0;
  transition: all .15s;
}
.menu-toggle:hover { background: var(--primary-light); color: var(--primary); border-color: #93c5fd; }

/* ── Filter pill ── */
.filter-pill { display: flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 10px; font-size: 12px; white-space: nowrap; }
.filter-pill label { color: var(--text-3); font-weight: 500; }
.filter-pill select, .filter-pill input { background: transparent; border: none; outline: none; font-size: 12px; font-weight: 600; color: var(--text-1); cursor: pointer; font-family: 'DM Sans', sans-serif; max-width: 130px; }

/* ── Export / icon buttons ── */
.icon-btn { width: 32px; height: 32px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all .15s; color: var(--text-3); }
.icon-btn:hover { background: var(--primary-light); color: var(--primary); border-color: #93c5fd; }
.export-btn { display: flex; align-items: center; gap: 6px; background: var(--primary); color: #fff; border: none; border-radius: var(--radius-sm); padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer; transition: all .15s; font-family: 'DM Sans', sans-serif; white-space: nowrap; }
.export-btn:hover { background: var(--primary-dark); }
.export-btn:disabled { opacity: .6; cursor: not-allowed; }

/* ══════════════════════════════════════
   PAGE CONTENT
══════════════════════════════════════ */
.page-content { flex: 1; overflow-y: auto; padding: 18px 20px; }

/* ══════════════════════════════════════
   CARDS & STATS
══════════════════════════════════════ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); }
.card-p { padding: 16px 18px; }
.card-hover { transition: all .18s; }
.card-hover:hover { border-color: #93c5fd; box-shadow: var(--shadow-md); transform: translateY(-1px); }
.card-accent-top { position: relative; overflow: hidden; }
.card-accent-top::before { content:''; position:absolute; top:0; left:0; right:0; height:3px; background: var(--accent, var(--primary)); border-radius: var(--radius-md) var(--radius-md) 0 0; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px 16px; display: flex; align-items: flex-start; gap: 10px; transition: box-shadow .18s; }
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-icon { width: 36px; height: 36px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-val { font-size: 22px; font-weight: 700; color: var(--text-1); line-height: 1.1; }
.stat-label { font-size: 11px; color: var(--text-3); font-weight: 500; margin-bottom: 2px; }
.stat-sub { font-size: 10.5px; color: var(--text-4); margin-top: 2px; }

.stat-pill { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; text-align: center; }
.stat-pill-val { font-size: 16px; font-weight: 700; color: var(--text-1); line-height: 1.1; }
.stat-pill-lbl { font-size: 10px; color: var(--text-4); font-weight: 500; margin-top: 2px; }

/* ══════════════════════════════════════
   BADGES
══════════════════════════════════════ */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-amber  { background: #fef3c7; color: #92400e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-slate  { background: #f1f5f9; color: #475569; }

/* ══════════════════════════════════════
   SECTION CHIP
══════════════════════════════════════ */
.section-chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 12px; }
.chip-title { font-size: 10.5px; color: var(--text-3); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }

/* ══════════════════════════════════════
   TABLES
══════════════════════════════════════ */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; padding: 9px 12px; font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.data-table td { padding: 10px 12px; font-size: 12.5px; border-bottom: 1px solid var(--border-2); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background .12s; cursor: pointer; }
.data-table tbody tr:hover { background: var(--surface-2); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ══════════════════════════════════════
   SORT BUTTONS
══════════════════════════════════════ */
.sort-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.sort-label { font-size: 12px; color: var(--text-3); font-weight: 500; }
.sort-btn { padding: 5px 11px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 500; cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: var(--text-3); transition: all .15s; font-family: 'DM Sans', sans-serif; }
.sort-btn:hover { border-color: #93c5fd; color: var(--primary); }
.sort-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ══════════════════════════════════════
   BAR TRACKS
══════════════════════════════════════ */
.bar-track { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; flex: 1; }
.bar-fill { height: 100%; border-radius: 3px; transition: width .4s ease; }

/* ══════════════════════════════════════
   TABS
══════════════════════════════════════ */
.tab-bar { display: flex; border-bottom: 1px solid var(--border); gap: 2px; overflow-x: auto; }
.tab-btn { padding: 9px 14px; font-size: 13px; font-weight: 500; color: var(--text-3); border-bottom: 2px solid transparent; cursor: pointer; transition: all .15s; white-space: nowrap; font-family: 'DM Sans', sans-serif; background: none; border-top: none; border-left: none; border-right: none; }
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ══════════════════════════════════════
   MODAL
══════════════════════════════════════ */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; backdrop-filter: blur(3px); }
.modal-overlay.hidden { display: none; }
.modal-box { background: var(--surface); border-radius: var(--radius-xl); width: 100%; max-width: 800px; max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow-xl); }
.modal-band { height: 5px; border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
.modal-header { padding: 16px 20px 12px; border-bottom: 1px solid var(--border); }
.modal-close { width: 32px; height: 32px; border-radius: var(--radius-sm); background: var(--surface-2); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all .15s; }
.modal-close:hover { background: #fee2e2; color: var(--danger); }

/* ══════════════════════════════════════
   AVATAR
══════════════════════════════════════ */
.avatar { border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.avatar-sm { width: 30px; height: 30px; font-size: 11px; }
.avatar-md { width: 40px; height: 40px; font-size: 13px; }
.avatar-lg { width: 48px; height: 48px; font-size: 15px; }

/* ══════════════════════════════════════
   PAGINATION
══════════════════════════════════════ */
.pagination { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.page-btn { width: 30px; height: 30px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 500; cursor: pointer; transition: all .15s; border: 1px solid var(--border); color: var(--text-3); background: var(--surface); }
.page-btn:hover { background: var(--primary-light); border-color: #93c5fd; color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn.disabled { opacity: .4; pointer-events: none; }

/* ══════════════════════════════════════
   SPINNER
══════════════════════════════════════ */
.spinner-wrap { display: flex; align-items: center; justify-content: center; height: 100%; min-height: 200px; }
.spinner { border: 3px solid var(--border); border-top: 3px solid var(--primary); border-radius: 50%; width: 32px; height: 32px; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════
   SEARCH INPUT
══════════════════════════════════════ */
.search-wrap { position: relative; }
.search-wrap .search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--text-4); pointer-events: none; }
.search-input { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 10px 6px 30px; font-size: 12px; font-family: 'DM Sans', sans-serif; color: var(--text-1); outline: none; transition: border .15s; }
.search-input:focus { border-color: #93c5fd; }

/* ══════════════════════════════════════
   RANK ROW
══════════════════════════════════════ */
.rank-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border-2); }
.rank-row:last-child { border-bottom: none; }
.rank-row.highlight { background: #eff6ff; margin: 0 -8px; padding: 7px 8px; border-radius: 6px; border-bottom: none; }

/* ══════════════════════════════════════
   GRID UTILS
══════════════════════════════════════ */
.g2    { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.g3    { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.g4    { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.g-auto{ display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }

/* ══════════════════════════════════════
   TOGGLE
══════════════════════════════════════ */
.toggle-wrap { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.toggle-btn { padding: 5px 14px; border-radius: 6px; font-size: 12px; font-weight: 500; cursor: pointer; transition: all .15s; color: var(--text-3); background: transparent; border: none; font-family: 'DM Sans', sans-serif; }
.toggle-btn.active { background: var(--surface); color: var(--primary); font-weight: 600; box-shadow: var(--shadow-sm); }

/* ══════════════════════════════════════
   VIDEO CARD
══════════════════════════════════════ */
.video-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; cursor: pointer; transition: all .18s; }
.video-card:hover { border-color: #93c5fd; box-shadow: var(--shadow-md); transform: translateY(-2px); }
.video-thumb { background: linear-gradient(135deg, #1e293b, #334155); aspect-ratio: 16/9; display: flex; align-items: center; justify-content: center; position: relative; }
.video-play { width: 44px; height: 44px; background: rgba(255,255,255,.15); backdrop-filter: blur(4px); border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 2px solid rgba(255,255,255,.3); transition: all .2s; }
.video-card:hover .video-play { background: rgba(37,99,235,.8); border-color: transparent; transform: scale(1.1); }
.video-info { padding: 12px 14px; }
.video-meta { font-size: 10.5px; color: var(--text-4); margin-bottom: 4px; }
.video-title { font-size: 12.5px; font-weight: 600; color: var(--text-1); line-height: 1.3; }

/* ══════════════════════════════════════
   ENTITY CARDS (clubs / referees)
══════════════════════════════════════ */
.entity-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px; cursor: pointer; transition: all .18s; position: relative; overflow: hidden; }
.entity-card:hover { border-color: #93c5fd; box-shadow: var(--shadow-md); transform: translateY(-2px); }
.entity-card::before { content:''; position:absolute; top:0; left:0; right:0; height:3px; background: var(--accent, var(--primary)); border-radius: var(--radius-md) var(--radius-md) 0 0; }
.entity-avatar { border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }

/* ══════════════════════════════════════
   FILTER CHIPS / SELECTS (matchlog)
══════════════════════════════════════ */
.filter-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; cursor: pointer; border: 1px solid var(--border); }
.filter-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.filter-chip:not(.active) { background: var(--surface-2); color: var(--text-3); }
.filter-chip:hover:not(.active) { background: var(--primary-light); color: var(--primary); border-color: #93c5fd; }
select.filter-sel { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 5px 9px; font-size: 12px; font-family: 'DM Sans', sans-serif; color: var(--text-2); outline: none; cursor: pointer; }
.active-filter-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 14px; background: #eff6ff; border-bottom: 1px solid #dbeafe; font-size: 11px; color: #1d4ed8; flex-shrink: 0; }
.active-filter-tag { display: inline-flex; align-items: center; gap: 4px; background: #fff; border: 1px solid #bfdbfe; padding: 2px 7px; border-radius: 20px; font-weight: 500; }
.filter-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; }

/* ══════════════════════════════════════
   MATCHLOG ROW
══════════════════════════════════════ */
.log-row { display: grid; grid-template-columns: 22px 46px 80px 50px 1fr 80px 80px 90px 66px 52px 46px; gap: 6px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border-2); font-size: 12px; cursor: pointer; transition: background .1s; }
.log-row:hover { background: var(--surface-2); }
.log-header-row { font-size: 10px; font-weight: 600; color: var(--text-4); text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); border-bottom: 1px solid var(--border); cursor: default; }
.log-header-row:hover { background: var(--surface-2); }

/* ══════════════════════════════════════
   INCIDENT ROW (fixtures modal)
══════════════════════════════════════ */
.inc-row { display: grid; grid-template-columns: 28px 1fr 88px 108px 76px 68px 1fr 46px; gap: 6px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--border-2); font-size: 11.5px; }
.inc-row:last-child { border-bottom: none; }
.inc-header { font-size: 10px; font-weight: 600; color: var(--text-4); text-transform: uppercase; letter-spacing: .04em; }

/* ══════════════════════════════════════
   SUMMARY / KPI
══════════════════════════════════════ */
.kpi-big-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 16px; text-align: center; }
.kpi-big-val  { font-size: 28px; font-weight: 700; color: var(--text-1); line-height: 1; }
.kpi-big-lbl  { font-size: 11px; color: var(--text-4); font-weight: 500; margin-top: 5px; }
.kpi-big-sub  { font-size: 11px; font-weight: 600; margin-top: 3px; }
.leaderboard-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border-2); font-size: 12px; }
.leaderboard-row:last-child { border-bottom: none; }

/* ══════════════════════════════════════
   UPLOAD HINT
══════════════════════════════════════ */
.upload-hint { background: linear-gradient(135deg, #eff6ff, #dbeafe); border: 1px solid #bfdbfe; border-radius: var(--radius-md); padding: 14px 18px; margin-bottom: 14px; display: flex; align-items: center; gap: 12px; }


/* ████████████████████████████████████
   RESPONSIVE BREAKPOINTS
████████████████████████████████████ */

/* ── TABLET ≤ 1024px ── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 200px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .g4 { grid-template-columns: repeat(2, 1fr); }
  .g3 { grid-template-columns: 1fr 1fr; }
  .topbar-sub { display: none; }
  .filter-pill label { display: none; }
  .log-row { grid-template-columns: 22px 44px 76px 1fr 76px 76px 58px 44px; }
  .log-row > *:nth-child(4), .log-row > *:nth-child(6) { display: none; }
}

/* ── MOBILE ≤ 768px ── */
@media (max-width: 768px) {
  :root { --topbar-h: 52px; }

  /* Sidebar becomes off-canvas drawer */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    box-shadow: none;
  }
  /* When .open is added by JS, slide in */
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }

  /* Show hamburger button */
  .menu-toggle { display: flex; }

  /* Stack grids */
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .g2  { grid-template-columns: 1fr; }
  .g3  { grid-template-columns: 1fr 1fr; }
  .g4  { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .g-auto { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

  /* Tighter spacing */
  .page-content { padding: 12px 13px; }
  .topbar { padding: 0 13px; gap: 8px; }
  .topbar-title { font-size: 13px; }
  .topbar-controls { gap: 5px; }
  /* Hide secondary topbar controls on mobile, keep only first filter + export */
  .topbar-controls > *:not(:first-child):not(:last-child) { display: none; }
  .filter-pill { padding: 4px 8px; }
  .filter-pill select { max-width: 90px; font-size: 11px; }
  .page-toolbar { padding: 8px 13px; gap: 6px; }
  .page-toolbar .filter-pill label { display: none; }
  .page-toolbar .search-wrap.push-right,
  .page-toolbar .toolbar-spacer { margin-left: 0; }
  .page-toolbar .search-wrap { width: 100%; }
  .page-toolbar .search-input { width: 100% !important; }
  .page-toolbar .toolbar-actions { margin-left: 0; }

  /* Cards */
  .stat-card { padding: 11px 12px; }
  .stat-val { font-size: 19px; }
  .stat-icon { width: 32px; height: 32px; }
  .section-chip { padding: 11px 12px; }

  /* Tables: allow scroll */
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table th, .data-table td { padding: 8px 9px; font-size: 11.5px; }

  /* Matchlog row — show fewer columns */
  .log-row { grid-template-columns: 1fr 72px 56px 36px; font-size: 11px; }
  .log-row > *:nth-child(1),
  .log-row > *:nth-child(2),
  .log-row > *:nth-child(4),
  .log-row > *:nth-child(5),
  .log-row > *:nth-child(6),
  .log-row > *:nth-child(7),
  .log-row > *:nth-child(11) { display: none; }

  /* Modal: bottom sheet on mobile */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-box { max-width: 100%; max-height: 94vh; border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
  .modal-band { border-radius: var(--radius-xl) var(--radius-xl) 0 0; }

  /* Entity cards */
  .entity-card { padding: 11px 12px; }

  /* Incident row in modal */
  .inc-row { grid-template-columns: 24px 1fr 68px 76px 56px; }
  .inc-row > *:nth-child(6),
  .inc-row > *:nth-child(7),
  .inc-row > *:nth-child(8) { display: none; }

  /* Sort bar */
  .sort-btn { padding: 3px 8px; font-size: 11px; }

  /* KPI */
  .kpi-big-val { font-size: 22px; }

  /* Upload hint */
  .upload-hint { flex-direction: column; gap: 8px; text-align: center; }

  /* Filter row (matchlog) */
  .filter-row { padding: 8px 10px; gap: 5px; }
  select.filter-sel { font-size: 11px; padding: 4px 7px; }
}

/* ── SMALL MOBILE ≤ 480px ── */
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .g3  { grid-template-columns: 1fr; }
  .g4  { grid-template-columns: 1fr 1fr; }
  .stat-val { font-size: 17px; }
  .stat-icon { width: 30px; height: 30px; }
  .kpi-big-val { font-size: 20px; }
  .tab-btn { padding: 7px 10px; font-size: 12px; }
  .sort-btn { font-size: 10.5px; padding: 3px 7px; }
  /* Export btn: icon only */
  .export-btn span { display: none; }
  .export-btn { padding: 6px 9px; }
}
