:root {
  --navy-900: #0f2540;
  --navy-800: #15335a;
  --navy-700: #1c3d63;
  --blue-600: #2f6690;
  --blue-500: #3b7ba8;
  --blue-100: #eaf1f7;
  --slate-50: #f5f7fa;
  --slate-100: #eef1f5;
  --slate-200: #e2e6ea;
  --slate-400: #9aa5b1;
  --slate-600: #5a6472;
  --ink-900: #16202b;
  --green-600: #2e7d32;
  --green-100: #e6f4ea;
  --amber-700: #9c6500;
  --amber-100: #fdf2df;
  --red-700: #b3261e;
  --red-100: #fbe9e8;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(15, 37, 64, 0.06), 0 1px 6px rgba(15, 37, 64, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--ink-900);
  background: var(--slate-50);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- App shell ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy-900), var(--navy-800));
  color: #dce6f1;
  display: flex;
  flex-direction: column;
  padding: 20px 0;
}

.sidebar-brand {
  padding: 0 20px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 12px;
}

.sidebar-brand .name {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.2px;
}

.sidebar-brand .subtitle {
  font-size: 11px;
  color: #9db3c9;
  margin-top: 2px;
}

.nav-section {
  padding: 6px 12px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  color: #c6d5e5;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
}

.nav-link:hover {
  background: rgba(255,255,255,0.06);
  color: #ffffff;
  text-decoration: none;
}

.nav-link.active {
  background: var(--blue-600);
  color: #ffffff;
}

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.9;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 20px 0 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12px;
  color: #93a7bd;
}

.sidebar-footer a { color: #cfe0f0; }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: #ffffff;
  border-bottom: 1px solid var(--slate-200);
}

.topbar h1 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  color: var(--navy-900);
}

.topbar .meta {
  font-size: 12.5px;
  color: var(--slate-600);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--slate-600);
}

.content {
  padding: 24px 28px 40px 28px;
}

/* ---------- Disclaimer banner ---------- */

.disclaimer {
  background: var(--amber-100);
  border: 1px solid #f0d9a6;
  color: var(--amber-700);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 12.5px;
  margin-bottom: 20px;
}

/* ---------- KPI cards ---------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.kpi-card {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.kpi-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--slate-600);
  font-weight: 600;
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--navy-900);
}

.kpi-sub {
  font-size: 12px;
  color: var(--slate-600);
  margin-top: 4px;
}

/* ---------- Cards / panels ---------- */

.panel {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 22px;
}

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-header h2 {
  font-size: 15px;
  margin: 0;
  font-weight: 700;
  color: var(--navy-900);
}

.panel-header .hint {
  font-size: 12px;
  color: var(--slate-600);
}

.panel-header .header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.info-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--slate-200);
  background: #fff;
  color: var(--slate-600);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.info-icon-btn:hover,
.info-icon-btn:focus-visible {
  color: var(--blue-600, #2f6690);
  border-color: var(--blue-600, #2f6690);
  background: #eef4f9;
  outline: none;
}

.info-icon-btn svg {
  width: 14px;
  height: 14px;
}

.panel-body {
  padding: 18px 20px;
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: #fff;
  border-radius: 10px;
  max-width: 560px;
  width: 100%;
  max-height: 82vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.3);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--slate-200);
  position: sticky;
  top: 0;
  background: #fff;
  border-radius: 10px 10px 0 0;
}

.modal-header h3 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--navy-900);
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--slate-600);
  cursor: pointer;
  padding: 0 2px;
}

.modal-close:hover {
  color: var(--navy-900);
}

.modal-body {
  padding: 18px 20px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--slate-700, #33404f);
}

.modal-body p {
  margin: 0 0 10px;
}

.modal-body p:last-child {
  margin-bottom: 0;
}

.modal-body ul {
  margin: 4px 0 12px 20px;
  padding: 0;
}

.modal-body li {
  margin-bottom: 4px;
}

.modal-body code {
  background: var(--slate-100, #f1f4f8);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12.5px;
}

.chart-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 20px;
}

@media (max-width: 980px) {
  .chart-grid { grid-template-columns: 1fr; }
}

canvas { max-width: 100%; }

/* ---------- Tables ---------- */

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

.data-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--slate-600);
  font-weight: 700;
  padding: 9px 12px;
  border-bottom: 2px solid var(--slate-200);
  background: var(--slate-50);
  white-space: nowrap;
}

.data-table th a {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.data-table th a:hover { color: var(--blue-600); }

.data-table th .sort-arrow { color: var(--blue-600); font-size: 9px; }

.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--slate-100);
  color: var(--ink-900);
}

.data-table tbody tr:hover { background: var(--blue-100); }

.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }

.text-muted { color: var(--slate-600); }

/* ---------- Badges ---------- */

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.badge-green { background: var(--green-100); color: var(--green-600); }
.badge-amber { background: var(--amber-100); color: var(--amber-700); }
.badge-red { background: var(--red-100); color: var(--red-700); }
.badge-slate { background: var(--slate-100); color: var(--slate-600); }

/* ---------- Per-table search bar (payer summary / AR by payer / denial
   detail / executive payer detail - see _table_macros.html) ---------- */

.table-search-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.table-search-bar input[type="text"] {
  padding: 6px 10px;
  border: 1px solid var(--slate-200);
  border-radius: 6px;
  font-size: 12.5px;
  font-family: var(--font);
  background: #ffffff;
  color: var(--ink-900);
}

/* ---------- Forms / filters ---------- */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
  align-items: center;
}

