:root {
  --primary: #0284c7;
  --primary-dark: #0369a1;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --cat-tax: #dc2626;
  --cat-employment: #2563eb;
  --cat-licensing: #16a34a;
  --cat-safety: #ea580c;
  --cat-custom: #7c3aed;
  --green: #16a34a;
  --yellow: #ca8a04;
  --orange: #ea580c;
  --red: #dc2626;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --surface: #1e293b;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: #334155;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
  }
}

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

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

#app { max-width: 480px; margin: 0 auto; padding: 16px; }

.hidden { display: none !important; }

/* Bottom Navigation */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-around;
  padding: 8px 0 env(safe-area-inset-bottom, 8px);
  z-index: 100;
}
.bottom-nav button {
  background: none; border: none; color: var(--text-secondary);
  font-size: 10px; display: flex; flex-direction: column;
  align-items: center; gap: 2px; cursor: pointer; padding: 4px 12px;
}
.bottom-nav button.active { color: var(--primary); }
.bottom-nav button .nav-icon { font-size: 20px; }

/* Cards */
.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 20px; border-radius: var(--radius); border: none;
  font-size: 14px; font-weight: 600; cursor: pointer; gap: 6px;
  transition: opacity 0.15s;
}
.btn:active { opacity: 0.8; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* Form Elements */
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 14px; background: var(--surface);
  color: var(--text);
}
textarea { resize: vertical; min-height: 60px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--text-secondary); }
.form-group { margin-bottom: 14px; }

/* Header */
.screen-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.screen-header h1 { font-size: 20px; font-weight: 700; }
.screen-header h2 { font-size: 18px; font-weight: 600; }

/* Wizard */
.wizard-step { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.wizard-progress { display: flex; gap: 6px; margin-bottom: 20px; }
.wizard-progress .step-dot {
  flex: 1; height: 4px; border-radius: 2px; background: var(--border);
}
.wizard-progress .step-dot.active { background: var(--primary); }
.wizard-progress .step-dot.done { background: var(--green); }

.option-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  margin: 12px 0;
}
.option-card {
  background: var(--surface); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 12px; text-align: center;
  cursor: pointer; font-size: 13px; font-weight: 500;
  transition: border-color 0.15s;
}
.option-card.selected { border-color: var(--primary); background: rgba(2,132,199,0.08); }
.option-card .option-icon { font-size: 24px; display: block; margin-bottom: 4px; }

.state-list {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  max-height: 300px; overflow-y: auto; margin: 10px 0; padding: 4px;
}
.state-chip {
  padding: 6px 4px; border: 1px solid var(--border); border-radius: 4px;
  text-align: center; font-size: 12px; cursor: pointer;
  background: var(--surface);
}
.state-chip.selected { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Dashboard */
.score-ring { text-align: center; margin: 12px 0; }
.overdue-banner {
  background: rgba(220,38,38,0.1); border: 1px solid var(--red);
  border-radius: var(--radius); padding: 12px; margin-bottom: 12px;
}
.overdue-banner h3 { color: var(--red); font-size: 14px; margin-bottom: 6px; }

.category-pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.cat-pill {
  font-size: 11px; padding: 4px 10px; border-radius: 12px; font-weight: 600;
  color: #fff;
}
.cat-pill.tax { background: var(--cat-tax); }
.cat-pill.employment { background: var(--cat-employment); }
.cat-pill.licensing { background: var(--cat-licensing); }
.cat-pill.safety { background: var(--cat-safety); }
.cat-pill.custom { background: var(--cat-custom); }

/* Deadline List Items */
.deadline-item {
  display: flex; align-items: center; gap: 10px; padding: 10px;
  border-bottom: 1px solid var(--border); cursor: pointer;
}
.deadline-item:last-child { border-bottom: none; }
.deadline-cat-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.deadline-info { flex: 1; min-width: 0; }
.deadline-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deadline-meta { font-size: 11px; color: var(--text-secondary); }
.deadline-badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px;
  border-radius: 10px; white-space: nowrap;
}
.badge-green { background: rgba(22,163,74,0.15); color: var(--green); }
.badge-yellow { background: rgba(202,138,4,0.15); color: var(--yellow); }
.badge-orange { background: rgba(234,88,12,0.15); color: var(--orange); }
.badge-red { background: rgba(220,38,38,0.15); color: var(--red); }

