:root {
  --bg: #08090a;
  --surface: #111214;
  --surface-2: #191a1e;
  --surface-3: #1f2125;
  --border: rgba(255, 255, 255, 0.06);
  --border-2: rgba(255, 255, 255, 0.10);
  --border-3: rgba(255, 255, 255, 0.15);
  --text: #e4e4e8;
  --text-2: #8b8d94;
  --text-3: #55575e;
  --text-4: #3a3c42;
  --accent: #8b7ad8;
  --accent-dim: rgba(139, 122, 216, 0.10);
  --green: #3dd68c;
  --green-dim: rgba(61, 214, 140, 0.10);
  --red: #f04e4e;
  --red-dim: rgba(240, 78, 78, 0.10);
  --orange: #e8973f;
  --orange-dim: rgba(232, 151, 63, 0.10);
  --blue: #4da2f7;
  --radius: 8px;
  --radius-lg: 12px;
  --sans: 'IBM Plex Sans', -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', 'SF Mono', monospace;
  --ease: cubic-bezier(0.25, 1, 0.5, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle grain */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 200px;
  pointer-events: none;
  z-index: 9999;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 48px 24px 96px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* When loader is showing, constrain to viewport */
.container.is-landing {
  height: 100vh;
  min-height: 0;
  padding-bottom: 24px;
}

/* ── Header ── */
header {
  margin-bottom: 24px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.header-left h1 {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.header-left p {
  color: var(--text-3);
  font-size: 13px;
  font-family: var(--mono);
}

.header-links {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-links a {
  color: var(--text-4);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  transition: color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.header-links a:hover { color: var(--text-2); }
.header-links a svg { flex-shrink: 0; }

/* ── Loader ── */
#loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 20px;
  min-height: 0;
}

.loader-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
}

.loader-icon svg { width: 20px; height: 20px; opacity: 0.5; }

#loader .hint {
  color: var(--text-3);
  font-size: 13px;
  font-family: var(--mono);
  text-align: center;
}

#loader code {
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
  border: 1px solid var(--border);
}

.drop-zone {
  width: 100%;
  max-width: 420px;
  border: 1.5px dashed var(--border-2);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  position: relative;
  overflow: hidden;
}

.drop-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, var(--accent-dim), transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
}

.drop-zone:hover::before,
.drop-zone.drag-over::before { opacity: 1; }

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(139, 122, 216, 0.03);
}

.drop-zone p {
  color: var(--text-3);
  font-size: 13px;
  font-family: var(--mono);
  position: relative;
  z-index: 1;
}

.drop-zone .drop-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  color: var(--accent);
  font-size: 13px;
  font-family: var(--mono);
  font-weight: 500;
  position: relative;
  z-index: 1;
}

/* ── Usage guide ── */
.usage-guide {
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  flex-shrink: 0;
}

.usage-guide summary {
  cursor: pointer;
  font-weight: 500;
  font-family: var(--mono);
  color: var(--text-2);
  font-size: 12px;
  padding: 12px 16px;
  letter-spacing: 0.02em;
  transition: color 0.15s;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.usage-guide summary::-webkit-details-marker { display: none; }
.usage-guide summary::before {
  content: '▸';
  font-size: 10px;
  color: var(--text-4);
  transition: transform 0.15s var(--ease);
}

.usage-guide[open] summary::before { transform: rotate(90deg); }
.usage-guide summary:hover { color: var(--text); }

.usage-steps {
  padding: 0 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.usage-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.step-num {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  margin-top: 1px;
}

.step-body strong {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  display: block;
  margin-bottom: 4px;
}

.step-body p {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.6;
}

.step-body code {
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  border: 1px solid var(--border);
}

.step-body em {
  font-style: normal;
  color: var(--text);
  font-weight: 500;
}

.usage-commands {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.usage-cmd {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.cmd-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-4);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 80px;
  flex-shrink: 0;
}

.usage-cmd code {
  font-size: 11px;
  padding: 4px 10px;
  white-space: nowrap;
  user-select: all;
}

/* ── Global drop overlay ── */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(8, 9, 10, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.drop-overlay.visible {
  display: flex;
  pointer-events: auto;
}

.drop-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px 64px;
  border: 2px dashed var(--accent);
  border-radius: var(--radius-lg);
  background: rgba(139, 122, 216, 0.04);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  animation: fadeUp 0.2s var(--ease);
}

.drop-overlay-inner svg {
  opacity: 0.6;
}

/* ── Machine bar ── */
.machine-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.machine-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 8px 5px 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-2);
  transition: border-color 0.15s;
}

