/* ILS brand fonts, self-hosted (see /css/fonts) - no runtime CDN dependency */
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 700; font-display: swap; src: url('fonts/poppins-700.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 800; font-display: swap; src: url('fonts/poppins-800.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 900; font-display: swap; src: url('fonts/poppins-900.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/montserrat-400.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 500; font-display: swap; src: url('fonts/montserrat-500.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 600; font-display: swap; src: url('fonts/montserrat-600.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 700; font-display: swap; src: url('fonts/montserrat-700.woff2') format('woff2'); }

:root {
  /* ---- Light theme, ILS branded ---- */
  --bg: #f7f7f5;
  --bg-card: #ffffff;
  --bg-elevated: #f0f2ee;
  --bg-card-hover: #eaede8;
  --border: #e3e6e1;
  --border-light: #d3d8d1;
  --text: #1c2620;
  --text-dim: #5c6b61;
  --text-faint: #8b988e;

  /* ILS brand hexes, exact - used for the header masthead and the green "hero" cards. */
  --ils-green: #004B23;
  --ils-gold: #FFC20E;

  /* readable-on-white variants for plain text/links/icons (raw --ils-green is dark
     enough to use directly as text; raw gold is too light to read as text on white,
     so --gold-dark exists for that specific case - see badge.gold/alert-warn below) */
  --accent: #0B7A3D;
  --accent-dim: #086030;
  --gold: #FFC20E;
  --gold-dark: #96690A;
  --accent-blue: #1D4ED8;
  --silver: #78828c;
  --bronze: #9c5a28;

  /* chip/pill backgrounds (always paired with their own contrasting text, so these stay
     vivid regardless of page theme) vs. plain-text-on-white variants (up/down) */
  --win: #1FA668;
  --loss: #FF5D6C;
  --draw: #9aa4a0;
  --up: #0B7A3D;
  --down: #B3261E;

  /* the green "hero card" surface - stat tiles, champion callouts. Establishes its own
     local --text/--accent/etc scope (see .card-brand) so nested content automatically
     renders in white/gold without per-component overrides. */
  --card-brand-bg: #004B23;
  --card-brand-bg-elevated: #0a5c30;
  --card-brand-bg-hover: #0d6b39;
  --card-brand-border: rgba(255,255,255,0.18);
  --card-brand-border-light: rgba(255,255,255,0.3);
  --card-brand-text: #ffffff;
  --card-brand-text-dim: #cfe8da;
  --card-brand-text-faint: #9fc6ae;

  --radius: 10px;
  --shadow: 0 2px 10px rgba(20,30,24,0.08);
  --font: 'Montserrat', 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --font-heading: 'Poppins', 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0 0 0.5em; font-family: var(--font-heading); font-weight: 700; letter-spacing: 0.01em; }
p { margin: 0 0 0.75em; }
img { max-width: 100%; }
button { font-family: inherit; }

/* ---------- App shell: collapsible icon sidebar ---------- */
:root { --sidebar-w: 68px; --sidebar-w-expanded: 236px; }

.app-shell { display: flex; min-height: 100vh; }

/* Green masthead, now vertical - establishes the same light-on-green local scope as
   before so nav links/footer/icons all render in white/gold with zero per-component
   overrides. Collapsed to an icon-only rail by default; widens on hover (desktop) or
   when pinned/opened (mobile drawer) - see js/app.js's setupNav. */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w); z-index: 300;
  background: linear-gradient(180deg, #00612f 0%, var(--ils-green) 100%);
  border-right: 1px solid rgba(255,255,255,0.15);
  display: flex; flex-direction: column; overflow: hidden;
  transition: width .18s ease;
  --text: #ffffff;
  --text-dim: #cfe8da;
  --text-faint: #a3ceb5;
  --border: rgba(255,255,255,0.15);
  --border-light: rgba(255,255,255,0.28);
  --bg-card: rgba(255,255,255,0.1);
  --bg-elevated: rgba(255,255,255,0.08);
  --bg-card-hover: rgba(255,255,255,0.18);
  color: var(--text);
}
@media (hover: hover) {
  .sidebar:hover { width: var(--sidebar-w-expanded); }
}
.sidebar.pinned { width: var(--sidebar-w-expanded); }

.sidebar-label { display: inline-block; opacity: 0; max-width: 0; overflow: hidden; white-space: nowrap; transition: opacity .12s, max-width .18s; }
.sidebar:hover .sidebar-label, .sidebar.pinned .sidebar-label { opacity: 1; max-width: 180px; }

.sidebar-top { display: flex; align-items: center; gap: 2px; padding: 12px 8px; flex-shrink: 0; }
.sidebar-logo { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.sidebar-logo-badge { width: 46px; height: 46px; object-fit: contain; flex-shrink: 0; display: block; }
.sidebar-brand-text { font-family: var(--font-heading); font-weight: 800; font-size: 0.95rem; letter-spacing: 0.01em; }

.sidebar-pin, .sidebar-close-mobile {
  background: none; border: none; color: var(--text-dim); cursor: pointer; flex-shrink: 0;
  width: 28px; height: 28px; border-radius: 6px; display: flex; align-items: center; justify-content: center;
}
.sidebar-pin svg, .sidebar-close-mobile svg { width: 16px; height: 16px; transition: transform .18s; }
.sidebar-pin:hover, .sidebar-close-mobile:hover { background: var(--bg-card-hover); color: var(--text); }
/* display:none rather than just opacity:0 while collapsed, so the invisible pin button
   doesn't still reserve its 28px of flex space and squeeze the logo off-center. */
.sidebar-pin { display: none; }
.sidebar:hover .sidebar-pin, .sidebar.pinned .sidebar-pin { display: flex; }
.sidebar.pinned .sidebar-pin svg { transform: rotate(180deg); }
.sidebar-close-mobile { display: none; }

.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 6px 8px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-footer { flex-shrink: 0; padding: 10px 8px 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }

.sidebar-nav a, .sidebar-footer a, .sidebar-footer button {
  display: flex; align-items: center; gap: 14px; padding: 10px 12px; border-radius: 8px;
  color: var(--text-dim); font-weight: 600; font-size: 0.88rem; white-space: nowrap;
  background: none; border: none; cursor: pointer; font-family: inherit; text-align: left; width: 100%;
  transition: background .15s, color .15s;
}
.sidebar-nav a svg, .sidebar-footer a svg, .sidebar-footer button svg { width: 20px; height: 20px; flex-shrink: 0; }
.sidebar-nav a:hover, .sidebar-footer a:hover, .sidebar-footer button:hover { background: var(--bg-card-hover); color: var(--text); }
.sidebar-nav a.active { background: var(--gold); color: #1a1400; }
.auth-error { font-size: 0.8rem; color: #ffb4b4; font-weight: 600; padding: 6px 12px; }

.sidebar-backdrop { display: none; }

/* ---------- Main content area + top bar ---------- */
.app-main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }

.topbar { display: flex; align-items: center; gap: 14px; padding: 12px 20px; background: var(--bg-card); border-bottom: 1px solid var(--border); }
.nav-toggle {
  display: none; background: none; border: none; color: var(--text); cursor: pointer;
  padding: 6px; border-radius: 6px; align-items: center; justify-content: center;
}
.nav-toggle svg { width: 22px; height: 22px; }
.nav-toggle:hover { background: var(--bg-elevated); }

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 12px; min-width: 220px; max-width: 360px;
}
.search-box input {
  background: transparent; border: none; outline: none; color: var(--text); font-size: 0.85rem; width: 100%;
}
.search-box input::placeholder { color: var(--text-faint); }

.search-results {
  position: absolute; margin: 4px 0 0 20px; background: #ffffff; border: 1px solid var(--border-light, #d3d8d1);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(20,30,24,0.18); max-height: 320px; overflow-y: auto; min-width: 260px; z-index: 100;
}
.search-results a { display: block; padding: 8px 12px; font-size: 0.85rem; border-bottom: 1px solid #eceeea; color: #1c2620; }
.search-results a:hover { background: #f0f2ee; }

.page-container { max-width: 1400px; margin: 0 auto; padding: 24px 20px 64px; }

.page-title { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.page-title h1 { font-size: 1.6rem; color: var(--ils-green); }
.page-subtitle { color: var(--text-dim); font-size: 0.9rem; }

/* ---------- Layout helpers ---------- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card-title { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); margin-bottom: 8px; font-weight: 700; }

/* The green "hero card" - stat tiles and brand callouts (Current Champion, etc). Redefines
   the shared tokens locally so every nested component (card-title, buttons, links) just
   works via the same var() rules used everywhere else, in white/gold instead of dark text. */
.card-brand, .stat-tile {
  background: var(--card-brand-bg);
  border: 1px solid var(--card-brand-border);
  color: var(--card-brand-text);
  --text: var(--card-brand-text);
  --text-dim: var(--card-brand-text-dim);
  --text-faint: var(--card-brand-text-faint);
  --border: var(--card-brand-border);
  --border-light: var(--card-brand-border-light);
  --bg-elevated: var(--card-brand-bg-elevated);
  --bg-card-hover: var(--card-brand-bg-hover);
  --accent: var(--gold);
}
.stat-tile { text-align: center; padding: 18px 12px; }
.stat-tile .value { font-size: 2rem; font-weight: 800; color: var(--gold); font-family: var(--font-heading); }
.stat-tile .label { font-size: 0.78rem; color: var(--card-brand-text-dim); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 4px; }

.section { margin-bottom: 28px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.section-head h2 { font-size: 1.1rem; color: var(--ils-green); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; min-width: 640px; }
thead th {
  text-align: left; padding: 10px 12px; background: var(--bg-elevated); color: var(--text-faint);
  text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.06em; border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--bg-card); }
tbody tr:hover td { background: var(--bg-card-hover); }
tbody tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Player / rank ---------- */
.player-link { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--bg-elevated);
  display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 800;
  color: var(--accent); border: 1px solid var(--border-light); flex-shrink: 0;
}
.avatar-lg { width: 72px; height: 72px; font-size: 1.4rem; }
.rank-badge { font-weight: 800; font-variant-numeric: tabular-nums; }
.rank-1 { color: var(--gold-dark); }
.rank-2 { color: var(--silver); }
.rank-3 { color: var(--bronze); }

.movement { font-size: 0.8rem; font-weight: 700; }
.movement.up { color: var(--up); }
.movement.down { color: var(--down); }
.movement.same { color: var(--text-faint); }
.movement.new { color: var(--accent-blue); }

.form-dots { display: flex; gap: 3px; }
.form-dot {
  width: 20px; height: 20px; border-radius: 5px; display: flex; align-items: center; justify-content: center;
  font-size: 0.68rem; font-weight: 800; color: #06110c;
}
.form-dot.W { background: var(--win); }
.form-dot.L { background: var(--loss); color: #2a0409; }
.form-dot.D { background: var(--draw); color: #06110c; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; background: var(--bg-elevated); border: 1px solid var(--border-light); color: var(--text-dim);
}
.badge.gold { background: rgba(255,194,14,0.14); color: var(--gold-dark); border-color: rgba(255,194,14,0.4); }
.badge.accent { background: rgba(11,122,61,0.1); color: var(--accent); border-color: rgba(11,122,61,0.3); }

.title-chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; background: var(--bg-elevated); border: 1px solid var(--border-light); font-size: 0.78rem; font-weight: 700; margin: 2px; }

/* ---------- Buttons / forms ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border-light);
  background: var(--bg-elevated); color: var(--text); font-weight: 700; font-size: 0.85rem; cursor: pointer; transition: all .15s;
}
.btn:hover { background: var(--bg-card-hover); border-color: var(--accent-dim); }
.btn-primary { background: var(--gold); color: #1a1400; border-color: var(--gold); }
.btn-primary:hover { background: #ffcf3d; }
.btn-danger { border-color: rgba(179,38,30,0.4); color: var(--down); }
.btn-danger:hover { background: rgba(179,38,30,0.08); }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

input, select, textarea {
  background: var(--bg-card); border: 1px solid var(--border-light); border-radius: 6px; color: var(--text);
  padding: 8px 10px; font-size: 0.85rem; font-family: inherit;
}
input:disabled { background: var(--bg-elevated); color: var(--text-faint); cursor: not-allowed; }
label { display: block; font-size: 0.78rem; color: var(--text-dim); margin-bottom: 4px; font-weight: 600; }
.field { margin-bottom: 12px; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tab-btn { padding: 8px 14px; border-radius: 8px 8px 0 0; color: var(--text-dim); font-weight: 700; font-size: 0.85rem; cursor: pointer; border: none; background: transparent; }
.tab-btn.active { color: var(--accent); background: var(--bg-card); border: 1px solid var(--border); border-bottom: none; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-faint); }

/* ---------- Champion / hero ---------- */
.hero-champion { display: flex; align-items: center; gap: 20px; }
.hero-champion .avatar { width: 80px; height: 80px; font-size: 1.6rem; }
.champion-crown { font-size: 1.8rem; }

.result-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); gap: 10px; flex-wrap: wrap; }
.result-row:last-child { border-bottom: none; }
.score-pill { font-weight: 800; padding: 4px 10px; border-radius: 6px; background: var(--bg-elevated); }

/* ---------- Bracket ---------- */
.bracket { display: flex; gap: 30px; overflow-x: auto; padding: 10px 0; }
.bracket-round { display: flex; flex-direction: column; justify-content: space-around; gap: 20px; min-width: 220px; }
.bracket-round h4 { text-align: center; color: var(--text-faint); font-size: 0.78rem; text-transform: uppercase; }
.bracket-match { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.bracket-slot { display: flex; justify-content: space-between; padding: 5px 8px; border-radius: 5px; font-size: 0.82rem; }
.bracket-slot.winner { background: rgba(11,122,61,0.1); font-weight: 800; color: var(--accent); }

/* ---------- Alerts ---------- */
.alert { padding: 12px 14px; border-radius: 8px; font-size: 0.85rem; margin-bottom: 12px; border: 1px solid; }
.alert-warn { background: rgba(255,194,14,0.12); border-color: rgba(255,194,14,0.4); color: var(--gold-dark); }
.alert-error { background: rgba(179,38,30,0.08); border-color: rgba(179,38,30,0.3); color: var(--down); }
.alert-ok { background: rgba(11,122,61,0.08); border-color: rgba(11,122,61,0.3); color: var(--accent); }
.alert-info { background: rgba(29,78,216,0.08); border-color: rgba(29,78,216,0.3); color: var(--accent-blue); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 1000;
  padding: 12px 18px; border-radius: 8px; font-weight: 700; font-size: 0.88rem;
  box-shadow: 0 8px 24px rgba(20,30,24,0.18); opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: opacity .2s, transform .2s;
  background: #ffffff; border: 1px solid var(--border-light); color: var(--text);
  max-width: min(360px, calc(100vw - 32px));
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-saving { border-color: var(--accent-blue); color: var(--accent-blue); }
.toast-success { border-color: var(--accent); color: var(--accent); }
.toast-error { border-color: var(--down); color: var(--down); }
@media (max-width: 600px) {
  .toast { left: 16px; right: 16px; bottom: 16px; max-width: none; text-align: center; }
}

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,20,17,0.6); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px; }
.modal { background: #ffffff; border: 1px solid var(--border-light); border-radius: 12px; padding: 22px; max-width: 560px; width: 100%; max-height: 86vh; overflow-y: auto; box-shadow: 0 12px 32px rgba(20,30,24,0.22); }
.modal-close { float: right; cursor: pointer; color: var(--text-faint); font-size: 1.1rem; }

/* ---------- Display mode ----------
   Runs full-screen on TVs of very different sizes/resolutions with nobody around to
   scroll it, so two things matter: text must scale with the viewport (clamp() against
   both vw and vh, not a fixed rem) rather than only having one 600px phone breakpoint,
   and .dm-body must be allowed to shrink/scroll (min-height:0 + overflow-y:auto) instead
   of silently clipping when a slide's content is taller than a shorter/lower-res screen. */
.display-mode {
  position: fixed; inset: 0; background: linear-gradient(180deg, #ffffff 0%, #eef3ee 100%);
  color: var(--text); z-index: 500; display: flex; flex-direction: column;
  padding: clamp(16px, 3vh, 40px) clamp(16px, 4vw, 60px);
}
.display-mode .dm-header, .display-mode .dm-title, .display-mode .dm-body { padding-right: clamp(90px, 18vw, 240px); }
.display-mode .dm-header { font-size: clamp(1rem, 2.4vh, 1.6rem); font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); margin-bottom: clamp(6px, 1.4vh, 10px); flex-shrink: 0; }
.display-mode .dm-title { font-family: var(--font-heading); font-size: clamp(1.5rem, 5vh, 3rem); font-weight: 900; margin-bottom: clamp(14px, 3vh, 30px); background: linear-gradient(90deg, var(--ils-green), var(--gold-dark)); -webkit-background-clip: text; background-clip: text; color: transparent; flex-shrink: 0; }
.display-mode .dm-body { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.display-mode table { font-size: clamp(0.78rem, 2vh, 1.3rem); }
.display-mode thead th { padding: clamp(4px, 1vh, 10px) 12px; }
.display-mode tbody td { padding: clamp(4px, 1vh, 10px) 12px; }
.display-mode .dm-exit { position: absolute; top: 20px; right: 24px; opacity: 0.5; z-index: 2; }
.display-mode .dm-exit:hover { opacity: 1; }

/* Fills over the rotation interval (see js/pages/display.js's startProgressBar) so
   viewers can see how much longer the current slide has before it advances. */
.dm-progress { height: 5px; border-radius: 3px; background: var(--border); overflow: hidden; flex-shrink: 0; margin-top: clamp(10px, 2vh, 20px); }
.dm-progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--ils-green), var(--gold-dark)); }

/* Tournament Spotlight - one card, two columns, instead of two separate cards - so the
   shared padding/border overhead doesn't eat into the room needed to fit the QR code
   without .dm-body having to scroll. */
.dm-tourney-card { display: flex; flex-direction: column; justify-content: center; height: 100%; padding: clamp(14px, 2.5vh, 28px) clamp(16px, 3vw, 32px); }
.dm-tourney-split { display: flex; align-items: center; gap: clamp(16px, 3vw, 32px); }
.dm-tourney-col { flex: 1; min-width: 0; text-align: center; }
.dm-tourney-divider { width: 1px; align-self: stretch; background: var(--border); flex-shrink: 0; }
.dm-qr-inline { width: clamp(52px, 8vh, 84px); height: clamp(52px, 8vh, 84px); flex-shrink: 0; }
.dm-qr-inline svg { display: block; width: 100%; height: 100%; }
@media (max-width: 700px) {
  .dm-tourney-split { flex-direction: column; }
  .dm-tourney-divider { width: 60%; height: 1px; }
}

/* Content-size utility classes used by js/pages/display.js instead of one-off inline
   font-size styles, so every slide scales together with the same clamp() rules above. */
.dm-name { font-weight: 800; font-size: clamp(1rem, 2.4vh, 1.3rem); }
.dm-big { font-weight: 900; font-size: clamp(1.2rem, 3.4vh, 1.8rem); }
.dm-huge { font-size: clamp(1.8rem, 5.5vh, 2.8rem); }
.dm-sub { font-size: clamp(0.85rem, 1.9vh, 1.1rem); }
.dm-row { font-size: clamp(0.9rem, 2.2vh, 1.2rem); }

.dm-qr {
  position: absolute; top: 56px; right: 24px; z-index: 1;
  display: flex; flex-direction: row-reverse; align-items: center; gap: 12px;
  background: #ffffff; border: 1px solid var(--border-light); border-radius: 12px;
  padding: 10px 14px; box-shadow: var(--shadow);
}
.dm-qr-box { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 6px; width: 76px; height: 76px; flex-shrink: 0; }
.dm-qr-box svg { display: block; width: 100%; height: 100%; }
.dm-qr-label { font-size: 0.8rem; font-weight: 700; color: var(--text-dim); line-height: 1.3; text-align: right; }
@media (max-width: 700px) {
  .dm-qr { top: 44px; right: 12px; padding: 6px 10px; gap: 8px; }
  .dm-qr-box { width: 52px; height: 52px; }
  .dm-qr-label { font-size: 0.62rem; }
}

/* ---------- Footer ---------- */
.app-footer { text-align: center; padding: 30px 20px; color: var(--text-faint); font-size: 0.78rem; border-top: 1px solid var(--border); }

/* ---------- Responsive nav: sidebar becomes an off-canvas drawer ---------- */
@media (max-width: 860px) {
  .app-main { margin-left: 0; }
  .sidebar {
    width: var(--sidebar-w-expanded); transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: 0 0 0 transparent;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 8px 0 24px rgba(0,0,0,0.25); }
  /* No hover-to-peek on a drawer - it's either fully open or fully off-screen, and
     labels are always legible once it's open regardless of pointer position. */
  .sidebar .sidebar-label { opacity: 1; max-width: 180px; }
  .sidebar-pin { display: none; }
  .sidebar-close-mobile { display: flex; }
  .nav-toggle { display: flex; }
  .sidebar-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(10,15,12,0.45); z-index: 290; }
}

@media (max-width: 600px) {
  .page-container { padding: 16px 12px 48px; }
  table { min-width: 520px; }
}

@media (max-width: 480px) {
  .page-title h1 { font-size: 1.25rem; }
  .card { padding: 12px; }
  .stat-tile { padding: 14px 10px; }
  .stat-tile .value { font-size: 1.5rem; }
  .btn { padding: 8px 12px; }
  .badge { padding: 3px 7px; }
  .section-head h2 { font-size: 1rem; }
  .sidebar-brand-text { font-size: 0.88rem; }
  .sidebar-logo-badge { width: 30px; height: 30px; }
  .search-box { min-width: 0; }
}
