:root {
  color-scheme: light;
  --ink: #171212;
  --muted: #756c6c;
  --line: #e2dada;
  --paper: #f6f3f1;
  --panel: #ffffff;
  --green: #b30f18;
  --lime: #ff313d;
  --red: #b30f18;
  --steel: #241b1b;
  --gold: #d59a38;
  --blue: #2b2b2f;
  --orange: #e74725;
  --shadow: 0 18px 45px rgba(32, 16, 16, 0.12);
  --shadow-soft: 0 10px 24px rgba(32, 16, 16, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(23, 18, 18, 0.03), rgba(246, 243, 241, 0.98) 34%),
    radial-gradient(circle at top left, rgba(255, 49, 61, 0.16), transparent 26%),
    url("data:image/svg+xml,%3Csvg width='180' height='180' viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23e7dddb' stroke-width='2'%3E%3Cpath d='M30 48h120M30 90h120M30 132h120M48 30v120M90 30v120M132 30v120'/%3E%3C/g%3E%3C/svg%3E");
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, background 160ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(255, 49, 61, 0.4);
  outline-offset: 2px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 28px clamp(16px, 4vw, 46px) 26px;
  background:
    linear-gradient(135deg, rgba(10, 8, 8, 0.98), rgba(36, 27, 27, 0.96)),
    linear-gradient(90deg, transparent, rgba(255, 49, 61, 0.17));
  color: white;
  border-bottom: 4px solid var(--lime);
  box-shadow: 0 14px 40px rgba(25, 8, 8, 0.28);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--lime);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 3vw, 2.35rem);
  letter-spacing: 0;
}

.topbar-subtitle {
  margin: 8px 0 0;
  color: #f0dfdd;
  font-size: 0.96rem;
  font-weight: 700;
}

h2 {
  margin-bottom: 14px;
  font-size: 1.15rem;
}

h3 {
  margin-bottom: 10px;
  font-size: 0.95rem;
}

.date-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-control input,
.icon-button {
  min-height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.13);
  color: white;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.date-control input {
  padding: 0 10px;
}

.icon-button {
  width: 46px;
  font-size: 1.8rem;
  line-height: 1;
}

