/* Evolt 360 Body Recomp Tracker */

:root {
  --bg: #0b0f14;
  --bg-elevated: #121820;
  --bg-card: #161d27;
  --bg-card-hover: #1b2430;
  --border: #243041;
  --border-soft: #1c2633;
  --text: #e8eef6;
  --text-muted: #8b9bb0;
  --text-dim: #5c6b7e;
  --accent: #3d9cf0;
  --accent-soft: rgba(61, 156, 240, 0.15);
  --orange: #f0a03d;
  --orange-soft: rgba(240, 160, 61, 0.15);
  --red: #f05555;
  --red-soft: rgba(240, 85, 85, 0.15);
  --green: #3dd68c;
  --green-soft: rgba(61, 214, 140, 0.15);
  --purple: #a78bfa;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "Consolas", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(61, 156, 240, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 90% 0%, rgba(240, 160, 61, 0.08), transparent),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* ---------- Layout ---------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  background: rgba(11, 15, 20, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #2563eb);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: -0.02em;
  box-shadow: 0 0 20px rgba(61, 156, 240, 0.35);
}

.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.brand p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.dash-nav {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 0.2rem;
  gap: 0.15rem;
}

.nav-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.nav-link.active {
  color: #fff;
  background: linear-gradient(135deg, #3d9cf0, #2563eb);
}

body.eufy-theme .nav-link.active {
  background: linear-gradient(135deg, #34d399, #059669);
}

.brand-mark-eufy {
  background: linear-gradient(135deg, #34d399, #059669) !important;
  box-shadow: 0 0 20px rgba(52, 211, 153, 0.35) !important;
}

body.eufy-theme {
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(52, 211, 153, 0.1), transparent),
    radial-gradient(ellipse 60% 40% at 90% 0%, rgba(61, 156, 240, 0.06), transparent),
    var(--bg);
}

body.eufy-theme .btn-primary {
  background: linear-gradient(135deg, #34d399, #059669);
  box-shadow: 0 4px 16px rgba(5, 150, 105, 0.35);
}

body.eufy-theme .btn-primary:hover {
  background: linear-gradient(135deg, #4ade80, #10b981);
}

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 3rem;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.75rem 0 0.85rem;
}

.section-title h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.section-title .hint {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* ---------- Buttons ---------- */

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 550;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn:hover {
  background: var(--bg-card-hover);
  border-color: #334155;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, #3d9cf0, #2563eb);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4aa6f5, #3b72f0);
}

.btn-ghost {
  background: transparent;
}

.btn-danger {
  border-color: rgba(240, 85, 85, 0.4);
  color: #fca5a5;
}

.btn-delete-scan {
  font-size: 0.75rem;
  padding: 0.3rem 0.65rem;
  color: #fca5a5;
  border-color: rgba(240, 85, 85, 0.35);
}

.btn-delete-scan:hover {
  background: rgba(240, 85, 85, 0.12);
  border-color: rgba(240, 85, 85, 0.55);
}

/* ---------- KPI grid ---------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}

.kpi {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1rem 1.05rem;
  box-shadow: var(--shadow);
  transition: border-color 0.15s;
}

.kpi:hover {
  border-color: var(--border);
}

.kpi-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.kpi-value {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.kpi-unit {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 0.15rem;
}

.kpi-delta {
  margin-top: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.kpi-delta.good {
  color: var(--green);
}
.kpi-delta.bad {
  color: var(--red);
}
.kpi-delta.neutral {
  color: var(--text-dim);
}

.kpi.accent-orange .kpi-value {
  color: var(--orange);
}
.kpi.accent-red .kpi-value {
  color: var(--red);
}
.kpi.accent-green .kpi-value {
  color: var(--green);
}
.kpi.accent-blue .kpi-value {
  color: var(--accent);
}

/* ---------- Goal banner ---------- */

.goal-banner {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1.25rem;
  align-items: center;
  background: linear-gradient(135deg, rgba(61, 156, 240, 0.12), rgba(240, 160, 61, 0.08));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.35rem;
  margin-bottom: 1rem;
}

.goal-banner h3 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  font-weight: 650;
}

.goal-banner p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.progress-wrap {
  margin-top: 0.75rem;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.progress-bar {
  height: 10px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--orange), var(--green));
  transition: width 0.6s ease;
}

.goal-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  text-align: right;
}

.goal-stat strong {
  display: block;
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}

.goal-stat span {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ---------- Charts ---------- */

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 0.75rem;
  box-shadow: var(--shadow);
  min-height: 280px;
}

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

.chart-card h3 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.chart-card canvas {
  width: 100% !important;
  max-height: 240px;
}

.trend-card {
  padding: 1rem 1.15rem 1rem;
}

.trend-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  margin-bottom: 0.75rem;
}

.trend-label {
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.metric-select {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 550;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.45rem 2rem 0.45rem 0.9rem;
  min-width: 200px;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238b9bb0' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
}

.metric-select:hover,
.metric-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.metric-select option {
  background: var(--bg-elevated);
  color: var(--text);
}

.trend-hint {
  font-size: 0.8rem;
  color: var(--text-dim);
  flex: 1;
  min-width: 160px;
}

.trend-chart-wrap {
  height: 320px;
  position: relative;
}

.trend-chart-wrap canvas {
  max-height: none !important;
}

/* ---------- Key insights ---------- */

.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}

