:root {
  color-scheme: dark;
  --bg: #08101d;
  --surface: #111b2b;
  --surface-soft: #17293f;
  --surface-strong: #20334e;
  --text: #edf2ff;
  --muted: #7a94bb;
  --accent: #6f8fff;
  --accent-strong: #4b64ff;
  --success: #78d4a3;
  --warning: #f0c147;
  --danger: #f56f6f;
  --border: rgba(255,255,255,0.08);
  --shadow: 0 8px 40px rgba(0,0,0,0.32);
  --radius: 20px;
}

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

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  background: #08101d;
  color: var(--text);
  min-height: 100vh;
}

button, input { font: inherit; }

/* ── Top bar ── */
.top-bar {
  padding: 20px 28px;
}
.logo {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--accent);
}

/* ── Shell ── */
.app-shell {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

/* ── Hero input ── */
.hero-input-section {
  padding: 48px 0 40px;
}

.hero-input-section h1 {
  font-size: clamp(1.9rem, 4vw, 3rem);
  line-height: 1.1;
  margin-bottom: 12px;
}

.hero-sub {
  color: var(--muted);
  font-size: 1rem;
  margin-bottom: 32px;
  max-width: 520px;
  line-height: 1.6;
}

.salary-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
  flex-wrap: wrap;
}

.salary-field {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: var(--radius);
  padding: 0 18px;
  gap: 8px;
  flex: 1;
  min-width: 160px;
  max-width: 280px;
  transition: border-color 200ms, box-shadow 200ms;
}

.salary-field:focus-within {
  border-color: rgba(111,143,255,0.6);
  box-shadow: 0 0 0 4px rgba(111,143,255,0.12);
}

.currency-prefix {
  font-size: 1.3rem;
  color: var(--accent);
  font-weight: 600;
  flex-shrink: 0;
}

.salary-field input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 1.6rem;
  font-weight: 600;
  width: 100%;
  padding: 16px 0;
}

.salary-field input::-webkit-inner-spin-button,
.salary-field input::-webkit-outer-spin-button { -webkit-appearance: none; }

/* ── Household quick toggle ── */
.household-toggle {
  display: flex;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
}

.hh-btn {
  padding: 0 14px;
  background: rgba(255,255,255,0.03);
  border: none;
  border-right: 1px solid rgba(255,255,255,0.1);
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 150ms, color 150ms;
  height: 100%;
}

.hh-btn:last-child { border-right: none; }

.hh-btn.active {
  background: rgba(111,143,255,0.18);
  color: var(--accent);
  font-weight: 600;
}

.hh-btn:hover:not(.active) {
  background: rgba(255,255,255,0.07);
  color: var(--text);
}

.expenses-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 20px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.92rem;
  white-space: nowrap;
  transition: background 150ms, color 150ms, border-color 150ms;
}

.expenses-btn:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border-color: rgba(255,255,255,0.22);
}

.calc-btn {
  padding: 0 28px;
  border: none;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  font-weight: 700;
  font-size: 0.96rem;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 180ms, transform 180ms;
}

.calc-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.calc-btn:active { transform: translateY(0); }

/* ── Expense chips (after calculation) ── */
.expense-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.expense-chips.hidden { display: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
}

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

.total-chip {
  background: rgba(111,143,255,0.12);
  border-color: rgba(111,143,255,0.25);
  color: var(--text);
}

/* ── Content stack ── */
.content { display: grid; gap: 20px; }

/* ── Cards ── */
.card {
  background: rgba(13,22,38,0.96);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 24px 28px;
}

.card h2 {
  font-size: 1.1rem;
  margin-bottom: 16px;
}

.section-copy {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 18px;
  line-height: 1.6;
}

/* ── Result grid ── */
.result-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.result-tile {
  padding: 16px;
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
}

.result-tile p {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.result-tile strong {
  display: block;
  font-size: 1.25rem;
}

.highlight {
  background: linear-gradient(160deg, rgba(111,143,255,0.15), rgba(75,100,255,0.06));
  border-color: rgba(111,143,255,0.22);
}

/* ── Item grid (basket) ── */
.item-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.item-card {
  padding: 16px;
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  display: grid;
  gap: 5px;
}

.item-card h3 {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.4;
}

.item-cat {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.item-note {
  font-size: 0.8rem;
  color: var(--muted);
}

.item-price {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 4px;
}

.item-price strong { color: var(--text); }

.item-price span { font-size: 0.78rem; }

/* ── Menu grid ── */
.menu-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.menu-day {
  padding: 16px;
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
}

.menu-day h3 {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text);
}

.menu-day p {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.55;
}

.meal-label {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: rgba(111,143,255,0.12);
  border-radius: 5px;
  padding: 1px 6px;
  margin-right: 5px;
}

/* ── Menu status banner ── */
.menu-status {
  padding: 14px 16px;
  border-radius: 12px;
  margin-bottom: 16px;
  background: rgba(255,255,255,0.03);
  border: 1px dashed rgba(255,255,255,0.1);
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.6;
}

.menu-status strong { color: var(--accent); }
.menu-status.hidden { display: none; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 0 12px 12px;
  transition: opacity 200ms;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: #131e30;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 24px 24px 20px 20px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 -8px 60px rgba(0,0,0,0.5);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
}

.modal-close {
  background: rgba(255,255,255,0.07);
  border: none;
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms;
}

.modal-close:hover { background: rgba(255,255,255,0.14); color: var(--text); }

.modal-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 20px 24px;
}

.modal-body label {
  display: grid;
  gap: 7px;
  font-size: 0.85rem;
  color: var(--muted);
}

.modal-body input,
.modal-body select {
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  padding: 11px 14px;
  outline: none;
  font-size: 1rem;
  transition: border-color 150ms, box-shadow 150ms;
}

.modal-body select {
  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 d='M1 1l5 5 5-5' stroke='%237a94bb' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}

.modal-body select option { background: #131e30; }

.modal-body input:focus,
.modal-body select:focus {
  border-color: rgba(111,143,255,0.6);
  box-shadow: 0 0 0 3px rgba(111,143,255,0.12);
}

.modal-note {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
  padding: 10px 12px;
  background: rgba(111,143,255,0.07);
  border-radius: 10px;
  border: 1px solid rgba(111,143,255,0.15);
}

.modal-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
}

.primary-button {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  font-weight: 700;
  font-size: 0.96rem;
  cursor: pointer;
  transition: filter 180ms;
}

.primary-button:hover { filter: brightness(1.08); }

/* ── Responsive ── */
@media (max-width: 760px) {
  .result-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .result-grid { grid-template-columns: 1fr 1fr; }
  .salary-row { flex-direction: column; }
  .salary-field { max-width: 100%; }
  .expenses-btn, .calc-btn { width: 100%; justify-content: center; padding: 14px; }
  .modal-body { grid-template-columns: 1fr; }
  .card { padding: 20px; }
}
