:root {
  --navy: #10233f;
  --gold: #d4a72c;
  --green: #1f9d55;
  --red: #d64545;
  --amber: #e0952a;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #12203a;
  --muted: #5a6b85;
  font-size: 20px; /* elder-friendly base size */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.5rem;
  background: var(--navy);
  color: white;
}
.brand { font-size: 1.6rem; font-weight: 700; }
.whoami { font-size: 1rem; opacity: 0.85; }

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.card {
  background: var(--card);
  border-radius: 20px;
  padding: 1.3rem;
  box-shadow: 0 2px 10px rgba(16, 35, 63, 0.08);
}
.card h2 {
  margin: 0 0 0.8rem 0;
  font-size: 1.3rem;
  color: var(--navy);
}

.accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.9rem;
}
.account-tile {
  border-radius: 16px;
  padding: 1rem;
  background: linear-gradient(135deg, #eef3ff, #e4ecff);
  border: 1px solid #dbe4fb;
}
.account-tile .name { font-weight: 600; color: var(--navy); }
.account-tile .institution { font-size: 0.85rem; color: var(--muted); }
.account-tile .balance { font-size: 1.6rem; font-weight: 700; margin-top: 0.3rem; }

.pill-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.pill {
  border: 2px solid var(--navy);
  background: white;
  color: var(--navy);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.pill.active { background: var(--navy); color: white; }

.chart-wrap { margin-bottom: 1rem; }

.category-list { display: flex; flex-direction: column; gap: 0.5rem; }
.category-row {
  display: flex;
  justify-content: space-between;
  padding: 0.6rem 0.9rem;
  border-radius: 12px;
  background: #f7f9fd;
  font-weight: 600;
}

.transactions-list { display: flex; flex-direction: column; gap: 0.5rem; }
.txn-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  background: #f7f9fd;
}
.txn-row.anomaly { background: #fff3e0; border: 1px solid var(--amber); }
.txn-main { display: flex; flex-direction: column; }
.txn-payee { font-weight: 600; }
.txn-meta { font-size: 0.85rem; color: var(--muted); }
.txn-amount { font-weight: 700; font-size: 1.1rem; }
.txn-amount.negative { color: var(--red); }
.txn-amount.positive { color: var(--green); }

.alerts-card { border: 2px solid var(--amber); }
.alerts-list { display: flex; flex-direction: column; gap: 0.6rem; }
.alert-item {
  border-radius: 12px;
  padding: 0.8rem 1rem;
  background: #fff8ec;
}
.alert-item.critical { background: #fdeceb; }
.alert-item .alert-title { font-weight: 700; }
.alert-item .alert-body { color: var(--muted); font-size: 0.95rem; }

.usage-bar {
  background: #e6ebf5;
  border-radius: 999px;
  height: 22px;
  overflow: hidden;
}
.usage-fill { height: 100%; background: var(--gold); width: 0%; }
.usage-label { margin-top: 0.5rem; color: var(--muted); }

.settings-accounts-list { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 1rem; }
.settings-account-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  background: #f7f9fd;
  gap: 0.6rem;
}
.settings-account-row .name { font-weight: 600; }
.settings-account-row .institution { font-size: 0.85rem; color: var(--muted); }
.settings-account-row select {
  border: 2px solid var(--navy);
  border-radius: 10px;
  padding: 0.35rem 0.5rem;
  font-size: 0.95rem;
  color: var(--navy);
  background: white;
}

.pill-ghost {
  border: none;
  background: none;
  color: var(--muted);
  text-decoration: underline;
  font-size: 0.95rem;
  cursor: pointer;
}

/* --- Sign-in screen --- */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.auth-card {
  background: var(--card);
  border-radius: 24px;
  padding: 2.5rem 2rem;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 4px 24px rgba(16, 35, 63, 0.12);
  text-align: center;
}
.auth-brand { justify-content: center; margin-bottom: 1.5rem; color: var(--navy); }
.auth-step p { color: var(--muted); margin-bottom: 1.2rem; }
.auth-step input {
  width: 100%;
  padding: 0.9rem;
  font-size: 1.05rem;
  border: 2px solid #dbe4fb;
  border-radius: 12px;
  margin-bottom: 1rem;
  box-sizing: border-box;
}
.auth-step button[type="submit"],
.auth-step button:not(.pill-ghost) {
  width: 100%;
  padding: 0.9rem;
  font-size: 1.05rem;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  background: var(--navy);
  color: white;
  cursor: pointer;
}
.auth-error { color: var(--red); font-size: 0.9rem; margin-top: 0.8rem; }

/* --- Users admin section --- */
.add-user-form { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.add-user-form input { flex: 1; min-width: 180px; padding: 0.6rem; border: 2px solid #dbe4fb; border-radius: 10px; }
.add-user-form select { padding: 0.6rem; border: 2px solid #dbe4fb; border-radius: 10px; }
.add-user-form button {
  border: none;
  background: var(--navy);
  color: white;
  border-radius: 10px;
  padding: 0.6rem 1rem;
  font-weight: 600;
  cursor: pointer;
}
.users-list { display: flex; flex-direction: column; gap: 0.6rem; }
.user-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  background: #f7f9fd;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.user-row .email { font-weight: 600; }
.user-row .meta { font-size: 0.85rem; color: var(--muted); }
.user-row .actions { display: flex; gap: 0.5rem; }
.user-row .actions button {
  border: 1px solid #cdd6e8;
  background: white;
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
}
.user-row .actions button.danger { color: var(--red); border-color: var(--red); }

.chat-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: var(--navy);
  color: white;
  font-size: 1.8rem;
  box-shadow: 0 4px 14px rgba(16, 35, 63, 0.35);
  cursor: pointer;
}

.chat-panel {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: min(400px, 92vw);
  height: min(560px, 80vh);
  background: white;
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(16, 35, 63, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-header {
  background: var(--navy);
  color: white;
  padding: 0.9rem 1.1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}
.chat-header button { background: none; border: none; color: white; font-size: 1.1rem; cursor: pointer; }
.chat-messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.6rem; }
.chat-msg { padding: 0.6rem 0.9rem; border-radius: 14px; max-width: 85%; font-size: 0.95rem; }
.chat-msg.user { align-self: flex-end; background: var(--navy); color: white; }
.chat-msg.assistant { align-self: flex-start; background: #eef1f8; }
.chat-suggestions { display: flex; gap: 0.4rem; flex-wrap: wrap; padding: 0 1rem 0.5rem; }
.chat-suggestion {
  border: 1px solid #cdd6e8;
  background: white;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  cursor: pointer;
}
.chat-form { display: flex; border-top: 1px solid #e6ebf5; }
.chat-form input { flex: 1; border: none; padding: 0.9rem; font-size: 1rem; }
.chat-form input:focus { outline: none; }
.chat-form button {
  border: none;
  background: var(--gold);
  color: var(--navy);
  font-weight: 700;
  padding: 0 1.2rem;
  cursor: pointer;
}

@media (max-width: 480px) {
  :root { font-size: 18px; }
  .chat-panel { right: 0; bottom: 0; width: 100vw; height: 100vh; border-radius: 0; }
}
