/* RegLens — SNF Survey Intelligence */
:root {
  --navy: #0A1628;
  --navy-light: #162340;
  --navy-mid: #1e3357;
  --teal: #2FAE7E;
  --teal-dark: #239966;
  --teal-light: #e6f7f1;
  --cream: #F7F4EC;
  --cream-dark: #ede9df;
  --red: #DC3545;
  --red-light: #fdf0f1;
  --amber: #FFC107;
  --amber-light: #fff8e1;
  --orange: #fd7e14;
  --orange-light: #fff3e8;
  --gray: #6c757d;
  --gray-light: #f8f9fa;
  --gray-border: #dee2e6;
  --white: #ffffff;
  --text: #212529;
  --text-muted: #6c757d;
  --shadow: 0 1px 4px rgba(10,22,40,0.10);
  --shadow-md: 0 2px 12px rgba(10,22,40,0.14);
  --radius: 8px;
  --radius-sm: 4px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  --transition: 150ms ease;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Layout ── */
#app { display: flex; flex-direction: column; min-height: 100vh; }

.shell { display: flex; flex: 1; min-height: 0; }

.main-content { flex: 1; overflow-y: auto; padding: 24px; max-width: 1200px; margin: 0 auto; width: 100%; }

/* ── Nav ── */
.nav {
  background: var(--navy);
  color: var(--white);
  display: flex;
  align-items: center;
  padding: 0 24px;
  height: 56px;
  box-shadow: var(--shadow-md);
  flex-shrink: 0;
  gap: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--white);
  text-decoration: none;
  letter-spacing: -0.3px;
  flex-shrink: 0;
}

.nav-brand .logo-dot { color: var(--teal); font-size: 1.4rem; line-height: 1; }
.nav-brand .logo-sub { font-size: 0.7rem; font-weight: 400; opacity: 0.7; letter-spacing: 0.5px; text-transform: uppercase; margin-left: 2px; }

.nav-links { display: flex; align-items: center; gap: 2px; margin-left: 32px; flex: 1; }

.nav-link {
  color: rgba(255,255,255,0.72);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.nav-link:hover { background: rgba(255,255,255,0.1); color: var(--white); }
.nav-link.active { background: rgba(47,174,126,0.22); color: var(--teal); }

.nav-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.nav-version { font-size: 0.7rem; opacity: 0.45; font-family: var(--font-mono); }

/* ── Page header ── */
.page-header { margin-bottom: 24px; }
.page-title { font-size: 1.5rem; font-weight: 700; color: var(--navy); letter-spacing: -0.4px; }
.page-subtitle { color: var(--text-muted); font-size: 0.875rem; margin-top: 4px; }

/* ── Cards / Panels ── */
.panel {
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
}

.panel-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── Stat cards ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }

.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-card .stat-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.7px; color: var(--text-muted); margin-bottom: 6px; }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; line-height: 1; color: var(--navy); }
.stat-card .stat-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.stat-card.danger .stat-value { color: var(--red); }
.stat-card.warn .stat-value { color: var(--orange); }
.stat-card.ok .stat-value { color: var(--teal-dark); }

/* ── Grid layouts ── */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }

/* ── Chips / Badges ── */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

