*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f0f4f8;
  color: #1a1a2e;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 1rem;
}
#app {
  width: 100%;
  max-width: 480px;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  border-bottom: 2px solid #e2e8f0;
  margin-bottom: 1.5rem;
}
.app-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #2d3748;
}
.app-header .user-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #4a5568;
  cursor: pointer;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: #edf2f7;
}
.app-header .user-badge:hover { background: #e2e8f0; }

/* Cards */
.card {
  background: #fff;
  border-radius: 1rem;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 1rem;
}
.card-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #718096;
  margin-bottom: 0.75rem;
}

/* Balance */
.balance-card {
  text-align: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}
.balance-card .currency {
  font-size: 0.9rem;
  opacity: 0.8;
}
.balance-amount {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0.5rem 0;
}
.balance-label {
  font-size: 0.85rem;
  opacity: 0.85;
}

/* User grid */
.user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
}
.user-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 1rem 0.5rem;
  background: #fff;
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 2px solid transparent;
}
.user-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.user-card.selected {
  border-color: #667eea;
}
.user-card .avatar { font-size: 2rem; }
.user-card .name { font-size: 0.85rem; font-weight: 600; }
.user-card .role-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  text-transform: uppercase;
}
.role-badge.admin { background: #fefcbf; color: #744210; }
.role-badge.child { background: #c6f6d5; color: #22543d; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  text-decoration: none;
  width: 100%;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: #667eea; color: #fff; }
.btn-primary:hover { background: #5a6fd6; }
.btn-success { background: #48bb78; color: #fff; }
.btn-success:hover { background: #38a169; }
.btn-danger { background: #fc8181; color: #fff; }
.btn-danger:hover { background: #f56565; }
.btn-outline {
  background: transparent;
  border: 2px solid #e2e8f0;
  color: #4a5568;
}
.btn-outline:hover { background: #f7fafc; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.8rem; width: auto; }
.btn-group { display: flex; gap: 0.5rem; }
.btn-group .btn { flex: 1; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #4a5568;
  margin-bottom: 0.35rem;
}
.form-input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 2px solid #e2e8f0;
  border-radius: 0.75rem;
  font-size: 1rem;
  transition: border-color 0.15s;
}
.form-input:focus {
  outline: none;
  border-color: #667eea;
}
.form-input:disabled {
  background: #f7fafc;
  color: #a0aec0;
}
select.form-input { appearance: auto; }

/* Transaction list */
.txn-list { list-style: none; }
.txn-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid #f0f4f8;
}
.txn-item:last-child { border-bottom: none; }
.txn-direction { font-size: 1.25rem; margin-right: 0.5rem; }
.txn-details { flex: 1; }
.txn-desc { font-weight: 600; font-size: 0.9rem; }
.txn-meta { font-size: 0.75rem; color: #718096; }
.txn-amount {
  font-weight: 700;
  font-size: 1rem;
}
.txn-amount.positive { color: #48bb78; }
.txn-amount.negative { color: #fc8181; }

/* Login screen */
.login-screen { text-align: center; padding-top: 2rem; }
.login-screen h2 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.login-screen .subtitle { color: #718096; margin-bottom: 1.5rem; }

/* Screens */
.screen { display: none; }
.screen.active { display: block; }

/* Flash message */
.flash {
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  margin-bottom: 1rem;
  font-weight: 600;
  font-size: 0.9rem;
  display: none;
}
.flash.show { display: block; }
.flash.error { background: #fed7d7; color: #9b2c2c; display: block; }
.flash.success { background: #c6f6d5; color: #22543d; display: block; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: #a0aec0;
}
.empty-state .icon { font-size: 2.5rem; margin-bottom: 0.5rem; }

/* Responsive */
@media (max-width: 400px) {
  .user-grid { grid-template-columns: repeat(2, 1fr); }
  .balance-amount { font-size: 2rem; }
}

/* Admin tabs */
.tabs {
  display: flex;
  gap: 0.25rem;
  background: #fff;
  border-radius: 1rem;
  padding: 0.35rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 1rem;
}
.tab-btn {
  flex: 1;
  padding: 0.5rem 0.25rem;
  border: none;
  background: transparent;
  border-radius: 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #718096;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tab-btn.active {
  background: #667eea;
  color: #fff;
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Inline row actions */
.user-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid #f0f4f8;
}
.user-row:last-child { border-bottom: none; }
.user-row .avatar { font-size: 1.5rem; flex-shrink: 0; }
.user-row .info { flex: 1; min-width: 0; }
.user-row .info .uname { font-weight: 700; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-row .info .umeta { font-size: 0.75rem; color: #718096; }
.user-row .actions { display: flex; gap: 0.4rem; flex-shrink: 0; }

/* Expand/collapse edit */
.edit-panel {
  background: #f7fafc;
  border-radius: 0.75rem;
  padding: 1rem;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

/* Modal overlay */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 1rem;
}
.modal {
  background: #fff;
  border-radius: 1rem;
  padding: 1.5rem;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
