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

:root {
  --green: #059669;
  --green-light: #d1fae5;
  --green-dark: #047857;
  --bg: #f0fdf4;
  --card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
}

body {
  font-family: 'Inter', sans-serif;
  color: var(--text);
  min-height: 100vh;
}

/* ==================== LOGIN ==================== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 50%, #a7f3d0 100%);
}

.login-card {
  background: var(--card);
  padding: 48px 40px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.08);
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-title {
  font-family: 'Amiri', serif;
  font-size: 36px;
  color: var(--green);
  margin-bottom: 4px;
}

.login-subtitle {
  font-weight: 600;
  font-size: 18px;
  color: var(--text);
  margin-bottom: 32px;
}

.login-desc {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.login-card input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color 0.2s;
}

.login-card input:focus {
  border-color: var(--green);
}

#otp-input {
  text-align: center;
  letter-spacing: 8px;
  font-size: 24px;
  font-weight: 600;
}

.login-card button {
  cursor: pointer;
}

.login-card button:not(.link-btn) {
  width: 100%;
  padding: 14px;
  background: var(--green);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  margin-top: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.login-card button:not(.link-btn):hover {
  background: var(--green-dark);
}

.login-card button:not(.link-btn):disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.link-btn {
  background: none;
  border: none;
  color: var(--green);
  font-size: 14px;
  margin-top: 16px;
  text-decoration: underline;
}

.error {
  color: #dc2626;
  font-size: 14px;
  margin-top: 8px;
  min-height: 20px;
}

/* ==================== APP ==================== */
.app-page {
  background: var(--bg);
}

header {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--green);
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-title-arabic {
  font-family: 'Amiri', serif;
  font-size: 28px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-email {
  font-size: 14px;
  color: var(--text-muted);
}

.logout-btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
}

.logout-btn:hover {
  border-color: #dc2626;
  color: #dc2626;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* Progress */
.progress-section {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.progress-stats {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
}

#progress-pct {
  color: var(--green);
}

.progress-bar {
  height: 12px;
  background: var(--green-light);
  border-radius: 6px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 6px;
  transition: width 0.4s ease;
}

/* Plan */
.plan-section {
  background: white;
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.plan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.plan-label {
  font-weight: 600;
  font-size: 15px;
}

.plan-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-muted);
}

.plan-input-row input {
  width: 64px;
  padding: 6px 10px;
  border: 2px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

.plan-input-row input:focus {
  border-color: var(--green);
}

#plan-btn {
  padding: 6px 14px;
  background: var(--green);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

#plan-btn:hover {
  background: var(--green-dark);
}

.plan-clear-btn {
  padding: 6px 14px;
  background: none;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.plan-clear-btn:hover {
  border-color: #dc2626;
  color: #dc2626;
}

.plan-summary {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.plan-day {
  padding: 6px 12px;
  background: var(--green-light);
  border-radius: 6px;
  font-size: 13px;
  color: var(--green-dark);
  font-weight: 500;
}

.plan-day.completed {
  background: var(--green);
  color: white;
}

/* Badges on name cards */
.name-num-badge {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: #f1f5f9;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}

.name-day-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: var(--green-light);
  color: var(--green-dark);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}

/* Filter */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.filter-group {
  display: flex;
  gap: 8px;
}

.filter-btn {
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: white;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-muted);
}

.filter-btn.active {
  background: var(--green);
  color: white;
  border-color: var(--green);
}

.sort-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 2px solid var(--border);
  border-radius: 20px;
  background: white;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
}

.sort-toggle:hover {
  border-color: var(--green);
  color: var(--green);
}

.sort-toggle.active {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
}

.sort-icon {
  font-size: 16px;
}

/* Names grid */
.group-section {
  margin-bottom: 32px;
}

.group-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}

.group-letter {
  font-size: 24px;
  font-weight: 700;
  color: var(--green);
}

.group-info {
  font-size: 13px;
  color: var(--text-muted);
}

.names-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.name-card {
  background: white;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.name-card:hover {
  border-color: var(--green);
  box-shadow: 0 2px 8px rgba(5,150,105,0.1);
}

.name-card.memorized {
  border-color: var(--green);
  background: #f0fdf4;
}

.name-card .checkbox {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.name-card.memorized .checkbox {
  background: var(--green);
  border-color: var(--green);
}

.name-card.memorized .checkbox::after {
  content: '✓';
  color: white;
  font-size: 14px;
  font-weight: bold;
}

.name-arabic {
  font-family: 'Amiri', serif;
  font-size: 32px;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.4;
}

.name-translit {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
}

.name-meaning {
  font-size: 13px;
  color: var(--text-muted);
}

/* Mobile */
@media (max-width: 640px) {
  .login-card {
    margin: 16px;
    padding: 32px 24px;
  }

  .header-inner {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }

  .names-grid {
    grid-template-columns: 1fr;
  }

  main {
    padding: 16px;
  }

  .user-email {
    display: none;
  }
}
