:root {
  --paper: #F7F4EF;
  --paper-soft: #EFEAE0;
  --card: #FFFFFF;
  --ink: #1A1209;
  --ink-soft: #5C4D3C;
  --ink-muted: #9C8B78;
  --clay: #B5713F;
  --clay-deep: #8A4F28;
  --clay-light: #E8CDB5;
  --clay-pale: #F5E8DC;
  --slate: #2E4A5E;
  --slate-deep: #1C3140;
  --slate-pale: #DDE6ED;
  --sage: #4F7A5C;
  --sage-pale: #DAE8DC;
  --rust: #A23B2E;
  --rust-pale: #F0D5D0;
  --line: #DDD4C5;
  --line-soft: #EDE6D8;
  --r-lg: 16px;
  --r-md: 10px;
  --r-sm: 6px;
  --sh-sm: 0 1px 4px rgba(26,18,9,0.05), 0 2px 10px rgba(26,18,9,0.06);
  --sh-md: 0 4px 16px rgba(26,18,9,0.07), 0 1px 3px rgba(26,18,9,0.05);
  --font-d: 'Playfair Display', serif;
  --font-b: 'Poppins', sans-serif;
  --font-m: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font-b);
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--clay-light); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ─── TENUN DIVIDER ─── */
.tenun-rule {
  height: 3px;
  width: 100%;
  background: repeating-linear-gradient(
    90deg,
    var(--clay) 0 12px,
    var(--clay-deep) 12px 14px,
    transparent 14px 19px,
    var(--slate) 19px 26px,
    transparent 26px 30px
  );
  opacity: 0.45;
  border-radius: 2px;
  margin: 0 0 24px;
}

/* ─── APP SHELL ─── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 256px;
  flex-shrink: 0;
  background: var(--slate-deep);
  color: #EDE6DA;
  display: flex;
  flex-direction: column;
  padding: 22px 14px 20px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 200;
  transition: transform .22s cubic-bezier(.4,0,.2,1);
  border-right: 1px solid rgba(0,0,0,0.18);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 2px 8px 18px;
  border-bottom: 1px solid rgba(237,230,218,0.11);
  margin-bottom: 14px;
}
.sidebar-logo { width: 38px; height: 44px; flex-shrink: 0; object-fit: contain; }
.brand-title-side {
  font-family: var(--font-d);
  font-weight: 800;
  letter-spacing: 1px;
  font-size: 17px;
  color: #fff;
}
.brand-sub-side {
  font-family: var(--font-b);
  font-size: 9.5px;
  line-height: 1.4;
  color: #BFB09A;
  margin-top: 3px;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }

.nav-section-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--clay);
  opacity: .85;
  margin: 16px 8px 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  text-align: left;
  font-family: var(--font-b);
  font-size: 12px;
  font-weight: 500;
  color: #D9CFBE;
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 9px 10px;
  cursor: pointer;
  line-height: 1.35;
  transition: background .12s ease, color .12s ease;
}
.nav-item .nav-icon { flex-shrink: 0; width: 16px; height: 16px; opacity: .75; }
.nav-item:hover { background: rgba(237,230,218,0.08); color: #fff; }
.nav-item.active { background: var(--clay); color: #fff; font-weight: 600; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-item:focus-visible { outline: 2px solid var(--clay-light); outline-offset: 2px; }

.sidebar-foot {
  margin-top: auto;
  padding: 14px 8px 2px;
  font-size: 10px;
  color: #8C7E6C;
  border-top: 1px solid rgba(237,230,218,0.1);
  line-height: 1.6;
}

.sidebar-toggle {
  display: none;
  position: fixed; top: 14px; left: 14px; z-index: 300;
  width: 40px; height: 40px; border-radius: 9px;
  background: var(--slate-deep); color: #fff; border: none;
  font-size: 18px; cursor: pointer; box-shadow: var(--sh-md);
}
.sidebar-overlay { display: none; }

.content {
  flex: 1;
  margin-left: 256px;
  padding: 30px 36px 56px;
  min-width: 0;
}

@media (max-width: 880px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: flex; align-items: center; justify-content: center; }
  .sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(28,49,64,0.5); z-index: 150;
  }
  .sidebar-overlay.open { display: block; }
  .content { margin-left: 0; padding: 72px 16px 48px; }
}

/* ─── PAGE TRANSITIONS ─── */
.page { display: none; }
.page.active { display: block; animation: fadeUp .28s ease; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ─── HEADER ─── */
.dash-header { margin-bottom: 16px; }
.eyebrow {
  font-family: var(--font-m);
  font-size: 10.5px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--clay-deep);
  margin-bottom: 7px;
  font-weight: 700;
}
.brand-title {
  font-family: var(--font-d);
  font-weight: 800;
  font-size: 30px;
  color: var(--ink);
  letter-spacing: 0.2px;
}
.brand-sub {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 5px;
}

