:root {
  --bg: #f2f5f9;
  --bg-soft: #e9eff6;
  --surface: #ffffff;
  --surface-2: #f7fafc;
  --ink: #0f172a;
  --muted: #4b5563;
  --line: #d7e1ec;
  --brand: #0f766e;
  --brand-2: #0891b2;
  --accent: #f97316;
  --protein: #0f766e;
  --carb: #f97316;
  --fat: #0ea5e9;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 8px 22px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 0% 0%, #ffffff, transparent 32%),
    radial-gradient(circle at 100% 0%, #ddf3f6, transparent 28%),
    linear-gradient(180deg, var(--bg-soft) 0%, var(--bg) 40%, var(--bg) 100%);
}

body.auth-locked > :not(.auth-splash) {
  filter: blur(2px) saturate(0.9);
  pointer-events: none;
  user-select: none;
}

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

.auth-splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 1rem;
  background:
    radial-gradient(circle at 15% 0%, rgba(8, 145, 178, 0.24), transparent 36%),
    radial-gradient(circle at 100% 0%, rgba(15, 118, 110, 0.24), transparent 34%),
    rgba(242, 245, 249, 0.92);
  backdrop-filter: blur(8px);
}

.auth-splash-card {
  width: min(460px, 100%);
  display: grid;
  gap: 0.8rem;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), #ffffff);
  box-shadow: var(--shadow);
  padding: 1.15rem;
}

.auth-splash-logo {
  width: clamp(160px, 36vw, 240px);
  height: auto;
}

.auth-splash h1 {
  font-size: 1.25rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 2vw, 2rem);
  border-bottom: 1px solid rgba(215, 225, 236, 0.8);
  background: rgba(247, 250, 252, 0.86);
  backdrop-filter: blur(14px);
}

.topbar h1 {
  font-size: clamp(1.2rem, 2.4vw, 1.65rem);
  line-height: 1.1;
  letter-spacing: 0.01em;
}

