@font-face {
  font-family: "Unageo";
  src: url("../fonts/Unageo-Regular.ttf") format("truetype");
  font-weight: 400;
}

@font-face {
  font-family: "Unageo";
  src: url("../fonts/Unageo-Bold.ttf") format("truetype");
  font-weight: 700;
}

@font-face {
  font-family: "Rubik";
  src: url("../fonts/Rubik-Regular.ttf") format("truetype");
  font-weight: 400;
}

@font-face {
  font-family: "Rubik";
  src: url("../fonts/Rubik-Medium.ttf") format("truetype");
  font-weight: 500;
}

:root {
  --text: #2d2d2d;
  --muted: #68727f;
  --main: #44bcd6;
  --main-strong: #249db7;
  --accent: #932580;
  --blue: #4494d8;
  --line: #dce8ed;
  --surface: #ffffff;
  --surface-soft: #f4fbfd;
  --page: #eef7fa;
  --shadow: 0 16px 40px rgba(45, 45, 45, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  color: var(--text);
  background: var(--page);
}

body {
  margin: 0;
  font-family: "Rubik", Arial, sans-serif;
  color: var(--text);
  background:
    linear-gradient(rgba(238, 247, 250, 0.9), rgba(238, 247, 250, 0.9)),
    url("../img/pattern.svg") top right / 360px auto no-repeat;
}

.dashboard-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(238, 247, 250, 0.88), rgba(238, 247, 250, 0.92)),
    url("../img/pattern.svg") top right / 360px auto no-repeat;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    visibility 180ms ease;
  backdrop-filter: blur(12px);
}

.dashboard-loader.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.dashboard-loader-card {
  display: grid;
  justify-items: center;
  width: min(360px, 100%);
  padding: 30px 28px 26px;
  border: 1px solid rgba(68, 188, 214, 0.3);
  border-radius: 8px;
  color: var(--text);
  text-align: center;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 24px 70px rgba(45, 45, 45, 0.15);
}

.dashboard-loader-mark {
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  margin-bottom: 18px;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(68, 188, 214, 0.14), transparent 68%),
    rgba(244, 251, 253, 0.96);
}

.dashboard-loader-mark img {
  width: 66px;
  height: 66px;
  animation: dashboard-loader-spin 1.15s linear infinite;
  transform-origin: 50% 50%;
}

.dashboard-loader-card strong {
  font-family: "Unageo", "Rubik", Arial, sans-serif;
  font-size: 1.28rem;
  line-height: 1.15;
}

.dashboard-loader-card span {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.dashboard-loader-bar {
  position: relative;
  width: 100%;
  height: 4px;
  margin-top: 22px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(68, 188, 214, 0.16);
}

.dashboard-loader-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 42%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--main), var(--accent));
  animation: dashboard-loader-bar 1.2s ease-in-out infinite;
}

