/* Physician Dashboard — custom clinical design system (no Bootstrap). */

:root {
  --canvas: #f3f6fa;
  --canvas-deep: #e9eef5;
  --card: #ffffff;
  --card-muted: #f7f9fc;

  --ink: #14213d;
  --ink-soft: #42526b;
  --muted: #6d7b91;

  --line: #dfe6ef;
  --line-strong: #cbd5e1;

  --navy: #183b5b;
  --navy-hover: #102f4b;

  --teal: #16847c;
  --teal-soft: #dff4f1;

  --coral: #e76f51;
  --gold: #d89a2b;
  --success: #147d64;

  --danger: #b42318;
  --danger-soft: #fef3f2;

  --shadow-sm: 0 4px 14px rgba(28, 45, 72, 0.06);
  --shadow-md: 0 14px 40px rgba(28, 45, 72, 0.09);

  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;

  --content-width: 1440px;
}

* { box-sizing: border-box; }

/* An author display rule (e.g. .error-banner{display:flex}) would otherwise
   beat the UA [hidden] rule; keep hidden authoritative. */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  color: var(--ink);
  background: var(--canvas);
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 40;
  background: var(--navy);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 12px; }

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--teal);
}

/* Global 80% scale applied only to the dashboard page shell. */
.dashboard-page { zoom: 0.8; }

/* --------------------------------------------------------------------- */
/* Sticky header                                                          */
/* --------------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.91);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.topbar-inner {
  max-width: var(--content-width);
  margin: 0 auto;
  min-height: 92px;
  padding: 14px clamp(20px, 3.2vw, 48px);
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.identity {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.back-button {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: background 0.15s ease;
}
.back-button:hover { background: var(--canvas-deep); }
.back-button:focus-visible { outline: 3px solid rgba(22, 132, 124, 0.3); outline-offset: 3px; }

.identity-text { display: flex; flex-direction: column; min-width: 0; }
.physician-name {
  font-size: 1.2rem;
  font-weight: 730;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 42vw;
}

/* Segmented product control */
.product-bar {
  margin-left: auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: max(680px, 50vw);
  max-width: 100%;
  gap: 7px;
  padding: 6px;
  background: var(--canvas-deep);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
}

