:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --border: #e8e4dc;
  --text: #2a2a2a;
  --text-dim: #8a8579;
  --accent: #8b9a4d;
  --accent-soft: rgba(139, 154, 77, 0.12);
  --warn: #c8954a;
  --warn-soft: rgba(200, 149, 74, 0.14);
  --neutral: #6f7a8a;
  --neutral-soft: rgba(111, 122, 138, 0.14);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding-left: 200px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.nav-rail {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 200px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 18px 12px;
  z-index: 10;
}
.nav-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.nav-brand .brand-name { font-weight: 700; font-size: 13px; letter-spacing: 0.2px; line-height: 1.2; }
.nav-links { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  color: var(--text-dim); text-decoration: none;
  font-size: 13px; font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav-link svg { flex-shrink: 0; }
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.page-title { font-weight: 600; font-size: 18px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; }
.logo-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #c4b56b);
}
.brand-name { font-weight: 600; letter-spacing: 0.2px; }

.next-send {
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px;
}
.next-send-label { font-size: 11px; text-transform: uppercase; color: var(--text-dim); letter-spacing: 0.5px; }
.next-send-value { font-weight: 600; font-size: 15px; }
.next-send-countdown { font-size: 12px; color: var(--accent); font-variant-numeric: tabular-nums; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 20px 28px 4px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 11px; text-transform: uppercase; color: var(--text-dim); letter-spacing: 0.5px; }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat-positive .stat-value { color: var(--accent); }
.stat-warn .stat-value { color: var(--warn); }

.layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 18px;
  padding: 20px 28px 32px;
}

.calendar-pane, .side-pane > .side-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.side-pane { display: flex; flex-direction: column; gap: 18px; }

.calendar-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
}
.calendar-header h2 { margin: 0; font-size: 16px; flex: 1; text-align: center; text-transform: capitalize; font-variant-numeric: tabular-nums; }

.view-toggle {
  display: inline-flex; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 2px; gap: 2px;
}
.toggle-btn {
  padding: 5px 12px; border: none; background: transparent; cursor: pointer;
  border-radius: 6px; font-size: 12px; font-weight: 600; color: var(--text-dim);
}
.toggle-btn:hover { color: var(--text); }
.toggle-btn.active { background: var(--surface); color: var(--accent); box-shadow: 0 1px 2px rgba(0,0,0,0.05); }

.table-toolbar {
  display: flex; gap: 10px; align-items: center;
  margin-bottom: 12px; flex-wrap: wrap;
}
.table-columns {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
.table-col { display: flex; flex-direction: column; }
.col-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-radius: 8px;
  margin-bottom: 8px;
}
.col-active { background: var(--accent-soft); color: var(--accent); }
.col-inactive { background: var(--bg); color: var(--text-dim); }
.col-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.col-count {
  background: var(--surface); padding: 2px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; min-width: 22px; text-align: center;
}
.col-active .col-count { color: var(--accent); }
.col-inactive .col-count { color: var(--text-dim); }

.appt-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: 8px 10px; border-radius: 7px;
  background: var(--surface); border: 1px solid var(--border);
  margin-bottom: 4px;
}
.appt-card:hover { background: var(--bg); }
.card-row-1 { display: flex; align-items: center; gap: 6px; }
.card-time { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 13px; color: var(--text); margin-left: auto; }
.card-row-2 { font-weight: 600; font-size: 13px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.card-tags { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.tag-chip {
  background: rgba(139, 154, 77, 0.18);
  color: var(--accent);
  padding: 1px 7px; border-radius: 4px;
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.card-row-3 {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  font-size: 11px; color: var(--text-dim);
}
.card-service { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-phone.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px; flex-shrink: 0; }

/* ============ Contacts page ============ */
.contacts-page { padding: 20px 28px 32px; }
.contacts-table-wrapper {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); overflow: hidden;
}
.contacts-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.contacts-table thead {
  background: var(--bg);
  text-align: left; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-dim);
}
.contacts-table th, .contacts-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.contacts-table tbody tr:last-child td { border-bottom: none; }
.contacts-table tbody tr:hover { background: var(--bg); }
.contacts-table .empty { text-align: center; color: var(--text-dim); padding: 32px 16px; }
.contacts-table .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; }

.contact-cell { display: flex; align-items: center; gap: 10px; }
.contact-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 700; font-size: 11px; letter-spacing: 0.5px;
  flex-shrink: 0;
}

