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

:root {
  --primary: #0d9488;
  --primary-dark: #0f766e;
  --primary-light: #ccfbf1;
  --success: #10b981;
  --danger: #f56565;
  --warning: #ed8936;
  --gray-100: #f7fafc;
  --gray-200: #edf2f7;
  --gray-300: #e2e8f0;
  --gray-600: #718096;
  --gray-800: #2d3748;
  --bg: var(--gray-100);
  --card-bg: white;
  --text: var(--gray-800);
  --text-secondary: var(--gray-600);
}

body.dark-mode {
  --bg: #1a202c;
  --card-bg: #2d3748;
  --text: #f7fafc;
  --text-secondary: #a0aec0;
  --gray-100: #2d3748;
  --gray-200: #4a5568;
  --gray-300: #4a5568;
  --primary-light: #134e4a;
}

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

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 100px;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  margin-bottom: 16px;
}

header h1 {
  font-size: 24px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), #0f766e);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--card-bg);
  border-radius: 10px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  text-decoration: none;
  color: var(--text);
}

.icon-btn:hover {
  background: var(--gray-200);
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card-bg);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 11px;
  padding: 4px 12px;
  transition: color 0.2s;
}

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

.nav-icon {
  font-size: 22px;
  margin-bottom: 2px;
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Toggle items */
.toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-200);
}

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

.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
}

.toggle-icon {
  font-size: 20px;
  width: 28px;
  text-align: center;
}

.prayer-time {
  display: inline-block;
  margin-left: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  padding: 2px 6px;
  border-radius: 6px;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--gray-300);
  border-radius: 28px;
  transition: background 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* 3-state prayer button */
.state-btn {
  width: 44px;
  height: 44px;
  border: 2px solid var(--gray-300);
  background: var(--bg);
  border-radius: 12px;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.state-btn:active { transform: scale(0.9); }

.state-btn.done {
  border-color: var(--success);
  background: #ecfdf5;
}

.state-btn.missed {
  border-color: var(--danger);
  background: #fef2f2;
}

body.dark-mode .state-btn.done { background: rgba(16,185,129,0.15); }
body.dark-mode .state-btn.missed { background: rgba(245,101,101,0.15); }

/* Istighfar counter */
.istighfar-total {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
  padding: 8px 0 12px;
}

.istighfar-add {
  display: flex;
  gap: 8px;
  align-items: center;
}

.istighfar-btn {
  padding: 10px 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.2s;
}

.istighfar-btn:hover { opacity: 0.9; }
.istighfar-btn:active { transform: scale(0.97); }

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

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  border-radius: 8px;
  transition: width 0.4s ease;
}

/* Date header */
.date-header {
  text-align: center;
  margin-bottom: 16px;
}

.date-header-day {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.date-header-info {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.progress-text {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: right;
  margin-top: 2px;
}

/* Text input in card */
.text-input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--gray-200);
  border-radius: 10px;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s;
}

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

/* Toast */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--gray-800);
  color: white;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 14px;
  opacity: 0;
  transition: all 0.3s;
  z-index: 200;
  white-space: nowrap;
}

body.dark-mode .toast {
  background: var(--gray-100);
  color: var(--text);
}

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

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

.empty-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

/* Calendar grid */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 16px;
}

.calendar-header {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 4px;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  position: relative;
}

.calendar-day.empty {
  cursor: default;
}

.calendar-day.today {
  border: 2px solid var(--primary);
  font-weight: 700;
}

.calendar-day.full {
  background: var(--primary);
  color: white;
}

.calendar-day.partial {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.calendar-day.none {
  background: var(--gray-200);
}

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

.calendar-nav-btn {
  background: var(--card-bg);
  border: none;
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 18px;
  cursor: pointer;
  color: var(--text);
}

.calendar-month {
  font-size: 16px;
  font-weight: 600;
}

/* Stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Progress rows */
.progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-200);
}

.progress-row:last-child {
  border-bottom: none;
}

.progress-row-label {
  font-size: 14px;
  width: 100px;
  flex-shrink: 0;
}

.progress-row-bar {
  flex: 1;
  height: 8px;
  background: var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

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

.progress-row-fill-missed {
  position: absolute;
  top: 0;
  height: 100%;
  background: var(--danger);
  border-radius: 4px;
  opacity: 0.4;
  transition: width 0.4s;
}

.progress-row-pct {
  font-size: 13px;
  font-weight: 600;
  width: 40px;
  text-align: right;
  color: var(--primary);
}

/* History summary */
.history-summary { margin-bottom: 12px; }
.summary-row {
  display: flex;
  justify-content: space-around;
  background: var(--card-bg);
  border-radius: 12px;
  padding: 12px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

/* History table */
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}

.history-table th {
  position: sticky;
  top: 0;
  background: var(--card-bg);
  padding: 6px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--gray-200);
  z-index: 2;
}

.history-table td {
  padding: 6px 4px;
  text-align: center;
  border-bottom: 1px solid var(--gray-200);
  cursor: pointer;
}

.history-table tr:hover td { background: var(--gray-100); }

.sticky-col {
  position: sticky;
  left: 0;
  background: var(--card-bg);
  z-index: 1;
}

.history-table tr:hover .sticky-col { background: var(--gray-100); }

.date-cell {
  text-align: left !important;
  font-weight: 600;
  font-size: 12px;
  min-width: 60px;
}

.day-label {
  display: block;
  font-size: 10px;
  font-weight: 400;
  color: var(--text-secondary);
}

.cell-done { font-size: 13px; }
.cell-missed { font-size: 13px; }
.cell-empty { color: var(--gray-300); font-size: 16px; }
.cell-qaza { color: var(--primary); font-weight: 700; }
.cell-ist { color: var(--primary); font-weight: 600; font-size: 11px; }

/* Day detail modal */
.day-detail {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.day-detail.show {
  opacity: 1;
  pointer-events: auto;
}

.day-detail-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 24px;
  width: 90%;
  max-width: 360px;
  max-height: 80vh;
  overflow-y: auto;
}

.day-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.day-detail-title {
  font-size: 18px;
  font-weight: 700;
}

.day-detail-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
}

.detail-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 14px;
}

.detail-check {
  font-size: 16px;
}