.machine-pill:hover { border-color: var(--border-2); }

.machine-pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  animation: pulse-dot 2s ease infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.machine-pill-name { color: var(--text); font-weight: 500; }
.machine-pill-ago { color: var(--text-4); font-size: 10px; }

.machine-pill-update,
.machine-pill-remove {
  background: none;
  border: none;
  color: var(--text-4);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
}

.machine-pill-update:hover { color: var(--blue); background: rgba(77, 162, 247, 0.1); }
.machine-pill-remove:hover { color: var(--red); background: rgba(240, 78, 78, 0.1); }

.add-machine-btn {
  display: inline-flex;
  align-items: center;
  background: transparent;
  color: var(--text-3);
  border: 1px dashed var(--border-2);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-family: var(--mono);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.add-machine-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}

/* ── Name dialog ── */
dialog {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  padding: 24px;
  color: var(--text);
  max-width: 360px;
  width: 90vw;
  margin: auto;
  position: fixed;
  inset: 0;
  height: fit-content;
}

dialog::backdrop { background: rgba(0, 0, 0, 0.6); }

dialog h3 {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}

dialog input[type="text"] {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

dialog input[type="text"]:focus { border-color: var(--accent); }

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.dialog-actions button {
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--sans);
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.btn-cancel {
  background: transparent;
  color: var(--text-3);
  border: 1px solid var(--border-2);
}
.btn-cancel:hover { color: var(--text-2); background: var(--surface-3); }

.btn-confirm {
  background: var(--accent);
  color: #fff;
}
.btn-confirm:hover { background: #9b8ade; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 8px 16px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
  opacity: 0;
  transition: all 0.25s var(--ease);
  pointer-events: none;
  z-index: 10000;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error { border-color: rgba(240, 78, 78, 0.3); color: var(--red); }

/* ── Dashboard ── */
#dashboard { display: none; }

.fade-in {
  opacity: 0;
  transform: translateY(12px);
  animation: fadeUp 0.5s var(--ease) forwards;
}

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

/* ── Summary cards ── */
.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 24px;
}

@media (max-width: 768px) { .cards { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .cards { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  padding: 20px;
  transition: background 0.15s var(--ease);
}

.card:hover { background: var(--surface-2); }

.card-label {
  font-size: 11px;
  font-weight: 500;
  font-family: var(--mono);
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

.card-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.03em;
  font-family: var(--mono);
  line-height: 1.1;
}

.card-sub {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-3);
  margin-top: 6px;
}

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

/* ── Sections ── */
.section { margin-bottom: 24px; }

.section-title {
  font-size: 11px;
  font-weight: 500;
  font-family: var(--mono);
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

/* ── Charts ── */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 24px;
}

@media (max-width: 768px) { .chart-grid { grid-template-columns: 1fr; } }

.chart-card {
  background: var(--surface);
  padding: 20px;
}

.chart-card h3 {
  font-size: 11px;
  font-weight: 500;
  font-family: var(--mono);
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
}

.chart-card canvas { max-height: 260px; }

/* ── Tables ── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th {
  text-align: left;
  font-weight: 500;
  font-family: var(--mono);
  color: var(--text-4);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }

td.label-cell {
  font-family: var(--sans);
  font-weight: 500;
  color: var(--text);
}

td.right, th.right { text-align: right; }

tr.total-row td {
  font-weight: 600;
  border-top: 1px solid var(--border-2);
  color: var(--text);
  background: transparent !important;
}

.model-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-right: 8px;
  vertical-align: middle;
}

/* ── Burger section ── */
.burger-zone {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  position: relative;
  overflow: hidden;
}

.burger-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, var(--green-dim), transparent 60%);
  pointer-events: none;
}