/* ============ Logs page ============ */
.logs-page { padding: 20px 28px 32px; }
.check-row.inline { flex-direction: row; gap: 6px; align-items: center; font-size: 12px; font-weight: 500; cursor: pointer; }
.check-row.inline input { width: auto; }

.logs-list { display: flex; flex-direction: column; gap: 4px; }
.log-row {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px;
  font-size: 13px;
  transition: background 0.12s, border-color 0.12s;
}
.log-row:hover { background: var(--bg); }
.log-row.has-error { border-color: var(--warn); background: var(--warn-soft); }
.log-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.log-toggle {
  background: transparent; border: none; cursor: pointer;
  font-size: 11px; color: var(--text-dim); padding: 2px 4px;
}
.log-time.mono {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px; color: var(--text-dim); min-width: 130px;
}
.log-provider { font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-dim); }
.log-clinic { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-appt.mono {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px; color: var(--text-dim);
  background: var(--bg); padding: 2px 6px; border-radius: 4px;
}
.sig-ok { color: var(--accent); font-size: 11px; font-weight: 600; }
.sig-bad { color: var(--warn); font-size: 11px; font-weight: 700; }
.sig-none { color: var(--text-dim); font-size: 11px; }
.log-err-flag {
  background: var(--warn); color: #fff;
  padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
}
.log-payload {
  margin: 8px 0 0;
  padding: 12px; background: var(--bg);
  border-radius: 6px; font-size: 11px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  overflow-x: auto; max-height: 400px;
  white-space: pre; color: var(--text);
}

.tag-rescheduled {
  display: inline-block;
  background: rgba(200, 149, 74, 0.14);
  color: var(--warn);
  padding: 1px 6px; border-radius: 999px;
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px;
  margin-left: 4px;
}
.table-toolbar .search-input { flex: 1; max-width: 320px; }
.filter-select {
  padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg); color: var(--text);
  font: inherit; font-size: 13px; cursor: pointer;
}
.filter-select:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.result-count { font-size: 12px; color: var(--text-dim); }

.appt-table { display: flex; flex-direction: column; }
.table-head {
  display: grid;
  grid-template-columns: 110px 80px 1.2fr 1fr 1fr 130px;
  gap: 12px; padding: 8px 12px;
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-dim); font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.date-section { margin-top: 14px; }
.date-section:first-of-type { margin-top: 0; }
.date-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: var(--bg);
  font-size: 13px; text-transform: capitalize;
  border-radius: 6px;
}
.date-header strong { font-weight: 700; }
.count-badge {
  background: var(--accent-soft); color: var(--accent);
  padding: 1px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
}

.clinic-section { margin-top: 6px; }
.clinic-subheader {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-dim); font-weight: 600;
}
.clinic-subheader-name { color: var(--text); }
.clinic-subheader-count {
  background: var(--bg); color: var(--text-dim);
  padding: 1px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 700;
}

