:root {
  color-scheme: light;
  --bg: #edf5ff;
  --surface: rgba(255, 255, 255, 0.62);
  --surface-solid: #ffffff;
  --surface-soft: rgba(239, 247, 255, 0.72);
  --ink: #0d1b2a;
  --muted: #58708a;
  --faint: #8398ad;
  --line: rgba(138, 177, 220, 0.34);
  --teal: #2563eb;
  --teal-dark: #1d4ed8;
  --mint: #38bdf8;
  --coral: #ef5b6b;
  --gold: #f2b84b;
  --blue: #2563eb;
  --violet: #5b6ee1;
  --glass-edge: rgba(255, 255, 255, 0.68);
  --shadow: 0 26px 70px rgba(30, 90, 168, 0.18);
  --shadow-soft: 0 12px 32px rgba(30, 90, 168, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  min-height: 100%;
  background:
    linear-gradient(145deg, rgba(37, 99, 235, 0.18), transparent 44%),
    linear-gradient(315deg, rgba(56, 189, 248, 0.2), transparent 42%),
    linear-gradient(180deg, #f7fbff, #eaf4ff 48%, #f7fbff),
    var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(37, 99, 235, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37, 99, 235, 0.05) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.78), transparent 72%);
}

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

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.ambient-grid {
  position: fixed;
  inset: auto 0 0;
  z-index: -1;
  height: 36vh;
  pointer-events: none;
  background:
    linear-gradient(to bottom, transparent, rgba(237, 245, 255, 0.96)),
    repeating-linear-gradient(90deg, rgba(37, 99, 235, 0.07) 0 1px, transparent 1px 72px);
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 22px;
  align-items: center;
  padding: 12px 0 26px;
}

.brand-block {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 14px;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: var(--radius);
  background:
    conic-gradient(from 220deg, #1d4ed8, #38bdf8, #dbeafe, #5b6ee1, #1d4ed8);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.brand-mark::after {
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: var(--surface-solid);
  content: "";
}

.brand-mark span {
  position: relative;
  z-index: 1;
  width: 18px;
  height: 26px;
  border: 3px solid var(--teal-dark);
  border-top: 0;
  border-radius: 0 0 16px 16px;
  transform: rotate(28deg);
}

.brand-mark span::before,
.brand-mark span::after {
  position: absolute;
  content: "";
  background: var(--teal-dark);
}

.brand-mark span::before {
  top: -5px;
  left: 3px;
  width: 3px;
  height: 10px;
  border-radius: 999px;
}

.brand-mark span::after {
  top: 4px;
  right: -8px;
  width: 12px;
  height: 3px;
  border-radius: 999px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: 36px;
  line-height: 1.06;
}

h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

h3 {
  margin: 0;
  font-size: 15px;
}

.lead {
  max-width: 520px;
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 650;
}

.energy-visual {
  display: grid;
  grid-template-columns: 92px 1fr;
  align-items: center;
  gap: 14px;
  min-height: 92px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: var(--radius);
  padding: 14px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.76), rgba(224, 242, 254, 0.45));
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(20px) saturate(1.25);
  overflow: hidden;
}

.plate-visual {
  position: relative;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: conic-gradient(var(--mint) 0 38%, var(--gold) 38% 70%, var(--coral) 70% 100%);
  animation: plateSpin 16s linear infinite;
}

.plate-ring {
  position: absolute;
  inset: 8px;
  border: 8px solid rgba(255, 255, 255, 0.92);
  border-radius: inherit;
}

.plate-slice {
  position: absolute;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 12px rgba(23, 33, 36, 0.12);
}

.plate-slice.protein {
  width: 22px;
  height: 12px;
  left: 20px;
  top: 20px;
}

.plate-slice.carbs {
  width: 26px;
  height: 10px;
  right: 14px;
  bottom: 25px;
}

.plate-slice.fat {
  width: 12px;
  height: 12px;
  left: 28px;
  bottom: 17px;
}

.signal-bars {
  display: grid;
  align-items: end;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  height: 62px;
}

.signal-bars span {
  display: block;
  min-width: 0;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--teal), var(--mint));
  animation: barPulse 1.8s ease-in-out infinite;
}

.signal-bars span:nth-child(1) {
  height: 38%;
}

.signal-bars span:nth-child(2) {
  height: 78%;
  background: linear-gradient(180deg, var(--gold), var(--mint));
  animation-delay: 160ms;
}

.signal-bars span:nth-child(3) {
  height: 54%;
  background: linear-gradient(180deg, var(--blue), var(--teal));
  animation-delay: 320ms;
}

