:root {
  --bg: #f7f8f5;
  --surface: #ffffff;
  --ink: #1f2933;
  --ink-soft: #54616d;
  --muted: #8a96a3;
  --line: #e6e9ec;
  --accent: #2a9d8f;
  --accent-dark: #1f7367;
  --danger: #d62828;
  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 8px 24px rgba(20, 30, 30, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }

.hero {
  background: linear-gradient(135deg, #143b3a 0%, #2a9d8f 100%);
  color: #fff;
  padding: 2.5rem 0 2rem;
  margin-bottom: 2rem;
}
.hero h1 { margin: 0 0 .25rem; font-size: 2rem; font-weight: 600; letter-spacing: -0.01em; }
.hero .lead { margin: 0; opacity: .82; font-size: 1rem; }

main { display: grid; grid-template-columns: 1fr 360px; gap: 1.5rem; padding-bottom: 3rem; }
@media (max-width: 900px) { main { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.25rem 1.25rem 1rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.card-header h2 { margin: 0; font-size: 1.1rem; font-weight: 600; }

.results-card {
  position: sticky;
  top: 1rem;
  align-self: start;
}

.row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: .75rem; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .875rem; color: var(--ink-soft); flex: 1 1 180px; }
input, select { font: inherit; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
small.muted, .muted { color: var(--muted); font-size: .8rem; }

.btn-secondary {
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid var(--accent);
  padding: .35rem .75rem;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}
.btn-secondary:hover { background: var(--accent); color: #fff; }

.inline-row {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
  padding: .5rem 0;
  border-bottom: 1px dashed var(--line);
}
.inline-row:last-child { border-bottom: none; }
.inline-row input[type="text"], .inline-row input:not([type]), .inline-row input[type="number"], .inline-row select { flex: 1 1 110px; min-width: 90px; }
.inline-row .arrow { color: var(--muted); font-weight: 600; }
.checkbox { flex: 0 1 auto; flex-direction: row; gap: .35rem; align-items: center; font-size: .85rem; }
.remove-row {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: .9rem;
  cursor: pointer;
  padding: .25rem .5rem;
}
.remove-row:hover { color: var(--danger); border-color: var(--danger); }

.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data-table th, .data-table td { padding: .4rem .5rem; text-align: left; border-bottom: 1px solid var(--line); }
.data-table th { font-weight: 500; color: var(--ink-soft); font-size: .8rem; }
.data-table input { width: 110px; }

.total {
  font-size: 2.4rem;
  font-weight: 600;
  color: var(--accent-dark);
  letter-spacing: -0.02em;
  margin: .5rem 0 1rem;
}

.breakdown { margin: .5rem 0 1rem; display: flex; flex-direction: column; gap: .35rem; }
.bar-row { display: grid; grid-template-columns: 100px 1fr 110px; align-items: center; gap: .5rem; font-size: .85rem; }
.bar-label { color: var(--ink-soft); }
.bar-track { height: 12px; background: var(--line); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; transition: width .3s ease; min-width: 2px; }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }

details { margin-top: 1rem; }
details summary { cursor: pointer; color: var(--accent-dark); padding: .25rem 0; font-size: .9rem; }
details summary:hover { text-decoration: underline; }
.details, .sources { font-size: .85rem; color: var(--ink-soft); padding: .5rem 0; }
.details h4, .sources h4 { margin: .75rem 0 .25rem; color: var(--ink); font-size: .9rem; }
.details ul, .sources ul { margin: .25rem 0; padding-left: 1.25rem; }
.details li, .sources li { margin: .15rem 0; }
.sources a { color: var(--accent-dark); }

.error { color: var(--danger); font-size: .8rem; flex-basis: 100%; }

footer { padding: 2rem 0 3rem; border-top: 1px solid var(--line); }
footer p { margin: 0; font-size: .85rem; }
code { font: 0.85em ui-monospace, SFMono-Regular, Menlo, monospace; background: rgba(42, 157, 143, 0.08); padding: .1em .35em; border-radius: 4px; }

.section-sources {
  margin: .75rem 0 0;
  padding-top: .65rem;
  border-top: 1px solid var(--line);
  font-size: .75rem;
  color: var(--muted);
  line-height: 1.45;
}
.section-sources a { color: var(--accent-dark); text-decoration: none; }
.section-sources a:hover { text-decoration: underline; }

.pie {
  margin: 1rem auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
}
.pie svg { display: block; max-width: 100%; height: auto; }
.legend { width: 100%; display: flex; flex-direction: column; gap: .25rem; font-size: .82rem; }
.legend-row { display: grid; grid-template-columns: 14px 1fr auto; gap: .5rem; align-items: center; }
.legend-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.legend-label { color: var(--ink-soft); }
.legend-pct { color: var(--ink); font-variant-numeric: tabular-nums; }

.saves-card { grid-column: 1 / -1; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  padding: .4rem .9rem;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary.danger { color: var(--danger); border-color: var(--danger); }
.btn-secondary.danger:hover { background: var(--danger); color: #fff; }
.file-label { display: inline-flex; align-items: center; cursor: pointer; }
.save-status {
  font-size: .82rem;
  color: var(--accent-dark);
  font-weight: 500;
}
.save-status.error { color: var(--danger); }

.flight-row {
  padding: .5rem 0;
  border-bottom: 1px dashed var(--line);
}
.flight-row:last-child { border-bottom: none; }
.flight-row .inline-row { padding: 0; border: none; }
.flight-info {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  padding-left: .25rem;
  margin-top: .15rem;
  min-height: 1.1em;
}
.flight-info small { font-size: .75rem; line-height: 1.35; }
.flight-info .accent { color: var(--accent-dark); }
.flight-info .error { color: var(--danger); }

.warning-banner {
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-left: 3px solid #f9a825;
  border-radius: 8px;
  padding: .65rem .85rem;
  font-size: .82rem;
  color: #6e4c00;
  line-height: 1.5;
  margin: .25rem 0 .85rem;
}
.warning-banner strong { color: #4f3700; }

.consumption-table td:first-child small { display: block; margin-top: .15rem; line-height: 1.3; }
.consumption-table td:last-child small { display: block; font-size: .7rem; color: var(--muted); margin-top: .1rem; }
.consumption-table td:last-child { white-space: nowrap; min-width: 120px; }

.preset-row {
  display: grid;
  grid-template-columns: 200px 1fr 60px;
  gap: .75rem;
  align-items: center;
  padding: .35rem 0;
}
.preset-label { font-size: .9rem; color: var(--ink); margin: 0; }
.preset-slider { width: 100%; accent-color: var(--accent); }
.preset-value { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-soft); font-size: .85rem; }
.preset-sum { margin: .5rem 0 0; font-size: .82rem; color: var(--muted); }
.preset-sum.ok { color: var(--accent-dark); }

.carshare-grid {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) 110px 90px 90px 32px;
  gap: .5rem;
  align-items: center;
  padding: .5rem 0;
  border-bottom: 1px dashed var(--line);
}
.carshare-grid:last-child { border-bottom: none; }
.carshare-grid .cs-pct-output { padding-top: .15rem; font-size: .78rem; color: var(--accent-dark); }
@media (max-width: 720px) {
  .carshare-grid { grid-template-columns: 1fr 1fr 32px; }
  .preset-row { grid-template-columns: 140px 1fr 50px; }
}