@keyframes dashboard-loader-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes dashboard-loader-bar {
  0% {
    transform: translateX(-120%);
  }

  50% {
    transform: translateX(80%);
  }

  100% {
    transform: translateX(240%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .dashboard-loader-mark img,
  .dashboard-loader-bar::after {
    animation-duration: 2.8s;
  }
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 20px;
  border: 1px solid rgba(68, 188, 214, 0.25);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 260px;
  gap: 18px;
}

.brand-logo {
  width: 182px;
  height: auto;
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--main-strong);
  font-size: 0.86rem;
  font-weight: 500;
}

h1,
h2 {
  font-family: "Unageo", "Rubik", Arial, sans-serif;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 1.85rem;
  line-height: 1.1;
}

.filters {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.date-field {
  display: grid;
  gap: 6px;
  min-width: 156px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.date-field input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
}

.quick-range {
  display: flex;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.quick-range button {
  border: 0;
  border-right: 1px solid var(--line);
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
}

.quick-range button:last-child {
  border-right: 0;
}

.quick-range button.is-active {
  color: #fff;
  background: var(--accent);
}

.dashboard-tabs {
  display: inline-flex;
  gap: 0;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 28px rgba(45, 45, 45, 0.05);
}

.dashboard-tabs button {
  min-height: 42px;
  border: 0;
  border-right: 1px solid var(--line);
  padding: 0 18px;
  color: var(--muted);
  background: transparent;
  font-weight: 500;
}

.dashboard-tabs button:last-child {
  border-right: 0;
}

.dashboard-tabs button.is-active {
  color: #fff;
  background: var(--accent);
}

main {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.dashboard-view {
  display: none;
}

.dashboard-view.is-active {
  display: grid;
  gap: 18px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}

.metric-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 128px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(45, 45, 45, 0.05);
}

.metric-card img {
  width: 36px;
  height: 36px;
  padding: 7px;
  border-radius: 8px;
  background: rgba(68, 188, 214, 0.12);
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.28;
}

.metric-card strong {
  display: block;
  margin: 7px 0 3px;
  font-family: "Unageo", "Rubik", Arial, sans-serif;
  font-size: 1.55rem;
  line-height: 1.05;
  white-space: normal;
}

.metric-value-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  margin: 7px 0 3px;
}

.metric-value-row strong {
  margin: 0;
}

.metric-card .metric-delta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}

.metric-delta.is-positive {
  color: #14753b;
  background: rgba(37, 177, 91, 0.14);
}

.metric-delta.is-negative {
  color: #a13737;
  background: rgba(220, 74, 74, 0.14);
}

.metric-delta.is-neutral {
  color: var(--muted);
  background: rgba(104, 114, 127, 0.12);
}

.metric-card small {
  display: block;
  min-height: 1rem;
  color: var(--main-strong);
  font-size: 0.74rem;
}

.metric-card .metric-comparison {
  margin-top: 3px;
  color: var(--muted);
}

.telephony-summary .metric-card strong {
  font-size: 1.48rem;
}

.medwork-summary .metric-card strong {
  font-size: 1.34rem;
  overflow-wrap: anywhere;
}

#medworkView .summary-strip {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

#doctorPatientView .summary-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

#patientMapView .summary-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.panel {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(45, 45, 45, 0.05);
}

.panel-wide {
  grid-column: span 2;
}

#medworkView .dashboard-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

#doctorPatientView .dashboard-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

#laboratoryView .dashboard-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

#patientMapView .dashboard-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: start;
}

#medworkView .medwork-main-panel,
#medworkView .medwork-appointments-panel {
  grid-column: span 8;
}

#laboratoryView .laboratory-overview-panel {
  grid-column: span 8;
}

#laboratoryView .laboratory-match-panel {
  grid-column: span 4;
}

#doctorPatientView .medwork-appointments-panel {
  grid-column: span 8;
}

#doctorPatientView .doctor-slot-panel {
  grid-column: span 12;
}

#laboratoryView .laboratory-full-panel {
  grid-column: span 12;
}

#patientMapView .patient-map-panel {
  grid-column: span 12;
  align-content: start;
}

#patientMapView .patient-map-side-panel {
  grid-column: span 12;
}

#patientMapView .patient-map-wide-panel {
  grid-column: span 6;
}

#patientMapView .patient-map-full-panel {
  grid-column: span 12;
}

#medworkView .medwork-service-mix-panel,
#medworkView .medwork-patients-panel {
  grid-column: span 4;
}

#doctorPatientView .medwork-patients-panel {
  grid-column: span 4;
}

#medworkView .medwork-half-panel {
  grid-column: span 6;
}

#doctorPatientView .medwork-half-panel {
  grid-column: span 6;
}

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  min-height: 48px;
  margin-bottom: 12px;
}

.panel-heading h2 {
  margin: 0 0 4px;
  font-size: 1.08rem;
  line-height: 1.2;
}

.panel-heading p,
.panel-heading span {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.panel-heading span {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--accent);
  background: rgba(147, 37, 128, 0.08);
  font-weight: 500;
}

.chart-box {
  position: relative;
  width: 100%;
  height: 310px;
}

.chart-legend-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.chart-legend-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.25;
}

.chart-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.chart-legend-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-legend-value {
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
}

.chart-legend-empty {
  color: var(--muted);
  font-size: 0.82rem;
}

.service-mix-link {
  width: 100%;
  padding: 6px 4px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
}

.service-mix-link:hover {
  background: var(--surface-soft);
  color: var(--main-strong);
}

.service-mix-link:focus-visible,
.service-details-dialog button:focus-visible,
.service-details-dialog input:focus-visible,
.service-details-dialog select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body.service-details-open {
  overflow: hidden;
}