.signal-bars span:nth-child(4) {
  height: 90%;
  background: linear-gradient(180deg, var(--coral), var(--gold));
  animation-delay: 480ms;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  gap: 12px;
}

.date-field {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.date-field input,
.profile-grid input,
.profile-grid select,
.config-form input,
.config-form select,
.tcx-picker input,
.notes-field textarea {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.date-field input {
  width: 150px;
  padding: 10px 12px;
}

.profile-grid input,
.profile-grid select,
.config-form input,
.config-form select,
.tcx-picker input,
.notes-field textarea {
  padding: 11px 12px;
}

.date-field input:focus,
.profile-grid input:focus,
.profile-grid select:focus,
.config-form input:focus,
.config-form select:focus,
.tcx-picker input:focus,
.notes-field textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(8, 125, 121, 0.13);
  transform: translateY(-1px);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  max-width: 230px;
  border: 1px solid rgba(37, 99, 235, 0.22);
  border-radius: 999px;
  padding: 7px 12px;
  background: rgba(37, 99, 235, 0.1);
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill.neutral {
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--muted);
}

.status-pill.warning {
  border-color: rgba(216, 92, 70, 0.28);
  background: rgba(216, 92, 70, 0.09);
  color: #9c3f2f;
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  gap: 18px;
  align-items: start;
}

.panel {
  position: relative;
  min-width: 0;
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.76), rgba(220, 238, 255, 0.42)),
    rgba(255, 255, 255, 0.42);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(1.3);
  transform: translateY(14px);
  opacity: 0;
  overflow: hidden;
}

.panel::before,
.modal-card::before {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.72), transparent 34%),
    linear-gradient(315deg, rgba(96, 165, 250, 0.16), transparent 44%);
  opacity: 0.78;
}

body.ready .panel {
  animation: enterPanel 560ms cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}

body.ready .upload-panel {
  animation-delay: 70ms;
}

body.ready .result-panel {
  animation-delay: 140ms;
}

body.ready .history-panel {
  animation-delay: 210ms;
}

.profile-panel,
.upload-panel,
.result-panel,
.history-panel {
  padding: 18px;
}

.result-panel {
  position: relative;
  overflow: hidden;
}

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

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.ghost-button,
.primary-button {
  position: relative;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-weight: 850;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
  overflow: hidden;
}

.ghost-button {
  background: var(--surface-soft);
  color: var(--ink);
}

.ghost-button:hover {
  border-color: var(--line);
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

.ghost-button.danger {
  color: #9c3f2f;
}

.config-entry {
  min-width: 68px;
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--ink);
  font-weight: 900;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.icon-button:hover {
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.primary-button {
  background: linear-gradient(135deg, #1d4ed8, #2563eb 55%, #38bdf8);
  color: #fff;
  box-shadow: 0 16px 36px rgba(37, 99, 235, 0.28);
}

.primary-button::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(110deg, transparent, rgba(255, 255, 255, 0.26), transparent);
  transform: translateX(-120%);
}

.primary-button:hover {
  box-shadow: 0 20px 44px rgba(37, 99, 235, 0.34);
  transform: translateY(-1px);
}

.primary-button:hover::after,
body.is-analyzing .primary-button::after {
  animation: buttonSheen 1.2s ease;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.72;
  transform: none;
}

.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.profile-grid label,
.notes-field,
.tcx-picker {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

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

.profile-state {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  margin-bottom: 14px;
  border: 1px solid rgba(37, 99, 235, 0.22);
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.1);
  color: var(--teal-dark);
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 850;
}

.profile-state.warning {
  border-color: rgba(216, 92, 70, 0.24);
  background: rgba(216, 92, 70, 0.08);
  color: #9c3f2f;
}

.quick-profile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  border: 1px solid rgba(147, 197, 253, 0.42);
  border-radius: var(--radius);
  background: rgba(239, 247, 255, 0.58);
  padding: 12px;
}

.quick-profile span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.quick-profile strong {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  font-size: 16px;
}

.quick-profile .ghost-button {
  width: auto;
  flex: 0 0 auto;
}

.profile-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.profile-summary div {
  min-width: 0;
  border: 1px solid rgba(217, 225, 224, 0.92);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  padding: 11px 12px;
}

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

.profile-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.profile-summary strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--ink);
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.baseline-box,
.macro-grid,
.source-strip,
.kpi-grid {
  display: grid;
  gap: 10px;
}

.baseline-box {
  grid-template-columns: 1fr 1fr;
  margin-top: 16px;
}

