/* ==========================================================================
   Mad Factory Tracker — app stylesheet
   Dark theme: #080808 bg, #111/#161616 surfaces, #222 borders, #00E676 accent.
   Inter for UI; JetBrains Mono for all numbers/data.
   The login page (.page/.card/.form*) styles are kept at the bottom unchanged.
   ========================================================================== */

:root {
  --bg: #080808;
  --surface: #111111;
  --surface-2: #161616;
  --border: #222222;
  --border-soft: #1b1b1b;
  --text: #f5f5f5;
  --muted: #8a8a8a;
  --dim: #5c5c5c;
  --accent: #00e676;
  --accent-dim: rgba(0, 230, 118, 0.12);
  --red: #ff5c5c;
  --red-dim: rgba(255, 92, 92, 0.12);
  --yellow: #ffcf5c;
  --yellow-dim: rgba(255, 207, 92, 0.12);
  --blue: #5ca8ff;
  --blue-dim: rgba(92, 168, 255, 0.12);
  /* per-platform accent colours for sales tags */
  --p-ebay: #5ca8ff;
  --p-vinted: #00c9a7;
  --p-depop: #ff5c8a;
  --p-site: #00e676;
  --p-carboot: #ffcf5c;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: var(--mono); }

a { color: inherit; }

/* ==========================================================================
   App shell: fixed sidebar + main column
   ========================================================================== */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 200px;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 0 14px;
}

.sidebar__logo {
  display: block;
  text-decoration: none;
  padding: 0 18px 18px;
  line-height: 1.15;
}
.sidebar__logo-main {
  display: block;
  color: var(--accent);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.sidebar__logo-sub {
  display: block;
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-top: 2px;
}

.nav {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}
.nav-group {
  padding: 6px 0;
}
.nav-group + .nav-group {
  border-top: 1px solid var(--border-soft);
}

.nav-a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-left: 2px solid transparent;
  transition: color 0.12s ease, background 0.12s ease;
}
.nav-a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.02);
}
.nav-a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-dim);
}
.nav-i { flex: 0 0 14px; }

.sidebar__footer {
  padding: 12px 18px 2px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}
.sidebar__user { color: var(--muted); font-size: 13px; font-weight: 600; }
.sidebar__site { color: var(--dim); font-size: 11px; }

.app-main {
  margin-left: 200px;
  min-height: 100vh;
}