.topbar p {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.brand {
  display: grid;
  gap: 0.28rem;
  align-items: center;
}

.brand-logo {
  width: clamp(148px, 24vw, 210px);
  height: auto;
  display: block;
}

.brand p {
  margin-left: 0.2rem;
}

.topbar-right {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(15, 118, 110, 0.2);
  color: #115e59;
  background: linear-gradient(135deg, #d5f5f1, #ecfeff);
  white-space: nowrap;
}

.user-pill-btn {
  width: auto;
  border: 1px solid rgba(15, 118, 110, 0.2);
  color: #115e59;
  background: linear-gradient(135deg, #d5f5f1, #ecfeff);
  box-shadow: none;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  padding: 0.45rem 0.75rem;
  line-height: 1;
}

.user-pill-btn:hover {
  transform: none;
  filter: none;
  background: linear-gradient(135deg, #c9efe9, #e5fbff);
}

.ai-pill {
  border-color: rgba(8, 145, 178, 0.35);
  color: #0c4a6e;
  background: linear-gradient(135deg, #dff6ff, #e8fcff);
  animation: aiPulse 1s ease-in-out infinite;
}

.is-hidden {
  display: none !important;
}

.tabs {
  width: min(1560px, 100%);
  margin: 0.7rem auto 0;
  padding: 0 clamp(1rem, 2vw, 2rem);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.45rem;
}

.tabs-left {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.tabs-right {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.tabs-right input[type="date"] {
  width: 168px;
  height: 36px;
  padding: 0.4rem 0.55rem;
  font-size: 0.82rem;
}

.tab-btn {
  width: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  border: 1px solid #cdd9e8;
  border-radius: 999px;
  background: #f9fbff;
  color: #334155;
  font-size: 0.84rem;
  font-weight: 700;
  padding: 0.46rem 0.82rem;
  box-shadow: none;
}

.tab-icon {
  width: 1rem;
  text-align: center;
  font-size: 0.86rem;
  opacity: 0.9;
}

.tab-btn:hover {
  transform: none;
  filter: none;
  background: #f2f7fd;
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-color: transparent;
  color: #ffffff;
}

.grid {
  width: min(1560px, 100%);
  margin: 0 auto;
  padding: 1rem clamp(1rem, 2vw, 2rem) 1.25rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.95rem;
  align-items: start;
}

.card.is-hidden {
  display: none !important;
}

.card {
  position: relative;
  display: grid;
  gap: 0.85rem;
  align-content: start;
  padding: 1rem;
  border-radius: 18px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 1)),
    var(--surface);
  box-shadow: var(--shadow-soft);
  animation: reveal 340ms ease both;
}

.card.layout-size-s {
  min-height: 180px;
}

.card.layout-size-m {
  min-height: 280px;
}

.card.layout-size-l {
  min-height: 380px;
}

.card.layout-size-xl {
  min-height: 500px;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(140deg, rgba(8, 145, 178, 0.18), transparent 26%, rgba(249, 115, 22, 0.12));
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.card:nth-child(2) {
  animation-delay: 60ms;
}

.card:nth-child(3) {
  animation-delay: 100ms;
}

.card:nth-child(4) {
  animation-delay: 140ms;
}

.card:nth-child(5) {
  animation-delay: 180ms;
}

.card h2 {
  font-size: 1.03rem;
  letter-spacing: 0.01em;
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}

.card-header-row h2 {
  flex: 1;
  min-width: 0;
}

.card-tools {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem;
  border-radius: 999px;
  border: 1px solid #d5dfeb;
  background: #f9fbff;
}

.drag-handle {
  width: auto;
  min-width: 48px;
  height: 28px;
  padding: 0 0.5rem;
  border-radius: 999px;
  background: #ffffff;
  color: #334155;
  border: 1px solid #d3dde9;
  box-shadow: none;
  font-size: 0.68rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-weight: 700;
  cursor: grab;
}

.drag-handle:hover {
  background: #f2f7fd;
  transform: none;
  filter: none;
}

.drag-handle:active {
  cursor: grabbing;
}

.size-select {
  width: 54px;
  height: 28px;
  padding: 0 0.4rem;
  border-radius: 999px;
  font-size: 0.75rem;
  border-color: #d3dde9;
  background: #ffffff;
}

.kpis .card-tools {
  margin-left: 0.35rem;
}

.card.dragging {
  opacity: 0.55;
  transform: scale(0.99);
}

.snapshot-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.72rem;
}

.snapshot-hero {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.58rem;
}

.hero-stat {
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 0.65rem 0.72rem;
  background: linear-gradient(160deg, #ffffff 0%, #f7fbff 100%);
}

.hero-stat .label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  font-weight: 700;
}

.hero-stat strong {
  margin-top: 0.18rem;
  display: block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 1rem;
  color: #0f172a;
}

.snapshot-macros {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, #ffffff 0%, #f4f9ff 100%);
  padding: 0.82rem;
}

.snapshot-macros h3,
.snapshot-stat h3 {
  font-size: 0.74rem;
  font-weight: 700;
  color: #475569;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.macro-progress {
  margin-top: 0.58rem;
  display: grid;
  gap: 0.26rem;
}

.macro-progress-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
  font-size: 0.82rem;
  color: #334155;
}

.macro-progress-head strong {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.96rem;
  color: #0f172a;
}

.macro-track {
  height: 8px;
  border-radius: 999px;
  background: #e6edf6;
  overflow: hidden;
}

.macro-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  transition: width 260ms ease;
}

.macro-fill.protein {
  background: linear-gradient(90deg, #0f766e, #14b8a6);
}

.macro-fill.carbs {
  background: linear-gradient(90deg, #f97316, #fb923c);
}

.macro-fill.fat {
  background: linear-gradient(90deg, #0ea5e9, #38bdf8);
}

.macro-fill.water {
  background: linear-gradient(90deg, #0284c7, #22d3ee);
}

.snapshot-stat {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, #ffffff 0%, #f8fbff 100%);
  padding: 0.82rem;
}

.snapshot-stat p {
  margin-top: 0.24rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.02rem;
  font-weight: 700;
  color: #0f172a;
}

.coaching-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.coach-item {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, #ffffff, #f8fbff);
  padding: 0.62rem 0.7rem;
}

.coach-item h3 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-bottom: 0.26rem;
}

.coach-item p {
  font-size: 0.88rem;
  color: #0f172a;
}

.review-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.review-item {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, #ffffff, #f8fbff);
  padding: 0.62rem 0.7rem;
}

.review-item h3 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-bottom: 0.26rem;
}

.review-item p {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.94rem;
  color: #0f172a;
}

.review-note {
  border: 1px dashed #c4d4e5;
  background: #f8fbff;
  border-radius: 10px;
  padding: 0.6rem 0.68rem;
  font-size: 0.84rem;
  color: #334155;
}

.review-analytics-grid {
  margin-top: 0.55rem;
}

.review-change-note {
  margin-top: 0.55rem;
}

.review-change-list {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
  color: #334155;
  font-size: 0.82rem;
  display: grid;
  gap: 0.28rem;
}

.forecast-meta {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.forecast-meta span {
  font-size: 0.76rem;
  border: 1px solid #d4e1ee;
  border-radius: 999px;
  background: #f7fbff;
  color: #334155;
  padding: 0.2rem 0.5rem;
}

small,
.hint {
  font-size: 0.82rem;
  color: #64748b;
}

.stack,
.row-wrap {
  display: grid;
  gap: 0.58rem;
}

.file-field {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  color: #64748b;
}

.camera-panel {
  border: 1px solid #d2deea;
  border-radius: 12px;
  background: #f8fbff;
  padding: 0.58rem;
  display: grid;
  gap: 0.45rem;
}

.camera-video,
.camera-preview {
  width: 100%;
  border-radius: 10px;
  border: 1px solid #d0dce7;
  background: #000;
  max-height: 280px;
  object-fit: cover;
}

.camera-preview {
  background: #f8fbff;
}

.camera-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.42rem;
}

.form-label-grid {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.15rem;
}

.form-label-grid span {
  font-size: 0.7rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 700;
}

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

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

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

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

#quickSetForm {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

#quickSetForm button {
  grid-column: 1 / -1;
}

#exerciseForm {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

#exerciseForm button {
  grid-column: 1 / -1;
}

#metricsForm {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

#metricsForm button {
  grid-column: 1 / -1;
}

#goalsForm {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

#goalsForm button {
  grid-column: 1 / -1;
}

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

#authForm {
  grid-template-columns: 1fr 1fr 1.5fr;
}

