:root {
  --accent: #00d4ff;
  --navy: #0f172a;
  --sidebar-width: 390px;
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --green: #16a34a;
  --blue: #2563eb;
  --orange: #f97316;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text-primary);
  background: var(--bg);
}

/* ---- Header ---- */
header {
  background: var(--navy);
  color: white;
  padding: 0 20px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-bottom: 2px solid var(--accent);
}

.header-inner { display: flex; flex-direction: column; gap: 1px; }

.header-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.api-status {
  font-size: 11px;
  color: #64748b;
}

.api-status.live { color: var(--accent); }

.header-brand {
  font-size: 10px;
  color: #475569;
  text-decoration: none;
  letter-spacing: 0.03em;
}

.header-brand:hover { color: var(--accent); }

/* ---- Layout ---- */
.layout {
  display: flex;
  height: calc(100vh - 54px);
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: white;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
}

.sidebar-count {
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 8px;
  min-width: 22px;
  text-align: center;
}

.mode-toggle {
  display: flex;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.toggle-btn {
  flex: 1;
  padding: 7px 0;
  border: 1.5px solid var(--border);
  background: white;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  letter-spacing: 0.02em;
}

.toggle-btn:first-child { border-radius: 5px 0 0 5px; }
.toggle-btn:last-child  { border-radius: 0 5px 5px 0; border-left: none; }

.toggle-btn:hover:not(.active) { background: #f8fafc; color: var(--text-primary); }

.toggle-btn.active {
  background: var(--navy);
  color: white;
  border-color: var(--navy);
}

.sidebar-hint {
  padding: 6px 16px 8px;
  font-size: 11px;
  color: #94a3b8;
  font-style: italic;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.client-list {
  overflow-y: auto;
  flex: 1;
  padding: 10px 10px 4px;
}

.client-list::-webkit-scrollbar { width: 4px; }
.client-list::-webkit-scrollbar-track { background: transparent; }
.client-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ---- Legend ---- */
.legend {
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  gap: 14px;
  flex-shrink: 0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--text-secondary);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 0 0 1px #ccc;
  display: inline-block;
}

.client-dot { background: #3b82f6; }
.rbt-dot { background: #16a34a; }
.selected-dot { background: #3b82f6; border: 3px solid white; box-shadow: 0 0 0 1.5px #3b82f6; width: 8px; height: 8px; }
.matched-dot { background: #16a34a; border: 3px solid white; box-shadow: 0 0 0 1.5px #16a34a; width: 8px; height: 8px; }

/* ---- Client card ---- */
.client-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: white;
  overflow: hidden;
}

.client-card:hover:not(.selected) {
  border-color: #bae6fd;
  box-shadow: 0 1px 6px rgba(0,212,255,0.1);
}

.client-card.selected {
  border-color: var(--accent);
  border-left-width: 3px;
  box-shadow: 0 2px 12px rgba(0,212,255,0.18);
}

.client-card-header {
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.client-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.client-meta {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
}

.badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.02em;
  text-transform: capitalize;
}

.badge.state-tag { background: #e2e8f0; color: #475569; }
.badge.english { background: #dbeafe; color: #1d4ed8; }
.badge.spanish { background: #fce7f3; color: #be185d; }
.badge.medicaid { background: #ede9fe; color: #6d28d9; }
.badge.certified { background: #dcfce7; color: #15803d; }
.badge.trainee { background: #fee2e2; color: #b91c1c; }

.hours-badge {
  font-size: 10px;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 3px;
}

.client-days {
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

/* ---- Match results panel ---- */
.match-results {
  border-top: 1px solid var(--border);
  background: #f8fafc;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease, padding 0.2s ease;
}

.match-results.open {
  max-height: 900px;
  padding: 10px;
}

.match-loading {
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 14px 0;
}

.match-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 7px;
}

.match-item {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 9px 10px;
  border-radius: 6px;
  background: white;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  transition: border-color 0.15s;
}

.match-item:last-child { margin-bottom: 0; }
.match-item:hover { border-color: var(--accent); }
.match-item.ineligible { opacity: 0.7; border-color: #fecaca; background: #fff8f8; }

.rank-badge {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.rank-badge.rank-2 { background: #64748b; }
.rank-badge.rank-3 { background: #94a3b8; }
.rank-badge.rank-other { background: #cbd5e1; }

.match-info { flex: 1; min-width: 0; }

.match-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 5px;
}

.match-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.stat {
  font-size: 10px;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.stat.lang-yes  { color: #15803d; background: #dcfce7; }
.stat.lang-no   { color: #b91c1c; background: #fee2e2; }
.stat.cert-ok   { color: #15803d; background: #dcfce7; }
.stat.cert-fail { color: #b91c1c; background: #fee2e2; font-weight: 600; }

.match-score {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  margin-top: 5px;
}

.score-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}

.score-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* ---- State filter ---- */
.state-filter {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.state-filter-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  text-transform: uppercase;
  white-space: nowrap;
}

.state-select {
  flex: 1;
  padding: 5px 8px;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  background: white;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}

.state-select:focus { border-color: var(--accent); }

/* ---- Show more button ---- */
.show-more-btn {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 7px 0;
  background: none;
  border: 1.5px dashed var(--border);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  text-align: center;
}

.show-more-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.show-more-count { font-weight: 400; }

/* ---- Map ---- */
.map-container { flex: 1; position: relative; }
#map { width: 100%; height: 100%; }

/* ---- Mobile ---- */
@media (max-width: 700px) {
  header {
    padding: 0 12px;
    height: 46px;
  }

  .header-brand { display: none; }
  .api-status { display: none; }

  .layout {
    flex-direction: column;
    height: calc(100vh - 46px);
  }

  .sidebar {
    width: 100%;
    height: 58vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  .map-container {
    flex: 1;
    min-height: 0;
  }

  .legend {
    padding: 7px 12px;
    gap: 10px;
    flex-wrap: wrap;
  }

  .client-card-header { padding: 10px 11px; }

  .match-results.open { max-height: 600px; }

  .sidebar-header { padding: 10px 12px 8px; }

  .show-more-count { display: none; }
}
