:root {
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --text: #17202a;
  --muted: #617083;
  --line: #d9e0e7;
  --primary: #1769e0;
  --primary-dark: #1155b4;
  --doctor-1: #8b5cf6;
  --doctor-1-soft: #f3ecff;
  --doctor-1-card: #fbf8ff;
  --doctor-1-border: #eadcff;
  --doctor-2: #14b8a6;
  --doctor-2-soft: #e9fbf7;
  --doctor-2-card: #f4fdfb;
  --doctor-2-border: #cdf4ed;
  --danger: #b42318;
  --warning: #8a5a00;
  --ok: #16794f;
  --radius: 8px;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 24px;
}

h2 {
  margin-bottom: 14px;
  font-size: 18px;
}

h3 {
  margin-bottom: 4px;
  font-size: 16px;
}

.topbar-actions,
.dialog-actions,
.dialog-actions-right,
.toolbar,
.segmented,
.view-switch,
.card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.api-status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.api-status.connected {
  color: var(--ok);
}

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  padding: 18px;
}

.sidebar,
.content {
  min-width: 0;
}

.panel,
.content {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
  margin-bottom: 14px;
}

.btn.full {
  width: 100%;
}

.content {
  padding: 18px;
  background: #ffffff;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stats div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.stats span {
  display: block;
  font-size: 24px;
  font-weight: 700;
}

.stats small,
.meta,
.notes,
#agendaSubtitle {
  color: var(--muted);
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.doctor-key {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: #344256;
  font-size: 14px;
}

.doctor-key span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.key-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.key-dot.doctor-1 {
  background: var(--doctor-1);
}

.key-dot.doctor-2 {
  background: var(--doctor-2);
}

.field span {
  color: #3d4a5c;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
}

textarea {
  resize: vertical;
}

.search {
  margin-bottom: 10px;
}

#newPatientBtn {
  margin-bottom: 10px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
}

.btn.primary:hover {
  background: var(--primary-dark);
}

.btn.secondary {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.btn.danger {
  background: #fff;
  border-color: #f0b8b3;
  color: var(--danger);
}

.btn.small {
  padding: 7px 9px;
  font-size: 13px;
}

.file-btn {
  display: inline-block;
}

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

.toolbar {
  justify-content: space-between;
  margin-bottom: 16px;
}

.segmented {
  gap: 0;
}

.segmented button,
.view-switch button {
  border: 1px solid var(--line);
  background: #fff;
  padding: 9px 12px;
  cursor: pointer;
}

.segmented button:first-child,
.view-switch button:first-child {
  border-radius: 6px 0 0 6px;
}

.segmented button:last-child,
.view-switch button:last-child {
  border-radius: 0 6px 6px 0;
}

.view-switch {
  gap: 0;
}

.view-switch button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.appointments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 12px;
}

.day-column {
  min-height: 180px;
  border: 1px solid #d8e0e8;
  border-radius: var(--radius);
  background: #ffffff;
  overflow: hidden;
}

.doctor-column.doctor-1 {
  border-top: 4px solid var(--doctor-1);
}

.doctor-column.doctor-2 {
  border-top: 4px solid var(--doctor-2);
}

.doctor-column.doctor-1 .day-column-header {
  background: var(--doctor-1-soft);
}

.doctor-column.doctor-2 .day-column-header {
  background: var(--doctor-2-soft);
}

.day-column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}

.day-column-header strong {
  font-size: 15px;
}

.day-column-body {
  display: grid;
  gap: 7px;
  padding: 10px;
}

.empty {
  padding: 16px;
  color: var(--muted);
  text-align: center;
}

.empty.compact {
  padding: 10px;
}

.appointment-card {
  border: 1px solid var(--line);
  border-left: 5px solid var(--primary);
  border-radius: 6px;
  background: var(--surface);
  padding: 8px 9px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.appointment-card:hover {
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.1);
  transform: translateY(-1px);
}

.appointment-card.status-confirmed {
  border-left-color: var(--ok);
}

.appointment-card.status-change {
  border-left-color: var(--warning);
}

.appointment-card.status-no_response {
  border-left-color: #64748b;
}

.appointment-card.status-cancelled {
  border-left-color: var(--danger);
  opacity: 0.78;
}

.appointment-card.doctor-1 {
  background: var(--doctor-1-card);
  border-color: var(--doctor-1-border);
  border-left-color: var(--doctor-1);
}

.appointment-card.doctor-2 {
  background: var(--doctor-2-card);
  border-color: var(--doctor-2-border);
  border-left-color: var(--doctor-2);
}

.appointment-main {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 8px;
}

.time {
  align-self: start;
  padding: 6px;
  border-radius: 6px;
  background: var(--surface-2);
  font-weight: 700;
  font-size: 13px;
  text-align: center;
}

.time small {
  display: block;
  margin-top: 2px;
  color: inherit;
  font-size: 10px;
  font-weight: 700;
}

.appointment-card.doctor-1 .time {
  background: #eadcff;
  color: #5b21b6;
}

.appointment-card.doctor-2 .time {
  background: #d9f7f1;
  color: #0f766e;
}

.appointment-card h3 {
  margin-bottom: 2px;
  font-size: 14px;
}

.appointment-card .meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  font-size: 12px;
}

.notes {
  min-height: 20px;
  margin: 6px 0 8px 60px;
  font-size: 12px;
  line-height: 1.35;
  white-space: pre-wrap;
}

.status-pill {
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 4px 7px;
}

.status-pill.status-pending {
  background: var(--primary);
}

.status-pill.status-confirmed {
  background: var(--ok);
}

.status-pill.status-change {
  background: var(--warning);
}

.status-pill.status-no_response {
  background: #64748b;
}

.status-pill.status-cancelled {
  background: var(--danger);
}

.appointment-card .card-actions {
  justify-content: flex-end;
}

.appointment-card .status-select {
  max-width: 132px;
  padding: 6px 8px;
  font-size: 12px;
}

.patient-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
}

.patient-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 10px;
  cursor: pointer;
}

.patient-item strong {
  display: block;
  margin-bottom: 4px;
}

.patient-item small {
  color: var(--muted);
}

.dialog {
  width: min(760px, calc(100vw - 28px));
  border: 0;
  border-radius: var(--radius);
  box-shadow: 0 24px 72px rgba(15, 23, 42, 0.24);
  padding: 0;
}

.dialog.small-dialog {
  width: min(440px, calc(100vw - 28px));
}

.dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.dialog form,
.dialog-body {
  padding: 18px;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.dialog-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
}

.form-error {
  margin: 4px 0 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

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

.dialog-actions {
  justify-content: space-between;
  margin-top: 18px;
}

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

.patient-appointment-group h3 {
  margin: 0 0 8px;
  color: #344256;
  font-size: 15px;
}

.patient-appointment {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  padding: 11px;
  text-align: left;
}

.patient-appointment span {
  color: var(--muted);
}

.patient-appointment small {
  color: var(--muted);
}

@media (max-width: 900px) {
  .topbar,
  .toolbar,
  .dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }

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

  .topbar-actions,
  .dialog-actions-right {
    flex-wrap: wrap;
  }
}

@media (max-width: 560px) {
  .layout {
    padding: 10px;
  }

  .topbar {
    padding: 14px;
  }

  .form-grid,
  .appointments-grid {
    grid-template-columns: 1fr;
  }

  .card-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
