:root {
  --purple: #7c5cfc;
  --purple-dark: #5f3fe0;
  --pink: #ff6fa5;
  --yellow: #ffd75a;
  --green: #33c481;
  --red: #ff5a6e;
  --ink: #3a2e57;
  --card-radius: 26px;
  --shadow: 0 10px 24px rgba(90, 50, 160, 0.18);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, "Segoe UI", "Segoe UI Rounded", Roboto, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--purple) 0%, var(--pink) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  padding: env(safe-area-inset-top) 16px calc(env(safe-area-inset-bottom) + 24px);
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* ---------- Header ---------- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 4px 8px;
}

.app-title {
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.icon-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.25);
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}

.icon-btn:active {
  transform: scale(0.9);
  background: rgba(255, 255, 255, 0.4);
}

/* ---------- Screens ---------- */

.screen {
  flex: 1;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.screen-hint {
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  margin: 6px 4px 16px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.empty-msg {
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 18px;
  padding: 16px;
  text-align: center;
  font-size: 15px;
  line-height: 1.4;
}

/* ---------- Kid picker grid ---------- */

.kids-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 14px;
}

.kid-card {
  background: #fff;
  border-radius: var(--card-radius);
  box-shadow: var(--shadow);
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  border: none;
  transition: transform 0.12s ease;
}

.kid-card:active {
  transform: scale(0.94);
}

.kid-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}

.kid-card-name {
  font-weight: 700;
  font-size: 15px;
  text-align: center;
}

.kid-card-balance {
  font-size: 13px;
  color: #8a7fae;
  font-weight: 600;
}

/* ---------- Kid detail ---------- */

.back-btn {
  border: none;
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 12px;
}

.back-btn:active {
  transform: scale(0.95);
}

.kid-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.kid-avatar-big {
  position: relative;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  box-shadow: var(--shadow);
  border: none;
  padding: 0;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.kid-avatar-big:active {
  transform: scale(0.94);
}

.avatar-edit-badge {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  box-shadow: var(--shadow);
}

.kid-name-big {
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.balance-card {
  background: #fff;
  border-radius: var(--card-radius);
  box-shadow: var(--shadow);
  padding: 22px;
  text-align: center;
  margin-bottom: 22px;
}

.balance-label {
  font-size: 14px;
  font-weight: 700;
  color: #8a7fae;
  margin-bottom: 6px;
}

.balance-amount {
  font-size: 40px;
  font-weight: 800;
  color: var(--purple-dark);
}

.history-title {
  color: #fff;
  font-size: 17px;
  margin: 0 4px 10px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.tx-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tx-item {
  background: #fff;
  border-radius: 18px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 12px rgba(90, 50, 160, 0.1);
}

.tx-info {
  display: flex;
  flex-direction: column;
}

.tx-reason {
  font-weight: 700;
  font-size: 14px;
}

.tx-date {
  font-size: 12px;
  color: #a79bc7;
}

.tx-amount {
  font-weight: 800;
  font-size: 16px;
  white-space: nowrap;
}

.tx-amount.positive {
  color: var(--green);
}

.tx-amount.negative {
  color: var(--red);
}

/* ---------- Login / forms ---------- */

.login-card {
  background: #fff;
  border-radius: var(--card-radius);
  box-shadow: var(--shadow);
  padding: 28px 22px;
  text-align: center;
  margin-top: 30px;
}

.login-icon {
  font-size: 48px;
  margin-bottom: 6px;
}

.login-card h2 {
  font-size: 18px;
  margin: 0 0 18px;
}

.text-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 2px solid #eee2ff;
  font-size: 16px;
  margin-bottom: 12px;
  background: #faf7ff;
  color: var(--ink);
}

.text-input:focus {
  outline: none;
  border-color: var(--purple);
}

.primary-btn {
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--purple), var(--pink));
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(124, 92, 252, 0.35);
  transition: transform 0.12s ease;
}

.primary-btn:active {
  transform: scale(0.97);
}

.error-msg {
  color: var(--red);
  font-weight: 700;
  font-size: 14px;
  margin-top: 12px;
}

/* ---------- Admin ---------- */

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.text-btn {
  border: none;
  background: none;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  text-decoration: underline;
}

.admin-title {
  color: #fff;
  font-size: 19px;
  margin: 4px 4px 14px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.admin-kids-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}

.admin-kid-card {
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
}

.admin-kid-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-kid-info {
  flex: 1;
}

.admin-kid-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.admin-kid-avatar:active {
  transform: scale(0.9);
}

.admin-kid-name {
  font-weight: 800;
  font-size: 15px;
}

.admin-kid-balance {
  font-size: 13px;
  color: #8a7fae;
  font-weight: 700;
}

.admin-kid-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.chip-btn {
  flex: 1;
  border: none;
  border-radius: 14px;
  padding: 10px 6px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.chip-btn:active {
  transform: scale(0.93);
}

.chip-plus {
  background: #e2f9ee;
  color: var(--green);
}

.chip-minus {
  background: #ffe9ec;
  color: var(--red);
}

.chip-swear {
  background: #fff1d6;
  color: #c98a1c;
}

.chip-homework {
  background: #e3f2fd;
  color: #1e88e5;
}

.chip-delete-icon {
  border: none;
  background: #f2eefc;
  color: #8a7fae;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.12s ease;
}

.chip-delete-icon:active {
  transform: scale(0.9);
}

.add-kid-btn {
  margin-top: 4px;
}

/* ---------- Modals ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(40, 20, 70, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  animation: fadeIn 0.15s ease;
}

.modal-box {
  background: #fff;
  border-radius: 28px 28px 0 0;
  padding: 26px 20px calc(env(safe-area-inset-bottom) + 26px);
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.2);
}

.modal-box h3 {
  margin: 0 0 16px;
  font-size: 19px;
  text-align: center;
}

.modal-label {
  font-weight: 700;
  font-size: 13px;
  color: #8a7fae;
  margin: 10px 0 8px;
}

.modal-text {
  text-align: center;
  color: #6b6180;
  margin-bottom: 6px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.modal-actions .primary-btn,
.modal-actions .secondary-btn,
.modal-actions .danger-btn {
  flex: 1;
  width: auto;
}

.secondary-btn {
  border: 2px solid #eee2ff;
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  font-weight: 800;
  font-size: 15px;
  padding: 13px;
  cursor: pointer;
}

.danger-btn {
  border: none;
  background: var(--red);
  color: #fff;
  border-radius: 999px;
  font-weight: 800;
  font-size: 15px;
  padding: 13px;
  cursor: pointer;
}

.avatar-picker {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.avatar-option {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 14px;
  border: 3px solid transparent;
  background: #faf7ff;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.avatar-option.selected {
  border-color: var(--purple);
  background: #eee2ff;
}

.color-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.color-option {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
}

.color-option.selected {
  border-color: var(--ink);
}

.sign-toggle {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.sign-btn {
  flex: 1;
  border: 2px solid #eee2ff;
  background: #fff;
  border-radius: 16px;
  padding: 13px;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  color: #a79bc7;
}

.sign-btn.active.sign-plus {
  background: #e2f9ee;
  border-color: var(--green);
  color: var(--green);
}

.sign-btn.active.sign-minus {
  background: #ffe9ec;
  border-color: var(--red);
  color: var(--red);
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  z-index: 100;
  max-width: 90%;
  text-align: center;
}