.appt-row {
  display: grid;
  grid-template-columns: 110px 80px 1.2fr 1fr 1fr 130px;
  gap: 12px; align-items: center;
  padding: 10px 12px; border-radius: 8px;
  transition: background 0.12s;
  font-size: 13px;
}
.appt-row:hover { background: var(--bg); }
.cell-time { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text-dim); }
.cell-customer { font-weight: 600; }
.clinic-chip {
  display: inline-block; background: var(--accent-soft); color: var(--accent);
  padding: 3px 10px; border-radius: 6px; font-size: 11px; font-weight: 600;
  white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.cell-service { color: var(--text-dim); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-phone.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; color: var(--text-dim); }
.appt-table .empty { padding: 30px; text-align: center; color: var(--text-dim); font-size: 13px; }

@media (max-width: 980px) {
  .table-columns { grid-template-columns: 1fr; }
}
.nav-btn {
  background: transparent; border: 1px solid var(--border); border-radius: 8px;
  width: 32px; height: 32px; cursor: pointer; font-size: 16px; color: var(--text);
}
.nav-btn:hover { background: var(--bg); }
.today-btn {
  background: var(--accent-soft); color: var(--accent); border: none;
  padding: 6px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 12px;
}

.week-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
}
.week-day {
  min-height: 200px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 8px;
  display: flex; flex-direction: column; gap: 6px;
  cursor: pointer; background: var(--surface);
  transition: background 0.15s, border-color 0.15s;
}
.week-day:hover { background: var(--bg); }
.week-day.today { border-color: var(--accent); border-width: 2px; padding: 9px 7px; }
.week-day.selected { background: var(--accent-soft); border-color: var(--accent); }
.week-day-header { display: flex; align-items: baseline; justify-content: space-between; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.weekday-label { font-size: 10px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.day-number { font-size: 18px; font-weight: 700; line-height: 1; }
.week-day.today .day-number { color: var(--accent); }
.day-dots { display: flex; gap: 3px; flex-wrap: wrap; min-height: 8px; }
.dot { width: 6px; height: 6px; border-radius: 50%; }
.dot-pending { background: var(--neutral); }
.dot-sent { background: var(--accent); }
.dot-cancelled { background: var(--text-dim); opacity: 0.4; }
.day-empty { color: var(--text-dim); font-size: 11px; text-align: center; padding: 20px 0; opacity: 0.4; }
.week-day-appts { display: flex; flex-direction: column; gap: 3px; }
.mini-appt {
  display: flex; gap: 6px; align-items: baseline;
  padding: 3px 6px; border-radius: 5px;
  background: var(--accent-soft);
  font-size: 11px;
  overflow: hidden;
}
.mini-appt.sent { background: var(--bg); opacity: 0.6; }
.mini-appt.cancelled { background: var(--bg); opacity: 0.4; text-decoration: line-through; }
.mini-time { font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.mini-appt.sent .mini-time, .mini-appt.cancelled .mini-time { color: var(--text-dim); }
.mini-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-more { font-size: 10px; color: var(--text-dim); padding: 2px 6px; font-style: italic; }

.legend {
  margin-top: 14px; font-size: 11px; color: var(--text-dim);
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.legend-pending { background: var(--neutral); }
.legend-sent { background: var(--accent); }
.legend-cancelled { background: var(--text-dim); opacity: 0.4; }

.side-title {
  font-weight: 600; margin-bottom: 10px; font-size: 13px;
  display: flex; align-items: center; gap: 8px;
}
.side-count {
  background: var(--accent-soft); color: var(--accent);
  padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
}
.side-list { display: flex; flex-direction: column; gap: 8px; }
.side-list.scroll { max-height: 540px; overflow-y: auto; padding-right: 4px; }
.empty { color: var(--text-dim); font-size: 12px; padding: 8px 4px; }

.send-card {
  border: 1px solid var(--border);
  border-left: 3px solid var(--neutral);
  border-radius: 8px;
  padding: 12px;
  background: #fcfbf7;
  display: flex; flex-direction: column; gap: 6px;
}
.send-card.soon { border-left-color: var(--accent); background: var(--accent-soft); }
.send-card.urgent { border-left-color: var(--warn); background: var(--warn-soft); }

.send-countdown {
  font-size: 18px; font-weight: 700; letter-spacing: -0.3px;
  font-variant-numeric: tabular-nums; color: var(--text);
}
.send-card.soon .send-countdown { color: var(--accent); }
.send-card.urgent .send-countdown { color: var(--warn); }

.send-name { font-weight: 600; font-size: 13px; }
.send-meta { font-size: 12px; color: var(--text-dim); }
.send-times {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  font-size: 11px; color: var(--text-dim);
  border-top: 1px dashed var(--border); padding-top: 8px;
}
.send-times strong { display: block; color: var(--text); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.send-times-label { display: block; text-transform: uppercase; letter-spacing: 0.4px; font-size: 10px; }

.appt-card {
  border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px;
  background: #fcfbf7;
  display: flex; flex-direction: column; gap: 4px;
}
.appt-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.appt-name { font-weight: 600; font-size: 13px; }
.appt-time { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.appt-service { font-size: 12px; color: var(--text-dim); }
.appt-phone { font-size: 11px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.pill {
  display: inline-block; font-size: 10px; padding: 2px 8px; border-radius: 999px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px;
}
.pill-pending { background: var(--neutral-soft); color: var(--neutral); }
.pill-sent { background: var(--accent-soft); color: var(--accent); }
.pill-cancelled { background: var(--bg); color: var(--text-dim); }
.pill-failed { background: var(--warn-soft); color: var(--warn); }

.appt-reminder { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.appt-reminder strong { color: var(--text); font-weight: 600; }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  body { padding-left: 0; }
  .nav-rail { position: relative; width: 100%; height: auto; flex-direction: row; padding: 12px; }
  .nav-brand { border: none; padding: 0 12px 0 4px; margin: 0; border-right: 1px solid var(--border); }
  .nav-links { flex-direction: row; flex: 1; padding-left: 12px; }
}

/* ============ Clinics page ============ */
.btn-primary {
  background: var(--accent); color: #fff; border: none;
  padding: 8px 16px; border-radius: 8px; cursor: pointer;
  font-weight: 600; font-size: 13px;
}
.btn-primary:hover { background: #7a8842; }
.btn-secondary {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  padding: 7px 14px; border-radius: 8px; cursor: pointer;
  font-weight: 500; font-size: 13px;
}
.btn-secondary:hover { background: var(--surface); }
.btn-link {
  background: transparent; border: none; cursor: pointer;
  color: var(--accent); font-size: 12px; font-weight: 600;
  padding: 4px 8px; border-radius: 6px;
}
.btn-link:hover { background: var(--accent-soft); }
.btn-link.danger { color: var(--warn); }
.btn-link.danger:hover { background: var(--warn-soft); }

/* ============ Clinics 2-pane layout ============ */
.clinics-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  padding: 20px 28px 32px;
  min-height: calc(100vh - 80px);
}
.clinics-list-pane {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; max-height: calc(100vh - 110px);
}
.list-header { padding: 12px; border-bottom: 1px solid var(--border); }
.search-input {
  width: 100%; box-sizing: border-box;
  padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 7px; background: var(--bg); color: var(--text);
  font: inherit; font-size: 13px;
}
.search-input:focus { outline: none; border-color: var(--accent); background: var(--surface); }

.clinic-list {
  list-style: none; margin: 0; padding: 6px;
  overflow-y: auto; flex: 1;
}
.clinic-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: 7px; cursor: pointer;
  font-size: 13px; gap: 6px;
  transition: background 0.12s;
}
.clinic-item:hover { background: var(--bg); }
.clinic-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.clinic-item.dim { opacity: 0.55; }
.clinic-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-badge {
  background: var(--accent); color: #fff; font-size: 10px; font-weight: 700;
  padding: 1px 7px; border-radius: 999px;
}
.clinic-list .empty { color: var(--text-dim); padding: 16px; text-align: center; font-size: 12px; }

.clinic-detail-pane {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
  padding: 24px; overflow-y: auto;
}
.empty-state {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--text-dim); font-size: 13px;
  min-height: 300px;
}

.detail-header { display: flex; align-items: center; margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.detail-title { display: flex; align-items: center; gap: 14px; }
.detail-title h2 { margin: 0; font-size: 20px; }
.detail-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  object-fit: cover; background: var(--bg); border: 1px solid var(--border);
}
.detail-avatar.placeholder { background: linear-gradient(135deg, var(--accent-soft), var(--bg)); }

.detail-section { margin-bottom: 28px; }
.section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-dim); font-weight: 600; margin-bottom: 12px;
}

.calendars-list { display: flex; flex-direction: column; gap: 10px; }
.calendar-card {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; background: #fcfbf7;
}
.calendar-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.cal-type {
  text-transform: capitalize; font-size: 14px; margin-right: 10px;
}
.cal-actions { display: flex; gap: 4px; }
.calendar-card-body { display: flex; flex-direction: column; gap: 6px; }
.cal-row { display: flex; align-items: center; gap: 12px; font-size: 12px; }
.cal-label { color: var(--text-dim); min-width: 100px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }
.empty.small-pad { padding: 14px; text-align: center; color: var(--text-dim); font-size: 12px; background: var(--bg); border-radius: 8px; }

.calendar-form { display: flex; flex-direction: column; gap: 12px; max-width: 540px; }
.calendar-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; }
.calendar-form label small { font-weight: 400; color: var(--text-dim); font-size: 11px; }
.calendar-form input[type=text], .calendar-form input[type=number], .calendar-form select {
  font: inherit; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); color: var(--text);
}
.calendar-form input:focus, .calendar-form select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft);
}
.calendar-form label.check-row { flex-direction: row; align-items: center; gap: 8px; }
.calendar-form .form-actions { display: flex; align-items: center; gap: 10px; padding-top: 12px; border-top: 1px solid var(--border); margin-top: 4px; }
.calendar-form .form-actions .grow { flex: 1; }
.calendar-form .type-fields { display: flex; flex-direction: column; gap: 12px; padding: 14px; background: var(--bg); border-radius: 10px; border: 1px dashed var(--border); }
.calendar-form .type-fields[hidden] { display: none; }