/* Calendar Grid */
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-header h2 { font-size: 16px; }
.cal-header button { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text); padding: 4px 8px; }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 11px; color: var(--text-secondary); margin-bottom: 4px; font-weight: 600; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-day {
  aspect-ratio: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: 13px;
  border-radius: 4px; cursor: pointer; position: relative;
  gap: 2px;
}
.cal-day:hover { background: var(--border); }
.cal-day.today { font-weight: 700; color: var(--primary); }
.cal-day.other-month { color: var(--text-secondary); opacity: 0.4; }
.cal-dots { display: flex; gap: 2px; }
.cal-dot { width: 5px; height: 5px; border-radius: 50%; }

/* Category Legend */
.legend { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0; font-size: 11px; }
.legend-item { display: flex; align-items: center; gap: 4px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }

/* Filter Chips */
.filter-chips { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0; margin-bottom: 10px; }
.filter-chip {
  padding: 5px 12px; border-radius: 16px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer;
  white-space: nowrap; color: var(--text);
}
.filter-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Detail View */
.detail-section { margin-bottom: 16px; }
.detail-section h3 { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.detail-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; }
.detail-label { font-size: 13px; color: var(--text-secondary); }
.detail-value { font-size: 14px; font-weight: 500; }

.reminder-toggles { display: flex; flex-wrap: wrap; gap: 8px; }
.reminder-toggle {
  display: flex; align-items: center; gap: 6px; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: 4px; cursor: pointer;
  font-size: 12px; background: var(--surface);
}
.reminder-toggle.active { border-color: var(--primary); background: rgba(2,132,199,0.08); }

/* Completion Log */
.completion-item { padding: 10px; border-bottom: 1px solid var(--border); }
.completion-item:last-child { border-bottom: none; }
.on-time-badge {
  font-size: 10px; padding: 2px 6px; border-radius: 8px;
  font-weight: 600;
}
.on-time { background: rgba(22,163,74,0.15); color: var(--green); }
.late { background: rgba(220,38,38,0.15); color: var(--red); }

/* Settings */
.settings-group { margin-bottom: 20px; }
.settings-group h3 { font-size: 14px; margin-bottom: 8px; }
.settings-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px; border-bottom: 1px solid var(--border); cursor: pointer;
}
.settings-item:last-child { border-bottom: none; }

/* Toggle Switch */
.toggle { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; background: var(--border);
  border-radius: 12px; cursor: pointer; transition: background 0.2s;
}
.toggle-slider::before {
  content: ''; position: absolute; width: 18px; height: 18px;
  left: 3px; bottom: 3px; background: #fff; border-radius: 50%;
  transition: transform 0.2s;
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 200;
}
.modal {
  background: var(--surface); border-radius: 16px 16px 0 0;
  padding: 20px; width: 100%; max-width: 480px; max-height: 80vh;
  overflow-y: auto;
}
.modal h2 { font-size: 18px; margin-bottom: 16px; }

/* Responsive */
@media (min-width: 600px) {
  #app { padding: 20px; }
  .option-grid { grid-template-columns: repeat(3, 1fr); }
  .state-list { grid-template-columns: repeat(5, 1fr); }
}

/* Search input */
.search-input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 13px; margin-bottom: 10px;
  background: var(--surface); color: var(--text);
}

/* Donut chart */
.donut-container { display: flex; align-items: center; gap: 16px; }
.donut-label { text-align: left; }
.donut-label .score-pct { font-size: 28px; font-weight: 700; color: var(--primary); }
.donut-label .score-text { font-size: 12px; color: var(--text-secondary); }

/* Back button */
.back-btn {
  background: none; border: none; font-size: 18px; cursor: pointer;
  color: var(--text); padding: 4px 8px; margin-right: 8px;
}