.product-tab {
  min-height: 50px;
  border: none;
  border-radius: 13px;
  background: transparent;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 720;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.product-tab:hover:not([aria-pressed="true"]):not([disabled]) { background: #fff; }
.product-tab[aria-pressed="true"] {
  background: var(--navy);
  color: #fff;
  box-shadow: 0 6px 16px rgba(24, 59, 91, 0.22);
}
.product-tab[disabled] {
  opacity: 0.62;
  color: #98a3b2;
  cursor: not-allowed;
}
.product-tab:focus-visible { outline: 3px solid rgba(22, 132, 124, 0.3); outline-offset: 2px; }

.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot-rbc { background: #dd5f5f; }
.dot-plt { background: #e9a63a; }
.dot-plasma { background: #5ebc83; }
.dot-alb { background: #aab5c3; }

/* Tooltip for disabled products */
.product-tab[disabled]::after {
  content: "No data available";
  position: absolute;
  transform: translateY(40px);
  background: var(--ink);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.product-tab { position: relative; }
.product-tab[disabled]:hover::after,
.product-tab[disabled]:focus-visible::after { opacity: 1; }

.mobile-product { display: none; }
.mobile-product select {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  font-family: inherit;
  font-size: 1rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
}

/* --------------------------------------------------------------------- */
/* Dashboard shell + grid                                                */
/* --------------------------------------------------------------------- */
.dashboard-shell {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: clamp(18px, 2.4vw, 32px) clamp(20px, 3.2vw, 48px) 48px;
}

.error-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--danger-soft);
  border: 1px solid #f3c6c1;
  color: #7f1d17;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 18px;
  font-weight: 600;
}
.retry-button {
  border: none;
  background: var(--danger);
  color: #fff;
  font-weight: 700;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-rows: repeat(2, clamp(380px, 34vh, 440px));
  gap: 18px;
}
.dashboard-grid[aria-busy="true"] { opacity: 0.72; }

.card-utilization { grid-column: 1 / 4;  grid-row: 1; }
.card-peer        { grid-column: 4 / 8;  grid-row: 1; }
.card-diagnoses   { grid-column: 8 / 10; grid-row: 1; }
.card-clinical    { grid-column: 1 / 7;  grid-row: 2; }
.card-benchmark   { grid-column: 7 / 10; grid-row: 2; }
.card-resources   { grid-column: 10 / 13; grid-row: 1 / 3; }

.card {
  background: var(--card);
  border: 1px solid rgba(218, 226, 236, 0.9);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: clamp(18px, 1.6vw, 24px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.card-title {
  margin: 0;
  font-size: clamp(1.05rem, 1.5vw, 1.28rem);
  font-weight: 720;
  letter-spacing: -0.022em;
  line-height: 1.2;
}
.card-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.chart-body {
  display: flex;
  align-items: center;
  justify-content: center;
}
.chart-body img { max-width: 100%; max-height: 100%; object-fit: contain; }

.product-badge {
  flex: none;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--navy);
  background: var(--canvas-deep);
  padding: 6px 12px;
  border-radius: 999px;
}

/* --------------------------------------------------------------------- */
/* Product utilization panel                                             */
/* --------------------------------------------------------------------- */
.util-heading {
  margin: 0 0 16px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink-soft);
  line-height: 1.35;
}
.percentile-scale { margin-bottom: 20px; }
.scale-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #dce9f2 0%, #7bbab8 55%, #e7a678 100%);
  margin: 26px 0 8px;
}
.scale-marker {
  position: absolute;
  top: 50%;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--navy);
  border: 4px solid #fff;
  box-shadow: 0 3px 8px rgba(20, 33, 61, 0.28);
  transform: translate(-50%, -50%);
}
.scale-marker-label {
  position: absolute;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--navy);
  white-space: nowrap;
}
.scale-ends {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--muted);
}
.metric-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.metric-card {
  background: var(--card-muted);
  border-radius: var(--radius-md);
  padding: 15px;
}
.metric-value {
  font-size: 1.5rem;
  font-weight: 760;
  letter-spacing: -0.02em;
}
.metric-label {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.3;
}

/* --------------------------------------------------------------------- */
/* Diagnoses panel                                                       */
/* --------------------------------------------------------------------- */
.diagnoses-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}
.diagnosis-item {
  line-height: 1.18;
  letter-spacing: -0.02em;
  width: 100%;
}

/* --------------------------------------------------------------------- */
/* Hospital benchmark panel                                              */
/* --------------------------------------------------------------------- */
.benchmark-head { min-width: 0; }
.benchmark-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.info-button {
  flex: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink-soft);
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 0.95rem;
  cursor: pointer;
}
.info-button:hover { background: var(--canvas-deep); }
.info-button:focus-visible { outline: 3px solid rgba(22, 132, 124, 0.3); outline-offset: 2px; }

