/* PapasBank - clean banking look, mobile first */
:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --navy: #0a2540;
  --navy-2: #103d6e;
  --text: #111b2b;
  --muted: #5b6778;
  --border: #e3e8ef;
  --input-border: #cdd6e3;
  --primary: #0b5cad;
  --primary-dark: #084a8c;
  --primary-tint: #e8f0fb;
  --teal: #00a3a1;
  --green: #14804a;
  --green-tint: #e7f5ee;
  --red: #b42318;
  --red-tint: #fdecea;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(10, 37, 64, 0.06), 0 4px 16px rgba(10, 37, 64, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; }
h1, h2, h3 { margin: 0; color: var(--navy); }
h2 { font-size: 1.05rem; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid rgba(11, 92, 173, 0.35); outline-offset: 2px; }

/* ---------- Header and navigation ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 960px;
  margin: 0 auto;
  height: 64px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--navy);
  text-decoration: none;
  white-space: nowrap;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--navy);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.1rem;
  flex: none;
}
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
}
.nav a:hover { color: var(--navy); background: #f0f3f8; }
.nav a[aria-current="page"] { color: var(--primary); background: var(--primary-tint); }
.header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* ---------- Layout ---------- */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px;
  display: grid;
  gap: 16px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card h2 { margin-bottom: 14px; }
.card h3 { font-size: 1rem; margin: 22px 0 8px; }
.card-hint { text-align: center; padding: 8px 0; }
.panel-head { display: grid; gap: 2px; margin-bottom: 16px; }
.back-link { display: inline-flex; font-weight: 600; text-decoration: none; color: var(--primary); }

/* ---------- Balance hero card ---------- */
.balance-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff;
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.balance-card::after {
  content: "";
  position: absolute;
  right: -60px;
  top: -70px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: rgba(0, 163, 161, 0.22);
  pointer-events: none;
}
.balance-card .greeting { margin: 0; font-weight: 600; opacity: 0.9; position: relative; }
.balance-card .label {
  margin: 22px 0 0;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.7;
  position: relative;
}
.balance {
  margin: 4px 0 20px;
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  position: relative;
}
.balance.negative { color: #ffb4ab; }
.balance-actions { position: relative; display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  background: #eef2f7;
  color: var(--navy);
  transition: background 0.15s ease, transform 0.05s ease;
}
.btn:hover { background: #e2e8f1; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.accent { background: #fff; color: var(--navy); }
.btn.accent:hover { background: #eef2f7; }
.btn.danger { background: var(--red); color: #fff; }
.btn.danger:hover { background: #8f1d14; }
.btn.ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn.ghost:hover { color: var(--navy); background: #f5f7fa; }
.btn.block { width: 100%; }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 0.85rem; border-radius: 8px; }

.lang-switch {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--navy);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}
.lang-switch:hover { background: #f5f7fa; }

/* ---------- Forms ---------- */
label {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}
label > span { font-weight: 600; color: var(--text); }
input, select {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--input-border);
  border-radius: 10px;
  font-size: 16px; /* 16px stops iPhone from zooming in */
  background: #fff;
  color: var(--text);
}
input:focus, select:focus {
  outline: 3px solid rgba(11, 92, 173, 0.2);
  border-color: var(--primary);
}
.stack { display: grid; gap: 14px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row.buttons { grid-template-columns: 1fr 1fr; }

.error { color: var(--red); margin: 0; font-weight: 600; }
.success { color: var(--green); margin: 0; font-weight: 600; }
.muted { color: var(--muted); margin: 0; }
.confirm-text { font-size: 1.1rem; font-weight: 600; margin: 0; color: var(--navy); }

/* ---------- Login page ---------- */
.login-layout { min-height: 100vh; display: grid; }
.login-hero { display: none; }
.login-main {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 16px;
  padding: 24px 16px;
}
.app-note {
  margin: 0;
  padding: 16px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}
.login-top { position: absolute; top: 16px; right: 16px; }
.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}
.login-card h1 { font-size: 1.5rem; }
.login-card .brand { margin-bottom: 8px; }

@media (min-width: 900px) {
  .login-layout { grid-template-columns: 1.1fr 1fr; }
  .login-hero {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 16px;
    padding: 64px;
    color: #fff;
    background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 100%);
  }
  .login-hero .brand { color: #fff; }
  .login-hero .brand-mark { background: #fff; color: var(--navy); }
  .login-hero h2 { color: #fff; font-size: 2.2rem; line-height: 1.15; }
  .login-hero p { margin: 0; opacity: 0.85; max-width: 420px; font-size: 1.05rem; }
  .login-card .brand { display: none; }
}

/* ---------- Transactions ---------- */
.tx-list { list-style: none; margin: 0; padding: 0; }
.tx {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.tx:last-child { border-bottom: 0; }
.tx-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  flex: none;
}
.tx-icon.in { background: var(--green-tint); color: var(--green); }
.tx-icon.out { background: var(--red-tint); color: var(--red); }
.tx-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.tx-main strong { color: var(--navy); font-weight: 600; }
.tx-main small { color: var(--muted); overflow-wrap: anywhere; }
.tx-amount { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tx-amount.pos { color: var(--green); }
.tx-amount.neg { color: var(--red); }
.tx .btn.small { margin-left: auto; }

/* ---------- Admin account tiles ---------- */
.kid-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.kid-card {
  text-align: left;
  color: inherit;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  display: grid;
  gap: 2px;
  min-height: 44px;
}
.kid-card:hover { border-color: #b8c7db; }
.kid-card.active {
  border-color: var(--primary);
  background: var(--primary-tint);
  box-shadow: 0 0 0 3px rgba(11, 92, 173, 0.12);
}
.kid-card .name { font-weight: 700; color: var(--navy); }
.kid-card .label { font-size: 0.8rem; color: var(--muted); }
.kid-card .amt { font-size: 1.3rem; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ---------- Tablet and up: nav in the header ---------- */
@media (min-width: 721px) {
  .app-page .container { padding-top: 28px; }
}

/* ---------- Phones: bottom tab bar ---------- */
@media (max-width: 720px) {
  .header-inner { gap: 10px; }
  .nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
    box-shadow: 0 -4px 16px rgba(10, 37, 64, 0.06);
  }
  .nav a {
    flex: 1;
    text-align: center;
    padding: 10px 6px;
    font-size: 0.9rem;
  }
  .nav a[aria-current="page"] {
    background: none;
    box-shadow: inset 0 3px 0 var(--primary);
  }
  .app-page { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
}

@media (max-width: 560px) {
  .row, .row.buttons { grid-template-columns: 1fr; }
  .balance { font-size: 2.1rem; }
  .balance-card { padding: 20px; }
  .card { padding: 16px; }
  .container { padding: 16px; }
  .header-actions .btn.ghost { padding: 6px 10px; }
}
