﻿/* Icon color & effects */
i[data-lucide] { stroke-width: 2.5; transition: color 0.15s, filter 0.15s; filter: drop-shadow(0 0 1px rgba(0,0,0,0.05)); }
i[data-lucide]:hover { filter: drop-shadow(0 0 3px currentColor); }
.card-icon[data-lucide], .nav-icon[data-lucide] { stroke-width: 2.5; }
[data-theme="dark"] .status-active, [data-theme="dark"] .sector-mixed { color: #34d399 !important; }
:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --border: #475569;
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --nav-height: 65px;
  --top-height: 60px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: block !important;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  padding-top: var(--top-height);
  padding-bottom: calc(var(--nav-height) + 20px);
}

/* â”€â”€ Top Bar â”€â”€ */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--top-height);
  background: #0b1220;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  z-index: 1000;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chw-id {
  background: var(--primary);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}

.chw-name {
  font-weight: 600;
  font-size: 14px;
}

.sync-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.sync-dot.online { background: var(--success); box-shadow: 0 0 6px var(--success); }
.sync-dot.offline { background: var(--danger); box-shadow: 0 0 6px var(--danger); }

.scope-notice {
  display: grid;
  gap: 4px;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 12px;
  background: rgba(59, 130, 246, 0.1);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.scope-notice span {
  color: var(--muted);
}

.chw-guardrail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 14px;
}

.guardrail-card {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-size: 12px;
  line-height: 1.35;
}

.guardrail-card strong {
  display: block;
  margin-bottom: 4px;
}

.guardrail-card span {
  color: var(--muted);
}

.guardrail-card.allowed { border-color: rgba(34, 197, 94, 0.4); }
.guardrail-card.restricted { border-color: rgba(239, 68, 68, 0.45); }
.guardrail-card.audit { border-color: rgba(245, 158, 11, 0.45); }

/* â”€â”€ Bottom Nav â”€â”€ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: #0b1220;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  align-items: center;
  z-index: 1000;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}

.bottom-nav a,
.bottom-more-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  padding: 7px 4px;
  border-radius: 12px;
  min-width: 0;
  min-height: 50px;
  border: 0;
  background: transparent;
  font-family: inherit;
  transition: all 0.2s;
}

.bottom-nav a.active,
.bottom-more-btn.active {
  color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
}

.bottom-nav span,
.bottom-more-btn span {
  margin-top: 4px;
}

.bottom-more-menu {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--nav-height) + 12px + env(safe-area-inset-bottom));
  z-index: 999;
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.bottom-more-menu.active {
  display: grid;
}

.bottom-more-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
}

/* â”€â”€ Screens â”€â”€ */
.app-container {
  padding: 16px;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

h2 {
  margin: 20px 0 12px;
  font-size: 18px;
}

h3 {
  margin: 16px 0 10px;
  font-size: 16px;
}

/* â”€â”€ Greeting Card â”€â”€ */
.greeting-card {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
}

.greeting-card h1 {
  margin: 0 0 8px;
  font-size: 22px;
}

.greeting-card p {
  margin: 0 0 16px;
  color: rgba(255, 255, 255, 0.8);
}

.btn-sync {
  width: 100%;
  padding: 12px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.chw-score-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin: 14px 0 18px;
}
.score-main {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.score-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.score-main strong {
  display: block;
  font-size: 34px;
  line-height: 1;
  margin: 5px 0;
}
.score-main small {
  color: var(--muted);
  font-size: 12px;
}
.score-ring {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 7px solid rgba(34, 197, 94, 0.2);
  display: grid;
  place-items: center;
  color: var(--success);
  font-weight: 800;
}
.score-breakdown {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.score-breakdown div {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px;
  text-align: center;
}
.score-breakdown strong {
  display: block;
  font-size: 19px;
}
.score-breakdown span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin-top: 3px;
}
.badge-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.game-badge {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--bg);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.game-badge.unlocked {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--success));
  border-color: transparent;
}

