:root {
  color: #172026;
  background: #f5f7f8;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: #f5f7f8;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 256px minmax(0, 1fr);
}

.sidebar {
  border-right: 1px solid #dfe5e7;
  background: #ffffff;
  padding: 20px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 24px;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  background: #0f766e;
  color: #ffffff;
  font-size: 0.88rem;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 2px;
  color: #617177;
  font-size: 0.78rem;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #3d4c52;
  cursor: pointer;
  font: inherit;
  padding: 10px 12px;
  text-align: left;
  text-decoration: none;
}

.nav-item:hover,
.nav-item.active {
  background: #e7f4f2;
  color: #0f766e;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #607076;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  color: #172026;
  line-height: 1.15;
}

h1 {
  font-size: 1.85rem;
}

h2 {
  font-size: 1.15rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.metric {
  display: flex;
  min-width: 92px;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  border: 1px solid #dfe5e7;
  border-radius: 8px;
  background: #ffffff;
  padding: 8px 10px;
}

.metric strong {
  color: #0f766e;
}

.metric small {
  color: #607076;
}

.primary-action {
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  background: #0f766e;
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
  padding: 0 14px;
}

.primary-action:hover {
  background: #0b5f59;
}

.primary-action.secondary {
  border: 1px solid #cdd8db;
  background: #ffffff;
  color: #334247;
}

.primary-action.secondary:hover {
  background: #f1f5f6;
}

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(245, 247, 248, 0.94), rgba(235, 242, 243, 0.96)),
    #f5f7f8;
  padding: 24px;
}

.auth-panel {
  width: min(100%, 420px);
  border: 1px solid #d7e1e4;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 50px rgba(23, 32, 38, 0.1);
  padding: 28px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.auth-brand strong,
.auth-brand small {
  display: block;
}

.auth-brand small {
  margin-top: 2px;
  color: #617177;
  font-size: 0.78rem;
}

.auth-copy {
  display: grid;
  gap: 10px;
  margin-bottom: 22px;
}

.auth-copy p {
  margin: 0;
  color: #52646b;
  line-height: 1.55;
}

.auth-alert {
  border: 1px solid #f1c7bc;
  border-radius: 8px;
  background: #fff2ee;
  color: #8a2f1f;
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 16px;
  padding: 12px;
}

.auth-submit {
  width: 100%;
}

.auth-status {
  color: #607076;
  font-size: 0.88rem;
  font-weight: 700;
}

.auth-status.error {
  color: #a73923;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-badge {
  max-width: 220px;
  overflow: hidden;
  border: 1px solid #dfe5e7;
  border-radius: 999px;
  background: #ffffff;
  color: #334247;
  font-size: 0.86rem;
  font-weight: 700;
  padding: 8px 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-content {
  display: grid;
  gap: 20px;
}

.dashboard-page {
  display: grid;
  gap: 16px;
}

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

.dashboard-metric {
  min-height: 112px;
  border: 1px solid #dfe5e7;
  border-left: 4px solid #94a3aa;
  border-radius: 8px;
  background: #ffffff;
  padding: 16px;
}

.dashboard-metric.primary {
  border-left-color: #0f766e;
}

.dashboard-metric.warning {
  border-left-color: #b7791f;
}

.dashboard-metric.danger {
  border-left-color: #b23b2b;
}

.dashboard-metric span,
.dashboard-metric small {
  display: block;
  color: #607076;
}

.dashboard-metric strong {
  display: block;
  margin: 8px 0 4px;
  color: #172026;
  font-size: 1.8rem;
  line-height: 1;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 16px;
  align-items: start;
}

.dashboard-panel {
  min-height: 0;
}

.agenda-panel {
  grid-row: span 2;
}

.appointment-list,
.queue-list,
.work-list {
  display: grid;
}

.appointment-row,
.queue-item,
.work-item {
  display: grid;
  gap: 10px;
  border-bottom: 1px solid #edf1f2;
  padding: 14px 16px;
}

.appointment-row {
  grid-template-columns: 72px minmax(0, 1fr) max-content;
  align-items: center;
}

.queue-item {
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: center;
}

.work-item {
  border-left: 4px solid transparent;
}

.work-item.warning {
  border-left-color: #b7791f;
}

.work-item.danger {
  border-left-color: #b23b2b;
}

.work-item.success {
  border-left-color: #0f766e;
}

.appointment-row:last-child,
.queue-item:last-child,
.work-item:last-child {
  border-bottom: 0;
}

.appointment-row time {
  color: #0f766e;
  font-size: 0.95rem;
  font-weight: 800;
}

.appointment-row strong,
.queue-item strong,
.work-item strong {
  display: block;
  color: #172026;
}

.appointment-row span,
.queue-item span,
.work-item span {
  display: block;
  margin-top: 3px;
  color: #607076;
  font-size: 0.88rem;
  line-height: 1.4;
}

.appointment-row em,
.queue-item em {
  border-radius: 999px;
  background: #edf1f2;
  color: #45555b;
  font-size: 0.76rem;
  font-style: normal;
  font-weight: 800;
  padding: 5px 8px;
  white-space: nowrap;
}

.agenda-page {
  display: grid;
  gap: 16px;
}

.agenda-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
}

.agenda-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.agenda-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
}