.filter-bar input[type="text"],
.filter-bar input[type="date"],
.filter-bar input[type="number"],
.filter-bar select {
  padding: 8px 10px;
  border: 1px solid var(--slate-200);
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font);
  background: #ffffff;
  color: var(--ink-900);
}

.filter-bar .date-range-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-bar .date-range-group label {
  font-size: 12.5px;
  color: var(--slate-600);
  white-space: nowrap;
}

.active-range-note {
  font-size: 12.5px;
  color: var(--slate-600);
  margin-bottom: 14px;
}

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
}

.btn-primary { background: var(--blue-600); color: #ffffff; }
.btn-primary:hover { background: var(--navy-700); text-decoration: none; }
.btn-secondary { background: #ffffff; border-color: var(--slate-200); color: var(--ink-900); }
.btn-secondary:hover { background: var(--slate-50); text-decoration: none; }

/* ---------- Pagination ---------- */

.pagination {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--slate-600);
}

.pagination a, .pagination span {
  padding: 6px 11px;
  border-radius: 5px;
  border: 1px solid var(--slate-200);
  color: var(--ink-900);
}

.pagination a:hover { background: var(--slate-50); text-decoration: none; }
.pagination .disabled { color: var(--slate-400); }

/* ---------- Login ---------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, var(--navy-800), var(--navy-900));
}

.login-card {
  width: 360px;
  background: #ffffff;
  border-radius: 10px;
  padding: 32px 30px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.35);
}

.login-card h1 {
  font-size: 17px;
  margin: 0 0 4px 0;
  color: var(--navy-900);
}

.login-card .subtitle {
  font-size: 12.5px;
  color: var(--slate-600);
  margin-bottom: 22px;
}

.login-card label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--slate-600);
  margin-bottom: 5px;
  margin-top: 14px;
}

.login-card input {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--slate-200);
  border-radius: 6px;
  font-size: 14px;
  font-family: var(--font);
}

.login-card .btn { width: 100%; margin-top: 20px; padding: 10px; }

.login-error {
  background: var(--red-100);
  color: var(--red-700);
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  margin-top: 16px;
}

/* ---------- Waterfall ---------- */

.waterfall-bar-row {
  display: grid;
  grid-template-columns: 320px 1fr 130px;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--slate-100);
}

.waterfall-bar-track {
  background: var(--slate-100);
  border-radius: 4px;
  height: 22px;
  overflow: hidden;
}

.waterfall-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue-600), var(--blue-500));
  border-radius: 4px;
}

.waterfall-bar-fill.zero { background: var(--slate-200); }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--slate-600);
}

.breadcrumb {
  font-size: 12.5px;
  color: var(--slate-600);
  margin-bottom: 14px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.detail-field .label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--slate-600);
  font-weight: 600;
  letter-spacing: 0.3px;
}

.detail-field .value {
  font-size: 14px;
  color: var(--ink-900);
  margin-top: 2px;
}

/* ---------- Revenue-opportunity gauges ---------- */

.gauge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.gauge-card {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px 10px 16px;
  text-align: center;
}

.gauge-card .gauge-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--navy-900);
  margin-bottom: 4px;
}

.gauge-card canvas {
  max-height: 130px;
}

.gauge-card .gauge-readout {
  margin-top: -6px;
}

.gauge-card .gauge-actual {
  font-size: 21px;
  font-weight: 700;
  color: var(--navy-900);
}

.gauge-card .gauge-target {
  font-size: 11.5px;
  color: var(--slate-600);
}

.gauge-card .gauge-status {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
}

.gauge-status.met { background: var(--green-100); color: var(--green-600); }
.gauge-status.gap { background: var(--amber-100); color: var(--amber-700); }

.targets-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.targets-form label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--slate-600);
  margin-bottom: 5px;
}

.targets-form input[type="number"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--slate-200);
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font);
}

.targets-note {
  font-size: 12px;
  color: var(--slate-600);
  margin-bottom: 14px;
}

/* ---------- Widget-wise async loading ---------- */
/* Every chart, KPI card, gauge, and table on every page is fetched
   independently (see static/js/widgets.js + static/js/datagrid.js), so one
   slow query never blocks the rest of the page and no grid interaction
   (sort/search/page) triggers a full navigation. Each async unit renders
   .widget-loading immediately in markup and swaps to .widget-content once
   its own fetch resolves - see WIDGET_LOADING_HTML in _widget_macros.html. */

.widget-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 110px;
  color: var(--slate-400);
  font-size: 12.5px;
}

.widget-loading.compact { min-height: 54px; }

.widget-spinner {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border: 3px solid var(--slate-200);
  border-top-color: var(--blue-600);
  border-radius: 50%;
  animation: widget-spin 0.75s linear infinite;
}

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

.widget-content { display: none; }

.widget-error {
  color: var(--red-700);
  background: var(--red-100);
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 12.5px;
}

.widget-error a { color: var(--red-700); font-weight: 600; text-decoration: underline; }

/* KPI cards render their skeleton in place of the value/sub lines only, so
   the card grid doesn't jump around as each card's own fetch resolves. */
.kpi-card .kpi-value.skeleton,
.kpi-card .kpi-sub.skeleton {
  display: inline-block;
  background: var(--slate-100);
  color: transparent;
  border-radius: 4px;
  animation: widget-skeleton-pulse 1.1s ease-in-out infinite;
}

.kpi-card .kpi-value.skeleton { width: 90px; height: 24px; }
.kpi-card .kpi-sub.skeleton { width: 130px; height: 12px; margin-top: 6px; }

@keyframes widget-skeleton-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