.baseline-box div,
.macro-grid div,
.kpi,
.source-strip div {
  border: 1px solid rgba(217, 225, 224, 0.92);
  border-radius: var(--radius);
  background: rgba(238, 243, 242, 0.78);
  padding: 12px;
}

.baseline-box span,
.macro-grid span,
.kpi span,
.source-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.baseline-box strong,
.macro-grid strong,
.kpi strong,
.source-strip strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

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

.dropzone {
  position: relative;
  min-height: 230px;
  border: 1.5px dashed rgba(96, 165, 250, 0.72);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.64), rgba(219, 234, 254, 0.34));
  padding: 16px;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
  overflow: hidden;
}

.dropzone::before {
  position: absolute;
  top: -40%;
  bottom: -40%;
  left: -30%;
  width: 22%;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(8, 125, 121, 0.14), transparent);
  transform: rotate(18deg) translateX(-180%);
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--teal);
  background: rgba(37, 99, 235, 0.075);
  box-shadow: var(--shadow-soft);
  transform: translateY(-2px);
}

.dropzone:hover::before,
.dropzone.dragover::before,
body.is-analyzing .dropzone::before {
  animation: scanDropzone 1.35s ease;
}

.dropzone-icon {
  position: relative;
  display: grid;
  width: 42px;
  height: 42px;
  margin-bottom: 12px;
  place-items: center;
  border-radius: var(--radius);
  background: rgba(37, 99, 235, 0.12);
  color: var(--teal-dark);
  font-size: 28px;
  font-weight: 500;
}

.dropzone-icon::after {
  position: absolute;
  inset: -4px;
  border: 1px solid rgba(37, 99, 235, 0.24);
  border-radius: inherit;
  content: "";
  animation: softPing 2.2s ease-out infinite;
}

.dropzone h3 {
  margin-bottom: 4px;
}

.dropzone p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.source-strip {
  grid-template-columns: repeat(4, 1fr);
  margin-top: 14px;
}

.source-strip div {
  padding: 10px 12px;
}

.source-strip strong {
  color: var(--teal-dark);
  font-size: 20px;
}

.file-list,
.item-list,
.history-list {
  display: grid;
  gap: 9px;
}

.file-chip {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) 32px;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  padding: 8px;
  animation: popIn 240ms ease both;
}

.file-chip img {
  width: 50px;
  height: 50px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface-soft);
}

.file-meta {
  min-width: 0;
}

.file-meta strong,
.history-item strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta span {
  color: var(--muted);
  font-size: 12px;
}

.remove-button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--coral);
  font-weight: 900;
}

.remove-button:hover {
  background: rgba(216, 92, 70, 0.08);
}

.tcx-row {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 14px;
  align-items: end;
  margin-top: 14px;
}

.tcx-summary {
  min-height: 45px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(238, 243, 242, 0.78);
  padding: 11px 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.notes-field {
  margin-top: 14px;
}

.notes-field textarea {
  min-height: 112px;
  resize: vertical;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
}

.form-message {
  min-height: 24px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  transition: color 160ms ease, opacity 160ms ease;
}

.form-message.error {
  color: #9c3f2f;
}

.result-hero {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

.energy-ring {
  position: relative;
  display: grid;
  width: 148px;
  height: 148px;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--surface-solid) 0 56%, transparent 57%),
    conic-gradient(var(--teal) 0 var(--ring-progress), rgba(217, 225, 224, 0.95) var(--ring-progress) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.7),
    var(--shadow-soft);
  transition: background 260ms ease;
}

.energy-ring::after {
  position: absolute;
  inset: 13px;
  border: 1px solid rgba(8, 125, 121, 0.14);
  border-radius: inherit;
  content: "";
}

.energy-ring.positive {
  background:
    radial-gradient(circle at center, var(--surface-solid) 0 56%, transparent 57%),
    conic-gradient(var(--mint) 0 var(--ring-progress), rgba(217, 225, 224, 0.95) var(--ring-progress) 100%);
}

.energy-ring.negative {
  background:
    radial-gradient(circle at center, var(--surface-solid) 0 56%, transparent 57%),
    conic-gradient(var(--coral) 0 var(--ring-progress), rgba(217, 225, 224, 0.95) var(--ring-progress) 100%);
}

.energy-ring span,
.energy-ring small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.energy-ring strong {
  margin-top: -8px;
  font-size: 30px;
  line-height: 1;
}