/* ─── TOOLBAR ─── */
.data-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 20px;
  flex-wrap: wrap;
}

.status {
  font-family: var(--font-m);
  font-size: 11px;
  padding: 5px 11px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.status::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status.loading { background: var(--slate-pale); color: var(--slate-deep); }
.status.loading::before { background: var(--slate); animation: pulse 1.2s ease-in-out infinite; }
.status.ok { background: var(--sage-pale); color: #265233; }
.status.ok::before { background: var(--sage); }
.status.error { background: var(--rust-pale); color: #7A2A20; }
.status.error::before { background: var(--rust); }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.3; } }

.btn {
  font-family: var(--font-b);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform .1s ease, box-shadow .1s ease, background .1s ease;
  white-space: nowrap;
}
.btn:hover { box-shadow: var(--sh-sm); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--slate); outline-offset: 2px; }
.btn.primary { background: var(--clay); color: #fff; border-color: var(--clay); }
.btn.primary:hover { background: var(--clay-deep); }
.btn svg { width: 13px; height: 13px; flex-shrink: 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ─── DASHBOARD: TOP ROW ─── */
.top-row {
  display: flex;
  gap: 18px;
  align-items: stretch;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

/* ─── TOTAL CARD ─── */
.total-card {
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-md);
  padding: 24px 26px 20px;
  flex: 0 0 310px;
  min-width: 270px;
  position: relative;
  overflow: hidden;
}
.total-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--clay) 0%, var(--slate) 100%);
}
.total-card h2 {
  font-family: var(--font-d);
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 2px;
}
.period {
  font-family: var(--font-m);
  font-size: 10px;
  color: var(--ink-muted);
  margin-bottom: 18px;
  letter-spacing: .3px;
}
.donut-wrap {
  position: relative;
  width: 176px; height: 176px;
  margin: 0 auto 12px;
}
.donut { width: 176px; height: 176px; border-radius: 50%; }
.donut-hole {
  position: absolute;
  top: 16px; left: 16px;
  width: 144px; height: 144px;
  background: var(--card);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.big-num {
  font-family: var(--font-m);
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  line-height: 1.1;
}
.donut-label {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  text-align: center;
}
.donut-label.left { left: -70px; }
.donut-label.right { right: -70px; }
.donut-label .lbl {
  display: block;
  font-family: var(--font-m);
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--ink-muted);
}
.donut-label .val {
  display: block;
  font-family: var(--font-m);
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
}
.province {
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-top: 4px;
}

/* ─── CHART CARD ─── */
.chart-card {
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-md);
  padding: 22px 22px 14px;
  flex: 1 1 320px;
  min-width: 280px;
  min-height: 0;
}
.chart-card h3 {
  font-family: var(--font-d);
  font-size: 15px;
  margin-bottom: 12px;
  color: var(--ink);
}
.chart-card canvas { max-height: 210px; }

/* ─── CHART ROW ─── */
.chart-row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