.service-details-dialog {
  width: min(1120px, calc(100% - 40px));
  max-width: none;
  max-height: calc(100dvh - 40px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(20, 35, 40, 0.25);
  overflow: hidden;
  letter-spacing: 0;
}

.service-details-dialog[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.service-details-dialog::backdrop {
  background: rgba(22, 39, 44, 0.52);
}

.service-details-dialog [hidden] {
  display: none;
}

.service-details-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}

.service-details-heading {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.service-details-heading h2 {
  margin: 5px 0;
  font-size: 1.2rem;
  line-height: 1.35;
}

.service-details-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.service-details-icon {
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.service-details-icon:hover {
  color: var(--accent);
  background: var(--surface-soft);
}

.service-details-body {
  min-height: 0;
  padding: 0 24px 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.service-details-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  margin: 0;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}

.service-details-metrics div {
  min-width: 0;
}

.service-details-metrics dt {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.service-details-metrics dd {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.service-details-section-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 18px 0 12px;
}

.service-details-section-heading h3 {
  margin: 0;
  font-size: 0.95rem;
}

.service-details-section-heading > span {
  color: var(--muted);
  font-size: 0.78rem;
  text-align: right;
  overflow-wrap: anywhere;
}

.service-details-chart {
  position: relative;
  height: 235px;
  min-width: 0;
}

.service-details-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 12px;
  padding-bottom: 14px;
}

.service-details-tools label {
  display: grid;
  gap: 6px;
  min-width: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.service-details-tools input,
.service-details-tools select {
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 10px;
  color: var(--text);
  background: var(--surface);
  font: inherit;
}

.service-details-table {
  min-width: 0;
  table-layout: fixed;
  font-size: 0.82rem;
}

.service-details-table th,
.service-details-table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: normal;
  overflow-wrap: anywhere;
  vertical-align: middle;
}

.service-details-table th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 0.72rem;
}

.service-details-table th:first-child,
.service-details-table td:first-child {
  width: 42%;
  text-align: left;
}

.service-details-table small {
  display: block;
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--muted);
}

.service-detail-row {
  cursor: pointer;
}

.service-detail-row:hover,
.service-detail-row:focus-within {
  background: var(--surface-soft);
}

.service-detail-name {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  color: var(--text);
  background: transparent;
  text-align: left;
  font: inherit;
  line-height: 1.45;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.service-detail-name:hover > span {
  color: var(--main-strong);
  text-decoration: underline;
}

@media (max-width: 680px) {
  .service-details-dialog {
    width: calc(100% - 16px);
    max-height: calc(100dvh - 16px);
  }

  .service-details-header {
    padding: 14px 12px;
    gap: 8px;
  }

  .service-details-heading h2 {
    font-size: 1.05rem;
  }

  .service-details-body {
    padding: 0 12px 16px;
  }

  .service-details-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 12px;
  }

  .service-details-metrics dd {
    font-size: 1.1rem;
  }

  .service-details-tools {
    grid-template-columns: 1fr;
  }

  .service-details-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .service-details-table tr {
    display: block;
    border-bottom: 1px solid var(--line);
    padding: 10px 0;
  }

  .service-details-table td,
  .service-details-table td:first-child {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    width: 100%;
    padding: 5px 0;
    border: 0;
  }

  .service-details-table td::before {
    content: attr(data-label);
    flex: 1 0 46%;
    text-align: left;
    color: var(--muted);
    font-size: 0.75rem;
  }

  .service-details-table td:first-child::before,
  .service-details-table .empty-state::before {
    display: none;
  }

  .service-details-table td small {
    margin-top: 0;
  }

  .service-detail-name small {
    margin-top: 4px;
  }
}

.chart-box-large {
  height: 360px;
}

.mini-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.doctor-slot-panel .mini-metrics {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.laboratory-profit-metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mini-metric {
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(68, 188, 214, 0.22);
  border-radius: 8px;
  background: var(--surface-soft);
}

.mini-metric span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.25;
}

.mini-metric strong {
  display: block;
  font-family: "Unageo", "Rubik", Arial, sans-serif;
  font-size: 1.18rem;
  line-height: 1.15;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.compact-table table {
  min-width: 620px;
}

.chart-box + .table-wrap {
  margin-top: 14px;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

#medworkView .table-wrap {
  overflow-x: hidden;
}

#doctorPatientView .table-wrap {
  overflow-x: hidden;
}

#medworkView .medwork-table {
  min-width: 0;
  table-layout: fixed;
}