#changePasswordForm {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

#changePasswordForm button {
  grid-column: 1 / -1;
}

.auth-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

#burnCalibrationForm {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

#burnCalibrationForm button {
  grid-column: 1 / -1;
}

.session-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.62rem;
  background: linear-gradient(160deg, #ffffff, #f7fbff);
}

.session-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.4rem;
}

.session-row button {
  width: auto;
  padding: 0.46rem 0.72rem;
  min-height: 34px;
  border-radius: 10px;
  box-shadow: none;
}

.goal-row {
  display: grid;
  grid-template-columns: 102px 1fr;
  gap: 0.6rem;
  align-items: center;
}

.library-row {
  display: grid;
  grid-template-columns: 102px 1fr auto;
  gap: 0.5rem;
  align-items: center;
}

.library-row label {
  font-size: 0.82rem;
  color: #64748b;
  font-weight: 700;
}

.library-row button {
  width: auto;
  min-height: 36px;
  padding: 0.4rem 0.7rem;
  box-shadow: none;
}

.library-actions {
  display: flex;
  justify-content: flex-end;
}

.library-actions button {
  width: auto;
  min-height: 34px;
  padding: 0.32rem 0.62rem;
  box-shadow: none;
}

.goal-row label {
  font-size: 0.82rem;
  color: #64748b;
  font-weight: 700;
}

textarea,
input,
select,
button {
  width: 100%;
  font-family: inherit;
  font-size: 0.94rem;
  border-radius: 12px;
  border: 1px solid #cad6e2;
  background: #fff;
  color: #0f172a;
  padding: 0.68rem 0.78rem;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 120ms ease;
}

textarea::placeholder,
input::placeholder {
  color: #94a3b8;
}

textarea:focus,
input:focus,
select:focus {
  outline: none;
  border-color: #0ea5a4;
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.18);
}

button {
  border: none;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.25);
}

button:hover {
  cursor: pointer;
  transform: translateY(-1px);
  filter: brightness(1.02);
}

button:active {
  transform: translateY(0);
}

button.is-loading {
  opacity: 0.88;
  cursor: wait;
}

button.is-loading:hover {
  transform: none;
  filter: none;
}

.weights-only-field.hidden {
  display: none;
}

.list {
  display: grid;
  gap: 0.5rem;
}

.list-item {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, #ffffff, #f8fbff);
  padding: 0.66rem 0.72rem;
}

.list-item strong {
  font-size: 0.94rem;
}

.meal-card {
  padding: 0.72rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
  align-items: center;
  background: linear-gradient(160deg, #ffffff, #f8fbff);
}

.meal-left {
  min-width: 0;
}

.meal-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.meal-actions {
  display: inline-flex;
  gap: 0.28rem;
  align-items: center;
}

.meal-library-btn {
  width: 26px !important;
  min-width: 26px;
  min-height: 26px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid #c2d9ee;
  background: #f3f9ff;
  color: #0f4d7a;
  box-shadow: none;
  font-size: 0.9rem;
  line-height: 1;
}

.meal-library-btn:hover {
  transform: none;
  filter: none;
  background: #e8f4ff;
}

.meal-title {
  font-size: 0.95rem;
  line-height: 1.28;
}

.meal-delete-btn {
  width: auto !important;
  min-width: unset;
  min-height: 26px;
  padding: 0.16rem 0.45rem;
  border-radius: 8px;
  border: 1px solid #e8caca;
  background: #fff7f7;
  color: #a61b3f;
  box-shadow: none;
  font-size: 0.7rem;
  font-weight: 700;
}

.meal-delete-btn:hover {
  background: #ffeded;
  transform: none;
  filter: none;
}

.meal-sub {
  margin-top: 0.18rem;
  font-size: 0.78rem;
  color: #64748b;
}

.meal-item-breakdown {
  margin-top: 0.44rem;
  border: 1px solid #dbe5f1;
  border-radius: 10px;
  background: #fbfdff;
  overflow: hidden;
}

.meal-item-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
}