.services-section {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px; background: var(--bg); border-radius: 10px;
  border: 1px dashed var(--border);
}
.section-title-row { display: flex; justify-content: space-between; align-items: center; }
.services-meta { font-size: 11px; color: var(--text-dim); font-weight: 400; }
.services-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.services-list { display: flex; flex-direction: column; gap: 12px; max-height: 360px; overflow-y: auto; }
.svc-group { display: flex; flex-direction: column; gap: 4px; }
.svc-group-title {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-dim); font-weight: 700;
  padding: 6px 0 3px; border-bottom: 1px solid var(--border); margin-bottom: 2px;
}
.svc-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px; cursor: pointer;
  font-size: 12px; font-weight: 500;
}
.svc-item:hover { background: var(--surface); }
.svc-item input { width: auto; margin: 0; }
.svc-name { flex: 1; }
.svc-meta {
  font-size: 10px; color: var(--text-dim);
  background: var(--surface); padding: 1px 6px; border-radius: 4px;
  font-variant-numeric: tabular-nums;
}
.services-hint { color: var(--text-dim); font-size: 11px; font-weight: 400; }

@media (max-width: 980px) {
  .clinics-layout { grid-template-columns: 1fr; }
  .clinics-list-pane { max-height: 280px; }
}

.clinics-page { padding: 20px 28px 32px; }
.clinics-table-wrapper {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); overflow: hidden;
}
.clinics-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.clinics-table thead {
  background: var(--bg);
  text-align: left; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-dim);
}
.clinics-table th, .clinics-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.clinics-table tbody tr:last-child td { border-bottom: none; }
.clinics-table tbody tr:hover { background: var(--bg); }
.clinics-table .empty { text-align: center; color: var(--text-dim); padding: 32px 16px; }
.clinics-table .actions { display: flex; gap: 4px; justify-content: flex-end; }
.clinics-table .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px; color: var(--text-dim); }

