:root {
  --bg: #f4f5f2;
  --panel: #fffdfa;
  --panel-2: #f7faf8;
  --ink: #17251f;
  --muted: #5e7168;
  --line: rgba(23, 37, 31, 0.12);
  --line-strong: rgba(23, 37, 31, 0.24);
  --accent: #2a7d66;
  --accent-soft: rgba(42, 125, 102, 0.13);
  --calm-blue: #4078a9;
  --danger: #b8464c;
  --danger-soft: rgba(184, 70, 76, 0.1);
  --warning: #b6782f;
  --ok: #2c8c55;
  --status-taken: #2c8c55;
  --status-missed: #b8464c;
  --status-skipped: #b6782f;
  --status-refused: #7e4d84;
  --status-pending: #3f6f96;
  --radius: 16px;
  --shadow: 0 20px 46px rgba(22, 31, 27, 0.08);
}

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

body {
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(64, 120, 169, 0.09), transparent 32%),
    radial-gradient(circle at bottom left, rgba(42, 125, 102, 0.1), transparent 34%),
    var(--bg);
}

h1, h2, h3, h4 {
  font-family: "Segoe UI", Arial, sans-serif;
}

button, input, select, textarea {
  font: inherit;
}

.welcome-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(244, 245, 242, 0.9);
  backdrop-filter: blur(10px);
}

.welcome-card {
  width: min(980px, 100%);
  padding: 40px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.welcome-card h1 {
  margin-top: 16px;
  font-size: clamp(38px, 6vw, 66px);
  line-height: 0.98;
}

.welcome-card p {
  margin-top: 12px;
  max-width: 740px;
  color: var(--muted);
}

.welcome-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 18px;
  margin-top: 24px;
}

.welcome-panel,
.panel,
.stat-card,
.hero-card,
.mini-card,
.med-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.welcome-panel {
  padding: 20px;
}

.welcome-panel h3 {
  font-size: 28px;
}

.feature-list,
.list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.feature-item,
.list-item {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
}

.welcome-actions {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.mini-note,
.lead,
.mini-sub {
  color: var(--muted);
  font-size: 13px;
}

.btn,
.welcome-btn {
  border: none;
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 0.18s ease, filter 0.18s ease;
}

.btn:hover,
.welcome-btn:hover {
  transform: translateY(-1px);
  filter: brightness(0.99);
}

.btn-primary,
.welcome-btn.primary {
  background: linear-gradient(135deg, var(--accent), #34957a);
  color: #fff;
}

.btn-secondary,
.welcome-btn.secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line-strong);
}

.btn-success {
  background: rgba(44, 140, 85, 0.14);
  color: var(--ok);
  border: 1px solid rgba(44, 140, 85, 0.22);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(184, 70, 76, 0.22);
}

.btn-emergency {
  background: linear-gradient(135deg, #b8464c, #db5e5a);
  color: #fff;
  border: 0;
}

.btn-sm {
  padding: 7px 10px;
  font-size: 12px;
}

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

.app-shell.active {
  display: flex;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 292px;
  padding: 20px 16px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.9);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.sidebar-header {
  padding: 14px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(42, 125, 102, 0.15), rgba(64, 120, 169, 0.13));
  border: 1px solid var(--line);
  margin-bottom: 16px;
}

.sidebar-header h2 {
  margin-top: 8px;
  font-size: 28px;
}

.sidebar-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.nav-group {
  margin-bottom: 14px;
}

.nav-group-title {
  padding: 7px 10px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(42, 125, 102, 0.07);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(42, 125, 102, 0.16), rgba(64, 120, 169, 0.16));
  border-color: rgba(42, 125, 102, 0.24);
  color: var(--accent);
  font-weight: 700;
}

.nav-index {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
}

.sidebar-footer {
  position: sticky;
  bottom: 0;
  padding-top: 10px;
  background: linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,0.98) 26%);
}

.sidebar-footer .btn {
  width: 100%;
  margin-top: 8px;
}

.save-status {
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}