.rank-summary { text-align: center; padding-top: 6px; }
.rank-number {
  font-size: 2.6rem;
  font-weight: 780;
  letter-spacing: -0.03em;
}
.rank-of { color: var(--muted); font-weight: 600; }
.rank-metric {
  margin-top: 4px;
  font-size: 0.92rem;
  color: var(--ink-soft);
  font-weight: 600;
}
.rank-track {
  display: flex;
  gap: 3px;
  margin: 22px 0 10px;
}
.rank-seg {
  flex: 1;
  height: 12px;
  border-radius: 4px;
  background: var(--track-default, #dce4ed);
  position: relative;
}
.rank-seg.current {
  box-shadow: 0 0 0 4px rgba(169, 86, 79, 0.24);
}
.rank-seg.current::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 4px;
}
.rank-ends {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 700;
}
.rank-end-high { color: #9b514a; }
.rank-end-low { color: #39746f; }
.rank-hospital {
  text-align: center;
  margin-top: 12px;
  font-size: 0.82rem;
  color: var(--muted);
}

/* --------------------------------------------------------------------- */
/* Recommended resources panel                                           */
/* --------------------------------------------------------------------- */
.card-resources .card-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.resource-sub {
  display: grid;
  gap: 14px;
}
.resource-card {
  background: var(--card-muted);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
}
.resource-card h3 {
  margin: 0 0 10px;
  font-size: 0.92rem;
  font-weight: 720;
  color: var(--ink);
}
.resource-links { display: flex; flex-direction: column; gap: 9px; }
.resource-link {
  color: #35507a;
  text-decoration: none;
  font-size: 0.85rem;
  line-height: 1.3;
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
}
.resource-link:hover { text-decoration: underline; }
.resource-link .arrow { color: var(--teal); font-size: 0.78rem; }

/* --------------------------------------------------------------------- */
/* Albumin toggle controls                                               */
/* --------------------------------------------------------------------- */
.albumin-controls { display: flex; gap: 7px; }
.albumin-toggle {
  height: 30px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}
.albumin-toggle .box {
  width: 13px; height: 13px;
  border-radius: 3px;
  border: 1px solid var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  line-height: 1;
  color: transparent;
}
.albumin-toggle[aria-pressed="true"] {
  background: var(--teal-soft);
  border-color: var(--teal);
  color: var(--teal);
}
.albumin-toggle[aria-pressed="true"] .box {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}
.albumin-toggle:focus-visible { outline: 3px solid rgba(22, 132, 124, 0.3); outline-offset: 2px; }

/* --------------------------------------------------------------------- */
/* Loading / empty / error states                                        */
/* --------------------------------------------------------------------- */
.skeleton {
  background: linear-gradient(90deg, #eef2f7 25%, #e2e8f1 37%, #eef2f7 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
  border-radius: 8px;
}
.skeleton-line { height: 14px; margin-bottom: 12px; }
.skeleton-block { height: 100%; min-height: 120px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--teal-soft);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
  display: flex;
  align-items: center;
  height: 100%;
}

/* --------------------------------------------------------------------- */
/* Benchmark dialog                                                      */
/* --------------------------------------------------------------------- */
.benchmark-dialog {
  width: min(460px, calc(100% - 32px));
  border: none;
  border-radius: 20px;
  padding: 24px;
  background: #fff;
  box-shadow: 0 30px 80px rgba(20, 33, 61, 0.35);
  color: var(--ink);
}
.benchmark-dialog::backdrop {
  background: rgba(15, 25, 45, 0.5);
  backdrop-filter: blur(3px);
}
.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.dialog-head h3 { margin: 0; font-size: 1.15rem; font-weight: 730; }
.dialog-close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
.dialog-body { font-size: 0.92rem; line-height: 1.5; color: var(--ink-soft); }
.dialog-body p { margin: 0 0 10px; }

/* --------------------------------------------------------------------- */
/* Responsive tiers                                                      */
/* --------------------------------------------------------------------- */
@media (max-width: 1180px) {
  .dashboard-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-auto-rows: minmax(390px, auto);
    grid-template-rows: none;
  }
  .card-utilization { grid-column: span 4; grid-row: auto; }
  .card-peer        { grid-column: span 8; grid-row: auto; }
  .card-diagnoses   { grid-column: span 6; grid-row: auto; }
  .card-clinical    { grid-column: span 6; grid-row: auto; }
  .card-benchmark   { grid-column: span 6; grid-row: auto; }
  .card-resources   { grid-column: span 6; grid-row: auto; }
  .resource-sub { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 1120px) {
  .topbar-inner { flex-direction: column; align-items: stretch; }
  .identity { justify-content: flex-start; }
  .product-bar { margin-left: 0; width: 100%; }
  .physician-name { max-width: none; }
}

@media (max-width: 760px) {
  .topbar { position: static; }
  .product-bar { display: none; }
  .mobile-product { display: block; width: 100%; }
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 14px;
    grid-auto-rows: minmax(320px, auto);
  }
  .card { border-radius: 19px; }
  .card-utilization,
  .card-peer,
  .card-diagnoses,
  .card-clinical,
  .card-benchmark,
  .card-resources { grid-column: 1 / -1; }
  .card-clinical, .card-benchmark { min-height: 420px; }
  .resource-sub { grid-template-columns: 1fr; }
}

@media (max-width: 390px) {
  .metric-cards { grid-template-columns: 1fr; }
  .card-head { gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .skeleton { animation: none; }
}