#doctorPatientView .medwork-table {
  min-width: 0;
  table-layout: fixed;
}

#laboratoryView .table-wrap {
  overflow-x: hidden;
}

#laboratoryView .lab-detail-table {
  min-width: 0;
  table-layout: fixed;
}

#medworkView .medwork-table th,
#medworkView .medwork-table td {
  padding: 11px 10px;
  overflow-wrap: anywhere;
  font-size: 0.82rem;
}

#doctorPatientView .medwork-table th,
#doctorPatientView .medwork-table td {
  padding: 11px 10px;
  overflow-wrap: anywhere;
  font-size: 0.82rem;
}

#medworkView .medwork-table th {
  font-size: 0.68rem;
}

#doctorPatientView .medwork-table th {
  font-size: 0.68rem;
}

#laboratoryView .lab-detail-table th,
#laboratoryView .lab-detail-table td {
  padding: 11px 10px;
  overflow-wrap: anywhere;
  white-space: normal;
  font-size: 0.82rem;
}

#laboratoryView .lab-detail-table th {
  font-size: 0.68rem;
}

#laboratoryView .lab-detail-table .numeric {
  text-align: right;
  white-space: nowrap;
}

#laboratoryView .lab-services-table th:first-child,
#laboratoryView .lab-services-table td:first-child,
#laboratoryView .lab-unmatched-table th:first-child,
#laboratoryView .lab-unmatched-table td:first-child {
  width: 10%;
}

#laboratoryView .lab-services-table th:nth-child(2),
#laboratoryView .lab-services-table td:nth-child(2) {
  width: 34%;
}

#laboratoryView .lab-unmatched-table th:nth-child(2),
#laboratoryView .lab-unmatched-table td:nth-child(2) {
  width: 36%;
}

#patientMapView .table-wrap {
  overflow-x: hidden;
}

#patientMapView .patient-map-table {
  min-width: 0;
  table-layout: fixed;
}

#patientMapView .patient-map-table th,
#patientMapView .patient-map-table td {
  padding: 11px 10px;
  overflow-wrap: anywhere;
  white-space: normal;
  font-size: 0.82rem;
}

#patientMapView .patient-map-table th {
  font-size: 0.68rem;
}

#patientMapView .patient-map-table th.numeric,
#patientMapView .patient-map-table td.numeric {
  text-align: right;
  white-space: nowrap;
}

#patientMapView .patient-map-table td.numeric span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.72rem;
}

#patientMapView .patient-map-regions-table th:first-child,
#patientMapView .patient-map-regions-table td:first-child {
  width: 48%;
}

#patientMapView .patient-map-locations-table th:first-child,
#patientMapView .patient-map-locations-table td:first-child,
#patientMapView .patient-map-unmapped-table th:first-child,
#patientMapView .patient-map-unmapped-table td:first-child {
  width: 34%;
}

#patientMapView .patient-house-table th:first-child,
#patientMapView .patient-house-table td:first-child {
  width: 32%;
}

#patientMapView .patient-house-table th:nth-child(2),
#patientMapView .patient-house-table td:nth-child(2) {
  width: 26%;
}

#patientMapView .patient-house-other-table th:first-child,
#patientMapView .patient-house-other-table td:first-child {
  width: 48%;
}

#laboratoryView .lab-groups-table th:first-child,
#laboratoryView .lab-groups-table td:first-child {
  width: 36%;
}

#medworkView .medwork-table th:not(:first-child),
#medworkView .medwork-table td:not(:first-child) {
  text-align: right;
}

#doctorPatientView .medwork-table th:not(:first-child),
#doctorPatientView .medwork-table td:not(:first-child) {
  text-align: right;
}

#medworkView .medwork-services-table th:first-child,
#medworkView .medwork-services-table td:first-child,
#medworkView .medwork-resources-table th:first-child,
#medworkView .medwork-resources-table td:first-child,
#medworkView .medwork-directions-table th:first-child,
#medworkView .medwork-directions-table td:first-child,
#medworkView .medwork-doctor-table th:first-child,
#medworkView .medwork-doctor-table td:first-child {
  width: 44%;
}

#doctorPatientView .medwork-doctor-table th:first-child,
#doctorPatientView .medwork-doctor-table td:first-child {
  width: 42%;
}