.main {
  margin-left: 292px;
  width: calc(100% - 292px);
  padding: 28px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.page-header {
  margin-bottom: 16px;
}

.page-header h1 {
  font-size: clamp(36px, 5vw, 58px);
  line-height: 0.98;
}

.page-header p {
  margin-top: 10px;
  color: var(--muted);
}

.cards-4,
.grid-2,
.grid-3,
.field-grid,
.cards-3 {
  display: grid;
  gap: 14px;
}

.cards-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid-2,
.field-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3,
.cards-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel,
.stat-card,
.mini-card,
.med-card {
  padding: 18px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.stat-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stat-value {
  margin-top: 8px;
  font-size: clamp(24px, 3vw, 40px);
  font-weight: 800;
}

.stat-sub {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

.action-row,
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.action-col {
  display: grid;
  gap: 10px;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.list-item.stack {
  align-items: flex-start;
}

.list-item small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.compact {
  gap: 6px;
}

.pill,
.chip,
.status {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.chip,
.status.soft {
  background: #fff;
  border: 1px solid var(--line);
}

.status.yes {
  background: rgba(44, 140, 85, 0.12);
  border: 1px solid rgba(44, 140, 85, 0.2);
  color: var(--ok);
}

.status.pending {
  background: rgba(182, 120, 47, 0.12);
  border: 1px solid rgba(182, 120, 47, 0.2);
  color: var(--warning);
}

.status.no {
  background: var(--danger-soft);
  border: 1px solid rgba(184, 70, 76, 0.2);
  color: var(--danger);
}

.med-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.med-card h4 {
  font-size: 24px;
}

.med-warning {
  margin-top: 10px;
  padding: 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
}

.med-warning.urgent {
  background: var(--danger-soft);
  color: var(--danger);
}

.med-warning.warning {
  background: rgba(182, 120, 47, 0.1);
  color: var(--warning);
}

.med-warning.ok {
  background: rgba(44, 140, 85, 0.1);
  color: var(--ok);
}

.med-card.urgent {
  border-color: rgba(184, 70, 76, 0.35);
}

.med-card.warning {
  border-color: rgba(182, 120, 47, 0.35);
}

.med-card.ok {
  border-color: rgba(44, 140, 85, 0.26);
}

.mini-card {
  background: var(--panel-2);
}

.mini-value {
  margin-top: 7px;
  font-size: 22px;
  font-weight: 800;
}

.trend-wrap {
  height: 190px;
  margin-top: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(42, 125, 102, 0.08), rgba(64, 120, 169, 0.05));
  overflow: hidden;
  padding: 8px 10px 10px;
}

.trend-bars-wrap {
  margin-top: 10px;
}

.trend-bars-wrap.large {
  margin-top: 12px;
}

.trend-bar-list {
  display: grid;
  gap: 10px;
}

.trend-bar-row {
  display: grid;
  gap: 6px;
}

.trend-bar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
}

.trend-bar-label {
  color: var(--muted);
  font-weight: 700;
}

.trend-bar-head strong {
  color: var(--ink);
  font-size: 13px;
}

.trend-bar-track {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(23, 37, 31, 0.08);
}

.trend-bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(42, 125, 102, 0.72), var(--accent));
}

.trend-bar-track span.latest {
  background: linear-gradient(90deg, var(--calm-blue), var(--accent));
}

.sparkline {
  width: 100%;
  height: 100%;
}

.sparkline-shell {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 8px;
  align-items: stretch;
  height: 100%;
}

.sparkline-scale {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 2px 0 10px;
}

.sparkline-plot {
  min-width: 0;
}

.sparkline polyline {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sparkline-grid {
  stroke: rgba(23, 37, 31, 0.12);
  stroke-width: 1;
}

.sparkline-grid.mid {
  stroke-dasharray: 3 3;
}

.sparkline-callout {
  fill: var(--muted);
  font-size: 8px;
  font-weight: 700;
}

.sparkline-callout {
  fill: var(--ink);
  text-anchor: start;
}

.sparkline-dot {
  fill: #ffffff;
  stroke: var(--accent);
  stroke-width: 1.6;
}

.sparkline-dot.latest {
  fill: var(--accent);
}

.sparkline-guide {
  stroke: rgba(42, 125, 102, 0.25);
  stroke-width: 1;
  stroke-dasharray: 2 2;
}

.sparkline-summary-row {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
}

.sparkline-summary-row strong {
  color: var(--ink);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 9px 8px;
  vertical-align: top;
  font-size: 12px;
}

th {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.table-wrap {
  overflow-x: auto;
}

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  color: var(--muted);
  padding: 12px;
  text-align: center;
  background: #fff;
}

.emergency-panel {
  background: linear-gradient(135deg, rgba(184, 70, 76, 0.08), rgba(64, 120, 169, 0.08));
}

.emergency-block {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  margin-bottom: 10px;
}

.tight-list {
  margin: 6px 0 0 18px;
}

.tight-list li {
  margin-bottom: 4px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  min-width: 220px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.trend-wrap.mini {
  height: 112px;
  margin-top: 8px;
}

.today-hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 14px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(42, 125, 102, 0.18), rgba(64, 120, 169, 0.14)), #fff;
  box-shadow: var(--shadow);
}

.today-hero h2 {
  margin-top: 10px;
  font-size: clamp(28px, 3.8vw, 44px);
}

.hero-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.today-hero-side {
  display: grid;
  gap: 10px;
}

.hero-side-block {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
}

.hero-score {
  margin-top: 6px;
  font-size: 30px;
  font-weight: 800;
  color: var(--accent);
}

.today-visual-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: start;
}