.result-signal {
  position: relative;
  height: 124px;
  border: 1px solid rgba(217, 225, 224, 0.78);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(238, 243, 242, 0.7)),
    repeating-linear-gradient(0deg, transparent 0 22px, rgba(23, 33, 36, 0.045) 23px 24px);
  overflow: hidden;
}

.result-signal::before {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(8, 125, 121, 0.12), transparent);
  transform: translateX(-100%);
  animation: signalSweep 3.6s ease-in-out infinite;
}

.result-signal span {
  position: absolute;
  bottom: 18px;
  width: 16%;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--teal), var(--mint));
  animation: waveRise 2.4s ease-in-out infinite;
}

.result-signal span:nth-child(1) {
  left: 8%;
  height: 34%;
}

.result-signal span:nth-child(2) {
  left: 26%;
  height: 58%;
  background: linear-gradient(180deg, var(--gold), var(--mint));
  animation-delay: 140ms;
}

.result-signal span:nth-child(3) {
  left: 44%;
  height: 42%;
  background: linear-gradient(180deg, var(--blue), var(--teal));
  animation-delay: 280ms;
}

.result-signal span:nth-child(4) {
  left: 62%;
  height: 72%;
  background: linear-gradient(180deg, var(--coral), var(--gold));
  animation-delay: 420ms;
}

.result-signal span:nth-child(5) {
  left: 80%;
  height: 48%;
  background: linear-gradient(180deg, var(--violet), var(--blue));
  animation-delay: 560ms;
}

.loading-visual {
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  border: 1px solid rgba(37, 99, 235, 0.22);
  border-radius: var(--radius);
  background: rgba(37, 99, 235, 0.08);
  padding: 10px 12px;
  color: var(--teal-dark);
}

.loading-core {
  position: relative;
  width: 42px;
  height: 42px;
}

.loading-core span {
  position: absolute;
  inset: 0;
  border: 2px solid rgba(8, 125, 121, 0.18);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: ringSpin 900ms linear infinite;
}

.loading-core span:nth-child(2) {
  inset: 7px;
  border-top-color: var(--gold);
  animation-duration: 1.2s;
  animation-direction: reverse;
}

.loading-core span:nth-child(3) {
  inset: 14px;
  border-top-color: var(--coral);
  animation-duration: 1.6s;
}

.kpi-grid {
  grid-template-columns: repeat(3, 1fr);
}

.macro-grid {
  grid-template-columns: repeat(3, 1fr);
  margin: 14px 0;
}

.kpi {
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

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

.kpi.accent {
  border-color: rgba(47, 143, 91, 0.28);
  background: rgba(47, 143, 91, 0.08);
}

.kpi.accent.positive {
  border-color: rgba(47, 143, 91, 0.34);
  background: rgba(47, 143, 91, 0.12);
}

.kpi.accent.negative {
  border-color: rgba(216, 92, 70, 0.34);
  background: rgba(216, 92, 70, 0.11);
}

.balance-meter {
  height: 12px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(216, 92, 70, 0.22), rgba(214, 162, 50, 0.24), rgba(47, 143, 91, 0.24));
}

.balance-fill {
  width: 50%;
  height: 100%;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--teal-dark), var(--teal), var(--mint));
  transition: width 420ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.result-block {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 14px;
}

.result-block h3 {
  margin-bottom: 10px;
}

.food-row,
.history-item,
.workout-result {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  padding: 11px 12px;
}

.food-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px;
  gap: 10px;
  animation: popIn 280ms ease both;
}

.food-row p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.food-row strong:last-child {
  justify-self: end;
  color: var(--teal-dark);
}

.workout-result p {
  margin: 4px 0 0;
  color: var(--muted);
}

.suggestion-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.suggestion-list li {
  border-left: 3px solid var(--gold);
  border-radius: 6px;
  background: rgba(214, 162, 50, 0.09);
  padding: 10px 12px;
  animation: popIn 280ms ease both;
}

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

