:root {
  --sidebar-bg: #1a2332;
  --sidebar-fg: #cbd5e1;
  --sidebar-fg-active: #ffffff;
  --sidebar-active-bg: #2c3a52;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --radius: 6px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}

.mono { font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace; }

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

/* Sidebar */
.sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  padding: 24px 0;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid #2c3a52;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.user-info { font-size: 11px; color: #94a3b8; }
.user-email { color: #e2e8f0; font-weight: 500; font-size: 12px; word-break: break-all; }
.user-tenant { margin-top: 2px; }
.sidebar-footer .btn { background: #2c3a52; color: #e2e8f0; border: 1px solid #3b4a64; }
.sidebar-footer .btn:hover { background: #3b4a64; }

.disclaimer-banner {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-left: 4px solid #d97706;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 12px;
  color: #78350f;
  margin-bottom: 16px;
  line-height: 1.5;
}
.impersonation-banner {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-left: 4px solid var(--red);
  border-radius: var(--radius);
  color: #7f1d1d;
  margin-bottom: 16px;
  padding: 10px 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  line-height: 1.45;
}
.impersonation-banner strong { color: #7f1d1d; }
.impersonation-banner .btn {
  flex: 0 0 auto;
  background: #fff;
  border-color: #fca5a5;
  color: #7f1d1d;
}
.impersonation-banner .btn:hover { background: #fee2e2; }
.disclaimer-banner strong { color: #78350f; }
.disclaimer-banner a { color: #78350f; text-decoration: underline; }
.disclaimer-inline {
  background: #fffbeb;
  border-left: 3px solid #d97706;
  padding: 8px 12px;
  font-size: 11px;
  color: #78350f;
  border-radius: 4px;
  margin: 12px 0;
  line-height: 1.5;
}
.brand { padding: 0 24px 24px; border-bottom: 1px solid #2c3a52; }
.brand-title { font-size: 18px; font-weight: 600; color: var(--sidebar-fg-active); }
.brand-sub { font-size: 11px; color: #64748b; margin-top: 2px; }
.nav { display: flex; flex-direction: column; padding: 16px 0; }
.nav a {
  padding: 10px 24px;
  color: var(--sidebar-fg);
  text-decoration: none;
  font-size: 13px;
  border-left: 3px solid transparent;
}
.nav a:hover { color: var(--sidebar-fg-active); background: rgba(255,255,255,0.04); }
.nav a.active { color: var(--sidebar-fg-active); background: var(--sidebar-active-bg); border-left-color: var(--accent); font-weight: 500; }

/* Main */
.content { flex: 1; padding: 32px 88px 32px 40px; min-width: 0; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 600; margin: 0; }
.page-sub { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card h3 { margin: 0 0 12px 0; font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat .stat-value { font-size: 24px; font-weight: 600; font-family: 'IBM Plex Mono', monospace; }
.stat .stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.stat .stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* Clickable stat cards with colored accent + hover lift */
.stat-card-link { display: block; color: inherit; text-decoration: none; }
.stat-card-link .card.stat {
  position: relative;
  overflow: hidden;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
  height: 100%;
}
.stat-card-link .card.stat::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--stat-accent, var(--accent));
}
.stat-card-link:hover .card.stat {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
  border-color: #d1d5db;
}
.stat.accent-blue   { --stat-accent: #2563eb; }
.stat.accent-green  { --stat-accent: #10b981; }
.stat.accent-purple { --stat-accent: #8b5cf6; }
.stat.accent-amber  { --stat-accent: #f59e0b; }

/* Quick-action cards row */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.quick-action {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 12px;
  text-align: center;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.quick-action:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
  border-color: var(--accent);
}
.quick-action .qa-icon {
  width: 44px; height: 44px;
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  line-height: 1;
}
.quick-action .qa-icon.blue   { background: #dbeafe; color: #2563eb; }
.quick-action .qa-icon.green  { background: #d1fae5; color: #059669; }
.quick-action .qa-icon.purple { background: #ede9fe; color: #7c3aed; }
.quick-action .qa-icon.amber  { background: #fef3c7; color: #d97706; }
.quick-action .qa-icon.pink   { background: #fce7f3; color: #db2777; }
.quick-action .qa-icon.teal   { background: #ccfbf1; color: #0d9488; }
.quick-action .qa-label { font-size: 13px; font-weight: 600; }
.quick-action .qa-sub { font-size: 11px; color: var(--text-muted); }

.demo-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 54px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(255,255,255,.92);
  color: var(--accent);
  font-size: 21px;
  box-shadow: 0 10px 28px rgba(0,0,0,.22);
}
.demo-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}
.demo-video-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}
.demo-section-title {
  margin: 6px 0 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.demo-video-preview {
  position: relative;
  display: block;
  min-height: 158px;
  background: #0f172a;
  color: #fff;
  text-decoration: none;
}
.demo-video-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: .9;
}
.demo-video-preview:hover img { opacity: .78; }
.demo-video-copy {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.demo-video-copy h2 {
  margin: 4px 0 8px 0;
  font-size: 18px;
  font-weight: 600;
}
.demo-video-meta {
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}
.demo-video-copy p {
  margin: 0 0 16px 0;
  color: var(--text-muted);
  line-height: 1.55;
  max-width: 820px;
}
.demo-summary p {
  margin: 0 0 14px 0;
  color: var(--text-muted);
  line-height: 1.55;
}
.demo-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* What's New release notes button + modal */
.whats-new-button {
  position: fixed;
  top: 16px;
  right: 18px;
  z-index: 55;
  min-width: 42px;
  height: 40px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease;
}
.whats-new-button:hover {
  border-color: var(--accent);
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}
.whats-new-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}
.whats-new-icon {
  font-size: 18px;
  line-height: 1;
}
.whats-new-build {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  font: 600 11px/18px 'IBM Plex Mono', ui-monospace, Menlo, monospace;
}
.whats-new-build:empty { display: none; }
.whats-new-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.whats-new-current {
  font: 600 18px/1.2 'IBM Plex Mono', ui-monospace, Menlo, monospace;
}
.whats-new-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.whats-new-entry {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.whats-new-entry:last-child { border-bottom: none; }
.whats-new-entry-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 5px;
}
.whats-new-summary {
  font-size: 14px;
  line-height: 1.45;
}
.whats-new-commit { color: var(--text-muted); font-size: 11px; }

/* Help icons + popover */
.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  padding: 0;
  margin-left: 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f3f4f6;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  font-family: 'IBM Plex Sans', sans-serif;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.help-icon:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.help-icon:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}
/* Slightly larger touch target on phones */
@media (max-width: 640px) {
  .help-icon { width: 22px; height: 22px; font-size: 12px; }
}

.help-popover {
  position: absolute;
  z-index: 1000;
  max-width: 320px;
  background: #1f2937;
  color: #f9fafb;
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  animation: helpFadeIn .12s ease-out;
}
.help-popover p { margin: 0 0 8px 0; }
.help-popover p:last-child { margin-bottom: 0; }
.help-popover a { color: #93c5fd; text-decoration: underline; }
@keyframes helpFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.help-popover.flip-up { animation-name: helpFadeInUp; }
@keyframes helpFadeInUp {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Slightly tighter on phones so it doesn't dominate the screen */
@media (max-width: 640px) {
  .help-popover { max-width: calc(100vw - 32px); font-size: 13px; }
}

/* Forms */
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="tel"], select, textarea {
  font: inherit;
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
textarea { resize: vertical; min-height: 60px; }
label { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 4px; }
.form-row { display: grid; grid-template-columns: repeat(var(--cols, 2), 1fr); gap: 12px; margin-bottom: 12px; }
.form-row.cols-3 { --cols: 3; }
.form-row.cols-4 { --cols: 4; }
.form-row.cols-1 { --cols: 1; }
.form-row.cols-6 { --cols: 6; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: var(--radius);
  font: inherit;
  cursor: pointer;
  font-weight: 500;
}
.btn:hover { background: #f3f4f6; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.ghost { background: transparent; border: none; color: var(--accent); padding: 4px 8px; }
.btn.ghost:hover { background: rgba(37,99,235,0.08); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Tables */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table th { text-align: left; padding: 10px 12px; font-size: 11px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.04em; font-weight: 600; background: #fafbfc; border-bottom: 1px solid var(--border); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafbfc; }
.table .num { text-align: right; font-family: 'IBM Plex Mono', monospace; }
.empty { padding: 32px; text-align: center; color: var(--text-muted); }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.badge.draft { background: #e5e7eb; color: #374151; }
.badge.sent { background: #dbeafe; color: #1d4ed8; }
.badge.paid { background: #dcfce7; color: var(--green); }
.badge.overdue { background: #fee2e2; color: var(--red); }
.badge.active { background: #dcfce7; color: var(--green); }
.badge.archived { background: #e5e7eb; color: #6b7280; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal {
  background: #fff;
  border-radius: 8px;
  width: 520px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
}
.modal.wide { width: 720px; }
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h2 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-body { padding: 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: #fafbfc; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 20px; line-height: 1; }

/* Toast */
#toast-root { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--text); color: #fff; padding: 10px 16px; border-radius: var(--radius);
  box-shadow: 0 8px 16px rgba(0,0,0,0.15); font-size: 13px;
  animation: toast-in 0.18s ease-out;
  min-width: 220px;
}
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
@keyframes toast-in { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Misc */
.flex { display: flex; }
.flex.gap { gap: 12px; }
.flex.gap-sm { gap: 8px; }
.flex.center { align-items: center; }
.flex.between { justify-content: space-between; }
.flex.end { justify-content: flex-end; }
.row-gap { margin-top: 18px; }
.toolbar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar.secondary { justify-content: flex-end; margin-top: -8px; }
.toolbar .grow { flex: 1; }
.toolbar input, .toolbar select { width: auto; min-width: 132px; }
.toolbar-field { flex: 0 0 auto; }
.toolbar-field.compact input,
.toolbar-field.compact select,
.toolbar-field.compact .btn { min-width: 100px; width: 110px; }
.toolbar-field.wide select,
.toolbar-field.wide input { min-width: 200px; width: 240px; max-width: 300px; }
.toolbar-actions {
  min-height: 59px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.toolbar.secondary .toolbar-actions { min-height: 37px; }
.toolbar-actions .btn { min-height: 37px; }
.toolbar-note {
  min-height: 59px;
  display: inline-flex;
  align-items: flex-end;
  color: var(--text-muted);
  font-size: 12px;
  padding-bottom: 10px;
}
.table-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab-btn {
  padding: 8px 16px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); background: #f8fafc; }
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }
.muted { color: var(--text-muted); font-size: 12px; }
.section-title { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 24px 0 12px; }
.checkbox-row { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.error-text { color: var(--red); font-size: 12px; margin-top: 4px; }

.invoice-wizard .step-content { min-height: 320px; }
.invoice-wizard .steps { display: flex; gap: 8px; margin-bottom: 18px; }
.invoice-wizard .step { padding: 6px 12px; border-radius: 999px; background: #f3f4f6; color: var(--text-muted); font-size: 12px; font-weight: 500; }
.invoice-wizard .step.active { background: var(--accent); color: #fff; }
.invoice-wizard .step.done { background: #dbeafe; color: var(--accent); }

.chart-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.chart-wrap canvas { max-height: 280px; }

/* ============================================================ */
/* Mobile / responsive                                           */
/* ============================================================ */

/* Hamburger + mobile top bar — hidden on desktop. */
.mobile-topbar { display: none; }
.hamburger {
  display: flex; flex-direction: column; justify-content: space-around;
  width: 40px; height: 40px; padding: 8px; background: transparent;
  border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer;
}
.hamburger span {
  display: block; width: 100%; height: 2px; background: var(--text); border-radius: 1px;
}

/* Drawer backdrop — only rendered when drawer is open. */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
  z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s;
}
body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }

/* Tablet + Phone (≤ 1023px): sidebar becomes a drawer. */
@media (max-width: 1023px) {
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: -260px; width: 240px;
    z-index: 70; transition: left .25s ease; height: 100vh;
  }
  body.drawer-open .sidebar { left: 0; }
  .content { padding: 16px 18px; }
  .mobile-topbar {
    display: flex; align-items: center; gap: 12px;
    margin: -16px -18px 16px -18px;
    padding: 12px 64px 12px 18px;
    background: var(--surface); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
  }
  .mobile-topbar-title { font-weight: 600; font-size: 15px; }
  .page-header { flex-wrap: wrap; gap: 12px; }
  .page-title { font-size: 18px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .quick-actions { grid-template-columns: repeat(3, 1fr); }
  .demo-video-card { grid-template-columns: 220px minmax(0, 1fr); }
  .demo-video-preview { min-height: 140px; }

  /* All tables become horizontally-scrollable blocks at narrow widths.
     This handles every page that doesn't get a custom card-list pass. */
  .table {
    display: block; overflow-x: auto; white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .table thead, .table tbody, .table tr { display: table; width: max-content; min-width: 100%; table-layout: auto; }

  /* Modals get more breathing room at tablet widths. */
  .modal { width: 92vw; max-width: 92vw; }
  .modal.wide { width: 92vw; max-width: 92vw; }

  /* Toolbars wrap instead of overflowing. */
  .toolbar { gap: 8px; }
  .toolbar input, .toolbar select { min-width: 120px; }
}

/* Phone (≤ 640px): single-column everything, full-screen modal sheets,
   touch-target sizing, and the dashboard/entries card lists kick in. */
@media (max-width: 640px) {
  body.drawer-open { overflow: hidden; }

  .content { padding: 12px 14px; }
  .mobile-topbar { margin: -12px -14px 12px -14px; padding: 10px 62px 10px 14px; }

  .stat-grid { grid-template-columns: 1fr !important; gap: 10px; }
  .stat .stat-value { font-size: 22px; }
  .quick-actions { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .quick-action { padding: 12px 8px; }
  .quick-action .qa-icon { width: 38px; height: 38px; font-size: 18px; }
  .quick-action .qa-sub { display: none; }
  .demo-video-card { grid-template-columns: 1fr; }
  .demo-video-preview { min-height: 180px; }
  .demo-video-copy { padding: 16px; }

  /* All multi-column form rows collapse to single column. */
  .form-row { grid-template-columns: 1fr !important; }
  .form-row.cols-2, .form-row.cols-3, .form-row.cols-4, .form-row.cols-6 {
    grid-template-columns: 1fr !important;
  }

  /* Modals become full-screen sheets.
     Use dvh (dynamic viewport height) so iOS Safari's collapsing toolbar
     doesn't push the sticky footer below the visible area. Fall back to
     vh for browsers without dvh support. */
  .modal-backdrop { padding: 0; align-items: stretch; }
  .modal, .modal.wide {
    width: 100vw !important; max-width: 100vw !important;
    height: 100vh !important; max-height: 100vh !important;
    height: 100dvh !important; max-height: 100dvh !important;
    border-radius: 0;
    display: flex; flex-direction: column;
  }
  .modal-header { position: sticky; top: 0; background: var(--surface); z-index: 1; padding-top: max(18px, env(safe-area-inset-top)); }
  .modal-footer {
    position: sticky; bottom: 0; background: var(--surface); z-index: 1;
    flex-wrap: wrap; gap: 8px;
    /* Leave room for the iPhone home indicator at the bottom. */
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
  .modal-footer .btn { flex: 1; min-height: 44px; }
  .modal-body { flex: 1; overflow-y: auto; padding: 18px; }

  /* Touch targets */
  .btn { min-height: 44px; padding: 10px 14px; }
  .btn.small { min-height: 36px; padding: 6px 10px; }
  .btn.ghost { min-height: 36px; }
  input[type="text"], input[type="email"], input[type="tel"],
  input[type="number"], input[type="date"], input[type="password"],
  select, textarea { min-height: 44px; font-size: 16px; /* prevent iOS zoom-on-focus */ }
  textarea { min-height: 80px; }

  /* Toolbars stack so filter inputs are full-width. */
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar > * { width: 100%; }
  .toolbar input, .toolbar select { width: 100%; min-width: 0; }
  .toolbar-field.wide select,
  .toolbar-field.wide input { max-width: none; min-width: 0; }
  .toolbar-actions { width: 100%; }
  .toolbar-actions .btn { flex: 1; }
  .toolbar-note { width: 100%; min-height: 0; }
  .toolbar .grow { display: none; }

  /* Page header: title + action stack. */
  .page-header { flex-direction: column; align-items: stretch; gap: 8px; }
  .page-header .btn { width: 100%; }
  .page-header .flex.gap { flex-direction: column; gap: 8px; }
  .page-header .flex.gap .btn { width: 100%; }

  /* Card list pattern for dashboard "today's entries" and Time Entries page. */
  .entries-mobile-cards { display: flex; flex-direction: column; gap: 8px; }
  .entry-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 12px 14px;
    display: flex; flex-direction: column; gap: 4px;
    box-shadow: var(--shadow);
  }
  .entry-card.tappable { cursor: pointer; }
  .entry-card .ec-top {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  }
  .entry-card .ec-project { font-weight: 600; font-size: 14px; }
  .entry-card .ec-hours { font-family: 'IBM Plex Mono', monospace; font-weight: 600; font-size: 16px; }
  .entry-card .ec-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 10px; flex-wrap: wrap; }
  .entry-card .ec-comments { font-size: 13px; color: var(--text); }
  .entry-card .ec-actions { display: flex; gap: 6px; margin-top: 6px; }
  .entry-card .ec-actions .btn { flex: 1; }

  /* Hide the desktop inline quick-add form on phone (a button replaces it). */
  .dashboard-quick-add-desktop { display: none; }

  /* Hide the desktop table when card list is rendered (and vice versa). */
  .show-on-desktop-only { display: none !important; }
  .show-on-mobile-only { display: block; }

  /* Onboarding wizard: collapse the step indicator. */
  .onboarding-steps { display: none !important; }
  .onboarding-step-compact { display: block; }

  /* Sidebar drawer footer needs extra bottom padding on iOS for the home indicator. */
  .sidebar-footer { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
}

/* Desktop fallback for the show/hide helper classes (use only inside @media). */
.show-on-mobile-only { display: none; }
.onboarding-step-compact { display: none; }
