:root {
  --navy: #173f62;
  --blue: #285f8f;
  --blue-dark: #194b74;
  --blue-soft: #eaf2f8;
  --ink: #1d2731;
  --muted: #607080;
  --line: #d7e0e8;
  --paper: #ffffff;
  --page: #f3f6f9;
  --danger: #a12727;
  --danger-bg: #fff0f0;
  --success: #1d6b45;
  --shadow: 0 10px 30px rgba(26, 57, 84, 0.09);
  --radius: 14px;
}

* { box-sizing: border-box; }

html { color-scheme: light; scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--page);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 1000;
  transform: translateY(-150%);
  background: #fff;
  color: var(--navy);
  padding: 8px 12px;
  border-radius: 6px;
  box-shadow: var(--shadow);
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  background: linear-gradient(135deg, var(--navy), var(--blue));
  color: #fff;
  padding: 34px 22px;
}

.header-inner {
  max-width: 1380px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow {
  margin: 0 0 5px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: 0.76rem;
  font-weight: 700;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(2rem, 4vw, 3rem); line-height: 1.08; }
h2 { margin-bottom: 4px; font-size: 1.42rem; color: var(--navy); }
h3 { color: var(--navy); }
.subtitle { margin: 0; opacity: 0.9; font-size: 1.03rem; }

.source-badge {
  flex: 0 0 auto;
  padding: 10px 14px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 10px;
  background: rgba(255,255,255,0.09);
  text-align: right;
}
.source-badge span, .source-badge strong { display: block; }
.source-badge span { font-size: 0.75rem; opacity: 0.8; }
.source-badge strong { font-size: 0.95rem; }

.page-shell {
  max-width: 1380px;
  margin: 0 auto;
  padding: 26px 22px 36px;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 22px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 21px;
}
.section-heading p { margin: 0; color: var(--muted); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 17px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field-wide { grid-column: span 2; }
.field > span { color: #2b3a47; font-weight: 700; font-size: 0.9rem; }
.field small { color: var(--muted); font-size: 0.78rem; }

input, select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #bfcbd5;
  border-radius: 8px;
  padding: 9px 11px;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus {
  outline: 3px solid rgba(40, 95, 143, 0.18);
  border-color: var(--blue);
}

.search-options {
  margin-top: 18px;
  padding: 15px;
  border-radius: 9px;
  background: var(--blue-soft);
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
}
.check-field { display: inline-flex; align-items: flex-start; gap: 8px; font-size: 0.9rem; }
.check-field input { width: 17px; min-height: 17px; margin: 2px 0 0; }

.form-actions {
  margin-top: 19px;
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}
.keyboard-note { color: var(--muted); font-size: 0.84rem; }

.button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 700;
}
.button-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.button-primary:hover { background: var(--blue-dark); }
.button-secondary { background: var(--blue-soft); color: var(--navy); border-color: #bfd2e2; }
.button-secondary:hover { background: #dcebf5; }
.button-quiet { background: #fff; color: var(--navy); border-color: #bdcbd6; }
.button-quiet:hover { background: #f4f8fb; }
.button-small { min-height: 34px; padding: 5px 10px; font-size: 0.84rem; }

.message {
  border-radius: 8px;
  padding: 11px 13px;
  margin: 14px 0;
  background: var(--blue-soft);
  color: var(--navy);
}
.message-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #ecc2c2; }
.message-success { background: #eaf7f0; color: var(--success); border: 1px solid #bfe2ce; }

.results-heading-row { align-items: center; }
.result-actions { display: flex; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

table { width: 100%; border-collapse: collapse; min-width: 1050px; }
th, td { padding: 13px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { background: #edf3f7; color: var(--navy); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.035em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfd; }
.provider-name { display: block; font-weight: 700; color: var(--ink); }
.provider-meta, .secondary-text { display: block; color: var(--muted); font-size: 0.82rem; margin-top: 2px; }
.npi-number { white-space: nowrap; font-family: Consolas, "Courier New", monospace; }
.phone-link { white-space: nowrap; color: var(--blue-dark); font-weight: 700; text-decoration: none; }
.phone-link:hover { text-decoration: underline; }
.status-pill { display: inline-block; padding: 2px 7px; border-radius: 999px; font-size: 0.73rem; font-weight: 700; }
.status-active { background: #e4f4eb; color: #17623d; }
.status-inactive { background: #fbe8e8; color: #922d2d; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin-top: 18px;
}
#page-indicator { color: var(--muted); font-size: 0.9rem; }

.notice-card {
  border-left: 5px solid #d39a31;
  background: #fff8e9;
  padding: 15px 17px;
  border-radius: 8px;
  color: #5f4a20;
}

.details-dialog {
  width: min(940px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 0;
  border-radius: 14px;
  box-shadow: 0 22px 70px rgba(0,0,0,0.25);
}
.details-dialog::backdrop { background: rgba(10, 27, 42, 0.62); }
.dialog-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding: 20px 22px;
  background: var(--navy);
  color: #fff;
}
.dialog-header h2 { margin: 0; color: #fff; }
.icon-button { border: 0; background: transparent; color: #fff; font-size: 2rem; line-height: 1; padding: 0 4px; }
.dialog-content { padding: 22px; }
.detail-hero { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.detail-hero h3 { margin: 0 0 5px; font-size: 1.35rem; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 18px; }
.detail-card { border: 1px solid var(--line); border-radius: 9px; padding: 15px; }
.detail-card-wide { grid-column: 1 / -1; }
.detail-card h3 { margin-bottom: 10px; font-size: 1rem; }
.detail-list { margin: 0; padding: 0; list-style: none; }
.detail-list li + li { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.definition-grid { display: grid; grid-template-columns: minmax(130px, 0.45fr) 1fr; gap: 7px 12px; margin: 0; }
.definition-grid dt { color: var(--muted); font-weight: 700; }
.definition-grid dd { margin: 0; overflow-wrap: anywhere; }

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(12, 31, 48, 0.55);
  padding: 20px;
}
.loading-card {
  width: min(390px, 100%);
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 26px;
  border-radius: 13px;
  background: #fff;
  box-shadow: var(--shadow);
  text-align: center;
}
.spinner {
  width: 38px;
  height: 38px;
  border: 4px solid #d8e4ed;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

footer { text-align: center; color: var(--muted); padding: 4px 20px 28px; font-size: 0.82rem; }
footer p { margin: 0; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

@media (max-width: 980px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-wide { grid-column: span 2; }
  .header-inner { align-items: flex-start; }
}

@media (max-width: 650px) {
  .site-header { padding: 27px 16px; }
  .header-inner, .section-heading, .detail-hero { flex-direction: column; }
  .source-badge { text-align: left; }
  .page-shell { padding: 18px 12px 28px; }
  .panel { padding: 17px; }
  .form-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .result-actions { justify-content: flex-start; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-card-wide { grid-column: auto; }
  .definition-grid { grid-template-columns: 1fr; gap: 2px; }
  .definition-grid dd { margin-bottom: 8px; }
}
