:root {
  --bg: #f1f5f9;
  --surface: #e2e8f0;
  --panel: #ffffff;
  --panel-hover: #f8fafc;
  --ink: #0f172a;
  --muted: #475569;
  --line: #cbd5e1;
  --line-subtle: #eef2f6;
  --blue: #0d9488;
  --teal: #14b8a6;
  --gold: #d97706;
  --green: #16a34a;
  --purple: #4a3aa7;
  --rose: #e34948;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 8px 40px rgba(15, 23, 42, 0.16);
  --shadow-xl: 0 2px 4px rgba(15, 23, 42, 0.03), 0 8px 16px rgba(15, 23, 42, 0.06), 0 24px 48px rgba(15, 23, 42, 0.10);
  --ring: 0 0 0 3px rgba(13, 148, 136, 0.12);
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 100% 0%, rgba(20, 184, 166, 0.06), transparent 38%),
    radial-gradient(circle at 0% 12%, rgba(13, 148, 136, 0.05), transparent 34%),
    var(--bg);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.3s ease, color 0.3s ease;
}

h1, h2, h3, h4, p { margin: 0; }
h2 { color: var(--ink); font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
h3 { color: var(--muted); font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
p { color: var(--muted); }
.hidden { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: var(--ink);
  background: rgba(248, 250, 252, 0.82);
  border-bottom: 1px solid rgba(203, 213, 225, 0.6);
  box-shadow: none;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  transition: var(--transition-smooth);
}

.topbar:hover {
  background: rgba(248, 250, 252, 0.92);
  border-bottom-color: rgba(203, 213, 225, 0.8);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  transition: var(--transition-fast);
}
.navbar-brand:hover { opacity: 0.85; }
.brand-mark img { display: block; width: auto; height: 36px; transition: var(--transition-fast); }
.navbar-brand:hover .brand-mark img { transform: scale(1.05); }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { color: #1e3a5f; font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; }
.brand-tagline { color: #0d9488; font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; }

.topbar-controls { display: flex; align-items: center; gap: 16px; min-width: 0; }
.back-link { color: var(--muted); font-size: 0.8125rem; font-weight: 600; text-decoration: none; white-space: nowrap; transition: color 0.15s; }
.back-link:hover { color: var(--ink); }
.theme-toggle {
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
  box-shadow: none;
  font-size: 16px;
  cursor: pointer;
  transition: var(--transition-fast);
}
.theme-toggle::after { display: none; }
.theme-toggle:hover { color: var(--teal); background: var(--surface); border-color: var(--teal); box-shadow: none; transform: rotate(15deg); }
.status { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.pill, #usageDisplay {
  margin: 0;
  padding: 6px 12px;
  color: #1e293b;
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  border: 1px solid rgba(203, 213, 225, 0.6);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: var(--transition-fast);
}
.pill:hover, #usageDisplay:hover { border-color: rgba(203, 213, 225, 0.9); box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08); transform: translateY(-1px); }
#account { color: #0f766e; background: linear-gradient(135deg, rgba(13, 148, 136, 0.1), rgba(20, 184, 166, 0.08)); border-color: rgba(13, 148, 136, 0.3); }
#logout { min-height: 32px; padding: 6px 12px; }

.app-intro {
  padding: 10px 24px;
  color: var(--muted);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.page {
  width: auto;
  max-width: 1740px;
  margin: 0 auto;
  padding: 24px;
  display: block;
}

.workflow-note {
  margin-bottom: 16px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.workflow-note p { margin-top: 3px; font-size: 13px; }
.workflow-facts { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.workflow-facts span { padding: 5px 9px; color: #334155; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; font-size: 12px; font-weight: 700; white-space: nowrap; }

.upload-panel {
  margin: 0 0 16px;
  padding: 0;
  overflow: visible;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.upload-grid {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.upload-grid > *, .workflow-note > *, .topbar > * { min-width: 0; }
.upload-grid > .upload-box {
  position: relative;
  min-height: 90px;
  padding: 20px;
  overflow: hidden;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: var(--radius);
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
  transition: var(--transition-smooth);
}
.upload-grid > .upload-box::before {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 0;
  width: 5px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, #0d9488, #14b8a6);
  transition: var(--transition-fast);
}
.upload-grid > .upload-box:hover { border-color: #0d9488; box-shadow: var(--shadow-xl); transform: translateY(-2px); }
.upload-grid > .upload-box:hover::before { width: 6px; }
.upload-box label { display: block; margin: 0 0 8px; color: var(--ink); font-size: 13px; font-weight: 600; letter-spacing: 0; text-transform: none; }
.upload-box input[type="file"] {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition-fast);
}
.upload-box input[type="file"]:hover { background: rgba(13, 148, 136, 0.03); border-color: var(--teal); }
.help { margin-top: 6px; color: #334155; font-size: 14px; font-weight: 500; line-height: 1.5; }
.run-row { margin-top: 12px; display: flex; align-items: center; gap: 12px; }
.run-row .notice { margin: 0; flex: 1 1 auto; }

button, .button {
  min-height: 36px;
  padding: 8px 14px;
  position: relative;
  overflow: hidden;
  color: #ffffff;
  background: var(--blue);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  box-shadow: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}
button::after, .button::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.15) 50%, transparent 60%);
  transition: opacity 0.3s;
  pointer-events: none;
}
button:hover, .button:hover { background: #0f766e; box-shadow: 0 4px 14px rgba(13, 148, 136, 0.35); transform: translateY(-1px); }
button:hover::after, .button:hover::after { opacity: 1; }
button:active, .button:active { box-shadow: 0 1px 4px rgba(13, 148, 136, 0.2); transform: translateY(1px) scale(0.98); }
button.secondary, .button.secondary { color: var(--blue); background: transparent; border: 1.5px solid var(--line); box-shadow: none; }
button.secondary:hover, .button.secondary:hover { color: var(--blue); background: rgba(13, 148, 136, 0.08); border-color: var(--blue); box-shadow: 0 2px 8px rgba(13, 148, 136, 0.15); }
button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.notice, .wholesaler-empty {
  margin-top: 12px;
  padding: 10px 12px;
  color: #5a4200;
  background: #fff7df;
  border: 1px solid #f1d08c;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}
.notice.warn { color: #8a1c1c; background: #fff1f0; border-color: #f0b4ae; }
.upload-large { color: #b42318; font-weight: 700; }
.run-progress { margin-top: 12px; padding: 14px; border-color: rgba(13, 148, 136, 0.35); border-radius: var(--radius); background: #f0fdfa; }
.run-progress-summary, .run-progress-detail { color: var(--muted); font-size: 13px; }

#results.panel {
  margin: 0;
  padding: 0;
  overflow: visible;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
#results > .section-head {
  margin-bottom: 12px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }

.global-filter-panel {
  margin: 0 0 16px;
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  background: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}
.global-filter-panel .filter-grid { grid-template-columns: repeat(6, minmax(120px, 1fr)); }
.global-filter-actions { display: flex; align-items: flex-end; padding-bottom: 1px; }
.filter-grid { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.filter-field { margin: 0; display: grid; gap: 5px; }
.filter-field span { color: #1e293b; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
select, input:not([type="file"]) {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 13px;
  transition: var(--transition-fast);
}
select:focus, input:not([type="file"]):focus { outline: none; border-color: var(--teal); box-shadow: var(--ring); }
select[multiple] { min-height: 86px; padding: 7px; }

.tabs {
  margin: 16px 0;
  padding: 6px;
  display: flex;
  gap: 2px;
  overflow-x: auto;
  flex-wrap: nowrap;
  align-items: stretch;
  background: #e2e8f0;
  border: 2px solid #cbd5e1;
  border-radius: var(--radius);
  box-shadow: inset 0 2px 4px rgba(15, 23, 42, 0.06);
}
.result-tab {
  --tab-color: #0d9488;
  min-height: 42px;
  margin-right: 2px;
  padding: 10px 14px 10px 28px;
  flex: 0 0 auto;
  overflow: hidden;
  color: #1e293b;
  background: #ffffff;
  border: 1.5px solid transparent;
  border-bottom-color: var(--tab-color);
  border-radius: 8px;
  box-shadow: none;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.result-tab::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 10px;
  width: 10px;
  height: 10px;
  background: var(--tab-color);
  border: 2px solid var(--tab-color);
  border-radius: 50%;
  transform: translateY(-50%);
}
.result-tab::after { display: none; }
.result-tab:hover { color: #1e293b; background: #f8fafc; border-color: var(--tab-color); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); transform: translateY(-1px); }
.result-tab[data-result-tab="overview"] { --tab-color: #0d9488; }
.result-tab[data-result-tab="insurance"] { --tab-color: #2563eb; }
.result-tab[data-result-tab="patients"] { --tab-color: #7c3aed; }
.result-tab[data-result-tab="medications"] { --tab-color: #d97706; }
.result-tab[data-result-tab="reconciliation"] { --tab-color: #059669; }
.result-tab[data-result-tab="controls"] { --tab-color: #e11d48; }
.result-tab[data-result-tab="pickup"] { --tab-color: #4f46e5; }
.result-tab[data-result-tab="reimbursement"] { --tab-color: #06b6d4; }
.result-tab[data-result-tab="ndcAudit"] { --tab-color: #dc2626; }
.result-tab[data-result-tab="ordering"] { --tab-color: #1e293b; }
.result-tab.active { color: color-mix(in srgb, var(--tab-color) 82%, #111827); background: color-mix(in srgb, var(--tab-color) 8%, #ffffff); border-color: var(--tab-color); box-shadow: 0 4px 12px color-mix(in srgb, var(--tab-color) 20%, transparent); }

.summary-strip.grid { margin: 0 0 16px; grid-template-columns: repeat(6, minmax(150px, 1fr)); gap: 12px; }
.dashboard-grid, .subgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.overview-share-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
.insurance-layout, .controls-layout { display: grid; grid-template-columns: minmax(620px, 1.2fr) minmax(460px, 0.95fr); gap: 16px; align-items: start; }
.insurance-main, .insurance-side, .controls-main, .controls-side, .stack { display: grid; gap: 16px; align-items: start; }
.full-span { grid-column: 1 / -1; }

.table-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  transition: var(--transition-smooth);
}
.table-card::before { content: ""; display: block; height: 3px; margin: 0; background: linear-gradient(90deg, #0d9488, #14b8a6, #2dd4bf); opacity: 0.9; }
.table-card:hover { border-color: #cbd5e1; box-shadow: 0 2px 4px rgba(15, 23, 42, 0.05), 0 16px 40px rgba(15, 23, 42, 0.10); }
.table-head { padding: 15px 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--panel); border-bottom: 1px solid var(--line-subtle); }
.table-head h4 { color: var(--ink); font-size: 16px; font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; }
.table-note { margin-top: 3px; color: var(--muted); font-size: 13px; font-weight: 500; }
.table-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.table-filters { padding: 12px 16px; background: #f8fafc; border-bottom: 1px solid var(--line-subtle); }
.table-wrap { max-height: 430px; overflow: auto; border: 0; border-radius: 0; background: var(--panel); }
.table-card.show-all-rows .table-wrap { max-height: none; overflow-x: auto; overflow-y: visible; }
table { width: 100%; min-width: 760px; border-collapse: collapse; table-layout: auto; }
th, td {
  padding: 11px 14px;
  color: var(--ink);
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  transition: var(--transition-fast);
}
th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #0f172a;
  background: linear-gradient(180deg, #f8fafc, #eef2f7);
  border-color: #cbd5e1;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
tbody td { background: var(--panel); }
tbody tr:nth-child(even) td { background: #f8fafc; }
tbody tr:hover td { background: #ecfdf5; }
tbody tr:last-child td { border-bottom: 1px solid var(--line); }
.data-table tbody tr.total-row td { color: #0f766e; background: #ecfdf5; border-top: 2px solid rgba(13, 148, 136, 0.45); font-weight: 800; }
td.num, th.num { text-align: right; }
th .col-resize-handle { background: transparent; border: 0; }
th .col-resize-handle:hover { background: rgba(13, 148, 136, 0.16); box-shadow: inset -2px 0 0 var(--teal); }
.link-button { min-height: 0; padding: 0; overflow: visible; color: var(--teal); background: none; border: 0; border-radius: 0; box-shadow: none; font: inherit; font-weight: 600; text-decoration: none; }
.link-button::after { display: none; }
.link-button:hover { color: #0f766e; background: none; box-shadow: none; text-decoration: underline; transform: none; }
.link-button.selected { padding: 2px 6px; color: #ecfeff; background: #0f766e; border-radius: 6px; font-weight: 800; text-decoration: none; }

.metric {
  min-height: 88px;
  padding: 16px;
  position: relative;
  overflow: hidden;
  display: grid;
  align-content: center;
  color: var(--ink);
  background: var(--panel);
  border: 1.5px solid #cbd5e1;
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
  transition: var(--transition-smooth);
}
.metric::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: linear-gradient(180deg, #0d9488, #14b8a6); }
.metric:hover { border-color: #0d9488; box-shadow: var(--shadow-xl); transform: translateY(-3px); }
.metric span { display: block; color: #1e293b; font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.metric strong { display: block; margin-top: 6px; color: var(--ink); font-size: 24px; font-weight: 800; line-height: 1.2; }
.metric.green::before { background: #16a34a; }
.metric.gold::before { background: #d97706; }
.metric.red::before { background: #e34948; }
.metric.purple::before { background: #7c3aed; }
.metric.teal::before { background: #14b8a6; }
.metric.blue::before { background: #2563eb; }
.metric-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ops-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.padded { padding: 14px 16px; }

.empty { padding: 40px 20px; color: #334155; background: #f8fafc; border: 2px dashed #cbd5e1; border-radius: var(--radius-sm); text-align: center; font-size: 14px; font-weight: 500; }
.empty.tight { padding: 14px; }
.share-list { padding: 16px; display: grid; gap: 14px; }
.share-line { display: grid; gap: 7px; }
.share-label { display: flex; justify-content: space-between; gap: 14px; color: var(--ink); font-weight: 700; }
.share-track { height: 12px; overflow: hidden; background: var(--surface); border-radius: 999px; }
.share-track span { display: block; height: 100%; background: var(--teal); border-radius: inherit; }
.share-line:nth-child(2n) .share-track span { background: #2563eb; }
.share-line:nth-child(3n) .share-track span { background: #d97706; }
.share-line:nth-child(4n) .share-track span { background: #e34948; }
.share-line:nth-child(5n) .share-track span { background: #16a34a; }

.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.detail-block { padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.detail-block h5 { margin: 0 0 10px; color: var(--muted); font-size: 12px; letter-spacing: 0.05em; text-transform: uppercase; }
.detail-block dl { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.detail-block dt { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.detail-block dd { margin: 2px 0 0; color: var(--ink); font-weight: 600; white-space: normal; }
.recon-summary { display: grid; grid-template-columns: minmax(220px, 0.95fr) minmax(220px, 1.05fr); gap: 14px; }
.recon-summary-metrics { display: grid; gap: 10px; }
.ordering-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ordering-chart { min-height: 340px; padding: 28px 24px 18px; background: var(--panel); }

.modal-content { color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); }

[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --panel: #1e293b;
  --panel-hover: #334155;
  --ink: #f1f5f9;
  --muted: #94a3b8;
  --line: #334155;
  --line-subtle: #1e293b;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 2px 4px rgba(0, 0, 0, 0.2), 0 8px 16px rgba(0, 0, 0, 0.3), 0 24px 48px rgba(0, 0, 0, 0.4);
  --ring: 0 0 0 3px rgba(20, 184, 166, 0.25);
  color-scheme: dark;
}
[data-theme="dark"] .topbar { color: var(--ink); background: rgba(15, 23, 42, 0.88); border-bottom-color: rgba(51, 65, 85, 0.6); }
[data-theme="dark"] .topbar:hover { background: rgba(15, 23, 42, 0.95); border-bottom-color: rgba(51, 65, 85, 0.8); }
[data-theme="dark"] .brand-name { color: #ffffff; }
[data-theme="dark"] .brand-tagline { color: #22d3ee; }
[data-theme="dark"] .brand-mark img { filter: brightness(0) invert(1); }
[data-theme="dark"] .app-intro, [data-theme="dark"] .table-filters { background: var(--surface); }
[data-theme="dark"] .workflow-note { background: rgba(30, 41, 59, 0.7); }
[data-theme="dark"] .workflow-facts span, [data-theme="dark"] .pill, [data-theme="dark"] #usageDisplay { color: var(--muted); background: linear-gradient(135deg, #1e293b, #0f172a); border-color: rgba(51, 65, 85, 0.6); }
[data-theme="dark"] #account { color: #5eead4; background: rgba(13, 148, 136, 0.15); border-color: rgba(13, 148, 136, 0.3); }
[data-theme="dark"] .upload-grid > .upload-box, [data-theme="dark"] .global-filter-panel, [data-theme="dark"] #results > .section-head { background: var(--panel); border-color: var(--line); }
[data-theme="dark"] .upload-box input[type="file"] { color: var(--muted); background: var(--surface); border-color: var(--line); }
[data-theme="dark"] .help, [data-theme="dark"] .filter-field span, [data-theme="dark"] .metric span { color: var(--muted); }
[data-theme="dark"] select, [data-theme="dark"] input:not([type="file"]) { color: var(--ink); background: var(--panel); border-color: var(--line); }
[data-theme="dark"] .tabs { background: var(--surface); border-color: var(--line); }
[data-theme="dark"] .result-tab { color: var(--muted); background: var(--panel); }
[data-theme="dark"] .result-tab:hover { color: var(--ink); background: var(--panel-hover); }
[data-theme="dark"] .result-tab.active { color: color-mix(in srgb, var(--tab-color) 55%, #ffffff); background: color-mix(in srgb, var(--tab-color) 12%, var(--panel)); }
[data-theme="dark"] .table-card, [data-theme="dark"] .metric, [data-theme="dark"] .detail-block { background: var(--panel); border-color: var(--line); }
[data-theme="dark"] .table-head { background: var(--panel); border-color: var(--line); }
[data-theme="dark"] .table-wrap { background: var(--panel); }
[data-theme="dark"] th { color: var(--ink); background: var(--surface); border-color: var(--line); }
[data-theme="dark"] td { color: var(--ink); border-color: var(--line); }
[data-theme="dark"] tbody tr:nth-child(even) td { background: rgba(30, 41, 59, 0.6); }
[data-theme="dark"] tbody tr:hover td { background: rgba(255, 255, 255, 0.03); }
[data-theme="dark"] .empty { color: var(--muted); background: rgba(30, 41, 59, 0.6); border-color: var(--line); }
[data-theme="dark"] .notice { color: #fcd34d; background: rgba(217, 119, 6, 0.12); border-color: rgba(217, 119, 6, 0.25); }
[data-theme="dark"] .notice.warn { color: #fca5a5; background: rgba(220, 38, 38, 0.12); border-color: rgba(220, 38, 38, 0.3); }
[data-theme="dark"] .theme-toggle:hover { color: #fcd34d; border-color: #fcd34d; }

/* Report ownership advisory (non-blocking) */
.run-advisory {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin: 0 0 16px;
  padding: 14px 18px;
  background: linear-gradient(180deg, #fffbeb, #fef3c7);
  border: 1px solid #fcd34d;
  border-left: 4px solid #d97706;
  border-radius: var(--radius);
}
.run-advisory-icon {
  flex: 0 0 24px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-top: 1px;
  color: #ffffff;
  background: #d97706;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 800;
  font-style: italic;
}
.run-advisory strong { display: block; color: #7c2d12; font-size: 14px; font-weight: 800; }
.run-advisory p { margin: 4px 0 0; color: #92400e; font-size: 13px; line-height: 1.5; }
[data-theme="dark"] .run-advisory { background: rgba(217, 119, 6, 0.12); border-color: rgba(217, 119, 6, 0.35); border-left-color: #d97706; }
[data-theme="dark"] .run-advisory strong { color: #fcd34d; }
[data-theme="dark"] .run-advisory p { color: #fde68a; }

/* Reporting modules overview */
.modules-panel {
  margin: 0 0 18px;
  padding: 20px 22px 22px;
  background: var(--panel);
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 30px rgba(15, 23, 42, 0.06);
}
.modules-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.modules-eyebrow { display: inline-block; margin-bottom: 6px; padding: 3px 10px; color: #0f766e; background: rgba(13, 148, 136, 0.10); border: 1px solid rgba(13, 148, 136, 0.22); border-radius: 999px; font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.modules-head h2 { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.modules-head p { margin-top: 6px; max-width: 640px; color: var(--muted); font-size: 13.5px; }
.modules-count { flex: 0 0 auto; display: grid; place-items: center; min-width: 84px; padding: 12px 16px; color: #0f766e; background: linear-gradient(180deg, #f0fdfa, #ecfeff); border: 1px solid rgba(13, 148, 136, 0.25); border-radius: var(--radius); text-align: center; }
.modules-count strong { font-size: 30px; font-weight: 900; line-height: 1; letter-spacing: -0.03em; }
.modules-count span { margin-top: 3px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: #0d9488; }
.modules-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.module-card {
  --module-color: #0d9488;
  position: relative;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 14px 14px 15px;
  background: #fbfdfe;
  border: 1px solid #e2e8f0;
  border-left: 4px solid var(--module-color);
  border-radius: var(--radius-sm);
  transition: var(--transition-smooth);
}
.module-card:hover { transform: translateY(-2px); background: #ffffff; border-color: #cbd5e1; box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08); }
.module-icon {
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #ffffff;
  background: var(--module-color);
  border-radius: 9px;
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
}
.module-card h3 { font-size: 13.5px; font-weight: 800; letter-spacing: -0.01em; text-transform: none; color: #0f172a; }
.module-card p { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.module-card[data-module="overview"] { --module-color: #0d9488; }
.module-card[data-module="insurance"] { --module-color: #2563eb; }
.module-card[data-module="patients"] { --module-color: #7c3aed; }
.module-card[data-module="medications"] { --module-color: #d97706; }
.module-card[data-module="reconciliation"] { --module-color: #059669; }
.module-card[data-module="controls"] { --module-color: #e11d48; }
.module-card[data-module="pickup"] { --module-color: #4f46e5; }
.module-card[data-module="reimbursement"] { --module-color: #06b6d4; }
.module-card[data-module="ndcAudit"] { --module-color: #dc2626; }
.module-card[data-module="ordering"] { --module-color: #1e293b; }
[data-theme="dark"] .modules-panel { background: var(--panel); border-color: var(--line); }
[data-theme="dark"] .module-card { background: rgba(30, 41, 59, 0.5); border-color: var(--line); }
[data-theme="dark"] .module-card h3 { color: var(--ink); }

@media (max-width: 1200px) {
  .modules-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .topbar { align-items: flex-start; }
  .topbar-controls { align-items: flex-end; flex-direction: column; gap: 8px; }
  .global-filter-panel, .insurance-layout, .controls-layout { grid-template-columns: 1fr; }
  .global-filter-panel .filter-grid { grid-template-columns: repeat(3, minmax(130px, 1fr)); }
  .summary-strip.grid { grid-template-columns: repeat(3, 1fr); }
  .overview-share-grid { grid-template-columns: 1fr; }
  .ops-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 720px) {
  .modules-grid { grid-template-columns: 1fr 1fr; }
  .modules-head { flex-direction: column; }
  .topbar { position: static; display: block; padding: 14px 16px; }
  .topbar-controls { width: 100%; margin-top: 12px; align-items: flex-start; }
  .status { width: 100%; justify-content: flex-start; }
  .status .pill, .status #usageDisplay { white-space: normal; }
  .privacy-pill { display: none; }
  .app-intro { padding: 9px 14px; }
  .page { padding: 10px; }
  .workflow-note { align-items: flex-start; flex-direction: column; }
  .workflow-facts { width: 100%; justify-content: flex-start; }
  .workflow-facts span { white-space: normal; }
  .upload-grid, .dashboard-grid, .subgrid, .detail-grid, .recon-summary { grid-template-columns: 1fr; }
  .run-row { align-items: stretch; flex-direction: column; }
  .global-filter-panel .filter-grid, .filter-grid { grid-template-columns: 1fr 1fr; }
  .summary-strip.grid, .metric-row, .ops-grid, .ordering-summary { grid-template-columns: 1fr 1fr; }
  .table-head, .section-head { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 480px) {
  .back-link { display: none; }
  .modules-grid { grid-template-columns: 1fr; }
  .global-filter-panel .filter-grid, .filter-grid, .summary-strip.grid, .metric-row, .ops-grid, .ordering-summary { grid-template-columns: 1fr; }
}