.insight-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.95rem 1.05rem;
  box-shadow: var(--shadow);
}

.insight-card.kind-good {
  border-left-color: var(--green);
  background: linear-gradient(135deg, rgba(61, 214, 140, 0.06), var(--bg-card) 50%);
}
.insight-card.kind-warn {
  border-left-color: var(--orange);
  background: linear-gradient(135deg, rgba(240, 160, 61, 0.07), var(--bg-card) 50%);
}
.insight-card.kind-goal,
.insight-card.kind-pace {
  border-left-color: var(--accent);
}
.insight-card.kind-info {
  border-left-color: var(--purple);
}

.insight-card .insight-kind {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
}

.insight-card.kind-good .insight-kind {
  color: var(--green);
}
.insight-card.kind-warn .insight-kind {
  color: var(--orange);
}
.insight-card.kind-goal .insight-kind,
.insight-card.kind-pace .insight-kind {
  color: var(--accent);
}
.insight-card.kind-info .insight-kind {
  color: var(--purple);
}

.insight-card h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.insight-card p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* ---------- Body shape compare ---------- */

.wide-block {
  margin-bottom: 0.25rem;
}

.body-compare {
  padding: 1.15rem 1.25rem 1.25rem;
}

.body-compare-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.body-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.body-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.body-legend .swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.body-legend .swatch.fat {
  background: rgba(240, 160, 61, 0.55);
  box-shadow: 0 0 0 1px rgba(240, 160, 61, 0.4);
}
.body-legend .swatch.lean {
  background: #3a4454;
  box-shadow: 0 0 0 1px rgba(232, 238, 246, 0.15);
}
.body-legend .swatch.delta-down {
  background: var(--green);
}
.body-legend .swatch.delta-up {
  background: var(--orange);
}

.body-figures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: end;
}

.body-figure-card {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 0.85rem 0.5rem 0.75rem;
  text-align: center;
}

.body-figure-card h3 {
  margin: 0 0 0.15rem;
  font-size: 0.9rem;
  font-weight: 650;
}

.body-figure-card .fig-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.body-figure-card canvas {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
}

.sil-pair {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 0.75rem;
  margin: 0.35rem 0 0.15rem;
}

.sil-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.sil-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.body-figure-stats {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  margin-top: 0.5rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.body-figure-stats strong {
  color: var(--text);
  font-weight: 650;
}

.body-callouts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin-top: 0.55rem;
}

.body-callout {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
}

.body-callout.down {
  color: var(--green);
  border-color: rgba(61, 214, 140, 0.35);
}
.body-callout.up {
  color: var(--orange);
  border-color: rgba(240, 160, 61, 0.4);
}

/* ---------- Segmental ---------- */

.segmental-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.seg-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.seg-table th,
.seg-table td {
  padding: 0.55rem 0.4rem;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
}

.seg-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.seg-table td:not(:first-child) {
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: 0.8rem;
}

/* ---------- History table ---------- */

.table-wrap {
  overflow-x: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  min-width: 900px;
}

.history-table th,
.history-table td {
  padding: 0.65rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}

.history-table th {
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.history-table tbody tr:hover {
  background: rgba(61, 156, 240, 0.05);
}

.history-table td {
  font-variant-numeric: tabular-nums;
}

/* ---------- Modal / form ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  overflow-y: auto;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  width: min(780px, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  margin-bottom: 2rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border-soft);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.modal-body {
  padding: 1.25rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-soft);
}

.form-section {
  margin-bottom: 1.35rem;
}

.form-section h3 {
  margin: 0 0 0.75rem;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.field input,
.field textarea,
.field select {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field.span-2 {
  grid-column: span 2;
}

.field.full {
  grid-column: 1 / -1;
}

.field .req {
  color: var(--orange);
}

.form-hint {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin: 0 0 1rem;
}

/* ---------- Toast / status ---------- */

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 0.875rem;
  max-width: 360px;
  transform: translateY(120%);
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
}

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

.toast.ok {
  border-color: rgba(61, 214, 140, 0.45);
}
.toast.err {
  border-color: rgba(240, 85, 85, 0.45);
}

.status-pill {
  font-size: 0.72rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  color: var(--text-muted);
}

.status-pill.ok {
  color: var(--green);
  border-color: rgba(61, 214, 140, 0.35);
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty-state h3 {
  margin: 0 0 0.5rem;
  color: var(--text);
}

/* ---------- Import note ---------- */

.import-note {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.import-note strong {
  color: var(--text);
}

.import-note code {
  font-family: var(--mono);
  font-size: 0.8rem;
  background: var(--bg);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .chart-grid,
  .segmental-grid,
  .body-figures {
    grid-template-columns: 1fr;
  }

  .goal-banner {
    grid-template-columns: 1fr;
  }

  .goal-stats {
    text-align: left;
  }

  .field.span-2 {
    grid-column: span 1;
  }
}

@media (max-width: 600px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  main {
    padding: 1rem;
  }

  .kpi-value {
    font-size: 1.3rem;
  }
}