.btn-sync.syncing {
  opacity: 0.7;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* â”€â”€ KPIs â”€â”€ */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
}

.kpi-val {
  font-size: 24px;
  font-weight: 800;
  color: var(--primary);
}

.kpi-lbl {
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
  text-transform: uppercase;
}

.chw-flow-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 20px;
}

.flow-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.flow-header h2 {
  margin: 0 0 6px;
}

.flow-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.flow-steps {
  display: grid;
  grid-template-columns: repeat(7, minmax(110px, 1fr));
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.flow-step {
  min-height: 132px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 6px;
  align-content: start;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #0f172a;
  color: var(--text);
  padding: 12px;
  cursor: pointer;
}

.flow-step span {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(148, 163, 184, .16);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.flow-step strong {
  font-size: 13px;
}

.flow-step small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.flow-step.active {
  border-color: rgba(59, 130, 246, .6);
  background: rgba(59, 130, 246, .12);
}

.flow-step.active span {
  background: rgba(59, 130, 246, .2);
  color: #93c5fd;
}

/* â”€â”€ Task List â”€â”€ */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 0 12px;
}

.task-heading h2 {
  margin: 0 0 4px;
}

.queue-summary {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.compact {
  min-height: 0;
  padding: 8px 12px;
  font-size: 12px;
}

.task-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: all 0.2s;
}

.task-card.completed {
  opacity: 0.75;
  border-color: var(--success);
}

.task-card.system-card {
  border-style: dashed;
}

.task-priority {
  width: 50px;
  text-align: center;
  padding: 6px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}

.task-priority.red { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.task-priority.yellow { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.task-priority.green { background: rgba(34, 197, 94, 0.2); color: var(--success); }

.task-content {
  flex: 1;
}

.task-content h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.task-content p {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--muted);
}

.task-distance {
  font-size: 11px;
  color: var(--primary);
}

.task-btn {
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
}

.task-btn:disabled {
  background: var(--success);
  cursor: default;
}

.device-status {
  margin: 8px 0 12px;
  padding: 10px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.45);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.device-status.connected {
  color: #bbf7d0;
  border-color: rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.12);
}

@media (max-width: 720px) {
  .chw-guardrail-grid {
    grid-template-columns: 1fr;
  }

  .task-heading {
    align-items: stretch;
    flex-direction: column;
  }
}

.log-section {
  margin-top: 20px;
}

.log-entry {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}

/* â”€â”€ Patient Search â”€â”€ */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.search-bar input {
  flex: 1;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}

.patient-results, .patient-detail {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.patient-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
}

.pc-avatar {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  font-weight: 700;
  font-size: 14px;
}

.pc-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pc-info strong {
  font-size: 15px;
}

.pc-info span {
  font-size: 12px;
  color: var(--muted);
}

.tag-risk {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}

.tag-risk.high { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.tag-risk.med { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.tag-risk.low { background: rgba(34, 197, 94, 0.2); color: var(--success); }

.patient-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 12px;
}

.patient-avatar {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  font-weight: 800;
  font-size: 18px;
}

.patient-info h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.patient-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.patient-tags span {
  padding: 4px 8px;
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 12px;
}

.patient-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}

.summary-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

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

.adherence-good {
  color: var(--success);
  font-weight: 600;
}

.patient-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

/* â”€â”€ Workflow â”€â”€ */
.workflow-steps {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  opacity: 0.5;
}

.step.active {
  opacity: 1;
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
}

.step.done {
  opacity: 1;
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.1);
}

.step-number {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 12px;
  font-weight: 700;
}

.step-content {
  display: none;
}

.step-content h3 {
  margin: 0 0 4px;
  font-size: 13px;
}

.step-content p {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
}

.step-panel {
  display: none;
}

.step-panel.active {
  display: block;
}