/* Topbar: sticky, 52px, border-bottom */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(8, 8, 8, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar__crumb { font-size: 13px; display: flex; align-items: center; gap: 8px; }
.topbar__crumb-dim { color: var(--dim); }
.topbar__crumb-sep { color: var(--dim); }
.topbar__crumb-page { color: var(--text); font-weight: 600; text-transform: capitalize; }
.topbar__right { display: flex; align-items: center; gap: 16px; }
.topbar__date { color: var(--muted); font-size: 12px; }
.topbar__logout {
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.topbar__logout:hover { color: var(--text); border-color: var(--dim); }

.content { padding: 24px; max-width: 1280px; }

/* Flash messages */
.flash {
  margin: 16px 24px 0;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
}
.flash--info { background: var(--blue-dim); border: 1px solid var(--blue); color: var(--blue); }
.flash--success { background: var(--accent-dim); border: 1px solid var(--accent); color: var(--accent); }
.flash--error { background: var(--red-dim); border: 1px solid var(--red); color: var(--red); }

/* ==========================================================================
   Headings & layout helpers
   ========================================================================== */

.page-head { margin: 0 0 18px; }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2-1 { grid-template-columns: 2fr 1fr; }
.grid-1-1-2 { grid-template-columns: 1fr 1fr; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-2-1, .grid-1-1-2 { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Stat strip
   ========================================================================== */

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.stat-strip--3 { grid-template-columns: repeat(3, 1fr); }

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}
.stat__label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.stat__value {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 500;
  margin-top: 6px;
  line-height: 1.1;
}
.stat__sub { color: var(--dim); font-size: 12px; margin-top: 4px; }
.stat__delta { font-family: var(--mono); font-size: 12px; margin-top: 4px; }
.stat__delta.up { color: var(--accent); }
.stat__delta.down { color: var(--red); }

/* Hero variant — green background, used for the headline figure */
.stat--hero {
  background: linear-gradient(135deg, rgba(0, 230, 118, 0.16), rgba(0, 230, 118, 0.04));
  border-color: rgba(0, 230, 118, 0.35);
}
.stat--hero .stat__label { color: var(--accent); }
.stat--hero .stat__value { color: var(--accent); }

@media (max-width: 900px) {
  .stat-strip, .stat-strip--3 { grid-template-columns: 1fr 1fr; }
}

/* ==========================================================================
   Panel component
   ========================================================================== */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.panel__title { font-size: 14px; font-weight: 600; }
.panel__meta { color: var(--muted); font-size: 12px; font-family: var(--mono); }
.panel__body { padding: 16px; }
.panel__body--tight { padding: 0; }

/* Chart wrappers */
.chart { width: 100%; display: block; }
.chart-wrap { width: 100%; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ==========================================================================
   Tables
   ========================================================================== */

.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.tbl td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.tbl tr:last-child td { border-bottom: none; }
.tbl .num { font-family: var(--mono); text-align: right; }
.tbl .pos { color: var(--accent); }
.tbl .neg { color: var(--red); }

/* ==========================================================================
   Tags / badges
   ========================================================================== */

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--mono);
  line-height: 1.5;
}
.tag-green { background: var(--accent-dim); color: var(--accent); }
.tag-yellow { background: var(--yellow-dim); color: var(--yellow); }
.tag-red { background: var(--red-dim); color: var(--red); }
.tag-blue { background: var(--blue-dim); color: var(--blue); }
.tag-mid { background: rgba(255, 255, 255, 0.06); color: var(--muted); }

/* Platform tags */
.tag-ebay { background: rgba(92, 168, 255, 0.14); color: var(--p-ebay); }
.tag-vinted { background: rgba(0, 201, 167, 0.14); color: var(--p-vinted); }
.tag-depop { background: rgba(255, 92, 138, 0.14); color: var(--p-depop); }
.tag-site { background: rgba(0, 230, 118, 0.14); color: var(--p-site); }
.tag-carboot { background: rgba(255, 207, 92, 0.14); color: var(--p-carboot); }

/* ==========================================================================
   Progress bars
   ========================================================================== */

.prog-track {
  height: 6px;
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  overflow: hidden;
}
.prog-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}
.prog-fill.amber { background: var(--yellow); }
.prog-fill.blue { background: var(--blue); }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: filter 0.12s ease, border-color 0.12s ease;
}
.btn:hover { border-color: var(--dim); }
.btn-primary { background: var(--accent); color: #061a0e; border-color: transparent; }
.btn-primary:hover { filter: brightness(1.08); border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-danger { background: transparent; color: var(--red); border-color: rgba(255, 92, 92, 0.4); }
.btn-danger:hover { background: var(--red-dim); border-color: var(--red); }
.btn-block { width: 100%; }

/* Tiny inline transaction-delete × — dim by default, red on hover. */
.tx-del {
  background: none;
  border: none;
  color: var(--dim);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.12s ease, background 0.12s ease;
}
.tx-del:hover { color: var(--red); background: var(--red-dim); }

/* ==========================================================================
   Forms
   ========================================================================== */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid--3 { grid-template-columns: repeat(3, 1fr); }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field--full { grid-column: 1 / -1; }
.form-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.form-input, .form-select, .form-textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  width: 100%;
}
.form-input.mono { font-family: var(--mono); }
.form-textarea { resize: vertical; min-height: 72px; }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.form-actions { display: flex; gap: 10px; margin-top: 16px; }

@media (max-width: 700px) {
  .form-grid, .form-grid--3 { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Donut / breakdown rows (dashboard platform panel)
   ========================================================================== */

.donut-wrap { display: flex; align-items: center; gap: 20px; }
.breakdown { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.bd-row { display: grid; grid-template-columns: 90px 1fr 48px; align-items: center; gap: 10px; font-size: 12px; }
.bd-name { color: var(--muted); }
.bd-val { font-family: var(--mono); text-align: right; color: var(--text); }
/* Dim sub-label sitting in the bd-row's middle column (e.g. a date or count). */
.bd-sub { color: var(--dim); font-size: 11px; }

/* Dashboard helpers (Phase 10). */
.empty-note { color: var(--dim); font-size: 13px; margin: 4px 0; }
.goal-meta { color: var(--dim); font-size: 11px; margin: 4px 0 12px; }

/* ==========================================================================
   Water cups (health)
   ========================================================================== */

.cups { display: flex; gap: 8px; flex-wrap: wrap; }
.cup {
  width: 30px;
  height: 38px;
  border: 1.5px solid var(--border);
  border-radius: 4px 4px 7px 7px;
  background: var(--bg);
  cursor: pointer;
  position: relative;
  transition: border-color 0.12s ease;
}
.cup.filled {
  border-color: var(--accent);
  background: linear-gradient(to top, var(--accent-dim), transparent);
}
.cup.filled::after {
  content: '';
  position: absolute;
  left: 2px; right: 2px; bottom: 2px;
  height: 60%;
  background: rgba(0, 230, 118, 0.45);
  border-radius: 2px 2px 5px 5px;
}

/* ==========================================================================
   Workout cards (health)
   ========================================================================== */

.wo-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}
.wo-card + .wo-card { margin-top: 10px; }
.wo-card.planned { border-style: dashed; opacity: 0.8; }
.wo-name { font-weight: 600; font-size: 14px; }
.wo-meta { color: var(--muted); font-size: 12px; font-family: var(--mono); margin-top: 3px; }

/* Calorie ring macro list */
.macros { display: flex; flex-direction: column; gap: 10px; flex: 1; }
.macro-row { display: grid; grid-template-columns: 70px 1fr 56px; gap: 10px; align-items: center; font-size: 12px; }
.macro-name { color: var(--muted); }
.macro-val { font-family: var(--mono); text-align: right; }

/* ==========================================================================
   Habits — check-in, dot rows, streak cards, heatmap
   ========================================================================== */

.checkin-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-soft);
}
.checkin-row:last-child { border-bottom: none; }
.check-btn {
  width: 22px; height: 22px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex: 0 0 22px;
  color: transparent;
}
.check-btn.done { background: var(--accent); border-color: var(--accent); color: #061a0e; }
.checkin-name { font-size: 14px; font-weight: 500; flex: 1; }
.checkin-cat { color: var(--dim); font-size: 11px; }

.streak-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-2);
}
.streak-card__top { display: flex; justify-content: space-between; align-items: baseline; }
.streak-card__name { font-weight: 600; font-size: 14px; }
.streak-card__count { font-family: var(--mono); color: var(--accent); font-size: 13px; }
.dot-row { display: flex; gap: 4px; margin-top: 12px; flex-wrap: wrap; }
.dot { width: 12px; height: 12px; border-radius: 3px; background: rgba(255,255,255,0.07); }
.dot.on { background: var(--accent); }
.dot.miss { background: rgba(255, 92, 92, 0.35); }
.dot.today { background: transparent; border: 1.5px solid var(--accent); }

