:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-soft: #f8faff;
  --text: #131b2f;
  --muted: #5f6f93;
  --line: #dbe4f3;
  --primary: #2563eb;
  --primary-2: #1d4ed8;
  --accent: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 14px 34px rgba(20, 33, 68, 0.1);
  --shadow-soft: 0 8px 20px rgba(20, 33, 68, 0.08);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: "Inter", "Manrope", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 0% 0%, rgba(37, 99, 235, 0.12) 0, transparent 34%),
    radial-gradient(circle at 100% 0%, rgba(16, 185, 129, 0.12) 0, transparent 36%),
    var(--bg);
}

.container { width: min(1120px, 94%); margin: 0 auto; }
a { color: inherit; }
.bg-orb { display: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
}

.nav-wrap {
  min-height: 68px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  box-shadow: var(--shadow-soft);
}

.brand-text {
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--text);
}

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

.nav a {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 11px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  color: #2d3b5f;
  transition: 160ms ease;
}

.nav a:hover {
  transform: translateY(-1px);
  border-color: #b8c8ea;
  box-shadow: var(--shadow-soft);
}

.nav a.active {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}

main.container {
  padding: 14px 0 26px;
  display: grid;
  gap: 10px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 14px;
}

h1, h2 {
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(1.38rem, 1.9vw, 1.95rem); }
h2 { font-size: clamp(1.06rem, 1.2vw, 1.35rem); }
.muted { color: var(--muted); }

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

.protein-numbers strong {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
  color: #0f2047;
}

.protein-numbers span {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.protein-pct {
  font-size: 1.2rem;
  font-weight: 800;
}

.progress-track {
  margin-top: 10px;
  border-radius: 999px;
  height: 16px;
  border: 1px solid var(--line);
  background: #edf2fb;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 180ms ease;
}

.progress-red { background: linear-gradient(90deg, #ef4444, #dc2626); }
.progress-yellow { background: linear-gradient(90deg, #f59e0b, #d97706); }
.progress-green { background: linear-gradient(90deg, #10b981, #059669); }

.kpi-grid,
.quick-grid,
.saved-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}

.kpi,
.quick-grid form,
.saved-item {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  border-radius: var(--radius);
  padding: 10px;
}

.kpi span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 2px;
}

.kpi strong { font-size: 1.04rem; }

.saved-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

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

.compact-top { margin-top: 8px; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; }
.dash-link {
  text-decoration: none;
  border: 1px solid #ccd7ec;
  border-radius: 11px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
  color: #29467a;
  background: #f8fbff;
}
.dash-link:hover {
  border-color: #a9bde6;
  background: #eef4ff;
}

label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: #2f3d5f;
}

input,
select,
button {
  font-family: inherit;
  font-size: 14px;
}

input,
select {
  min-height: 40px;
  border: 1px solid #ccd7ec;
  border-radius: 11px;
  padding: 8px 10px;
  color: var(--text);
  background: #fff;
}

input:focus,
select:focus {
  outline: none;
  border-color: #8fb0ee;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 11px;
  padding: 8px 12px;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.25);
}

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

button.secondary {
  border: 1px solid #b8c8ea;
  color: #29467a;
  background: #f8fbff;
  box-shadow: none;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  flex-direction: row;
  cursor: pointer;
}
.checkbox-inline input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1.5px solid #9fb4de;
  background: #fff;
  display: grid;
  place-content: center;
  margin: 0;
}
.checkbox-inline input[type="checkbox"]::before {
  content: "";
  width: 10px;
  height: 10px;
  transform: scale(0);
  transition: transform 120ms ease-in-out;
  box-shadow: inset 1em 1em var(--primary);
  clip-path: polygon(14% 44%, 0 65%, 45% 100%, 100% 14%, 79% 0, 43% 62%);
}
.checkbox-inline input[type="checkbox"]:checked {
  border-color: var(--primary);
  background: #edf3ff;
}
.checkbox-inline input[type="checkbox"]:checked::before {
  transform: scale(1);
}
.checkbox-inline input[type="checkbox"]:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.2);
  outline-offset: 1px;
}

small { color: var(--muted); font-size: 12px; }

.alert {
  border-radius: var(--radius);
  padding: 10px 12px;
  border: 1px solid transparent;
}

.alert-success {
  border-color: #96dfc5;
  background: #ecfbf3;
  color: #0f7e54;
}

.alert-error {
  border-color: #f2bdbd;
  background: #fff1f1;
  color: #b22d2d;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.form-actions {
  align-items: end;
}

.recipe-picker {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  padding: 12px;
}

.recipe-picker-head {
  display: grid;
  gap: 3px;
  margin-bottom: 10px;
}

.recipe-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.recipe-choice {
  min-height: 58px;
  border: 1px solid #ccd7ec;
  border-radius: var(--radius);
  background: #fff;
  padding: 9px;
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: center;
  gap: 9px;
}

.recipe-choice input {
  min-height: 0;
  width: 17px;
  height: 17px;
  margin: 0;
}

.recipe-choice small {
  display: block;
  margin-top: 2px;
}

.plan-title-row,
.plan-day-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.plan-title-row {
  align-items: flex-start;
  margin-bottom: 10px;
}

.plan-day {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  padding: 12px;
  margin-top: 10px;
  break-inside: avoid;
}

.plan-day-head {
  border-bottom: 1px solid #e3eaf8;
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.recipe-row,
.limit-row {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
}

.box {
  width: 17px;
  height: 17px;
  border: 1.5px solid #304970;
  border-radius: 4px;
  background: #fff;
  display: inline-block;
}

.limit-row {
  border-top: 1px dashed #cbd5e1;
  margin-top: 8px;
  padding-top: 10px;
  font-weight: 800;
}

 table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  border-bottom: 1px solid #e3eaf8;
  padding: 9px;
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
}

th {
  background: #f5f8ff;
  color: #304970;
  font-weight: 700;
}

#proteinTrendChart {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.auth-card {
  width: min(430px, 96vw);
}

.auth-form { grid-template-columns: 1fr; }
.auth-link { margin-top: 10px; }

@media (max-width: 900px) {
  .nav-wrap { grid-template-columns: 1fr; align-items: start; }
  .nav a { flex: 1 1 auto; min-width: 94px; }
  .protein-head { flex-direction: column; align-items: flex-start; }
  .plan-title-row,
  .plan-day-head { flex-direction: column; }
}

@media print {
  body {
    background: #fff;
  }
  .topbar,
  .card:not(:has(.plan-sheet)),
  .alert,
  .plan-title-row button,
  script {
    display: none !important;
  }
  main.container {
    display: block;
    width: 100%;
    padding: 0;
  }
  .card {
    border: 0;
    box-shadow: none;
    padding: 0;
  }
  .plan-day {
    background: #fff;
    page-break-inside: avoid;
  }
}