.burger-zone.net-negative::before {
  background: radial-gradient(ellipse at 50% 0%, var(--red-dim), transparent 60%);
}

.burger-header {
  text-align: center;
  position: relative;
  z-index: 1;
  margin-bottom: 32px;
}

.burger-tagline {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--green);
  margin-bottom: 8px;
}

.burger-zone.net-negative .burger-tagline { color: var(--red); }

.burger-headline {
  font-family: var(--sans);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.burger-body {
  color: var(--text-2);
  font-size: 13px;
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.7;
}

.burger-body strong { color: var(--text); font-weight: 500; }

/* Tier toggle */
.tier-toggle {
  display: flex;
  justify-content: center;
  gap: 2px;
  margin: 20px auto 24px;
  background: var(--surface-2);
  border-radius: 6px;
  padding: 2px;
  width: fit-content;
  position: relative;
  z-index: 1;
}

.tier-btn {
  background: transparent;
  border: none;
  color: var(--text-3);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.tier-btn:hover { color: var(--text-2); }

.tier-btn.active {
  background: var(--surface-3);
  color: var(--text);
}

/* Diet profile selector */
.diet-profile-select {
  display: flex;
  justify-content: center;
  gap: 2px;
  margin: 16px auto 12px;
  background: var(--surface-2);
  border-radius: 6px;
  padding: 2px;
  width: fit-content;
  position: relative;
  z-index: 1;
}

.profile-btn {
  background: transparent;
  border: none;
  color: var(--text-3);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s var(--ease);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.profile-btn:hover { color: var(--text-2); }

.profile-btn.active {
  background: var(--surface-3);
  color: var(--text);
}

.profile-btn.baseline { opacity: 0.7; }
.profile-btn.baseline.active { opacity: 1; }

@media (max-width: 480px) {
  .diet-profile-select { flex-wrap: wrap; justify-content: center; }
  .profile-btn { padding: 6px 10px; font-size: 10px; }
}

/* Range comparison table */
.range-table-wrap {
  position: relative;
  z-index: 1;
  margin: 0 auto 24px;
  max-width: 480px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.range-table { font-size: 11px; }
.range-table th { font-size: 9px; padding: 8px 12px; }
.range-table td { padding: 6px 12px; font-size: 11px; }

/* Budget bar */
.budget-bar {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto 32px;
}

.budget-labels {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-2);
}

.budget-labels strong { color: var(--text); }
.budget-label-right { color: var(--text-3); }

.budget-track {
  height: 8px;
  background: var(--green);
  opacity: 0.2;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.budget-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: var(--orange);
  opacity: 1;
  border-radius: 4px;
  transition: width 1.2s var(--ease);
}

.budget-legend {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-3);
}

.budget-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 6px;
  height: 6px;
  border-radius: 2px;
  display: inline-block;
}

/* Stat row */
.burger-stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  z-index: 1;
}

@media (max-width: 600px) { .burger-stat-row { grid-template-columns: 1fr 1fr; } }

.burger-stat {
  background: var(--surface-2);
  padding: 16px;
  text-align: center;
}

.burger-stat .num {
  font-size: 24px;
  font-weight: 700;
  font-family: var(--mono);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.burger-stat .lbl {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 4px;
}

.methodology {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: left;
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.8;
  position: relative;
  z-index: 1;
}

.methodology summary {
  cursor: pointer;
  font-weight: 500;
  font-family: var(--mono);
  color: var(--text-2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.methodology p { margin-bottom: 6px; }
.methodology strong { color: var(--text-2); }

/* ── Footer ── */
.footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.footer span {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
}

.footer a {
  color: var(--text-3);
  text-decoration: none;
  transition: color 0.15s;
}

.footer a:hover { color: var(--accent); }

/* Landing footer (always visible at bottom of landing page) */
.landing-footer {
  flex-shrink: 0;
  text-align: center;
  padding-top: 16px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-4);
}

.landing-footer a {
  color: var(--text-3);
  text-decoration: none;
  transition: color 0.15s;
}

.landing-footer a:hover { color: var(--accent); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-4); }

/* ── Responsive table scroll ── */
@media (max-width: 640px) {
  .table-wrap { overflow-x: auto; }
  table { min-width: 520px; }
}