/* ─── STAT GRID PANEL ─── */
.data-panel {
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-md);
  padding: 22px 24px 12px;
}
.data-panel h3 {
  font-family: var(--font-d);
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--ink);
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 12px;
  padding-bottom: 14px;
}
@media (max-width: 900px) { .stat-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 560px) { .stat-grid { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  transition: border-color .12s, box-shadow .12s;
}
.stat-card:hover { border-color: var(--clay-light); box-shadow: var(--sh-sm); }
.stat-label { font-size: 11px; color: var(--ink-soft); margin-bottom: 5px; line-height: 1.35; }
.stat-value { font-family: var(--font-m); font-size: 20px; font-weight: 700; color: var(--ink); }
.stat-icon { position: relative; flex-shrink: 0; width: 28px; height: 28px; }
.badge {
  position: absolute; top: -5px; right: -5px;
  width: 14px; height: 14px;
  border-radius: 50%; color: #fff; font-size: 8px;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.badge.green { background: var(--sage); }
.badge.red { background: var(--rust); }

/* ─── MASCOT ─── */
.mascot-float {
  position: fixed;
  right: 22px; bottom: 20px;
  width: 90px;
  z-index: 250;
  cursor: pointer;
  animation: mascotBob 3.4s ease-in-out infinite;
}
.mascot-float img {
  width: 100%; display: block;
  filter: drop-shadow(0 8px 16px rgba(26,18,9,0.25));
  transition: transform .22s ease;
}
.mascot-float:hover img { transform: scale(1.18) rotate(-3deg); }
@keyframes mascotBob {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}
@media (max-width: 880px) { .mascot-float { width: 64px; right: 12px; bottom: 12px; } }

/* ─── TABLE PAGE: TWO-COLUMN LAYOUT ─── */
.table-page-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 18px;
  align-items: start;
}
@media (max-width: 1100px) { .table-page-layout { grid-template-columns: 1fr; } }

/* ─── TABLE TOOLBAR ─── */
.tbl-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.tbl-title {
  font-family: var(--font-d);
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
  white-space: pre-line;
  line-height: 1.4;
  flex: 1 1 280px;
}

.table-wrap {
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-md);
  overflow: auto;
  max-height: 64vh;
}
table { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 520px; }

thead th {
  position: sticky; top: 0; z-index: 5;
  background: var(--slate-deep); color: #EDE6DA;
  font-family: var(--font-b); font-weight: 600; font-size: 11px;
  text-align: left; padding: 11px 13px;
  letter-spacing: .2px; white-space: nowrap;
}
thead th.num { text-align: right; }
tbody td { padding: 9px 13px; border-bottom: 1px solid var(--line-soft); color: var(--ink); }
tbody td.num {
  text-align: right;
  font-family: var(--font-m);
  font-size: 12px;
}
tbody tr:nth-child(even) { background: var(--paper); }
tbody tr:hover { background: var(--clay-pale); }

tr.prov-row { background: var(--slate-pale) !important; }
tr.prov-row td { color: var(--slate-deep); font-weight: 700; border-bottom: 2px solid rgba(46,74,94,0.25); }
tr.prov-row:hover { background: var(--slate-pale) !important; }

.table-wrap::-webkit-scrollbar { height: 8px; width: 8px; }
.table-wrap::-webkit-scrollbar-track { background: var(--paper); }
.table-wrap::-webkit-scrollbar-thumb { background: var(--clay-deep); border-radius: 4px; }

/* ─── TABLE NOTE ─── */
.tbl-note { margin-top: 14px; }
.tbl-note-container { display: flex; gap: 12px; flex-wrap: wrap; }
.tbl-note-card {
  flex: 1 1 240px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--clay);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.65;
  color: var(--ink-soft);
}
.tbl-note-card b { color: var(--ink); }

/* ─── SUMMARY SIDEBAR (table page right panel) ─── */
.summary-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 20px;
}

.summary-header {
  font-family: var(--font-d);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  padding: 18px 18px 14px;
  background: var(--card);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--sh-md);
  border-bottom: 2px solid var(--clay-light);
  margin-bottom: -12px;
}
.summary-header .summary-eyebrow {
  font-family: var(--font-m);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--clay-deep);
  display: block;
  margin-bottom: 4px;
}

.summary-card {
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.summary-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}
.summary-metric:last-child { padding-bottom: 0; border-bottom: none; }

