:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --panel: #ffffff;
  --ink: #16211f;
  --muted: #697774;
  --line: #dce5e1;
  --green: #0f8b6f;
  --green-strong: #07624e;
  --teal-soft: #dff4ed;
  --amber: #b56a16;
  --amber-soft: #fff0d9;
  --red: #b63b45;
  --red-soft: #ffe4e6;
  --blue: #2f6fa5;
  --shadow: 0 18px 45px rgba(34, 48, 45, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #152724;
  color: #f7fbfa;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #c8efe4;
  color: #0b5d4b;
  font-size: 28px;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
}

h2 {
  font-size: 34px;
  line-height: 1.1;
}

h3 {
  font-size: 17px;
}

.brand p,
.sidebar-panel small {
  color: #adc1bc;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tab,
.quiet-button,
.primary-button,
.icon-button,
.dose-action {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease;
}

.nav-tab {
  text-align: left;
  background: transparent;
  color: #dce8e5;
}

.nav-tab.active,
.nav-tab:hover {
  background: #23413b;
  color: #ffffff;
}

.sidebar-panel {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.panel-label,
.eyebrow {
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar .quiet-button {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

main {
  padding: 36px;
  overflow: auto;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 24px;
}

.date-controls,
.button-row,
.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.primary-button {
  background: var(--green);
  color: #ffffff;
  border-color: var(--green);
  font-weight: 800;
}

.primary-button:hover {
  background: var(--green-strong);
}

.quiet-button,
.icon-button,
.dose-action {
  background: #ffffff;
  color: var(--ink);
  border-color: var(--line);
  font-weight: 750;
}

.quiet-button:hover,
.icon-button:hover,
.dose-action:hover {
  border-color: var(--green);
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 26px;
  line-height: 1;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.metric,
.report-panel,
.editor,
.med-card,
.dose-row,
.empty-state {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
  display: grid;
  gap: 8px;
}

.metric span {
  color: var(--muted);
  font-weight: 750;
}

.metric strong {
  font-size: 30px;
}

.metric.warning strong {
  color: var(--amber);
}

.timeline,
.card-grid,
.history-list {
  display: grid;
  gap: 12px;
}

.dose-row {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 16px;
}

.dose-time {
  font-size: 23px;
  font-weight: 850;
}

.dose-title {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
}

.dose-title strong {
  font-size: 17px;
}

.dose-title span,
.dose-meta,
.med-card p,
.history-item small {
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--green-strong);
  font-size: 12px;
  font-weight: 850;
}

.pill.warning {
  background: var(--amber-soft);
  color: var(--amber);
}

.pill.missed,
.pill.skipped {
  background: var(--red-soft);
  color: var(--red);
}

.dose-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.editor {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
  margin-bottom: 18px;
}

.editor.compact {
  grid-template-columns: 180px minmax(180px, 1fr) minmax(220px, 1.5fr) auto;
  align-items: end;
}

.wide {
  grid-column: 1 / -1;
}

.hidden {
  display: none;
}

.card-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.med-card {
  padding: 18px;
  display: grid;
  gap: 13px;
}

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

.med-card h3 {
  overflow-wrap: anywhere;
}

.stock-line {
  height: 9px;
  border-radius: 999px;
  overflow: hidden;
  background: #edf2f0;
}

.stock-line span {
  display: block;
  height: 100%;
  background: var(--blue);
}

.report-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 18px;
}

.report-panel {
  padding: 18px;
}

.bars {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.bar-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 12px;
}

.bar-row span {
  white-space: nowrap;
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: #e9efec;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--green);
}

.history-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.history-item > div {
  display: grid;
  gap: 4px;
}

.history-item:last-child {
  border-bottom: 0;
}

.empty-state {
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.empty-state strong {
  display: block;
  color: var(--ink);
  margin-bottom: 6px;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .nav-tabs {
    grid-template-columns: repeat(4, 1fr);
  }

  .sidebar-panel {
    margin-top: 0;
  }

  main {
    padding: 24px;
  }

  .metric-grid,
  .report-layout,
  .editor,
  .editor.compact {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 620px) {
  .sidebar,
  main {
    padding: 18px;
  }

  h2 {
    font-size: 28px;
  }

  .topbar,
  .dose-row {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .nav-tabs,
  .metric-grid,
  .editor,
  .editor.compact,
  .report-layout {
    grid-template-columns: 1fr;
  }

  .dose-actions {
    justify-content: flex-start;
  }
}