.history-item {
  display: grid;
  gap: 4px;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.history-item:hover {
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

.history-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.history-item button {
  justify-self: start;
  min-height: 32px;
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--ink);
  font-weight: 850;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(23, 33, 36, 0.34);
  backdrop-filter: blur(10px);
}

.modal-card {
  position: relative;
  width: min(620px, 100%);
  max-height: min(760px, calc(100vh - 44px));
  overflow: auto;
  border: 1px solid rgba(217, 225, 224, 0.9);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 30px 80px rgba(21, 36, 39, 0.24);
  padding: 20px;
  animation: modalIn 220ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.modal-heading {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.config-tabs {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 16px;
  border: 1px solid rgba(147, 197, 253, 0.48);
  border-radius: var(--radius);
  background: rgba(219, 234, 254, 0.36);
  padding: 5px;
}

.tab-button {
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.tab-button.active {
  background: rgba(255, 255, 255, 0.86);
  color: var(--teal-dark);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.12);
}

.config-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.config-form.config-panel {
  position: relative;
  display: none;
}

.config-form.config-panel.active {
  display: grid;
}

.config-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border: 1px solid rgba(147, 197, 253, 0.38);
  border-radius: var(--radius);
  background: rgba(239, 247, 255, 0.52);
  padding: 10px 12px;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

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

.config-preview {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 4px;
}

.config-preview div {
  border: 1px solid rgba(217, 225, 224, 0.92);
  border-radius: var(--radius);
  background: rgba(238, 243, 242, 0.78);
  padding: 12px;
}

.config-preview span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.config-preview strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 18px;
}

.ai-preview strong {
  font-size: 16px;
}

.test-status {
  min-height: 38px;
  margin: 0;
  border: 1px solid rgba(147, 197, 253, 0.42);
  border-radius: var(--radius);
  background: rgba(239, 247, 255, 0.58);
  color: var(--muted);
  padding: 9px 11px;
  font-size: 13px;
  font-weight: 750;
}

.test-status.success {
  border-color: rgba(37, 99, 235, 0.34);
  background: rgba(37, 99, 235, 0.1);
  color: var(--teal-dark);
}

.test-status.error {
  border-color: rgba(216, 92, 70, 0.28);
  background: rgba(216, 92, 70, 0.08);
  color: #9c3f2f;
}

.modal-actions {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 4px;
}

body.modal-open {
  overflow: hidden;
}

@keyframes enterPanel {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes buttonSheen {
  to {
    transform: translateX(120%);
  }
}

@keyframes scanDropzone {
  to {
    transform: rotate(18deg) translateX(760%);
  }
}

@keyframes softPing {
  0% {
    opacity: 0.68;
    transform: scale(0.92);
  }
  80%,
  100% {
    opacity: 0;
    transform: scale(1.25);
  }
}

@keyframes plateSpin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes barPulse {
  0%,
  100% {
    transform: scaleY(0.86);
  }
  50% {
    transform: scaleY(1);
  }
}

@keyframes signalSweep {
  0%,
  38% {
    transform: translateX(-100%);
  }
  72%,
  100% {
    transform: translateX(100%);
  }
}

@keyframes waveRise {
  0%,
  100% {
    transform: scaleY(0.82);
  }
  50% {
    transform: scaleY(1);
  }
}

@keyframes ringSpin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .dashboard {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 400px);
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding: 18px;
  }

  .topbar,
  .topbar-actions,
  .action-row {
    align-items: stretch;
  }

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

  .topbar-actions,
  .action-row {
    flex-direction: column;
  }

  h1 {
    font-size: 30px;
  }

  .dashboard,
  .upload-grid,
  .tcx-row,
  .result-hero {
    grid-template-columns: 1fr;
  }

  .history-panel,
  .result-panel,
  .upload-panel {
    grid-column: auto;
  }

  .date-field {
    align-items: stretch;
    flex-direction: column;
  }

  .date-field input,
  .status-pill,
  .config-entry,
  .primary-button {
    width: 100%;
    max-width: none;
  }

  .energy-ring {
    justify-self: center;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 14px;
  }

  .brand-block {
    align-items: flex-start;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
  }

  .profile-panel,
  .upload-panel,
  .result-panel,
  .history-panel {
    padding: 14px;
  }

  .profile-grid,
  .profile-summary,
  .baseline-box,
  .kpi-grid,
  .macro-grid,
  .source-strip,
  .config-form,
  .config-preview {
    grid-template-columns: 1fr;
  }

  .profile-summary .wide,
  .config-form .wide,
  .config-preview,
  .modal-actions {
    grid-column: auto;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .quick-profile {
    align-items: stretch;
    flex-direction: column;
  }

  .ghost-button {
    width: 100%;
  }

  .modal-backdrop {
    align-items: end;
    padding: 10px;
  }

  .modal-card {
    width: 100%;
    max-height: calc(100vh - 20px);
    padding: 16px;
  }

  .modal-heading {
    align-items: flex-start;
  }

  .modal-actions {
    flex-direction: column;
  }

  .modal-actions button {
    width: 100%;
  }

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

  .food-row strong:last-child {
    justify-self: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }

  .panel {
    opacity: 1;
    transform: none;
  }
}
