:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --ink: #17211f;
  --muted: #5c6966;
  --line: #d9ded8;
  --panel: #ffffff;
  --primary: #0f766e;
  --primary-dark: #0b4f4a;
  --amber: #a65f00;
  --red: #b42318;
  --green-soft: #dff3ee;
  --amber-soft: #fff0cf;
  --red-soft: #ffe1dd;
  --shadow: 0 18px 45px rgba(23, 33, 31, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(14px + env(safe-area-inset-top)) 18px 12px;
  background: rgba(246, 247, 244, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.topbar h1,
section h2 {
  margin: 0;
}

.topbar h1 {
  font-size: 22px;
  line-height: 1.1;
}

.eyebrow,
.status-label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--primary-dark);
  font-size: 24px;
}

main {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 14px 14px 92px;
}

section {
  margin: 0 0 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero-panel {
  border: 0;
  background: var(--primary-dark);
  color: #fff;
}

.hero-panel .status-label {
  color: #b9efdf;
}

.hero-panel h2 {
  color: #ddfff7;
  font-size: 16px;
  font-weight: 700;
}

.daily-limit {
  display: block;
  margin: 10px 0 18px;
  color: #fff;
  font-size: 46px;
  font-weight: 800;
  line-height: 1;
}

.hero-grid,
.input-grid {
  display: grid;
  gap: 10px;
}

.hero-grid {
  grid-template-columns: 1fr 1fr;
}

.hero-grid div {
  min-width: 0;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
}

.hero-grid span,
.metric-row span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.hero-grid span {
  color: #b9d8d2;
}

.hero-grid strong {
  display: block;
  margin-top: 4px;
  color: #fff;
  font-size: 20px;
}

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

.section-title h2 {
  font-size: 20px;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
  margin-bottom: 12px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.field input:focus,
.field select:focus,
.icon-button:focus {
  outline: 3px solid rgba(15, 118, 110, 0.2);
  border-color: var(--primary);
}

.result {
  min-height: 72px;
  padding: 14px;
  border-radius: 8px;
  background: var(--green-soft);
  color: var(--primary-dark);
  font-weight: 700;
  line-height: 1.35;
}

.result.warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.result.danger {
  background: var(--red-soft);
  color: var(--red);
}

.save-state {
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

.input-grid {
  grid-template-columns: 1fr;
}

.metric-list {
  display: grid;
  gap: 8px;
}

.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.metric-row strong {
  text-align: right;
  white-space: nowrap;
}

.cards-risk {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.card-risk {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.card-risk header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card-risk strong,
.card-risk span {
  min-width: 0;
}

.badge {
  border-radius: 999px;
  background: var(--red-soft);
  color: var(--red);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.progress {
  overflow: hidden;
  height: 9px;
  border-radius: 999px;
  background: #e8ece8;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--red);
}

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

.bottom-nav a {
  display: grid;
  min-height: 44px;
  place-items: center;
  border-radius: 8px;
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.bottom-nav a:focus,
.bottom-nav a:hover {
  background: var(--green-soft);
}

@media (min-width: 620px) {
  main {
    padding-top: 22px;
  }

  .input-grid {
    grid-template-columns: 1fr 1fr;
  }

  .daily-limit {
    font-size: 58px;
  }
}