.meal-item-table th,
.meal-item-table td {
  padding: 0.34rem 0.5rem;
  border-bottom: 1px solid #edf2f8;
  text-align: right;
  color: #475569;
}

.meal-item-table th {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #64748b;
  background: #f5f9ff;
}

.meal-item-table th:first-child,
.meal-item-table td:first-child {
  text-align: left;
}

.meal-item-table td.name {
  color: #1e293b;
}

.meal-item-table tbody tr.total td {
  font-weight: 700;
  color: #0f172a;
  background: #f3f8ff;
  border-bottom: none;
}

.meal-macro-row {
  margin-top: 0.45rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.32rem;
}

.meal-macro {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.42rem;
  border-radius: 999px;
  border: 1px solid #c6d4e2;
  background: #f8fafc;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  color: #334155;
}

.meal-macro em {
  font-style: normal;
  font-weight: 700;
}

.meal-macro.protein {
  background: rgba(15, 118, 110, 0.08);
}

.meal-macro.carbs {
  background: rgba(249, 115, 22, 0.1);
}

.meal-macro.fat {
  background: rgba(14, 165, 233, 0.1);
}

.meal-right {
  display: grid;
  justify-items: center;
  gap: 0.2rem;
}

.meal-right small {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  color: #64748b;
}

.macro-ring {
  --p: 33;
  --c: 33;
  --f: 34;
  width: 58px;
  height: 58px;
  border-radius: 999px;
  position: relative;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: conic-gradient(
    var(--protein) 0 calc(var(--p) * 1%),
    var(--carb) calc(var(--p) * 1%) calc((var(--p) + var(--c)) * 1%),
    var(--fat) calc((var(--p) + var(--c)) * 1%) 100%
  );
}

.macro-ring::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 999px;
  background: #ffffff;
}

.macro-ring span {
  position: relative;
  z-index: 1;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.74rem;
  font-weight: 700;
  color: #334155;
}

.ring-good {
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.22);
}

.ring-ok {
  box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.22);
}

.ring-bad {
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2);
}

.food-chips {
  margin-top: 0.45rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.macro-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.2rem 0.42rem;
  border-radius: 999px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  border: 1px solid #c6d4e2;
  background: #f8fafc;
  color: #334155;
}

.chip-protein {
  background: rgba(15, 118, 110, 0.08);
}

.chip-carb {
  background: rgba(249, 115, 22, 0.1);
}

.chip-fat {
  background: rgba(14, 165, 233, 0.1);
}

.chip-good {
  border-color: rgba(22, 163, 74, 0.4);
}

.chip-ok {
  border-color: rgba(217, 119, 6, 0.45);
}

.chip-bad {
  border-color: rgba(220, 38, 38, 0.4);
}

.list-item .meta {
  margin-top: 0.26rem;
  color: #475569;
  font-size: 0.8rem;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
}

.data-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.data-table th,
.data-table td {
  padding: 0.58rem 0.62rem;
  text-align: left;
  border-bottom: 1px solid #e4ebf3;
  white-space: nowrap;
}

.data-table th {
  font-size: 0.74rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #64748b;
  background: #f8fbff;
}

.data-table td {
  color: #334155;
}

.data-table tbody tr:hover {
  background: #f8fbff;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.table-delete-btn {
  width: auto;
  min-height: 24px;
  padding: 0.14rem 0.4rem;
  border-radius: 8px;
  border: 1px solid #e8caca;
  background: #fff7f7;
  color: #a61b3f;
  box-shadow: none;
  font-size: 0.68rem;
}

.table-delete-btn:hover {
  background: #ffeded;
  transform: none;
  filter: none;
}

.library-modal {
  border: none;
  border-radius: 16px;
  padding: 0;
  width: min(860px, calc(100vw - 2rem));
  background: transparent;
}

.settings-modal {
  border: none;
  border-radius: 18px;
  padding: 0;
  width: min(1120px, calc(100vw - 2rem));
  background: transparent;
}

