:root {
  color-scheme: light;
  --bg: #f6fbf9;
  --panel: #ffffff;
  --panel-2: #ecf8f5;
  --text: #14211f;
  --muted: #63706d;
  --line: #d9e6e2;
  --accent: #0f766e;
  --accent-2: #0e9488;
  --warn: #b45309;
  --danger: #b91c1c;
  --ok: #047857;
  --blue: #2563eb;
  --shadow: 0 10px 28px rgba(17, 43, 39, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 10% -10%, rgba(15, 118, 110, 0.14), transparent 32rem),
    linear-gradient(180deg, #f6fbf9 0%, #eef7f4 100%);
  color: var(--text);
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(14px, env(safe-area-inset-top)) 14px calc(86px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 960px;
  margin: 0 auto 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow);
}

.brand-mark svg,
.nav-button svg,
.icon-button svg,
.primary svg,
.secondary svg,
.ghost svg,
.danger svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand h1 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.05;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.main {
  max-width: 960px;
  margin: 0 auto;
}

.screen {
  display: grid;
  gap: 14px;
}

.grid {
  display: grid;
  gap: 12px;
}

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

.card {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(217, 230, 226, 0.92);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 15px;
}

.section-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.section-title h2 {
  margin: 0;
  font-size: 1.04rem;
  line-height: 1.2;
}

.section-title p,
.muted {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.hero {
  display: grid;
  gap: 14px;
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.13), rgba(255, 255, 255, 0.92));
}

.hero h2 {
  margin: 0;
  font-size: clamp(1.8rem, 8vw, 3.25rem);
  line-height: 0.98;
}

.hero p {
  max-width: 42rem;
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.primary,
.secondary,
.ghost,
.danger {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  text-decoration: none;
}

.primary {
  background: var(--accent);
  color: #fff;
}

.primary:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.secondary {
  background: #e0f2ef;
  color: #0b5d56;
}

.ghost {
  background: transparent;
  color: var(--accent);
}

.danger {
  background: #fee2e2;
  color: var(--danger);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.metric {
  min-height: 104px;
  display: grid;
  align-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--muted);
  margin-top: 4px;
}

.dot.ok {
  background: var(--ok);
}

.dot.warn {
  background: var(--warn);
}

.metric-value {
  font-size: 1.14rem;
  font-weight: 800;
  line-height: 1.1;
  word-break: break-word;
}

.metric-status {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.metric-status.ok {
  color: var(--ok);
}

.metric-status.warn {
  color: var(--warn);
}

.form-grid {
  display: grid;
  gap: 12px;
}

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

.field label,
.range-title {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.field small {
  color: var(--muted);
  line-height: 1.35;
}

.range-editor {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.range-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.range-row .field label {
  color: var(--muted);
  font-size: 0.75rem;
}

.recommendation {
  display: grid;
  gap: 9px;
  border-left: 4px solid var(--accent);
}

.recommendation.warn {
  border-left-color: var(--warn);
}

.recommendation.dose {
  border-left-color: var(--blue);
}

.recommendation.high {
  border-left-color: var(--danger);
}

.rec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.rec-head h3 {
  margin: 0;
  font-size: 1rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e0f2ef;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 800;
}

.badge.warn {
  background: #fef3c7;
  color: var(--warn);
}

.badge.dose {
  background: #dbeafe;
  color: var(--blue);
}

.badge.high {
  background: #fee2e2;
  color: var(--danger);
}

.dose-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--blue);
  font-weight: 800;
}

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

.reading-row {
  display: grid;
  gap: 7px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
  color: inherit;
}

.reading-row strong {
  font-size: 0.98rem;
}

.reading-row span {
  color: var(--muted);
  font-size: 0.82rem;
}

.empty {
  min-height: 210px;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 8px;
}

.empty svg {
  width: 42px;
  height: 42px;
  color: var(--accent);
}

.empty h2 {
  margin: 0;
  font-size: 1.1rem;
}

.empty p {
  max-width: 22rem;
  margin: 0;
  color: var(--muted);
}

.safety {
  border-color: rgba(180, 83, 9, 0.22);
  background: #fff7ed;
}

.safety h3 {
  margin: 0 0 6px;
  color: var(--warn);
  font-size: 1rem;
}

.safety p {
  margin: 0;
  color: #7c4a12;
  line-height: 1.42;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.92);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.nav-button {
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.nav-button.active {
  background: #e0f2ef;
  color: var(--accent);
}

.dialog-like {
  max-width: 720px;
  margin: 0 auto;
}

@media (min-width: 720px) {
  .app-shell {
    padding-left: 22px;
    padding-right: 22px;
  }

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

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

@media (max-width: 390px) {
  .grid.two,
  .range-row {
    grid-template-columns: 1fr;
  }

  .brand p,
  .status-pill {
    display: none;
  }

  .actions .primary,
  .actions .secondary,
  .actions .ghost,
  .actions .danger {
    width: 100%;
  }
}