.summary-metric-label {
  font-size: 10.5px;
  color: var(--ink-muted);
  font-weight: 500;
}
.summary-metric-value {
  font-family: var(--font-m);
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
}
.summary-metric-sub {
  font-size: 10.5px;
  color: var(--ink-soft);
  margin-top: 1px;
}

/* progress mini bar */
.mini-bar-wrap {
  margin-top: 4px;
  height: 5px;
  background: var(--paper-soft);
  border-radius: 3px;
  overflow: hidden;
}
.mini-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--clay) 0%, var(--clay-deep) 100%);
  transition: width .5s ease;
}
.mini-bar-fill.good { background: linear-gradient(90deg, var(--sage) 0%, #3A6B49 100%); }
.mini-bar-fill.bad  { background: linear-gradient(90deg, var(--rust) 0%, #8A2D22 100%); }

/* rank items */
.rank-list { display: flex; flex-direction: column; gap: 7px; }
.rank-item {
  display: flex;
  align-items: center;
  gap: 8px;
}
.rank-num {
  font-family: var(--font-m);
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-muted);
  width: 18px;
  flex-shrink: 0;
}
.rank-label {
  font-size: 11px;
  color: var(--ink);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rank-val {
  font-family: var(--font-m);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ink-soft);
  flex-shrink: 0;
}

/* insight tag */
.insight-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 20px;
}
.insight-tag.good { background: var(--sage-pale); color: #2E5C3A; }
.insight-tag.warn { background: #FFF3D0; color: #7A5C10; }
.insight-tag.bad  { background: var(--rust-pale); color: #7A2A20; }

.summary-no-data {
  padding: 24px 18px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-muted);
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-md);
  font-style: italic;
}

/* ══════════════════════════════════════════════════════════
   MOBILE-FIRST RESPONSIVE OVERRIDES
   ══════════════════════════════════════════════════════════ */

/* ── Tablet (≤ 768px) ── */
@media (max-width: 768px) {

  /* Header */
  .brand-title { font-size: 24px; }
  .brand-sub   { font-size: 12px; }
  .eyebrow     { font-size: 9.5px; letter-spacing: 1.4px; }

  /* Toolbar */
  .data-toolbar { margin: 12px 0 16px; gap: 8px; }
  .status       { font-size: 10.5px; padding: 5px 10px; }

  /* Dashboard top row: stack vertically */
  .top-row {
    flex-direction: column;
    gap: 14px;
  }
  .total-card {
    flex: 0 0 28%;
    min-width: 360px;
    max-width: 420px;
    width: 100%;
    padding: 20px 20px 16px;
  }
  .chart-card {
    flex: none;
    width: 100%;
    min-width: unset;
    padding: 18px 16px 12px;
  }
  .chart-card canvas { max-height: 200px; }
  .chart-row {
    display: flex;
    gap: 20px;
    margin-bottom: 18px;
    align-items: stretch;
  }

  /* Stat grid: 2 columns on tablet */
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-value { font-size: 17px; }
  .data-panel { padding: 18px 16px 10px; }

  /* Table toolbar */
  .tbl-toolbar { gap: 10px; margin-bottom: 10px; }
  .tbl-title   { font-size: 14px; }

  /* Table max-height looser */
  .table-wrap { max-height: 55vh; }

  /* Summary panel: horizontal scroll cards on tablet */
  .summary-panel {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;
  }
  .summary-card { flex: 1 1 220px; }

  /* Mascot smaller */
  .mascot-float { width: 68px; right: 12px; bottom: 12px; }
}

/* ── Mobile (≤ 480px) ── */
@media (max-width: 480px) {

  /* Content padding tighter */
  .content { padding: 64px 12px 80px; }

  /* Header compact */
  .dash-header { margin-bottom: 10px; }
  .brand-title { font-size: 22px; }
  .brand-sub   { font-size: 11.5px; margin-top: 4px; }
  .eyebrow     { font-size: 9px; letter-spacing: 1.2px; margin-bottom: 5px; }

  /* Tenun rule thinner margin */
  .tenun-rule { margin: 0 0 16px; }

  /* Toolbar: stacks */
  .data-toolbar  { flex-direction: column; align-items: flex-start; gap: 8px; margin: 10px 0 14px; }
  .btn           { font-size: 11.5px; padding: 8px 13px; }

  /* Donut chart smaller on small phones */
  .donut-wrap { width: 152px; height: 152px; }
  .donut      { width: 152px; height: 152px; }
  .donut-hole { top: 14px; left: 14px; width: 124px; height: 124px; }
  .big-num    { font-size: 18px; }
  .donut-label.left  { left: -34px; }
  .donut-label.right { right: -36px; }
  .donut-label .val  { font-size: 12px; }
  .total-card { padding: 16px 16px 14px; }
  .total-card h2 { font-size: 15px; }

  /* Stat grid: 1 column on phones */
  .stat-grid  { grid-template-columns: 1fr; gap: 8px; }
  .stat-card  { padding: 12px 13px; }
  .stat-label { font-size: 10.5px; }
  .stat-value { font-size: 16px; }
  .data-panel { padding: 14px 12px 8px; }
  .data-panel h3 { font-size: 14px; }

  /* Charts */
  .chart-card        { padding: 14px 12px 10px; }
  .chart-card h3     { font-size: 13.5px; margin-bottom: 10px; }
  .chart-card canvas { max-height: 180px; }

  /* Table page: remove two-column, fully stack */
  .table-page-layout { grid-template-columns: 1fr; gap: 14px; }
  .tbl-title   { font-size: 13px; }
  .tbl-toolbar { flex-direction: column; align-items: flex-start; }
  .btn.primary { width: 100%; justify-content: center; }
  .table-wrap  { max-height: 52vh; border-radius: var(--r-md); }

  /* Table font tighter */
  table          { font-size: 11.5px; }
  thead th       { padding: 9px 10px; font-size: 10px; }
  tbody td       { padding: 8px 10px; }
  tbody td.num   { font-size: 11px; }

  /* Notes */
  .tbl-note-card { padding: 10px 12px; font-size: 11.5px; }

  /* Summary panel: full-width stacked cards on phones */
  .summary-panel { flex-direction: column; }
  .summary-card  { flex: none; width: 100%; }
  .summary-metric-value { font-size: 17px; }

  /* Mascot hide on very small screens to save space */
  .mascot-float { width: 54px; right: 8px; bottom: 8px; }
}

/* ── Very small (≤ 360px) ── */
@media (max-width: 360px) {
  .content { padding: 60px 10px 72px; }
  .brand-title { font-size: 20px; }
  .donut-wrap { width: 136px; height: 136px; }
  .donut      { width: 136px; height: 136px; }
  .donut-hole { top: 12px; left: 12px; width: 112px; height: 112px; }
  .big-num    { font-size: 16px; }
  .mascot-float { display: none; }
}

/* ── Sidebar toggle: larger tap target on mobile ── */
@media (max-width: 880px) {
  .sidebar-toggle {
    width: 44px;
    height: 44px;
    top: 12px;
    left: 12px;
    border-radius: 10px;
    font-size: 19px;
    /* Prevent layout from overlapping header text */
    box-shadow: 0 2px 12px rgba(28,49,64,0.22);
  }

  /* Sidebar itself: full-width overlay on mobile */
  .sidebar {
    width: 280px;
    padding: 18px 14px 20px;
    /* Smooth touch scrolling */
    -webkit-overflow-scrolling: touch;
  }

  /* Nav items: bigger tap targets on touch */
  .nav-item { padding: 11px 10px; font-size: 12.5px; }
}

/* ── Safe area for notched phones (iPhone X+) ── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .content {
    padding-bottom: calc(56px + env(safe-area-inset-bottom));
  }
  @media (max-width: 480px) {
    .content {
      padding-bottom: calc(80px + env(safe-area-inset-bottom));
    }
  }
}

/* ── Landscape phone: keep donut compact ── */
@media (max-width: 768px) and (orientation: landscape) {
  .donut-wrap { width: 140px; height: 140px; }
  .donut      { width: 140px; height: 140px; }
  .donut-hole { top: 12px; left: 12px; width: 116px; height: 116px; }
  .big-num    { font-size: 17px; }
  .content    { padding-top: 56px; }
}