.today-visual-grid > .panel {
  align-self: start;
}

.adherence-layout {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 12px;
  align-items: start;
}

.adherence-ring {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1px rgba(23, 37, 31, 0.08);
}

.adherence-ring-center {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  text-align: center;
}

.ring-number {
  font-size: 24px;
  font-weight: 800;
  color: var(--ink);
}

.ring-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.adherence-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.adherence-meta-row {
  margin-top: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot.taken, .seg.taken { background: var(--status-taken); }
.dot.missed, .seg.missed { background: var(--status-missed); }
.dot.skipped, .seg.skipped { background: var(--status-skipped); }
.dot.refused, .seg.refused { background: var(--status-refused); }
.dot.pending, .seg.pending { background: var(--status-pending); }

.week-columns {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.day-col {
  text-align: center;
}

.day-stack {
  height: 72px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  display: flex;
  flex-direction: column-reverse;
  overflow: hidden;
}

.seg {
  width: 100%;
  min-height: 0;
}

.day-label {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
}

.day-pct {
  font-size: 11px;
  color: var(--ink);
  font-weight: 800;
}

.trend-strip-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.trend-tile {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.trend-meta-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.trend-metric {
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
}

.trend-metric span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.trend-metric strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  color: var(--ink);
}

.trend-caption {
  margin-top: 8px;
}

.trend-explain-row,
.trend-axis-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}

.trend-line-key,
.trend-value-key {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.trend-line-swatch {
  width: 22px;
  height: 0;
  border-top: 3px solid var(--accent);
  border-radius: 999px;
  display: inline-block;
}

.trend-axis-row {
  font-weight: 700;
}

.refill-risk-block {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
}

.refill-panel-block {
  margin-top: 12px;
}

.risk-row {
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.readiness-track {
  margin-top: 8px;
  height: 9px;
  border-radius: 999px;
  background: rgba(23, 37, 31, 0.12);
  overflow: hidden;
}

.readiness-track span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--calm-blue));
}