.agenda-day {
  padding: 0;
}

.agenda-time-grid {
  display: grid;
}

.agenda-slot,
.agenda-appointment,
.agenda-block {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 12px;
  min-height: 54px;
  border-bottom: 1px solid #edf1f2;
  padding: 12px 16px;
}

.agenda-slot {
  color: #8a9aa0;
}

.agenda-slot span {
  border-top: 1px dashed #dfe5e7;
  transform: translateY(13px);
}

.agenda-appointment {
  grid-template-columns: 74px minmax(0, 1fr) max-content max-content;
  align-items: center;
  border-left: 4px solid #0f766e;
  background: #fbfefe;
}

.agenda-block {
  align-items: center;
  border-left: 4px solid #94a3aa;
  background: #f8fafb;
}

.agenda-appointment time,
.agenda-block time,
.agenda-slot time {
  color: #607076;
  font-weight: 800;
}

.agenda-appointment strong,
.agenda-block strong {
  display: block;
  color: #172026;
}

.agenda-appointment span {
  display: block;
  margin-top: 3px;
  color: #607076;
  font-size: 0.88rem;
}

.agenda-appointment em {
  border-radius: 999px;
  background: #dff3ec;
  color: #0f6b4d;
  font-size: 0.76rem;
  font-style: normal;
  font-weight: 800;
  padding: 5px 8px;
  white-space: nowrap;
}

.agenda-appointment small {
  color: #607076;
  font-weight: 700;
  white-space: nowrap;
}

.agenda-side {
  overflow: hidden;
}

.agenda-filter-list,
.agenda-status-list {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.agenda-status-list {
  border-top: 1px solid #edf1f2;
}

.filter-pill {
  border: 1px solid #edf1f2;
  border-radius: 8px;
  background: #fbfcfc;
  padding: 10px;
}

.filter-pill span {
  display: block;
  color: #607076;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.filter-pill strong {
  display: block;
  margin-top: 4px;
  color: #172026;
}

.status-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #334247;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #94a3aa;
}

.status-dot.success {
  background: #0f766e;
}

.status-dot.warning {
  background: #b7791f;
}

.status-dot.danger {
  background: #b23b2b;
}

.clinical-page {
  display: grid;
  gap: 16px;
}

.clinical-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
}

.clinical-header p {
  margin: 6px 0 0;
  color: #607076;
}

.clinical-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

.note-editor {
  padding: 16px;
}

.note-context {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #edf1f2;
  padding-bottom: 16px;
}

.note-state {
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  padding: 6px 9px;
  white-space: nowrap;
}

.note-state.draft {
  background: #fff4d6;
  color: #8a5a13;
}

.note-state.blocked {
  background: #edf1f2;
  color: #45555b;
}

.soap-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.soap-section {
  display: grid;
  gap: 6px;
  border: 1px solid #edf1f2;
  border-radius: 8px;
  background: #fbfcfc;
  padding: 12px;
}

.soap-section span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 7px;
  background: #0f766e;
  color: #ffffff;
  font-weight: 900;
}

.soap-section strong {
  color: #172026;
}

.soap-section textarea {
  width: 100%;
  min-height: 132px;
  resize: vertical;
  border: 1px solid #dfe5e7;
  border-radius: 7px;
  color: #334247;
  line-height: 1.45;
  padding: 10px;
}

.soap-section textarea:focus {
  border-color: #0f766e;
  outline: 2px solid #bfe3dd;
  outline-offset: 0;
}

.note-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid #edf1f2;
  margin-top: 16px;
  padding-top: 16px;
}

.clinical-side {
  display: grid;
  gap: 16px;
}

.note-history {
  overflow: hidden;
}

.note-history-item {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  border-bottom: 1px solid #edf1f2;
  padding: 14px 16px;
}

.note-history-item:last-child {
  border-bottom: 0;
}

.note-history-item time {
  color: #607076;
  font-size: 0.82rem;
  font-weight: 800;
}

.note-history-item strong,
.note-history-item span {
  display: block;
}

.note-history-item strong {
  color: #172026;
}

.note-history-item span {
  margin-top: 3px;
  color: #607076;
  font-size: 0.86rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.summary-card {
  border: 1px solid #dfe5e7;
  border-radius: 8px;
  background: #ffffff;
  padding: 16px;
}

.summary-card span,
.summary-card small {
  display: block;
  color: #607076;
}

.summary-card strong {
  display: block;
  margin: 6px 0 2px;
  color: #172026;
  font-size: 1.65rem;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.45fr);
  gap: 16px;
  align-items: start;
}

.panel,
.detail-panel {
  border: 1px solid #dfe5e7;
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid #dfe5e7;
  padding: 16px;
}

.search-shell {
  display: flex;
  min-width: min(460px, 100%);
  align-items: center;
  gap: 8px;
}

.search-shell input,
.search-shell select {
  width: 100%;
  min-height: 38px;
  border: 1px solid #dfe5e7;
  border-radius: 7px;
  color: #334247;
  padding: 0 12px;
}

