:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #1e2a3a;
  --muted: #6b7a90;
  --accent: #0ea5e9;
  --accent-dark: #0284c7;
  --danger: #ef4444;
  --good: #22c55e;
  --radius: 18px;
  --ellad: #3b82f6;
  --adva: #ec4899;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
  animation: fadein .18s ease;
}
@keyframes fadein { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none; } }

/* ---------- Login ---------- */
.login-screen { justify-content: center; align-items: center; text-align: center; gap: 28px; }
.login-title { font-size: 26px; font-weight: 800; }
.login-sub { color: var(--muted); margin-top: -18px; }
.kid-picker { display: flex; gap: 20px; }
.kid-avatar {
  width: 120px; height: 120px; border-radius: 30px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; font-size: 40px; font-weight: 800; color: #fff;
  box-shadow: 0 8px 20px rgba(0,0,0,.15);
  transition: transform .1s;
}
.kid-avatar:active { transform: scale(.95); }
.kid-avatar.ellad { background: linear-gradient(160deg, var(--ellad), #1e3a8a); }
.kid-avatar.adva { background: linear-gradient(160deg, var(--adva), #9d174d); }
.kid-avatar .label { font-size: 16px; }

/* ---------- PIN pad ---------- */
.pin-screen { justify-content: center; align-items: center; gap: 22px; }
.pin-heading { font-size: 20px; font-weight: 700; text-align: center; }
.pin-heading .name { color: var(--accent-dark); }
.pin-dots { display: flex; gap: 14px; height: 20px; }
.pin-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--accent); }
.pin-dot.filled { background: var(--accent); }
.pin-error { color: var(--danger); font-size: 14px; min-height: 18px; }
.keypad { display: grid; grid-template-columns: repeat(3, 72px); gap: 14px; direction: ltr; }
.key {
  width: 72px; height: 72px; border-radius: 50%; background: var(--card);
  font-size: 26px; font-weight: 700; box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.key:active { background: #e6f4fd; }
.key.ghost { background: transparent; box-shadow: none; }
.back-link { color: var(--muted); font-size: 14px; margin-top: 6px; background: none; }

/* ---------- Home ---------- */
.home-screen { padding: 20px 16px 100px; gap: 16px; position: relative; }
.home-header { display: flex; justify-content: space-between; align-items: center; }
.greeting { font-size: 20px; font-weight: 800; }
.icon-btn { background: none; font-size: 20px; color: var(--muted); padding: 6px; }

.summary-card {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff; border-radius: var(--radius); padding: 20px;
  display: flex; flex-direction: column; gap: 4px;
}
.summary-total { font-size: 34px; font-weight: 800; }
.summary-label { opacity: .85; font-size: 13px; }
.summary-remaining { margin-top: 10px; font-size: 14px; opacity: .95; }
.budget-edit { background: rgba(255,255,255,.2); color: #fff; border-radius: 10px; padding: 8px 12px; font-size: 13px; align-self: flex-start; margin-top: 8px; }

.converter-card {
  background: var(--card); border-radius: var(--radius); padding: 16px 18px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.converter-row { display: flex; align-items: center; gap: 10px; }
.converter-field {
  flex: 1; display: flex; align-items: center; gap: 6px; background: var(--bg);
  border-radius: 12px; padding: 10px 12px;
}
.converter-sign { color: var(--muted); font-weight: 700; font-size: 15px; }
.converter-input {
  border: none; background: none; outline: none; font-size: 18px; font-weight: 700;
  color: var(--text); width: 100%; min-width: 0;
}
.converter-result { font-size: 18px; font-weight: 700; color: var(--accent-dark); }
.converter-eq { color: var(--muted); font-weight: 700; }
.converter-rate { color: var(--muted); font-size: 12.5px; margin-top: 10px; text-align: center; }

.expense-list { display: flex; flex-direction: column; gap: 10px; }
.day-label { color: var(--muted); font-size: 13px; font-weight: 700; margin: 6px 2px 0; }
.expense-card {
  background: var(--card); border-radius: 14px; padding: 14px 16px;
  display: flex; align-items: center; gap: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.expense-emoji { font-size: 26px; width: 40px; text-align: center; }
.expense-info { flex: 1; min-width: 0; }
.expense-store { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.expense-meta { color: var(--muted); font-size: 12.5px; }
.expense-amount { font-weight: 800; font-size: 17px; }
.empty-state { text-align: center; color: var(--muted); padding: 40px 10px; }

.fab {
  position: fixed; bottom: calc(24px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%); width: 64px; height: 64px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 30px; box-shadow: 0 10px 24px rgba(14,165,233,.45);
  max-width: 480px;
}
.fab:active { transform: translateX(-50%) scale(.93); }

/* ---------- Add/Edit expense ---------- */
.sheet-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.45);
  display: flex; align-items: flex-end; z-index: 20;
}
.sheet {
  background: var(--bg); width: 100%; max-width: 480px; margin: 0 auto;
  border-radius: 22px 22px 0 0; padding: 18px 20px calc(24px + env(safe-area-inset-bottom));
  max-height: 92vh; overflow-y: auto;
}
.sheet-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.sheet-title { font-size: 18px; font-weight: 800; }
.sheet-close { background: none; font-size: 22px; color: var(--muted); }

.amount-input-row { display: flex; align-items: baseline; justify-content: center; gap: 4px; margin: 10px 0 20px; }
.currency-sign { font-size: 26px; font-weight: 700; color: var(--muted); }
.amount-input {
  border: none; background: none; font-size: 44px; font-weight: 800; width: 200px;
  text-align: center; color: var(--text); outline: none;
}

.field-label { font-size: 13px; color: var(--muted); font-weight: 700; margin: 14px 0 8px; }
.category-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.category-btn {
  background: var(--card); border-radius: 14px; padding: 10px 4px; display: flex;
  flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--muted);
  border: 2px solid transparent;
}
.category-btn .emoji { font-size: 22px; }
.category-btn.active { border-color: var(--accent); color: var(--accent-dark); background: #e6f4fd; }

.store-row { display: flex; gap: 8px; }
.text-input {
  flex: 1; border: 1px solid #dbe4ee; border-radius: 12px; padding: 12px 14px;
  font-size: 15px; background: var(--card); outline: none;
}
.text-input:focus { border-color: var(--accent); }
textarea.text-input { min-height: 60px; resize: vertical; font-family: inherit; }

.locate-btn {
  background: var(--card); border: 1px solid #dbe4ee; border-radius: 12px; padding: 0 14px;
  font-size: 18px; color: var(--accent-dark); white-space: nowrap;
}
.locate-status { font-size: 12.5px; color: var(--muted); margin-top: 6px; min-height: 16px; }

.place-suggestions { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.place-item {
  background: var(--card); border: 1px solid #e5edf5; border-radius: 12px; padding: 10px 12px;
  text-align: right; font-size: 13.5px;
}
.place-item .p-name { font-weight: 700; }
.place-item .p-addr { color: var(--muted); font-size: 12px; }

.sheet-actions { display: flex; gap: 10px; margin-top: 22px; }
.btn { flex: 1; padding: 15px; border-radius: 14px; font-size: 16px; font-weight: 700; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:disabled { background: #b9d9ea; }
.btn-danger { background: #fee2e2; color: var(--danger); flex: 0 0 auto; padding: 15px 18px; }
.btn-secondary { background: var(--card); color: var(--text); border: 1px solid #dbe4ee; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1e2a3a; color: #fff; padding: 10px 18px; border-radius: 30px; font-size: 13.5px;
  z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.show { opacity: 1; }
