* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #06C755;
  --primary-dark: #05a647;
  --danger: #FF4444;
  --bg: #F5F5F5;
  --card-bg: #FFFFFF;
  --text: #333333;
  --text-light: #666666;
  --text-muted: #999999;
  --border: #E0E0E0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 70px;
}

/* Loading */
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
  color: var(--text-muted);
  font-size: 1.1rem;
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 10px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Header */
.header {
  background: var(--primary);
  color: white;
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header h1 {
  font-size: 1.2rem;
  font-weight: 700;
}

.header-sub {
  font-size: 0.8rem;
  opacity: 0.8;
}

/* Navigation */
.nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card-bg);
  display: flex;
  border-top: 1px solid var(--border);
  z-index: 100;
}

.nav a {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  transition: color 0.2s;
}

.nav a.active {
  color: var(--primary);
}

.nav a .nav-icon {
  display: block;
  font-size: 1.4rem;
  margin-bottom: 2px;
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 16px;
  margin: 12px 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
}

/* Child Card */
.child-card {
  display: flex;
  align-items: center;
  gap: 12px;
}

.child-avatar {
  font-size: 2.5rem;
  width: 50px;
  text-align: center;
}

.child-info {
  flex: 1;
}

.child-name {
  font-weight: 600;
  font-size: 1rem;
}

.child-points {
  font-size: 1.8rem;
  font-weight: 700;
}

.child-points.positive { color: var(--primary); }
.child-points.negative { color: var(--danger); }

.child-actions {
  display: flex;
  gap: 8px;
}

/* Buttons */
.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn:active { opacity: 0.7; }

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-secondary {
  background: var(--border);
  color: var(--text);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  padding: 0;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-block {
  display: block;
  width: 100%;
}

/* Progress Bar */
.progress-bar {
  background: var(--border);
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-fill {
  background: var(--primary);
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}

.progress-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-control:focus {
  border-color: var(--primary);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath fill='%23999' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* Milestone */
.milestone-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.milestone-item:last-child {
  border-bottom: none;
}

.milestone-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.milestone-name {
  font-weight: 600;
}

.milestone-threshold {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.milestone-type {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
}

.milestone-type.reward {
  background: #E8F5E9;
  color: var(--primary);
}

.milestone-type.punishment {
  background: #FFEBEE;
  color: var(--danger);
}

/* History */
.history-item {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}

.history-item:last-child {
  border-bottom: none;
}

.history-amount {
  font-weight: 700;
  font-size: 1rem;
  min-width: 50px;
}

.history-amount.positive { color: var(--primary); }
.history-amount.negative { color: var(--danger); }

.history-detail {
  flex: 1;
}

.history-reason {
  font-size: 0.85rem;
}

.history-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--card-bg);
  border-radius: 16px 16px 0 0;
  padding: 24px 20px;
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
}

/* Quick amount buttons */
.amount-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.amount-btn {
  border: 2px solid var(--border);
  background: white;
  border-radius: 8px;
  padding: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.amount-btn.selected {
  border-color: var(--primary);
  background: #E8F5E9;
  color: var(--primary);
}

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

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 0.9rem;
  margin-bottom: 16px;
}

/* Section title */
.section-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 16px 16px 8px;
}

/* Toast notification */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: var(--text);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 300;
  transition: transform 0.3s;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.success { background: var(--primary); }
.toast.error { background: var(--danger); }