.search-shell select {
  max-width: 150px;
  background: #ffffff;
}

.search-shell input:focus,
.search-shell select:focus {
  border-color: #0f766e;
  outline: 2px solid #bfe3dd;
  outline-offset: 0;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid #edf1f2;
  padding: 12px 16px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f8fafb;
  color: #607076;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

td {
  color: #334247;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected-row {
  background: #f2faf8;
}

.mono {
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.88rem;
}

.status {
  display: inline-flex;
  min-width: 72px;
  justify-content: center;
  border-radius: 999px;
  background: #edf1f2;
  color: #45555b;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 4px 8px;
}

.status.active {
  background: #dff3ec;
  color: #0f6b4d;
}

.status.inactive {
  background: #f2e5e5;
  color: #9a3412;
}

.state-box {
  margin: 16px;
  border: 1px dashed #cbd5d8;
  border-radius: 8px;
  color: #607076;
  padding: 24px;
}

.state-box.error {
  border-color: #f1b4a9;
  background: #fff7f5;
  color: #a73923;
}

.detail-panel {
  padding: 16px;
}

.patient-chart {
  display: grid;
  gap: 16px;
}

.chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #edf1f2;
  padding-bottom: 16px;
}

.chart-subtitle {
  display: block;
  margin-top: 6px;
  color: #607076;
  font-size: 0.9rem;
}

.chart-identity {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.chart-identity div {
  border: 1px solid #edf1f2;
  border-radius: 8px;
  background: #fbfcfc;
  padding: 10px;
}

.chart-identity span {
  display: block;
  color: #607076;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.chart-identity strong {
  display: block;
  margin-top: 4px;
  color: #26343a;
  overflow-wrap: anywhere;
}

.chart-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  border-bottom: 1px solid #edf1f2;
}

.chart-tabs button {
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: #607076;
  cursor: pointer;
  font-weight: 800;
  padding: 8px 10px 10px;
  white-space: nowrap;
}

.chart-tabs button.active,
.chart-tabs button:hover {
  border-bottom-color: #0f766e;
  color: #0f766e;
}

.chart-section {
  border: 1px solid #edf1f2;
  border-radius: 8px;
  background: #ffffff;
  padding: 14px;
}

.chart-section.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.chart-section h3,
.chart-section p {
  margin: 0;
}

.chart-section h3 {
  color: #172026;
  font-size: 1rem;
}

.chart-section p,
.chart-section span {
  color: #607076;
  font-size: 0.88rem;
  line-height: 1.45;
}

.chart-section strong {
  display: block;
  color: #172026;
}

.detail-header {
  display: grid;
  gap: 8px;
  border-bottom: 1px solid #edf1f2;
  padding-bottom: 16px;
}

.detail-list {
  display: grid;
  gap: 14px;
  margin: 16px 0 0;
}

.detail-list div {
  display: grid;
  gap: 4px;
}

.detail-list dt {
  color: #607076;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-list dd {
  margin: 0;
  color: #26343a;
  overflow-wrap: anywhere;
}

.detail-empty {
  display: grid;
  gap: 8px;
  color: #607076;
}

.detail-empty p {
  margin: 0;
}

.patient-form {
  display: grid;
  gap: 14px;
}

.patient-form label {
  display: grid;
  gap: 6px;
}

.patient-form label span {
  color: #607076;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.patient-form input,
.patient-form select {
  min-height: 38px;
  width: 100%;
  border: 1px solid #dfe5e7;
  border-radius: 7px;
  color: #334247;
  padding: 0 10px;
}

.patient-form input:focus,
.patient-form select:focus {
  border-color: #0f766e;
  outline: 2px solid #bfe3dd;
  outline-offset: 0;
}

.form-actions {
  display: flex;
  gap: 8px;
}

.form-feedback {
  border: 1px solid #c9e3dc;
  border-radius: 8px;
  background: #f1faf7;
  color: #0f6b4d;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 10px 12px;
}

.form-feedback.error {
  border-color: #f1b4a9;
  background: #fff7f5;
  color: #a73923;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid #dfe5e7;
  }

  .nav-list {
    grid-template-columns: repeat(5, minmax(max-content, 1fr));
    overflow-x: auto;
  }

  .workspace {
    padding: 16px;
  }

  .topbar,
  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .search-shell {
    width: 100%;
  }

  .topbar-actions,
  .user-menu {
    flex-wrap: wrap;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-metrics,
  .dashboard-grid,
  .agenda-layout,
  .clinical-layout {
    grid-template-columns: 1fr;
  }

  .appointment-row {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .appointment-row em {
    grid-column: 2;
    width: max-content;
  }

  .agenda-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .agenda-appointment {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .agenda-appointment em,
  .agenda-appointment small {
    grid-column: 2;
    width: max-content;
  }

  .clinical-header,
  .note-context,
  .note-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .soap-grid {
    grid-template-columns: 1fr;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .chart-identity,
  .chart-section.split {
    grid-template-columns: 1fr;
  }

  .search-shell {
    flex-direction: column;
    align-items: stretch;
  }

  .search-shell select {
    max-width: none;
  }
}