.settings-modal::backdrop {
  background: rgba(15, 23, 42, 0.38);
}

.settings-modal-shell {
  background: #ffffff;
  border: 1px solid #d7e1ec;
  border-radius: 18px;
  padding: 0.9rem;
  display: grid;
  gap: 0.8rem;
  max-height: min(86vh, 920px);
  overflow: auto;
}

.settings-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  position: sticky;
  top: 0;
  background: #ffffff;
  z-index: 2;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid #edf3fa;
}

.settings-panel {
  border: 1px solid #d9e4f0;
  border-radius: 14px;
  background: linear-gradient(160deg, #ffffff, #f8fbff);
  padding: 0.8rem;
  display: grid;
  gap: 0.62rem;
}

.library-modal::backdrop {
  background: rgba(15, 23, 42, 0.35);
}

.library-modal-shell {
  background: #ffffff;
  border: 1px solid #d7e1ec;
  border-radius: 16px;
  padding: 0.9rem;
  display: grid;
  gap: 0.6rem;
}

.library-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.library-modal-header h3 {
  font-size: 1rem;
}

.library-name-input {
  width: 100%;
  min-width: 220px;
  font-size: 0.8rem;
  padding: 0.34rem 0.45rem;
  border-radius: 8px;
}

.library-row-actions {
  display: inline-flex;
  gap: 0.28rem;
}

.table-action-btn {
  width: auto;
  min-height: 24px;
  padding: 0.14rem 0.4rem;
  border-radius: 8px;
  border: 1px solid #c7d6e5;
  background: #f5f9ff;
  color: #1f4468;
  box-shadow: none;
  font-size: 0.68rem;
}

.table-action-btn:hover {
  background: #ecf4ff;
  transform: none;
  filter: none;
}

.metrics-readout {
  min-height: 50px;
  padding: 0.6rem;
  border-radius: 12px;
  border: 1px solid #d7e3ef;
  background: linear-gradient(160deg, #f9fcff, #f3f8ff);
  font-family: inherit;
  font-size: 0.84rem;
  color: #0f172a;
}

.metric-mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.42rem;
}

.metric-mini {
  border: 1px solid #d6e2ee;
  background: #ffffff;
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
  display: grid;
  gap: 0.16rem;
}

.metric-mini .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  font-weight: 700;
}

.metric-mini strong {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.86rem;
  color: #0f172a;
}

.charts {
  display: grid;
  gap: 0.9rem;
}

canvas {
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #ffffff;
}

footer {
  width: min(1560px, 100%);
  margin: 0 auto;
  padding: 0 1rem 1.3rem;
  color: #64748b;
  font-size: 0.8rem;
}

code {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  background: #eef5ff;
  border: 1px solid #d4e2f0;
  border-radius: 6px;
  padding: 0.1rem 0.3rem;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes aiPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(8, 145, 178, 0.22);
  }
  70% {
    box-shadow: 0 0 0 9px rgba(8, 145, 178, 0.02);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(8, 145, 178, 0);
  }
}

@media (min-width: 900px) {
  .grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: 0;
  }

  .card {
    grid-column: span 6;
    margin: 0;
  }

  .card.layout-size-s {
    grid-column: span 4;
  }

  .card.layout-size-m {
    grid-column: span 6;
  }

  .card.layout-size-l {
    grid-column: span 8;
  }

  .card.layout-size-xl {
    grid-column: 1 / -1;
  }

  .snapshot-layout {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

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

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

  .row-wrap {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .snapshot-hero {
    grid-template-columns: 1fr;
  }

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

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

  .form-label-grid.cols-2,
  .form-label-grid.cols-3,
  .form-label-grid.cols-4,
  .form-label-grid.cols-5 {
    grid-template-columns: 1fr;
  }

  #quickSetForm,
  #exerciseForm,
  #metricsForm,
  #goalsForm,
  #aiSettingsForm,
  #authForm,
  #changePasswordForm,
  #burnCalibrationForm {
    grid-template-columns: 1fr;
  }

  .auth-actions {
    grid-template-columns: 1fr 1fr;
  }

  .meal-card {
    grid-template-columns: 1fr;
  }

  .meal-right {
    justify-items: start;
    grid-auto-flow: column;
    align-items: center;
  }

  .library-row {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 620px) {
  .tabs {
    align-items: flex-start;
    flex-direction: column;
  }

  .tabs-right {
    width: 100%;
  }

  .tabs-right input[type="date"] {
    width: 100%;
  }

  .brand-logo {
    width: 144px;
  }

  .brand p {
    font-size: 0.78rem;
  }
}