.vitals-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.screening-checks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 16px 0;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.check-item input {
  width: 20px;
  height: 20px;
}

.step-nav {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.btn-connect {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  margin: 12px 0;
  font-size: 14px;
}

.btn-connect.connected {
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.1);
  color: var(--success);
}

/* â”€â”€ Referrals â”€â”€ */
.referral-create {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.referral-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ref-card {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

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

.ref-card p {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted);
}

.ref-footer {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

.badge {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}

.badge.pending { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.badge.accepted { background: rgba(34, 197, 94, 0.2); color: var(--success); }

.basemap-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.basemap-btn {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.basemap-btn:hover {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary);
}

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

.basemap-btn.active i {
  color: white;
}

.basemap-btn i {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.basemap-btn span {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.map-placeholder {
  height: 200px;
  background: linear-gradient(135deg, #064e3b, #065f46);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.map-grid {
  width: 100%;
  height: 100%;
  position: relative;
}

.map-pin {
  position: absolute;
  font-size: 24px;
  cursor: pointer;
  transition: transform 0.2s;
}

.map-pin:hover {
  transform: scale(1.2);
}

.map-pin.chw-pin {
  font-size: 28px;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.map-legend {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.7);
  padding: 8px;
  border-radius: 8px;
  display: flex;
  justify-content: space-around;
  font-size: 11px;
}

.household-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.house-item {
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
}

.house-item strong {
  display: block;
  margin-bottom: 4px;
}

.house-item span {
  font-size: 12px;
  color: var(--muted);
}

/* â”€â”€ Forms â”€â”€ */
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 12px;
}

input, select, textarea {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary);
  border-color: var(--primary);
}

input.error, select.error {
  border-color: var(--danger);
  outline: 2px solid var(--danger);
}

/* Custom icon dropdown (uc-select) */
.uc-select { position: relative; }
.uc-select-trigger {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  box-sizing: border-box;
}
.uc-select-trigger:hover { border-color: var(--primary); }
.uc-select-value { display: flex; align-items: center; gap: 8px; }
.uc-select-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  max-height: 280px;
  overflow-y: auto;
  padding: 4px;
}
.uc-select-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
}
.uc-select-option:hover { background: rgba(16,185,129,0.10); }
.uc-select-option.selected { background: rgba(16,185,129,0.14); font-weight: 600; }
.uc-select-native { display: none; }

textarea {
  resize: vertical;
  min-height: 60px;
}

.btn-lg {
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}

.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }

.empty {
  color: var(--muted);
  text-align: center;
  padding: 30px;
}

/* â”€â”€ Survey Types â”€â”€ */
.survey-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.survey-type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.survey-type-card:hover {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
}

.survey-icon {
  font-size: 28px;
}

.survey-type-card strong {
  font-size: 13px;
}

.survey-type-card span {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
}

.survey-history {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.edu-history {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

@media (max-width: 360px) {
  .kpi-row {
    grid-template-columns: 1fr 1fr;
  }
  .flow-header {
    flex-direction: column;
  }
  .vitals-grid, .screening-checks {
    grid-template-columns: 1fr;
  }
  .survey-type-grid {
    grid-template-columns: 1fr;
  }
}

.location-toggle-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  transition: all 0.2s;
}
.location-toggle-btn:hover {
  background: var(--surface-2);
}
.location-toggle-btn.active {
  background: #dcfce7;
  border-color: #22c55e;
  color: #22c55e;
}

/* Risk Assessment Styles */
.risk-card { padding:16px;border-radius:12px;margin-bottom:12px; }
.risk-card.high,.risk-card.critical { background:#fef2f2;border:1px solid #ef4444; }
.risk-card.moderate { background:#fffbeb;border:1px solid #f59e0b; }
.risk-card.low { background:#f0fdf4;border:1px solid #22c55e; }
.risk-score,.risk-level,.risk-category,.risk-emergency { font-size:14px;margin-bottom:6px; }
.risk-referral { background:#fee2e2;padding:8px;border-radius:8px;margin:8px 0;font-weight:600; }
.risk-notes,.risk-action { margin:8px 0; }
.risk-notes h4,.risk-action h4,.risk-steps h4 { font-size:13px;margin-bottom:4px;color:var(--muted); }
.risk-notes p { font-size:13px;line-height:1.5; }
.risk-steps ul { margin:4px 0;padding-left:20px;font-size:13px; }
.risk-steps li { margin-bottom:3px; }
.risk-badge { font-size:11px;padding:2px 8px;border-radius:4px;margin-top:4px;display:inline-block; }
.risk-badge.high,.risk-badge.critical { background:#fef2f2;color:#ef4444; }
.risk-badge.moderate { background:#fffbeb;color:#f59e0b; }
.risk-badge.low { background:#f0fdf4;color:#22c55e; }
.risk-notes-preview { font-size:11px;color:var(--muted);margin-top:4px; }
.risk-action-preview { font-size:11px;color:#3b82f6;margin-top:2px; }
.queue-item .badge { font-size:10px;padding:2px 6px; }

/* Issue Reports */
.issue-item,.outreach-item { padding:12px;background:var(--surface);border:1px solid var(--border);border-radius:12px;margin-bottom:6px; }
.issue-header,.outreach-header { display:flex;justify-content:space-between;align-items:center;margin-bottom:4px; }
.issue-type { font-size:13px;font-weight:600; }
.issue-severity-low { color:#22c55e; }
.issue-severity-medium { color:#f59e0b; }
.issue-severity-high { color:#ef4444; }
.outreach-name { font-size:13px;font-weight:600; }
.issue-location,.outreach-location,.issue-time,.outreach-time,.outreach-status { font-size:11px;color:var(--muted); }

/* Household Profile */
.hh-card { background:var(--surface);border:1px solid var(--border);border-radius:12px;padding:14px; }
.hh-card h3 { margin:0 0 8px;font-size:15px; }
.hh-row { display:flex;justify-content:space-between;align-items:center;padding:6px 0;border-bottom:1px solid rgba(71,85,105,0.3);font-size:13px; }
.hh-row:last-child { border-bottom:none; }
.hh-label { color:var(--muted); }
.hh-value { font-weight:500; }
.hh-tag { display:inline-block;padding:3px 8px;border-radius:6px;font-size:11px;font-weight:600;margin:2px; }
.hh-tag.flag { background:rgba(239,68,68,0.15);color:var(--danger); }
.hh-tag.risk { background:rgba(245,158,11,0.15);color:var(--warning); }
.hh-tag.health { background:rgba(59,130,246,0.15);color:#60a5fa; }
.hh-member { padding:10px;background:var(--bg);border:1px solid var(--border);border-radius:8px;margin-bottom:6px; }
.hh-member-name { font-weight:600;font-size:13px; }
.hh-member-detail { font-size:11px;color:var(--muted); }
.hh-icon-row { display:flex;gap:12px;flex-wrap:wrap;padding:8px 0; }
.hh-icon-item { display:flex;flex-direction:column;align-items:center;gap:4px;font-size:11px;color:var(--muted);min-width:60px; }
.hh-icon-item .icon { font-size:20px; }
.house-item { cursor:pointer;transition:border-color 0.2s; }
.house-item:hover { border-color:var(--primary); }
.house-item.has-coordinates {
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.house-item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.house-risk {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 2px 8px;
  background: rgba(59, 130, 246, 0.14);
  color: #60a5fa;
  font-size: 10px;
  font-weight: 700;
}
.house-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}
.house-location,
.house-coordinates {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}
.house-coordinates {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.household-assignment-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 12px;
}
.household-assignment-summary span {
  color: var(--muted);
}
.assigned-household-marker {
  background: transparent;
  border: 0;
}
.assigned-household-marker span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.35);
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
}
.assigned-household-marker.routine span { background: #2563eb; }
.assigned-household-marker.medium span { background: #f59e0b; }
.assigned-household-marker.high span { background: #dc2626; }
.assigned-household-popup {
  min-width: 180px;
  color: #0f172a;
  font-size: 12px;
  line-height: 1.45;
}
.assigned-household-popup strong {
  display: block;
  margin-bottom: 4px;
}
.assigned-household-popup button {
  margin-top: 8px;
  border: 0;
  border-radius: 8px;
  padding: 6px 10px;
  background: #2563eb;
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
}
.assigned-household-legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.assigned-household-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #2563eb;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.25);
}
[data-theme="light"] .house-risk {
  background: #dbeafe;
  color: #1d4ed8;
}
@media (max-width: 520px) {
  .house-meta-grid {
    grid-template-columns: 1fr;
  }
  .household-assignment-summary,
  .house-item-top {
    flex-direction: column;
    align-items: flex-start;
  }
}

[data-theme="light"] {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
}

.login-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
}
.login-modal {
  background: var(--surface); padding: 2rem; border-radius: 12px;
  max-width: 360px; width: 90%; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.login-modal h2 { margin-top: 0; margin-bottom: 1.5rem; }
.portal-boot-status { margin: -0.75rem 0 1rem; color: var(--muted); font-size: 13px; }
.login-modal label { display: block; margin-bottom: 1rem; }
.login-modal input { width: 100%; padding: 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); margin-top: 4px; }
.login-modal .btn-lg { width: 100%; }
.inbox-item { padding: 10px; border-bottom: 1px solid var(--border); cursor: pointer; }
.inbox-item:hover { background: var(--surface-2); }
.inbox-item.unread { border-left: 3px solid var(--primary); }
.inbox-item strong { font-size: 13px; }
.inbox-item p { margin: 4px 0; font-size: 12px; color: var(--muted); }
.inbox-time { font-size: 11px; color: var(--muted); }
.inbox-item .empty { text-align: center; padding: 24px; color: var(--muted); }

/* Cross-screen selected states and readable field surfaces */
button.selected,
.btn-primary.selected,
.btn-secondary.selected,
.option-button.selected,
.flow-step.active,
.bottom-nav a.active,
.bottom-more-btn.active,
.map-pin.active,
.house-item.active {
  border-color: var(--primary) !important;
  background: color-mix(in srgb, var(--primary) 18%, var(--surface)) !important;
  color: var(--text) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}

button.selected i,
.btn-primary.selected i,
.btn-secondary.selected i,
.option-button.selected i,
.flow-step.active i,
.bottom-nav a.active i,
.bottom-more-btn.active i {
  color: #bfdbfe;
}

[data-theme="light"] button.selected,
[data-theme="light"] .btn-primary.selected,
[data-theme="light"] .btn-secondary.selected,
[data-theme="light"] .option-button.selected,
[data-theme="light"] .flow-step.active,
[data-theme="light"] .bottom-nav a.active,
[data-theme="light"] .bottom-more-btn.active,
[data-theme="light"] .map-pin.active,
[data-theme="light"] .house-item.active {
  background: color-mix(in srgb, var(--primary) 12%, #ffffff) !important;
  color: #0f172a !important;
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea,
[data-theme="dark"] .task-card,
[data-theme="dark"] .house-item,
[data-theme="dark"] .map-container,
[data-theme="dark"] .household-assignment-summary {
  background: #10211d;
  border-color: #29463d;
  color: #f0fdf4;
}

/* Mobile overrides (shared responsive layer covers generic classes) */
@media (max-width: 768px) {
  .bottom-nav { grid-template-columns: repeat(4, 1fr) !important; }
  .flow-steps { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}
@media (max-width: 480px) {
  .bottom-nav { grid-template-columns: repeat(3, 1fr) !important; }
  .flow-steps { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}