/* Severity badge — A-C=gray, D-F=amber, G-I=orange, J-L=red */
.sev { font-family: var(--font-mono); font-size: 0.78rem; font-weight: 700; min-width: 24px; text-align: center; }
.sev-ac { background: #e9ecef; color: #495057; }
.sev-df { background: var(--amber-light); color: #856404; border: 1px solid #ffc107; }
.sev-gi { background: var(--orange-light); color: #7c3a00; border: 1px solid #fd7e14; }
.sev-jl { background: var(--red-light); color: #842029; border: 1px solid #dc3545; }

.chip-high { background: #fdecea; color: #c0392b; }
.chip-med { background: #fff3cd; color: #856404; }
.chip-low { background: #e2f3ea; color: #1a6b3c; }

.chip-open { background: var(--red-light); color: var(--red); }
.chip-progress { background: var(--amber-light); color: #856404; }
.chip-corrected { background: var(--teal-light); color: var(--teal-dark); }

.chip-p0 { background: #fdecea; color: var(--red); }
.chip-p1 { background: #fff8e1; color: #856404; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn-primary { background: var(--teal); color: var(--white); border-color: var(--teal); }
.btn-primary:hover { background: var(--teal-dark); border-color: var(--teal-dark); }
.btn-outline { background: var(--white); color: var(--navy); border-color: var(--gray-border); }
.btn-outline:hover { background: var(--gray-light); }
.btn-danger { background: var(--red); color: var(--white); border-color: var(--red); }
.btn-danger:hover { background: #b02a37; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-icon { padding: 6px 8px; }

/* ── Form controls ── */
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.form-group { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 140px; }
.form-group.fixed { flex: 0 0 auto; }

label { font-size: 0.8rem; font-weight: 600; color: var(--navy); }

input[type="text"], input[type="date"], input[type="number"], select, textarea {
  padding: 8px 12px;
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--white);
  transition: border-color var(--transition);
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(47,174,126,0.12); }
textarea { resize: vertical; min-height: 72px; }

.search-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.search-input { flex: 1; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--gray-border); }

table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead { background: var(--navy); color: var(--white); }
thead th { padding: 10px 14px; text-align: left; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--gray-border); transition: background var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--gray-light); }
tbody td { padding: 10px 14px; vertical-align: top; }
.td-tag { font-family: var(--font-mono); font-weight: 700; font-size: 0.85rem; color: var(--navy); }
.td-reg { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-muted); }
.td-title { font-weight: 500; }
.td-muted { color: var(--text-muted); font-size: 0.8rem; }

/* ── F-tag expand ── */
.ftag-row { cursor: pointer; }
.ftag-row-active td { background: var(--teal-light); }
.ftag-detail-expand td { padding: 0 !important; border-bottom: 2px solid var(--teal) !important; background: var(--teal-light); }
.ftag-detail-panel { padding: 14px 20px 16px; display: flex; flex-direction: column; gap: 12px; }
.ftag-detail-header { display: flex; align-items: center; gap: 12px; font-size: 0.95rem; font-weight: 600; color: var(--navy); }
.ftag-detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px 24px; }
.ftag-detail-grid div { display: flex; flex-direction: column; gap: 3px; }
.ftag-detail-grid strong { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }
.ftag-detail-grid span { font-size: 0.875rem; }
.ftag-detail-actions { display: flex; gap: 10px; flex-wrap: wrap; padding-top: 2px; }

/* ── Deficiency cards ── */
.deficiency-list { display: flex; flex-direction: column; gap: 12px; }

.deficiency-card {
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-left: 4px solid var(--gray-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.deficiency-card.sev-g-i { border-left-color: var(--orange); }
.deficiency-card.sev-j-l { border-left-color: var(--red); }
.deficiency-card.sev-d-f { border-left-color: var(--amber); }
.deficiency-card.sev-a-c { border-left-color: var(--gray); }
.deficiency-card.corrected { opacity: 0.65; }

.deficiency-header { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.deficiency-tag { font-family: var(--font-mono); font-weight: 700; font-size: 0.9rem; color: var(--navy); }
.deficiency-title { font-weight: 600; font-size: 0.95rem; flex: 1; }
.deficiency-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.deficiency-notes { font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; }
.deficiency-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* ── Prep checklist ── */
.prep-section { margin-bottom: 24px; }
.prep-section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--gray-border); }
.prep-section-title { font-size: 1rem; font-weight: 700; color: var(--navy); }

.prep-progress { display: flex; align-items: center; gap: 10px; }
.progress-bar-wrap { width: 120px; height: 6px; background: var(--cream-dark); border-radius: 3px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--teal); border-radius: 3px; transition: width 0.3s ease; }
.progress-pct { font-size: 0.78rem; font-weight: 600; color: var(--teal-dark); min-width: 30px; }

.prep-items { display: flex; flex-direction: column; gap: 8px; }

.prep-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}
.prep-item:hover { background: var(--gray-light); }
.prep-item.checked { background: var(--teal-light); border-color: var(--teal); }
.prep-item.checked .prep-task { text-decoration: line-through; color: var(--text-muted); }

.prep-checkbox { width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--teal); cursor: pointer; margin-top: 1px; }
.prep-task { font-size: 0.875rem; line-height: 1.5; flex: 1; }
.prep-priority { flex-shrink: 0; }

/* ── Resources ── */
.resource-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }

.resource-card {
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.resource-card a { color: var(--teal-dark); text-decoration: none; font-weight: 500; font-size: 0.9rem; }
.resource-card a:hover { text-decoration: underline; }
.resource-desc { font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; }
.resource-tag { align-self: flex-start; }

/* ── Facilities / NPI ── */
.npi-result {
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-left: 4px solid var(--teal);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-top: 16px;
  box-shadow: var(--shadow);
}
.npi-result-name { font-size: 1.05rem; font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.npi-result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-top: 10px; }
.npi-field label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); display: block; margin-bottom: 2px; }
.npi-field span { font-size: 0.875rem; color: var(--text); }

/* ── Donut / progress visual ── */
.donut-wrap { display: flex; align-items: center; gap: 20px; }
.donut { position: relative; width: 90px; height: 90px; flex-shrink: 0; }
.donut svg { transform: rotate(-90deg); }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-pct { font-size: 1.2rem; font-weight: 800; color: var(--navy); line-height: 1; }
.donut-label { font-size: 0.6rem; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.4px; }
.donut-legend { font-size: 0.85rem; color: var(--text-muted); }
.donut-legend strong { display: block; font-size: 1rem; font-weight: 700; color: var(--navy); }

/* ── Risk tags ── */
.risk-tag-list { display: flex; flex-direction: column; gap: 8px; }
.risk-tag-item { display: flex; align-items: center; gap: 10px; }
.risk-tag-bar-wrap { flex: 1; height: 6px; background: var(--cream-dark); border-radius: 3px; overflow: hidden; }
.risk-tag-bar { height: 100%; background: var(--teal); border-radius: 3px; }
.risk-tag-count { font-size: 0.78rem; font-weight: 700; color: var(--text-muted); min-width: 20px; text-align: right; }

/* ── Alert banner ── */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 0.875rem; margin-bottom: 16px; }
.alert-info { background: #e8f4fd; color: #0c5460; border: 1px solid #bee5eb; }
.alert-warn { background: var(--amber-light); color: #856404; border: 1px solid #ffc107; }
.alert-error { background: var(--red-light); color: #842029; border: 1px solid #dc3545; }
.alert-success { background: var(--teal-light); color: #155724; border: 1px solid #c3e6cb; }

/* ── Empty state ── */
.empty { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-title { font-weight: 600; color: var(--navy); margin-bottom: 6px; }

/* ── Section divider ── */
.section-gap { margin-bottom: 24px; }

/* ── Severity matrix ── */
.sev-matrix { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.sev-cell { text-align: center; padding: 8px; border-radius: var(--radius-sm); font-size: 0.8rem; }
.sev-cell strong { display: block; font-size: 1.1rem; font-family: var(--font-mono); }

/* ── Loading ── */
.loading { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 0.875rem; padding: 16px 0; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--gray-border); border-top-color: var(--teal); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Footer ── */
.footer {
  background: var(--navy);
  color: rgba(255,255,255,0.45);
  font-size: 0.75rem;
  padding: 12px 24px;
  text-align: center;
  margin-top: auto;
}
.footer a { color: rgba(255,255,255,0.6); text-decoration: none; }
.footer a:hover { color: var(--teal); }

.legal-footer{display:flex;gap:16px;align-items:center;justify-content:center;padding:14px 20px;font-size:11px;color:#94a3b8;border-top:1px solid #e8ede9;background:#f8f9f7;flex-wrap:wrap;}
.legal-footer a{color:#4a7c59;text-decoration:none;}
.legal-footer a:hover{text-decoration:underline;}

/* ── Responsive ── */
@media (max-width: 768px) {
  .main-content { padding: 16px; }
  .nav-links { gap: 0; }
  .nav-link { padding: 6px 8px; font-size: 0.8rem; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { flex-direction: column; }
  .form-group { min-width: 0; }
}

@media (max-width: 480px) {
  .nav-links { display: none; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .page-title { font-size: 1.2rem; }
}