/* Heatmap grid (built by inline JS) */
.heatmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 13px); gap: 3px; overflow-x: auto; }
.hm-cell { width: 13px; height: 13px; border-radius: 3px; }

/* ==========================================================================
   Goals — cards, AI plan steps
   ========================================================================== */

.goal-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface);
}
.goal-card + .goal-card { margin-top: 14px; }
.goal-card__top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.goal-card__title { font-size: 15px; font-weight: 700; }
.goal-card__desc { color: var(--muted); font-size: 13px; margin: 8px 0 14px; line-height: 1.5; }
.goal-card__prog { display: flex; align-items: center; gap: 12px; }
.goal-card__pct { font-family: var(--mono); font-size: 12px; color: var(--accent); width: 38px; text-align: right; }
.goal-habits { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }

/* Goals — interactive bits added in Phase 9 (no existing rules changed). */
.goal-progress-form { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
.goal-progress-form .form-input { max-width: 130px; }
.goal-card__actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
/* The step marker is now a submit button; reset the button chrome so the inner
   .step__marker span keeps doing all the visual work. */
.step__toggle { margin: 0; flex: 0 0 22px; }
.step__toggle button { background: none; border: none; padding: 0; cursor: pointer; display: block; }
/* Goal selector chips above the AI plan panel (Phase 9 follow-up). */
.goal-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.goal-tab {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted);
  background: var(--surface-2); text-decoration: none; white-space: nowrap;
  transition: border-color 0.12s ease, color 0.12s ease;
}
.goal-tab:hover { border-color: var(--dim); color: var(--text); }
.goal-tab.is-active { border-color: var(--accent); color: var(--accent); }
.goal-tab.is-done { color: var(--dim); border-color: var(--border); }
/* When a completed goal is the selected one, keep the green active outline but
   let its dim text stand — the ✓ prefix + tooltip mark it as completed. */
.goal-tab.is-active.is-done { border-color: var(--accent); }

.ai-bubble {
  background: var(--accent-dim);
  border: 1px solid rgba(0, 230, 118, 0.3);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.55;
  color: #cdeedd;
  margin-bottom: 16px;
}
.ai-bubble__label {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--accent); font-weight: 700; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.step {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
}
.step:last-child { border-bottom: none; }
.step__marker {
  width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-family: var(--mono); color: var(--muted);
  flex: 0 0 22px;
}
.step.done .step__marker { background: var(--accent); border-color: var(--accent); color: #061a0e; }
.step.active .step__marker { border-color: var(--accent); color: var(--accent); }
.step__body { flex: 1; }
.step__title { font-size: 13px; font-weight: 600; }
.step.done .step__title { color: var(--muted); text-decoration: line-through; }
.step__detail { color: var(--muted); font-size: 12px; margin-top: 3px; }
.step__time { color: var(--dim); font-size: 11px; font-family: var(--mono); }

/* Toggles (visual only, settings) */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--border-soft);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-label { font-size: 13px; }
.toggle-label small { display: block; color: var(--dim); font-size: 11px; margin-top: 2px; }
.toggle {
  width: 38px; height: 22px; border-radius: 999px;
  background: rgba(255,255,255,0.08); position: relative; flex: 0 0 38px;
}
.toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%; background: var(--dim);
  transition: transform 0.15s ease;
}
.toggle.on { background: var(--accent-dim); }
.toggle.on::after { background: var(--accent); transform: translateX(16px); }

