/* ── WaterVault app.css ── */

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

:root {
  --blue: #0284C7;
  --blue-dark: #0C4A6E;
  --blue-light: #E0F2FE;
  --teal: #0891B2;
  --teal-light: #CFFAFE;
  --green: #059669;
  --green-light: #D1FAE5;
  --amber: #D97706;
  --amber-light: #FEF3C7;
  --red: #DC2626;
  --red-light: #FEE2E2;
  --text: #1E293B;
  --text-muted: #64748B;
  --border: #E2E8F0;
  --bg: #F0F9FF;
  --card: #FFFFFF;
  --nav-h: 64px;
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  min-height: 100vh;
}

/* ── Screens ── */
.screen { display: none; padding: 16px 16px calc(var(--nav-h) + 16px); min-height: 100vh; }
.screen.active { display: block; }

/* ── Header ── */
.screen-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}
.screen-title { font-size: 22px; font-weight: 700; color: var(--blue-dark); }
.screen-sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.version-badge {
  background: var(--blue-light);
  color: var(--blue);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  margin-top: 4px;
}

/* ── Alert Banner ── */
.alert-banner {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
}
.alert-warning { background: var(--amber-light); color: #92400E; border-left: 4px solid var(--amber); }

/* ── Stat Cards ── */
.card-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--card);
  border-radius: 12px;
  padding: 14px;
  border: 1px solid var(--border);
}
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 4px; }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1.1; }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.stat-blue  .stat-value { color: var(--blue); }
.stat-teal  .stat-value { color: var(--teal); }
.stat-green .stat-value { color: var(--green); }
.stat-amber .stat-value { color: var(--amber); }
.stat-red   .stat-value { color: var(--red); }

/* ── Info Card ── */
.info-card {
  background: var(--card);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.info-row-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.info-row-item:last-child { border-bottom: none; }
.info-label { font-size: 13px; color: var(--text-muted); flex-shrink: 0; }
.info-val { font-size: 13px; font-weight: 600; text-align: right; }

/* ── Section Label ── */
.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin: 16px 0 8px;
}

/* ── Quick Actions ── */
.quick-actions { display: flex; gap: 10px; margin-top: 16px; }
.quick-btn {
  flex: 1;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.quick-btn:active { background: var(--blue-dark); }
.quick-btn-outline {
  background: var(--card);
  color: var(--blue);
  border: 1.5px solid var(--blue);
}
.quick-btn-outline:active { background: var(--blue-light); }

/* ── Form ── */
.form-card {
  background: var(--card);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 16px;
  margin-bottom: 16px;
}
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  color: var(--text);
  background: #F8FAFC;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}
.form-input:focus { border-color: var(--blue); background: #fff; }

/* ── Coins ── */
.coin-grid { display: flex; flex-direction: column; gap: 8px; }
.coin-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; background: #F8FAFC; border-radius: 10px; border: 1px solid var(--border); }
.coin-badge { font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 20px; }
.coin-1  { background: #FEF9C3; color: #854D0E; }
.coin-2  { background: #DCFCE7; color: #166534; }
.coin-5  { background: #DBEAFE; color: #1E40AF; }
.coin-10 { background: #F3E8FF; color: #6B21A8; }
.coin-counter { display: flex; align-items: center; gap: 8px; }
.counter-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--blue);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.counter-btn:active { background: var(--blue-dark); }
.counter-input {
  width: 52px;
  text-align: center;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  background: #fff;
  -moz-appearance: textfield;
}
.counter-input::-webkit-inner-spin-button, .counter-input::-webkit-outer-spin-button { -webkit-appearance: none; }

/* ── Calc Summary ── */
.calc-summary {
  background: var(--blue-light);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 14px 0;
}
.calc-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.calc-row + .calc-row { margin-top: 6px; }
.calc-val { font-weight: 700; font-size: 18px; color: var(--blue); }
.calc-liters { color: var(--teal); }

/* ── Buttons ── */
.btn-primary {
  width: 100%;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.15s;
}
.btn-primary:active { background: var(--blue-dark); }
.btn-primary:disabled { background: #94A3B8; cursor: not-allowed; }

/* ── List Cards ── */
.list-card {
  background: var(--card);
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 12px 14px;
  margin-bottom: 8px;
}
.list-main { font-size: 14px; font-weight: 600; color: var(--text); }
.list-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.list-notes { font-size: 12px; color: var(--text-muted); font-style: italic; margin-top: 4px; }
.list-amount { font-size: 16px; font-weight: 700; }

/* ── Month Selector ── */
.month-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
}
.month-nav {
  background: var(--blue-light);
  color: var(--blue);
  border: none;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  font-size: 16px;
  cursor: pointer;
}
.month-label { font-size: 16px; font-weight: 700; color: var(--blue-dark); }

/* ── Bottom Nav ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--nav-h);
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 100;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  padding: 8px 4px;
  border: none;
  background: none;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.nav-item.active { color: var(--blue); }
.nav-icon { font-size: 22px; line-height: 1; }

/* ── Colors ── */
.text-green { color: var(--green); }
.text-red   { color: var(--red); }
.text-blue  { color: var(--blue); }
.text-amber { color: var(--amber); }

/* ── States ── */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 16px;
  font-size: 14px;
}
.loading-state {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 60px 0;
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--blue-light);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Action Buttons ── */
.item-actions { display: flex; gap: 8px; margin-top: 8px; justify-content: flex-end; }
.btn-edit, .btn-delete {
  border: none; border-radius: 6px; padding: 5px 12px;
  font-size: 12px; font-weight: 600; cursor: pointer; transition: opacity 0.15s;
}
.btn-edit { background: var(--blue-light); color: var(--blue); }
.btn-delete { background: var(--red-light); color: var(--red); }
.btn-edit:active, .btn-delete:active { opacity: 0.7; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 500;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 20px 20px 40px;
  width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
  font-size: 17px; font-weight: 700; color: var(--blue-dark);
}
.modal-close {
  background: var(--bg); border: none; border-radius: 50%;
  width: 30px; height: 30px; font-size: 14px; cursor: pointer; color: var(--text-muted);
}

/* ── PIN Lock ── */
.pin-overlay {
  position: fixed; inset: 0;
  background: var(--blue-dark);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
}
.pin-overlay.hidden { display: none; }
.pin-box { width: 100%; max-width: 320px; padding: 0 24px; text-align: center; }
.pin-logo { font-size: 52px; margin-bottom: 8px; }
.pin-title { font-size: 26px; font-weight: 700; color: #fff; margin-bottom: 4px; }
.pin-sub { font-size: 14px; color: rgba(255,255,255,0.7); margin-bottom: 28px; }
.pin-dots { display: flex; justify-content: center; gap: 16px; margin-bottom: 12px; }
.pin-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.5);
  background: transparent;
  transition: background 0.15s;
}
.pin-dot.filled { background: #fff; border-color: #fff; }
.pin-error { color: #FCA5A5; font-size: 13px; min-height: 20px; margin-bottom: 20px; }
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 8px;
}
.pin-key {
  aspect-ratio: 1;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 22px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.pin-key:active { background: rgba(255,255,255,0.3); }
.pin-key-empty { background: transparent; cursor: default; pointer-events: none; }
.pin-key-del { font-size: 18px; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1E293B;
  color: #fff;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s;
  z-index: 200;
  white-space: nowrap;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-error { background: var(--red); }
.toast.toast-success { background: var(--green); }