.readiness-track.refill span {
  background: linear-gradient(90deg, #b6782f, #b8464c);
}

@media (max-width: 1220px) {
  .cards-4,
  .grid-3,
  .cards-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .trend-strip-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .app-shell.active {
    display: block;
  }

  .sidebar {
    position: relative;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .main {
    margin-left: 0;
    width: 100%;
    padding: 18px;
  }

  .welcome-grid,
  .today-hero,
  .today-visual-grid,
  .grid-2,
  .field-grid,
  .field-grid.three {
    grid-template-columns: 1fr;
  }

  .adherence-layout {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .adherence-legend,
  .trend-meta-row {
    grid-template-columns: 1fr;
  }
}

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

  .welcome-card {
    padding: 24px;
  }
}


/* Installable browser PWA additions */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body.drawer-open {
  overflow: hidden;
}

.mobile-topbar,
.mobile-drawer,
.mobile-drawer-scrim,
.mobile-tabbar {
  display: none;
}

.mobile-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 35;
  align-items: center;
  gap: 10px;
  min-height: calc(68px + var(--safe-top));
  padding: calc(10px + var(--safe-top)) 12px 10px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.mobile-title {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 2px;
}

.mobile-title strong,
.mobile-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-title span {
  color: var(--muted);
  font-size: 12px;
}

.mobile-topbar .btn,
.mobile-drawer .btn {
  min-width: 0;
  padding: 10px 12px;
}

.mobile-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 35;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  padding: 8px 8px calc(8px + var(--safe-bottom));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.mobile-tab-btn {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  padding: 9px 4px;
  font-size: 12px;
  font-weight: 800;
}

.mobile-tab-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(42, 125, 102, 0.3);
}

.mobile-drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 38;
  background: rgba(23, 37, 31, 0.38);
}

.mobile-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 39;
  width: min(390px, 92vw);
  max-height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: calc(18px + var(--safe-top)) 16px calc(18px + var(--safe-bottom));
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 50px rgba(23, 37, 31, 0.18);
}

.mobile-drawer-header,
.mobile-drawer-actions {
  display: grid;
  gap: 10px;
}

.mobile-drawer-header {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  margin-bottom: 14px;
}

.mobile-drawer-actions {
  margin-bottom: 14px;
}

.app-shell.drawer-open .mobile-drawer,
.app-shell.drawer-open .mobile-drawer-scrim {
  display: block;
}

@media (pointer: coarse), (max-width: 980px), (display-mode: standalone) {
  html,
  body {
    height: 100% !important;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: hidden !important;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  body:not(.drawer-open) {
    position: static !important;
    overflow-y: hidden !important;
  }

  .app-shell {
    width: 100%;
    max-width: 100%;
  }

  .main,
  .page-stack,
  .page.active {
    height: auto !important;
    max-height: none !important;
    overflow-y: visible !important;
  }

  .welcome-screen {
    position: fixed;
    inset: 0;
    min-height: 0;
    height: 100dvh !important;
    align-items: flex-start;
    padding: calc(18px + var(--safe-top)) 14px calc(18px + var(--safe-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .welcome-card {
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 980px) {
  .app-shell.active {
    display: block;
    position: fixed !important;
    inset: 0 !important;
    width: 100%;
    max-width: 100%;
    height: 100dvh !important;
    max-height: 100dvh !important;
    min-height: 0;
    padding-top: calc(74px + var(--safe-top));
    padding-bottom: calc(78px + var(--safe-bottom));
    overflow-x: hidden;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
  }

  .mobile-topbar {
    display: flex;
  }

  .mobile-tabbar {
    display: grid;
  }

  .sidebar {
    display: none;
  }

  .main {
    margin-left: 0;
    width: 100%;
    max-width: 100%;
    padding: 16px;
  }

  .welcome-grid,
  .today-hero,
  .today-visual-grid,
  .grid-2,
  .grid-3,
  .cards-3,
  .cards-4,
  .field-grid,
  .field-grid.three,
  .mobile-drawer-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .panel,
  .stat-card,
  .mini-card,
  .med-card,
  .welcome-panel {
    padding: 16px;
    border-radius: 16px;
  }

  .page-header h1 {
    font-size: 34px;
    line-height: 1;
  }

  .panel-header,
  .list-item,
  .med-header,
  .action-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .tag-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .table-wrap {
    overflow-x: auto;
    max-width: 100%;
  }
}
