/* Import design system tokens */
@import './tokens.css';

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

html, body {
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Tabular figures for numbers, measurements, and timestamps */
.tabular-nums,
.num,
.pollutant-val,
.aqi-val,
.stat-num,
.time-stamp {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* Screen reader utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus states */
:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* Headings */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  line-height: 1.25;
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-base); }

/* Common Buttons */
button, input, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: var(--text-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

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

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
}

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

.btn-secondary:hover:not(:disabled) {
  background-color: var(--surface-sub);
  border-color: var(--muted-light);
}

.btn-ghost {
  background-color: transparent;
  color: var(--ink);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background-color: var(--surface-sub);
}

.btn-outline {
  background-color: var(--surface);
  color: var(--ink);
  border-color: var(--border);
}

.btn-outline:hover:not(:disabled) {
  background-color: var(--surface-sub);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-sm {
  padding: 6px 10px;
  font-size: var(--text-xs);
}

.btn-block {
  width: 100%;
}

.btn-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.preview-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
}

.google-btn {
  font-weight: 500;
}

.btn-google {
  background-color: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  width: 100%;
}

.btn-google:hover:not(:disabled) {
  background-color: var(--surface-sub);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--ink);
}

.btn-icon:hover {
  background-color: var(--surface-sub);
}

/* Spinner */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* =========================================================
   AUTH PAGES: SPLIT LAYOUT (/login & /register)
   ========================================================= */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background-color: var(--bg);
}

.auth-split-card {
  width: 100%;
  max-width: var(--max-auth-width);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: grid;
  grid-template-columns: 1fr;
  overflow: hidden;
}

@media (min-width: 860px) {
  .auth-split-card {
    grid-template-columns: 1.15fr 1fr;
  }
}

/* Left Brand Panel (Desktop) */
.auth-brand-panel {
  background-color: var(--surface-sub);
  border-bottom: 1px solid var(--border);
  padding: var(--space-8);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-6);
}

@media (min-width: 860px) {
  .auth-brand-panel {
    border-bottom: none;
    border-right: 1px solid var(--border);
    padding: var(--space-10) var(--space-8);
  }
}

.brand-header-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  width: fit-content;
  padding: 4px 10px;
  background-color: var(--primary-light);
  border: 1px solid var(--primary-ring);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.brand-title {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.3px;
}

.brand-tagline {
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.5;
}

/* Mini Live Preview Card inside Brand Panel */
.brand-preview-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

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

.preview-station-tag {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--muted);
}

.preview-pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--success);
}

.preview-aqi-row {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
}

.preview-aqi-num {
  font-size: 2.2rem;
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1;
}

.preview-aqi-badge {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background-color: var(--aqi-moderate-bg);
  color: var(--aqi-moderate);
  border: 1px solid currentColor;
}

.preview-pollutants-mini {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
}

.preview-pol-item span {
  display: block;
  color: var(--muted);
}

.preview-pol-item strong {
  color: var(--ink);
}

/* Brand Value List */
.brand-value-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.brand-value-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--ink-secondary);
}

.brand-value-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--primary);
  margin-top: 1px;
}

/* Right Form Panel */
.auth-form-panel {
  padding: var(--space-6) var(--space-6);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

@media (min-width: 860px) {
  .auth-form-panel {
    padding: var(--space-10) var(--space-8);
  }
}

.auth-form-header {
  margin-bottom: var(--space-6);
}

.auth-form-title {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--ink);
  margin-bottom: var(--space-1);
}

.auth-form-subtitle {
  font-size: var(--text-sm);
  color: var(--muted);
}

/* Form Groups & Inputs */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  position: relative;
}

.form-group label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--ink-secondary);
  display: flex;
  justify-content: space-between;
}

.input-container {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-field {
  width: 100%;
  padding: 10px 12px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--ink);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-field:hover {
  border-color: var(--muted-light);
}

.input-field:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.input-field.has-error {
  border-color: var(--error);
  background-color: var(--error-bg);
}

.input-container .input-field.with-toggle {
  padding-right: 40px;
}

.toggle-pw-btn {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.toggle-pw-btn:hover {
  color: var(--ink);
}

.field-error-msg {
  font-size: var(--text-xs);
  color: var(--error);
  margin-top: 2px;
}

/* Password Strength Meter */
.pw-strength-bar {
  display: flex;
  gap: 4px;
  height: 4px;
  margin-top: 6px;
}

.strength-segment {
  flex: 1;
  height: 100%;
  background-color: var(--border);
  border-radius: 2px;
  transition: background-color var(--transition-fast);
}

.strength-segment.active-weak { background-color: var(--error); }
.strength-segment.active-fair { background-color: var(--warning); }
.strength-segment.active-strong { background-color: var(--success); }

.pw-rules-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: 6px;
  list-style: none;
  font-size: var(--text-xs);
  color: var(--muted);
}

.pw-rule-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background-color: var(--surface-sub);
}