.clinic-cell { display: flex; align-items: center; gap: 10px; }
.clinic-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  object-fit: cover; background: var(--bg);
  border: 1px solid var(--border);
}
.clinic-avatar.placeholder { background: linear-gradient(135deg, var(--accent-soft), var(--bg)); }
.muted { color: var(--text-dim); }
.muted.small { font-size: 11px; margin-top: 2px; }
.pill-failed { background: var(--warn-soft); color: var(--warn); }
.topbar-meta { font-size: 12px; color: var(--text-dim); }
.readonly-field { background: var(--bg); padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); }
.readonly-field label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-dim); display: block; margin-bottom: 4px; }
.readonly-value { font-weight: 600; font-size: 14px; }

.webhook-url { display: flex; align-items: center; gap: 6px; }
.webhook-url code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px; background: var(--bg); padding: 3px 8px; border-radius: 6px;
  max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.btn-copy {
  background: transparent; border: 1px solid var(--border); border-radius: 6px;
  padding: 3px 8px; font-size: 10px; cursor: pointer; color: var(--text-dim);
}
.btn-copy:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

/* ============ Modal ============ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--surface); border-radius: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin: 0; font-size: 16px; }
.modal-close {
  background: transparent; border: none; font-size: 22px; cursor: pointer;
  color: var(--text-dim); width: 28px; height: 28px; border-radius: 6px;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-body label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--text); }
.modal-body label small { font-weight: 400; color: var(--text-dim); font-size: 11px; }
.modal-body input[type=text], .modal-body input[type=number], .modal-body select {
  font: inherit; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); color: var(--text);
}
.modal-body input:focus, .modal-body select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft);
}
.modal-body label.check-row { flex-direction: row; align-items: center; gap: 8px; }
.modal-body label.check-row input { width: auto; }
.modal-actions { display: flex; align-items: center; gap: 10px; padding-top: 6px; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 14px; }
.modal-actions .grow { flex: 1; }
.test-result { font-size: 12px; color: var(--text-dim); }
.test-result.success { color: var(--accent); font-weight: 600; }
.test-result.warn { color: var(--warn); font-weight: 600; }