.app-shell {
  width: min(1200px, calc(100% - 28px));
  margin: 22px auto 44px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.hero-panel,
.metric-card,
.panel,
.progress-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero-panel {
  grid-column: span 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 178px;
  padding: 22px;
  overflow: hidden;
  position: relative;
  background:
    linear-gradient(90deg, rgba(8, 7, 7, 0.97) 0%, rgba(16, 12, 12, 0.9) 46%, rgba(24, 12, 12, 0.36) 100%),
    url("assets/redline-weights.png");
  background-size: cover;
  background-position: center right;
  color: white;
}

.hero-panel::after {
  content: "";
  position: absolute;
  right: -18px;
  bottom: -26px;
  width: 160px;
  height: 160px;
  border: 22px solid rgba(255, 49, 61, 0.14);
  border-radius: 50%;
}

.hero-panel h2 {
  margin-bottom: 0;
  font-size: clamp(1.6rem, 4vw, 3rem);
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.hero-tags span {
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.1);
  color: #f4f8ee;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.score-ring {
  display: grid;
  place-items: center;
  width: 116px;
  height: 116px;
  flex: 0 0 auto;
  border: 8px solid var(--lime);
  border-radius: 999px;
  text-align: center;
  position: relative;
  z-index: 1;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 8px rgba(255, 49, 61, 0.12);
}

.score-ring span {
  display: block;
  font-size: 2rem;
  font-weight: 900;
}

.score-ring small {
  max-width: 74px;
  color: #f0dfdd;
  font-size: 0.68rem;
  line-height: 1.1;
}

.metric-card {
  min-height: 178px;
  padding: 17px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.dashboard-grid > article:nth-last-of-type(1),
.dashboard-grid > article:nth-last-of-type(2) {
  grid-column: span 2;
}

.metric-card::before {
  content: "";
  display: block;
  width: 48px;
  height: 5px;
  margin-bottom: 18px;
  border-radius: 999px;
  background: var(--green);
}

.metric-card:nth-of-type(3)::before,
.metric-card:nth-of-type(6)::before {
  background: var(--orange);
}

.metric-card:nth-of-type(4)::before,
.metric-card:nth-of-type(8)::before {
  background: var(--blue);
}

.metric-card:nth-of-type(5)::before,
.metric-card:nth-of-type(9)::before {
  background: var(--gold);
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin: 8px 0 5px;
  font-size: clamp(1.75rem, 4vw, 2.45rem);
  line-height: 1;
}

.metric-card small {
  color: var(--muted);
}

.quick-water {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 8px;
}

.quick-water button,
.button-list button,
.secondary-button,
.primary-button,
.file-button {
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 10px 13px;
  font-weight: 800;
}

.quick-water button,
.secondary-button,
.file-button {
  background: #eef3ec;
  color: var(--ink);
}

.primary-button {
  border-color: var(--green);
  background: linear-gradient(135deg, var(--green), #e01c28);
  color: white;
  box-shadow: 0 10px 22px rgba(179, 15, 24, 0.2);
}

.secondary-button:hover,
.quick-water button:hover,
.button-list button:hover,
.file-button:hover {
  border-color: #bfd0c4;
  background: #f6faf3;
  box-shadow: var(--shadow-soft);
}

.primary-button:hover {
  box-shadow: 0 14px 28px rgba(179, 15, 24, 0.28);
}

.progress-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
  margin-top: 12px;
  padding: 18px;
  box-shadow: var(--shadow-soft);
}

.progress-row {
  display: grid;
  grid-template-columns: 84px 1fr 46px;
  align-items: center;
  gap: 10px;
}

.progress-row label,
.progress-row span {
  font-size: 0.86rem;
  font-weight: 800;
}

progress {
  width: 100%;
  height: 14px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: #e8eee6;
}

progress::-webkit-progress-bar {
  background: #e8eee6;
}

progress::-webkit-progress-value {
  border-radius: 999px;
  background: var(--green);
}

.warnings {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.warning {
  border-left: 5px solid var(--gold);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff7e5;
  font-weight: 800;
  box-shadow: var(--shadow-soft);
}

.tabbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 16px 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-soft);
}

.tab {
  min-height: 48px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.tab.active {
  background: linear-gradient(135deg, var(--ink), var(--steel));
  color: white;
  box-shadow: 0 8px 20px rgba(22, 32, 26, 0.16);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.split-grid {
  display: grid;
  grid-template-columns: 1.12fr 0.88fr;
  gap: 16px;
}

.panel {
  margin-bottom: 16px;
  padding: 20px;
  box-shadow: var(--shadow-soft);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.panel-head h2 {
  margin-bottom: 0;
}

.entry-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
}

label {
  display: grid;
  gap: 6px;
  color: #526059;
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fcfdfb;
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(22, 32, 26, 0.03);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #bfcbc3;
  background: white;
}

input[type="range"] {
  padding: 0;
}

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

.toggle-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fcfdfb;
}

.toggle-label input {
  width: 24px;
  min-height: 24px;
}

.quick-lists {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

.online-results {
  display: none;
  gap: 8px;
}

.online-results.active {
  display: grid;
}

.button-list button {
  width: 100%;
  background: white;
  text-align: left;
  line-height: 1.25;
}

.online-result {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fcfdfb;
  color: var(--ink);
  text-align: left;
  font-weight: 800;
}

.online-result small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-weight: 700;
}

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

.easy-meals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.easy-meal {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
  background: linear-gradient(180deg, #ffffff, #fbf8f8);
  box-shadow: var(--shadow-soft);
  position: relative;
}

.easy-meal::before {
  content: "";
  display: block;
  width: 38px;
  height: 4px;
  margin-bottom: 12px;
  border-radius: 999px;
  background: var(--lime);
}

.easy-meal strong,
.easy-meal span {
  display: block;
}

.easy-meal span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.easy-meal .macro-line {
  color: var(--green);
  font-weight: 900;
}

.meal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: linear-gradient(180deg, #ffffff, #fbfcfa);
  box-shadow: 0 5px 14px rgba(20, 32, 26, 0.04);
}

.meal-item strong,
.meal-item span {
  display: block;
}

.meal-item span {
  color: var(--muted);
  font-size: 0.85rem;
}

.meal-item button {
  width: 42px;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: #f4dfdc;
  color: var(--red);
  font-size: 1.4rem;
  font-weight: 900;
}

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

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: linear-gradient(180deg, #ffffff, #fbf8f8);
  box-shadow: 0 5px 14px rgba(20, 32, 26, 0.04);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  margin-top: 5px;
  font-size: 1.28rem;
}

.export-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.export-actions .primary-button {
  grid-column: 1 / -1;
}

.file-button {
  display: grid;
  place-items: center;
  text-align: center;
  text-transform: none;
}

.file-button input {
  display: none;
}

textarea {
  min-height: 360px;
  resize: vertical;
  line-height: 1.45;
}

#reportOutput {
  background: #101812;
  color: #e9f2e9;
  border-color: #24352a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.88rem;
}

#performanceForm textarea {
  min-height: 96px;
}

#settingsForm textarea {
  min-height: 92px;
}

.target-note {
  margin: 0;
  border-radius: 8px;
  padding: 12px;
  background: linear-gradient(135deg, #fff0f0, #fbf6f4);
  color: var(--steel);
  font-weight: 800;
  border: 1px solid #d7e5d4;
}

.form-status {
  min-height: 22px;
  color: var(--green);
  font-size: 0.9rem;
  font-weight: 900;
}

.lookup-filled {
  border-color: var(--green);
  background: #f2f8ef;
}

.pulse {
  animation: pulseUpdate 520ms ease-out;
}

@keyframes pulseUpdate {
  0% {
    transform: scale(1);
    box-shadow: var(--shadow);
  }

  45% {
    transform: scale(1.015);
    box-shadow: 0 0 0 4px rgba(182, 215, 67, 0.28), var(--shadow);
  }

  100% {
    transform: scale(1);
    box-shadow: var(--shadow);
  }
}

@media (max-width: 900px) {
  .topbar,
  .split-grid,
  .progress-panel {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

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

  .hero-panel {
    grid-column: 1 / -1;
  }

  .dashboard-grid > article:nth-last-of-type(1),
  .dashboard-grid > article:nth-last-of-type(2) {
    grid-column: span 1;
  }

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

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

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 18px, 1180px);
    margin-top: 10px;
  }

  .dashboard-grid,
  .stats-grid,
  .quick-lists,
  .easy-meals,
  .export-actions,
  .entry-form {
    grid-template-columns: 1fr;
  }

  .metric-card,
  .hero-panel {
    min-height: 132px;
  }

  .tabbar {
    gap: 4px;
  }

  .tab {
    min-height: 44px;
    padding: 6px;
    font-size: 0.82rem;
  }

  .progress-row {
    grid-template-columns: 72px 1fr 42px;
  }
}
