:root {
  color-scheme: light;
  --bg: #f7f3ec;
  --panel: #fffdf8;
  --ink: #1f2a29;
  --muted: #687471;
  --line: #dcd4c8;
  --teal: #146a63;
  --teal-soft: #dcefed;
  --amber: #a26013;
  --danger: #a73b32;
  --shadow: 0 12px 30px rgba(33, 42, 39, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--ink);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
}

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

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  /* Keep controls readable and prevent iOS focus zoom from inherited label sizes. */
  font-size: 16px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(20, 106, 99, 0.22);
  outline-offset: 2px;
}

.app-shell {
  width: min(100%, 620px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 14px 12px 96px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -14px -12px 10px;
  padding: calc(14px + env(safe-area-inset-top)) 12px 12px;
  background: rgba(247, 243, 236, 0.94);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(220, 212, 200, 0.8);
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: 26px;
  line-height: 1.1;
}

.eyebrow {
  margin: 0;
  color: var(--teal);
  font-size: 13px;
  font-weight: 700;
}

.date-pill {
  display: grid;
  gap: 3px;
  min-width: 148px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.date-pill input {
  min-height: 40px;
  padding: 8px 9px;
}

.mini-btn {
  min-height: 34px;
  padding: 6px 10px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 12px;
  font-weight: 850;
}

.view,
.stack {
  display: grid;
  gap: 12px;
}

.card {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid rgba(220, 212, 200, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.subhead {
  margin: 4px 0 0;
  font-size: 15px;
}

[hidden] {
  display: none !important;
}

.form {
  display: grid;
  gap: 10px;
}

.details {
  display: grid;
  gap: 10px;
}

.details summary {
  min-height: 44px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbf8f1;
  color: var(--teal);
  font-weight: 850;
  cursor: pointer;
}

.details[open] summary {
  margin-bottom: 10px;
}

.field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--ink);
  font-weight: 650;
}

.check input {
  width: 22px;
  min-height: 22px;
}

.primary {
  background: var(--teal);
  color: #fff;
  font-weight: 800;
}

.secondary {
  min-height: 40px;
  padding: 8px 11px;
  background: var(--teal-soft);
  color: var(--teal);
  font-weight: 800;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.metric {
  min-width: 0;
  padding: 10px 8px;
  border-radius: 8px;
  background: #f2eee6;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric strong {
  display: block;
  overflow-wrap: anywhere;
  margin-top: 2px;
  font-size: 18px;
}

.empty,
.info,
.muted {
  margin: 0;
  line-height: 1.4;
}

.empty {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fbf8f1;
}

.info {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--teal-soft);
  color: #174f4a;
  font-weight: 650;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.list-row,
.product-card,
.plan-row,
.set-row,
.rest-timer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
}

.product-card {
  display: grid;
  justify-content: stretch;
}

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

.badge {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 999px;
  background: #eee8dc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.badge.ok {
  background: var(--teal-soft);
  color: var(--teal);
}

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

.rest-timer {
  align-items: center;
  background: #f6eee0;
}

.rest-timer strong {
  font-size: 22px;
}

.report-box {
  min-height: 120px;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
  line-height: 1.45;
}

.chart {
  display: flex;
  align-items: end;
  gap: 6px;
  min-height: 140px;
  padding: 10px;
  border-radius: 8px;
  background: #f2eee6;
}

.bar {
  flex: 1;
  min-width: 8px;
  border-radius: 5px 5px 0 0;
  background: var(--teal);
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  width: min(100%, 620px);
  margin: 0 auto;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 253, 248, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.nav-btn {
  min-width: 0;
  min-height: 48px;
  padding: 6px 4px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.nav-btn.active {
  background: var(--teal);
  color: #fff;
}

.toast {
  position: fixed;
  right: 12px;
  bottom: 84px;
  left: 12px;
  z-index: 20;
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: 8px;
  background: #1f2a29;
  color: #fff;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: 0.18s ease;
}

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

@media (max-width: 380px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .date-pill {
    min-width: 0;
  }

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

  .bottom-nav {
    gap: 2px;
    padding-right: 4px;
    padding-left: 4px;
  }

  .nav-btn {
    font-size: 11px;
  }
}