.pw-rule-chip.valid {
  color: var(--success);
  background-color: var(--success-bg);
}

/* City Autocomplete Dropdown */
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  max-height: 200px;
  overflow-y: auto;
  z-index: 50;
  list-style: none;
}

.autocomplete-item {
  padding: 8px 12px;
  font-size: var(--text-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.autocomplete-item:hover,
.autocomplete-item:focus {
  background-color: var(--surface-sub);
  color: var(--primary);
}

/* Checkbox and Helper Row */
.form-row-utility {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-xs);
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--ink-secondary);
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  accent-color: var(--primary);
  width: 15px;
  height: 15px;
}

.text-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
}

.text-link:hover {
  text-decoration: underline;
}

/* Form Level Alert */
.alert-box {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.alert-error {
  background-color: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error);
}

.alert-success {
  background-color: var(--success-bg);
  border: 1px solid var(--success);
  color: var(--success);
}

.alert-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 2px;
}

/* Divider */
.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: var(--space-4) 0;
  color: var(--muted);
  font-size: var(--text-xs);
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.auth-divider span {
  padding: 0 var(--space-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Footer Link line below form */
.auth-footer-line {
  margin-top: var(--space-6);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--muted);
}

.auth-footer-line a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.auth-footer-line a:hover {
  text-decoration: underline;
}

/* =========================================================
   DASHBOARD LAYOUT & TOP BAR
   ========================================================= */
.dashboard-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Top Navbar */
.top-navbar {
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.navbar-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--ink);
}

.nav-logo-icon {
  width: 28px;
  height: 28px;
  color: var(--primary);
}

.nav-brand-text {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-base);
  letter-spacing: -0.2px;
}

/* Search and Geolocation */
.nav-search-wrap {
  flex: 1;
  max-width: 440px;
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.nav-search-input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  background-color: var(--surface-sub);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--ink);
}

.nav-search-input:focus {
  background-color: var(--surface);
  border-color: var(--border-focus);
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.search-input-icon {
  position: absolute;
  left: 10px;
  color: var(--muted);
  pointer-events: none;
  width: 16px;
  height: 16px;
}

/* Nav Actions (Theme & Avatar) */
.nav-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

/* Avatar & Profile Dropdown */
.avatar-menu-container {
  position: relative;
}

.avatar-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-ring);
  font-weight: 600;
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
}

.avatar-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-2);
  display: none;
  flex-direction: column;
  z-index: 50;
}

.avatar-dropdown.open {
  display: flex;
}

.dropdown-user-info {
  padding: var(--space-3) var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}

.dropdown-user-name {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--ink);
}