#doctorPatientView .doctor-slot-table th:first-child,
#doctorPatientView .doctor-slot-table td:first-child {
  width: 28%;
}

#medworkView .medwork-unified-table th:first-child,
#medworkView .medwork-unified-table td:first-child {
  width: 42%;
}

#medworkView .medwork-laboratory-table th:first-child,
#medworkView .medwork-laboratory-table td:first-child,
#medworkView .medwork-sources-table th:first-child,
#medworkView .medwork-sources-table td:first-child {
  width: 52%;
}

#medworkView .medwork-laboratory-table th:first-child,
#medworkView .medwork-laboratory-table td:first-child {
  width: 40%;
}

#doctorPatientView .medwork-sources-table th:first-child,
#doctorPatientView .medwork-sources-table td:first-child {
  width: 52%;
}

.slot-level {
  display: inline-flex;
  justify-content: center;
  min-width: 86px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
  white-space: normal;
}

.slot-level-good {
  color: #14753b;
  background: rgba(37, 177, 91, 0.14);
}

.slot-level-warning {
  color: #8a5a00;
  background: rgba(234, 171, 50, 0.18);
}

.slot-level-danger {
  color: #a13737;
  background: rgba(220, 74, 74, 0.14);
}

.slot-level-muted {
  color: var(--muted);
  background: rgba(104, 114, 127, 0.12);
}

.slot-recommendation {
  display: inline-flex;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 0.74rem;
  font-weight: 500;
  line-height: 1.2;
}

.slot-recommendation-good {
  color: #14753b;
  background: rgba(37, 177, 91, 0.12);
}

.slot-recommendation-warning {
  color: #8a5a00;
  background: rgba(234, 171, 50, 0.16);
}

.slot-recommendation-danger {
  color: #a13737;
  background: rgba(220, 74, 74, 0.12);
}

.slot-recommendation-muted {
  color: var(--muted);
  background: rgba(104, 114, 127, 0.12);
}

.doctor-slot-table tr.slot-row-good td:first-child {
  box-shadow: inset 4px 0 0 #25b15b;
}

.doctor-slot-table tr.slot-row-warning td:first-child {
  box-shadow: inset 4px 0 0 #eaab32;
}

.doctor-slot-table tr.slot-row-danger td:first-child {
  box-shadow: inset 4px 0 0 #dc4a4a;
}

.doctor-slot-table tr.slot-row-muted td:first-child {
  box-shadow: inset 4px 0 0 rgba(104, 114, 127, 0.32);
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 0.88rem;
}

th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 0.76rem;
  font-weight: 500;
  text-transform: uppercase;
}

td:nth-child(2),
td:nth-child(3),
td:nth-child(4) {
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: 0;
}

.empty-state {
  padding: 26px;
  color: var(--muted);
  text-align: center;
}

.patient-map-mode {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  margin: -4px 0 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.patient-map-mode button {
  min-width: 92px;
  padding: 9px 14px;
  border: 0;
  border-right: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
}

.patient-map-mode button:last-child {
  border-right: 0;
}

.patient-map-mode button:hover {
  color: var(--accent);
  background: rgba(147, 37, 128, 0.06);
}

.patient-map-mode button.is-active {
  color: #fff;
  background: var(--accent);
}

.patient-map-canvas {
  position: relative;
  height: 680px;
  min-height: 680px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-soft);
}

