﻿/* 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;
  --info: #38bdf8;
  --nav-height: 70px;
}

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

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

/* â”€â”€ Navigation â”€â”€ */
.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;
  transition: all 0.2s;
  min-width: 0;
  min-height: 52px;
  border: 0;
  background: transparent;
  font-family: inherit;
}

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

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

.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;
}

/* â”€â”€ Top Bar â”€â”€ */
.top-bar {
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.top-bar h1 {
  margin: 0;
  font-size: 18px;
}

.top-bar p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

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

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

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

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

/* â”€â”€ Content â”€â”€ */
.workday-flow {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 14px;
}

.workday-flow button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 58px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.workday-flow span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
}

@media (max-width: 720px) {
  .app-content { padding: 12px; }
  .kpi-row { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .workday-flow {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .visit-card, .task-card { padding: 12px; }
}
@media (max-width: 360px) {
  .workday-flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .visit-card, .task-card { padding: 10px; font-size: 13px; }
  .kpi-row { gap: 8px; }
}

.app-content {
  padding: 16px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

/* â”€â”€ KPIs â”€â”€ */
.kpi-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

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

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

.kpi-lbl {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* â”€â”€ Map â”€â”€ */
.map-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 20px;
}

.map-placeholder {
  height: 150px;
  background: linear-gradient(135deg, #064e3b, #065f46);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

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

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

.map-info {
  color: white;
  font-weight: 600;
}

.route-info {
  padding: 12px;
  background: var(--surface-2);
  font-size: 14px;
}

#nurseDashboardMap {
  z-index: 1;
}

#dashRouteInfo {
  border-top: 1px solid var(--border);
  background: #0f172a;
}

#dashRouteInfo span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* â”€â”€ Quick Actions â”€â”€ */
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}

.action-btn {
  padding: 16px;
  border: none;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}

.action-btn:active {
  transform: scale(0.98);
  background: var(--surface-2);
}

/* â”€â”€ Lists â”€â”€ */
.activity-list, .queue-list, .stock-list, .referral-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.activity-list li, .queue-list li {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
}

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

/* â”€â”€ Forms â”€â”€ */
.large-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 24px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

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

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

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.btn-lg {
  padding: 16px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  margin-top: 10px;
}

.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);
}

.btn-sm {
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* â”€â”€ Screening â”€â”€ */
.screening-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0;
}

.screen-card {
  padding: 16px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.screen-card input {
  display: none;
}

.screen-card:has(input:checked) {
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.1);
}

.screen-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 4px;
  color: var(--text);
}

.screen-sub {
  font-size: 12px;
  color: var(--muted);
}

.summary-bars {
  margin-top: 16px;
}

.summary-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 13px;
}

.summary-row > span:first-child {
  width: 60px;
  font-weight: 600;
}

.bar {
  flex: 1;
  height: 24px;
  background: var(--surface-2);
  border-radius: 12px;
  overflow: hidden;
}

.fill {
  height: 100%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  color: white;
  font-size: 11px;
  font-weight: 600;
}

/* â”€â”€ Cold Chain â”€â”€ */
.cold-chain-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  margin-bottom: 24px;
}

.temp-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.temp-val {
  font-size: 48px;
  font-weight: 800;
  color: var(--text);
}

.temp-status {
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 14px;
}

.temp-status.ok {
  background: var(--success);
  color: white;
}

.temp-status.warn {
  background: var(--warning);
  color: black;
}

.temp-status.critical {
  background: var(--danger);
  color: white;
}

.temp-range {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 16px;
}

/* â”€â”€ Stock â”€â”€ */
.stock-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.stock-controls label {
  flex: 1;
}

.stock-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.stock-table th, .stock-table td {
  border: 1px solid var(--border);
  padding: 10px;
  text-align: left;
}

.stock-table th {
  background: var(--surface-2);
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
}

.stock-table tr:nth-child(even) {
  background: var(--surface);
}

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

.badge.ok { background: var(--success); color: white; }
.badge.low { background: var(--danger); color: white; }
.badge.warn { background: var(--warning); color: black; }

/* â”€â”€ CHW Sync â”€â”€ */
.hint {
  color: var(--muted);
  font-size: 13px;
  margin-top: -10px;
  margin-bottom: 20px;
}

.sync-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sync-info strong {
  display: block;
  font-size: 16px;
}

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

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

.ref-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 14px;
}

.ref-meta span {
  color: var(--muted);
}

.ref-item p {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 14px;
}

.ref-actions {
  display: flex;
  gap: 8px;
}

/* â”€â”€ Queue Colors â”€â”€ */
.queue-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 8px;
  border-left: 6px solid;
}

.queue-item.red {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--danger);
}

.queue-item.yellow {
  background: rgba(245, 158, 11, 0.15);
  border-color: var(--warning);
}

.queue-item.green {
  background: rgba(34, 197, 94, 0.15);
  border-color: var(--success);
}

/* â”€â”€ Location Toggle â”€â”€ */
.location-toggle-btn {
  background: transparent;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
  margin-left: 8px;
}
.location-toggle-btn:hover { background: #f0f0f0; }
.location-toggle-btn.active {
  background: #dcfce7;
  border-color: #22c55e;
  color: #22c55e;
}

/* â”€â”€ Households â”€â”€ */
.hh-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.2s;
}
.hh-card:active {
  transform: scale(0.98);
  border-color: var(--primary);
}
.hh-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 15px;
}
.hh-status {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #fff;
}
.hh-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}
.hh-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.vuln-badge {
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
}
.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.hh-profile-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}
.hh-profile-section h4 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--muted);
}
.hh-profile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.vuln-score-badge {
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}
.hh-profile-info p {
  margin: 4px 0;
  font-size: 13px;
  color: var(--text);
}
.dwelling-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 13px;
}
.risk-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.risk-tag {
  background: var(--surface-2);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}
.member-card {
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
}
.member-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}
.member-details {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}
.visit-info p {
  margin: 4px 0;
  font-size: 13px;
  color: var(--text);
}

[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; }
.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); }

button.selected,
.btn-primary.selected,
.btn-secondary.selected,
.option-button.selected,
.nav-tab.active,
.flow-step.active,
.card.selected {
  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);
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea,
[data-theme="dark"] .card,
[data-theme="dark"] .visit-card,
[data-theme="dark"] .task-card {
  background: #10211d;
  border-color: #29463d;
  color: #f0fdf4;
}