.dropdown-user-email {
  font-size: var(--text-xs);
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px 10px;
  font-size: var(--text-sm);
  color: var(--ink-secondary);
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.dropdown-item:hover {
  background-color: var(--surface-sub);
  color: var(--ink);
}

.dropdown-item.danger-item {
  color: var(--error);
}

.dropdown-item.danger-item:hover {
  background-color: var(--error-bg);
}

/* Offline Banner */
.offline-banner {
  background-color: var(--warning-bg);
  border-bottom: 1px solid var(--warning);
  color: var(--warning);
  font-size: var(--text-xs);
  padding: var(--space-2) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

/* Main Dashboard Grid */
.dashboard-main-content {
  flex: 1;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
}

@media (min-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1.8fr 1fr;
    align-items: start;
  }
}

.main-column {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.side-column {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* Scientific Cards */
.instrument-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

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

.card-title-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.card-title-group h3 {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--ink);
}

.card-subtitle {
  font-size: var(--text-xs);
  color: var(--muted);
}

/* =========================================================
   AQI HERO ELEMENT
   ========================================================= */
.aqi-hero-card {
  border-left: 5px solid var(--hero-aqi-color, var(--primary));
  position: relative;
  overflow: hidden;
}

.hero-meta-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.location-headline h2 {
  font-size: var(--text-xl);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.location-sub {
  font-size: var(--text-xs);
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: 2px;
}

.hero-gauge-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
  align-items: center;
  margin: var(--space-2) 0;
}

@media (min-width: 580px) {
  .hero-gauge-layout {
    grid-template-columns: auto 1fr;
  }
}

.gauge-svg-wrapper {
  position: relative;
  width: 170px;
  height: 170px;
  margin: 0 auto;
}

.gauge-svg-wrapper svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.gauge-bg-arc {
  fill: none;
  stroke: var(--surface-sub);
  stroke-width: 12;
}

.gauge-meter-arc {
  fill: none;
  stroke: var(--hero-aqi-color, var(--primary));
  stroke-width: 12;
  stroke-linecap: round;
  transition: stroke-dashoffset 600ms cubic-bezier(0.4, 0, 0.2, 1);
}

.gauge-inner-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.gauge-val-big {
  font-size: 3.2rem;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
}

.gauge-unit {
  font-size: var(--text-xs);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hero-status-details {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.hero-category-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: var(--text-sm);
  width: fit-content;
  border: 1px solid currentColor;
}

.hero-advisory-text {
  font-size: var(--text-sm);
  color: var(--ink-secondary);
  line-height: 1.55;
  background-color: var(--surface-sub);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--hero-aqi-color, var(--primary));
}

/* =========================================================
   POLLUTANTS COMPACT ROWS
   ========================================================= */
.pollutant-rows-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.pollutant-row {
  display: grid;
  grid-template-columns: 75px 80px 1fr;
  align-items: center;
  gap: var(--space-3);
  padding: 8px 12px;
  background-color: var(--surface-sub);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
}

.pollutant-name {
  font-weight: 600;
  color: var(--ink);
}

.pollutant-name small {
  font-size: var(--text-xs);
  color: var(--muted);
  font-weight: normal;
  margin-left: 2px;
}

.pollutant-val-col {
  text-align: right;
  font-weight: 600;
  color: var(--ink);
}

.pollutant-val-col small {
  font-size: var(--text-xs);
  color: var(--muted);
  font-weight: normal;
}

.pollutant-bar-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.pollutant-track {
  flex: 1;
  height: 6px;
  background-color: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.pollutant-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 400ms ease;
}

.pollutant-ratio-tag {
  font-size: var(--text-xs);
  color: var(--muted);
  width: 52px;
  text-align: right;
}

/* =========================================================
   TREND CHARTS (SVG-based Scientific Graph)
   ========================================================= */
.chart-tabs-bar {
  display: flex;
  gap: var(--space-2);
}

.chart-tab-btn {
  background: none;
  border: 1px solid transparent;
  padding: 4px 10px;
  font-size: var(--text-xs);
  font-weight: 500;
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
}

.chart-tab-btn.active {
  background-color: var(--surface-sub);
  border-color: var(--border);
  color: var(--ink);
  font-weight: 600;
}

.svg-chart-container {
  width: 100%;
  height: 220px;
  position: relative;
}

.svg-chart {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart-axis-line {
  stroke: var(--border);
  stroke-dasharray: 3 3;
}

.chart-axis-text {
  font-size: 11px;
  fill: var(--muted);
}

.chart-data-line {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-area-gradient {
  fill: url(#chartGradient);
}

.chart-point {
  fill: var(--surface);
  stroke: var(--primary);
  stroke-width: 2;
  cursor: pointer;
  transition: r var(--transition-fast);
}

.chart-point:hover {
  r: 5;
  fill: var(--primary);
}

/* Tooltip */
.chart-tooltip-box {
  position: absolute;
  pointer-events: none;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  box-shadow: var(--shadow-md);
  font-size: var(--text-xs);
  transform: translate(-50%, -100%);
  margin-top: -10px;
  white-space: nowrap;
  display: none;
  z-index: 20;
}

/* =========================================================
   HEALTH ADVICE & ACTIONABLE CARDS
   ========================================================= */
.advice-items-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.advice-card {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3);
  background-color: var(--surface-sub);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.advice-icon-badge {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background-color: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.advice-content h4 {
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: 2px;
}

.advice-content p {
  font-size: var(--text-xs);
  color: var(--muted);
  line-height: 1.45;
}

/* =========================================================
   AI ASSISTANT SIDE DRAWER
   ========================================================= */
.assistant-launcher-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-4);
  background: var(--surface-sub);
  border: 1px dashed var(--border-focus);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.assistant-launcher-btn:hover {
  background-color: var(--primary-light);
  border-style: solid;
}

.launcher-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.launcher-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background-color: var(--primary);
  color: var(--primary-contrast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.launcher-text h4 {
  font-size: var(--text-sm);
  margin-bottom: 2px;
}

.launcher-text p {
  font-size: var(--text-xs);
  color: var(--muted);
}

/* Assistant Drawer Overlay */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(20, 32, 28, 0.4);
  backdrop-filter: blur(2px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 440px;
  background-color: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-drawer);
  z-index: 101;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition-normal);
}

.drawer-backdrop.open .drawer-panel {
  transform: translateX(0);
}

.drawer-header {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-title-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.drawer-context-pill {
  font-size: var(--text-xs);
  padding: 2px 8px;
  background-color: var(--surface-sub);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--muted);
}

.drawer-messages-area {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.chat-bubble.user-bubble {
  align-self: flex-end;
  background-color: var(--primary);
  color: var(--primary-contrast);
  border-bottom-right-radius: 2px;
}

.chat-bubble.bot-bubble {
  align-self: flex-start;
  background-color: var(--surface-sub);
  color: var(--ink);
  border: 1px solid var(--border-subtle);
  border-bottom-left-radius: 2px;
}

.chat-sources-tag {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 4px;
}

.suggested-prompts-bar {
  padding: 0 var(--space-4) var(--space-3);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.prompt-chip {
  background-color: var(--surface-sub);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 4px 10px;
  font-size: var(--text-xs);
  color: var(--ink-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.prompt-chip:hover {
  background-color: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  width: fit-content;
  border-radius: var(--radius-md);
  background-color: var(--surface-sub);
}

.typing-dot {
  width: 5px;
  height: 5px;
  background-color: var(--muted);
  border-radius: 50%;
  animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-4px); }
}

.drawer-input-bar {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  display: flex;
  gap: var(--space-2);
}

.drawer-input {
  flex: 1;
  padding: 8px 12px;
  background-color: var(--surface-sub);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--ink);
}

.drawer-input:focus {
  outline: none;
  border-color: var(--border-focus);
  background-color: var(--surface);
}

/* =========================================================
   SKELETON LOADERS & EMPTY STATES
   ========================================================= */
.skeleton {
  background: linear-gradient(90deg, var(--surface-sub) 25%, var(--surface-hover) 50%, var(--surface-sub) 75%);
  background-size: 200% 100%;
  animation: skeletonPulse 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeletonPulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 14px;
  width: 100%;
  margin: 4px 0;
}

.skeleton-title {
  height: 24px;
  width: 60%;
  margin-bottom: var(--space-2);
}

.skeleton-gauge {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  margin: 0 auto;
}

.error-retry-state {
  padding: var(--space-8) var(--space-4);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.error-retry-state h4 {
  color: var(--error);
}

.error-retry-state p {
  font-size: var(--text-sm);
  color: var(--muted);
  max-width: 400px;
}

/* Reduced Motion Override */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}


/* =========================================================
   SENIOR & LARGE TEXT ACCESSIBILITY MODE
   ========================================================= */
[data-senior="true"],
[data-senior="true"] body {
  font-size: 18px;
  --text-xs: 15px;
  --text-sm: 17px;
  --text-base: 20px;
  --text-lg: 24px;
  --text-xl: 28px;
  --text-2xl: 34px;
  --text-3xl: 42px;
  --text-4xl: 52px;
  line-height: 1.6;
}

[data-senior="true"] .dashboard-grid,
[data-senior="true"] .card {
  border-width: 2px !important;
}

[data-senior="true"] .btn,
[data-senior="true"] button {
  min-height: 48px;
  font-size: 16px;
}

[data-senior="true"] .pollutant-row {
  padding: var(--space-3) var(--space-2);
}

[data-senior="true"] .stat-pill {
  font-size: 14px;
  padding: 4px 10px;
}

/* =========================================================
   MODAL DIALOGS (Profile, Day Planner, Smoke Spotter)
   ========================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(20, 32, 28, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(12px) scale(0.98);
  transition: transform var(--transition-normal);
}

.modal-overlay.open .modal-dialog {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--ink);
  margin: 0;
}

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  background-color: var(--surface-sub);
}

/* Day planner preset chips & chat */
.planner-presets {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.planner-preset-chip {
  background: var(--surface-sub);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 6px 12px;
  font-size: var(--text-xs);
  color: var(--ink);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.planner-preset-chip:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* Smoke Spotter Dropzone */
.spotter-dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  text-align: center;
  background-color: var(--surface-sub);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.spotter-dropzone:hover {
  border-color: var(--primary);
  background-color: var(--primary-light);
}

.spotter-preview-img {
  max-width: 100%;
  max-height: 220px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  margin-top: var(--space-3);
}