.patient-map-empty {
  display: grid;
  place-items: center;
  min-height: 680px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.patient-map-legend {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.patient-map-legend div {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(68, 188, 214, 0.2);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 0.78rem;
}

.patient-map-legend strong {
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
}

.patient-map-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.patient-map-popup {
  display: grid;
  gap: 5px;
  min-width: 190px;
  margin: 8px 0 0;
}

.patient-map-popup div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.patient-map-popup dt,
.patient-map-popup dd {
  margin: 0;
}

.patient-map-popup dt {
  color: var(--muted);
}

.patient-map-popup dd {
  font-weight: 600;
}

.leaflet-container {
  font-family: "Rubik", Arial, sans-serif;
}

.patient-house-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.patient-house-split {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.patient-house-split h3 {
  margin: 0 0 8px;
  color: var(--text);
  font-family: "Unageo", "Rubik", Arial, sans-serif;
  font-size: 0.95rem;
  line-height: 1.2;
}

@media (max-width: 1280px) {
  .summary-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #medworkView .dashboard-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  #doctorPatientView .dashboard-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  #laboratoryView .dashboard-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  #patientMapView .dashboard-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  #medworkView .medwork-main-panel,
  #medworkView .medwork-appointments-panel,
  #medworkView .medwork-half-panel {
    grid-column: 1 / -1;
  }

  #doctorPatientView .medwork-appointments-panel,
  #doctorPatientView .doctor-slot-panel,
  #doctorPatientView .medwork-half-panel {
    grid-column: 1 / -1;
  }

  #laboratoryView .laboratory-overview-panel,
  #laboratoryView .laboratory-match-panel,
  #laboratoryView .laboratory-full-panel {
    grid-column: 1 / -1;
  }

  #patientMapView .patient-map-panel,
  #patientMapView .patient-map-side-panel,
  #patientMapView .patient-map-full-panel,
  #patientMapView .patient-map-wide-panel {
    grid-column: 1 / -1;
  }

  #medworkView .medwork-service-mix-panel,
  #medworkView .medwork-patients-panel {
    grid-column: span 3;
  }

  #doctorPatientView .medwork-patients-panel {
    grid-column: span 3;
  }

  .patient-map-legend {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .patient-house-split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 880px) {
  .app-shell {
    padding: 14px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .brand {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-logo {
    width: 164px;
  }

  .filters {
    justify-content: stretch;
  }

  .date-field {
    flex: 1 1 150px;
  }

  .quick-range {
    flex: 1 1 100%;
  }

  .quick-range button {
    flex: 1;
  }

  .dashboard-tabs {
    display: flex;
    width: 100%;
  }

  .dashboard-tabs button {
    flex: 1;
    padding: 0 10px;
  }

  .summary-strip,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  #medworkView .summary-strip,
  #doctorPatientView .summary-strip,
  #patientMapView .summary-strip {
    grid-template-columns: 1fr;
  }

  #medworkView .dashboard-grid {
    grid-template-columns: 1fr;
  }

  #doctorPatientView .dashboard-grid {
    grid-template-columns: 1fr;
  }

  #laboratoryView .dashboard-grid {
    grid-template-columns: 1fr;
  }

  #patientMapView .dashboard-grid {
    grid-template-columns: 1fr;
  }

  #medworkView .medwork-main-panel,
  #medworkView .medwork-appointments-panel,
  #medworkView .medwork-service-mix-panel,
  #medworkView .medwork-patients-panel,
  #medworkView .medwork-half-panel {
    grid-column: 1;
  }

  #doctorPatientView .medwork-appointments-panel,
  #doctorPatientView .doctor-slot-panel,
  #doctorPatientView .medwork-patients-panel,
  #doctorPatientView .medwork-half-panel {
    grid-column: 1;
  }

  #laboratoryView .laboratory-overview-panel,
  #laboratoryView .laboratory-match-panel,
  #laboratoryView .laboratory-full-panel {
    grid-column: 1;
  }

  #patientMapView .patient-map-panel,
  #patientMapView .patient-map-side-panel,
  #patientMapView .patient-map-full-panel,
  #patientMapView .patient-map-wide-panel {
    grid-column: 1;
  }

  #laboratoryView .table-wrap {
    overflow-x: auto;
  }

  #patientMapView .table-wrap {
    overflow-x: auto;
  }

  .patient-map-canvas,
  .patient-map-empty {
    height: 420px;
    min-height: 420px;
  }

  .patient-map-mode {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .patient-map-mode button {
    min-width: 0;
    padding: 9px 8px;
  }

  .patient-map-legend {
    grid-template-columns: 1fr;
  }

  .patient-house-metrics {
    grid-template-columns: 1fr;
  }

  .mini-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .doctor-slot-panel .mini-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-wide {
    grid-column: span 1;
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 1.45rem;
  }

  .metric-card {
    min-height: 112px;
  }

  .mini-metrics {
    grid-template-columns: 1fr;
  }

  .doctor-slot-panel .mini-metrics {
    grid-template-columns: 1fr;
  }

  .chart-legend-item {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .chart-legend-value {
    grid-column: 2;
    white-space: normal;
  }

  .chart-box,
  .chart-box-large {
    height: 280px;
  }
}

/* Constructor-inspired production shell */
.app-shell {
  width: min(1520px, 100%);
}

.topbar {
  min-height: 96px;
  gap: 20px;
  background: rgba(255, 255, 255, 0.94);
}

.workspace.live-workspace {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.scenario-panel {
  display: grid;
  gap: 14px;
  position: sticky;
  top: 18px;
  min-width: 0;
}

.dashboard-tabs.scenario-list {
  display: grid;
  gap: 10px;
  width: 100%;
  margin-top: 0;
  border: 0;
  border-radius: 0;
  overflow: visible;
  background: transparent;
  box-shadow: none;
}

.dashboard-tabs.scenario-list button {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 28px rgba(45, 45, 45, 0.05);
  text-align: left;
}

.dashboard-tabs.scenario-list button img {
  width: 34px;
  height: 34px;
  padding: 7px;
  border-radius: 8px;
  background: rgba(68, 188, 214, 0.13);
}

.dashboard-tabs.scenario-list button span,
.dashboard-tabs.scenario-list button strong,
.dashboard-tabs.scenario-list button small {
  display: block;
  min-width: 0;
}

.dashboard-tabs.scenario-list button strong {
  margin-bottom: 4px;
  font-size: 0.95rem;
}

.dashboard-tabs.scenario-list button small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.3;
}

.dashboard-tabs.scenario-list button.is-active {
  color: var(--text);
  border-color: rgba(147, 37, 128, 0.45);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: inset 4px 0 0 var(--accent), 0 14px 34px rgba(147, 37, 128, 0.1);
}

.presentation-rail {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid rgba(68, 148, 216, 0.28);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(45, 45, 45, 0.05);
}

.presentation-rail span {
  display: block;
  color: var(--main-strong);
  font-size: 0.78rem;
  font-weight: 500;
}

.presentation-rail strong {
  display: block;
  margin-top: 4px;
  font-family: "Unageo", "Rubik", Arial, sans-serif;
  font-size: 1.1rem;
}

.presentation-rail p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.dashboard-stage {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.hero-band {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  min-height: 130px;
  padding: 22px;
  border-radius: 8px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(45, 45, 45, 0.72), rgba(36, 157, 183, 0.88)),
    url("../img/pattern.svg") center / 520px auto;
  box-shadow: var(--shadow);
}

.hero-band .eyebrow {
  color: rgba(255, 255, 255, 0.8);
}

.hero-band h2 {
  margin: 0;
  color: #fff;
  font-size: 1.8rem;
  line-height: 1.12;
}

.hero-band p {
  margin: 8px 0 0;
  max-width: 760px;
  color: rgba(255, 255, 255, 0.84);
  line-height: 1.45;
}

.status-stack {
  display: grid;
  justify-items: end;
  gap: 8px;
  min-width: 170px;
}

.status-stack span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  padding: 0 12px;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
}