.section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--dim); margin: 24px 0 10px;
}
.danger-zone {
  border: 1px solid rgba(255, 92, 92, 0.3);
  border-radius: 8px;
  padding: 16px;
  background: var(--red-dim);
}
.danger-zone p { margin: 0 0 12px; color: var(--muted); font-size: 13px; }

/* ==========================================================================
   Login page (Phase 1 skeleton) — unchanged, used by the bare layout
   ========================================================================== */

.page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.card {
  max-width: 560px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  padding: 32px 36px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.card__eyebrow {
  margin: 0 0 12px;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}
.card__title { margin: 0 0 16px; font-size: 26px; font-weight: 700; line-height: 1.2; }
.card__body { margin: 0 0 20px; color: var(--muted); line-height: 1.6; }
.card__body code { color: var(--accent); }
.card__meta { margin: 0; font-size: 13px; color: var(--muted); }

.form { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.form__label { font-size: 13px; color: var(--muted); }
.form__input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
}
.form__input:focus { outline: none; border-color: var(--accent); }
.form__button {
  margin-top: 6px;
  background: var(--accent);
  color: #061a0e;
  border: none;
  border-radius: 8px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.form__button:hover { filter: brightness(1.08); }
.form__error {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(255, 69, 58, 0.12);
  border: 1px solid rgba(255, 69, 58, 0.4);
  color: #ff6b60;
  font-size: 14px;
}
.logout-link { display: inline-block; margin-top: 20px; color: var(--accent); text-decoration: none; font-size: 14px; }
.logout-link:hover { text-decoration: underline; }

/* ==========================================================================
   Responsive / mobile (Phase 12)
   --------------------------------------------------------------------------
   The desktop shell uses a FIXED 200px sidebar with the content pushed over by
   margin-left:200px. On a phone that sidebar would eat half the screen, so
   below 900px we turn it into a horizontal, scrollable top strip and let the
   content use the full width. Placed at the very end of the file so these
   overrides win the cascade over the component defaults above.
   ========================================================================== */

@media (max-width: 900px) {
  /* Sidebar → horizontal top nav bar */
  .sidebar {
    position: static;      /* was fixed — let it sit in normal flow at the top */
    width: 100%;
    height: auto;
    flex-direction: row;   /* logo + nav side by side instead of stacked */
    align-items: center;
    padding: 8px 12px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar__logo { padding: 0 12px 0 4px; flex: 0 0 auto; }
  .sidebar__logo-sub { display: none; }           /* drop the "HUB" subtitle to save room */
  .nav { flex-direction: row; overflow-x: auto; padding: 0; }
  .nav-group { flex-direction: row; padding: 0; }
  /* Group separators become vertical rules between horizontal groups */
  .nav-group + .nav-group {
    border-top: none;
    border-left: 1px solid var(--border-soft);
    margin-left: 6px;
    padding-left: 6px;
  }
  /* The active marker moves from a left border to an underline */
  .nav-a {
    border-left: none;
    border-bottom: 2px solid transparent;
    padding: 8px 10px;
    white-space: nowrap;   /* keep each item on one line so the row scrolls */
  }
  .nav-a.active { border-left-color: transparent; border-bottom-color: var(--accent); }
  .sidebar__footer { display: none; }

  /* Content now spans the full width since the sidebar isn't fixed beside it */
  .app-main { margin-left: 0; }
  .content { padding: 16px; }
  .flash { margin: 12px 16px 0; }
  .topbar { padding: 0 16px; }
}

/* Narrow phones: tighten padding, and keep form fields at 16px so iOS Safari
   doesn't auto-zoom on focus (it zooms any input with a <16px font size).
   Slightly bigger button padding gives a comfortable tap target too. */
@media (max-width: 480px) {
  .content { padding: 12px; }
  .form-input, .form-select, .form-textarea { font-size: 16px; }
  .btn { padding: 10px 14px; }
  .btn-sm { padding: 8px 12px; }
}

/* Wide tables scroll horizontally INSIDE their panel rather than overflowing
   the viewport. Each wide <table class="tbl"> is wrapped in a .table-scroll.
   The min-width keeps columns readable on a phone (they scroll) while staying
   comfortably under a desktop panel's width, so no scrollbar shows there. */
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll .tbl { min-width: 460px; }