.dashboard-stage .dashboard-view.is-active {
  display: grid;
  gap: 18px;
}

.dashboard-stage .summary-strip,
#medworkView .summary-strip,
#doctorPatientView .summary-strip {
  grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
  gap: 14px;
}

.dashboard-stage .metric-card {
  min-height: 136px;
  padding: 18px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(45, 45, 45, 0.05);
}

.dashboard-stage .metric-card strong {
  font-size: 1.55rem;
}

.dashboard-stage .panel {
  display: grid;
  gap: 16px;
  min-height: 360px;
  box-shadow: 0 12px 32px rgba(45, 45, 45, 0.055);
}

.dashboard-stage .panel-heading {
  margin-bottom: 0;
}

.dashboard-stage .panel-heading span {
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid rgba(68, 188, 214, 0.28);
  color: var(--main-strong);
  background: rgba(68, 188, 214, 0.11);
}

.dashboard-stage .chart-box {
  min-height: 276px;
}

.dashboard-stage .chart-box-large {
  min-height: 316px;
}

@media (max-width: 1180px) {
  .workspace.live-workspace {
    grid-template-columns: 1fr;
  }

  .scenario-panel {
    position: static;
  }

  .dashboard-tabs.scenario-list {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .dashboard-tabs.scenario-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .workspace.live-workspace {
    gap: 14px;
  }

  .dashboard-tabs.scenario-list {
    grid-template-columns: 1fr;
  }

  .hero-band {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-stack {
    justify-items: start;
  }
}
