:root {
  --bg: #f4f6f8;
  --panel: #fff;
  --border: #d8dee4;
  --text: #1a2332;
  --muted: #5c6b7a;
  --accent: #0066a1;
  --row-h: 22px;
  --time-w: 72px;
  --header-h: 44px;
  --counts-h: 28px;
  --emp-col-w: 100px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.toolbar h1 {
  margin: 0 0 10px;
  font-size: 1.15rem;
  font-weight: 600;
}
.clinic-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.clinic-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.875rem;
  cursor: pointer;
}
.clinic-btn.has-appts {
  border-color: #000 !important;
  border-width: 2px;
}
.clinic-btn.no-appts {
  border-color: #dc2626 !important;
  border-width: 2px;
}
.clinic-btn:hover:not(:disabled) { filter: brightness(0.95); }
.clinic-btn.active { font-weight: 600; }
.clinic-btn.metro-btn {
  font-weight: 600;
  border-style: dashed;
  border-width: 2px;
  border-color: #5c6b7a;
}
.clinic-btn.metro-btn.active {
  font-weight: 700;
}
.clinic-btn.disabled,
.clinic-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.date-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.date-display {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 11rem;
  padding: 7px 10px 7px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
}
.date-display:hover { border-color: var(--accent); }
.date-display:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 102, 161, 0.15);
}
.date-display.is-today {
  background: #fff8e1;
  border-color: #f9a825;
  box-shadow: inset 4px 0 0 #f9a825;
}
.date-display.is-today:hover { border-color: #f57f17; }
.date-display.is-today:focus-within {
  border-color: #f57f17;
  box-shadow: inset 4px 0 0 #f9a825, 0 0 0 2px rgba(249, 168, 37, 0.25);
}
.date-display.is-today .date-label { color: #1a2332; }
.date-display.is-past {
  background: #eceff1;
  border-color: #cfd8dc;
}
.date-display.is-past:hover { border-color: #b0bec5; }
.date-display.is-past:focus-within {
  border-color: #b0bec5;
  box-shadow: 0 0 0 2px rgba(176, 190, 197, 0.25);
}
.date-display.is-past .date-label { color: #78909c; }
.date-display.is-future.has-appts {
  background: #e8f5e9;
  border-color: #c8e6c9;
}
.date-display.is-future.has-appts:hover { border-color: #a5d6a7; }
.date-display.is-future.has-appts:focus-within {
  border-color: #a5d6a7;
  box-shadow: 0 0 0 2px rgba(165, 214, 167, 0.35);
}
.date-display.is-future.has-appts .date-label { color: #1a2332; }
.date-display.is-future.no-appts {
  background: #ffffff;
  border-color: var(--border);
}
.date-display.is-future.no-appts .date-label { color: #1a2332; }
.date-picker {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.date-picker:disabled { cursor: not-allowed; }
.date-calendar-btn {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  line-height: 1;
  font-size: 1rem;
}
.date-calendar-btn:hover { background: rgba(0, 0, 0, 0.06); }
.date-calendar-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.nav-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
}
.nav-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.nav-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.today-btn {
  padding: 6px 12px;
  border: 1px solid #f9a825;
  border-radius: 8px;
  background: #fff8e1;
  color: #1a2332;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.2;
}
.today-btn:hover:not(:disabled) {
  border-color: #f57f17;
  background: #fff3c4;
}
.today-btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.refresh-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  font-size: 0.8rem;
  cursor: pointer;
  line-height: 1.2;
}
.refresh-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.refresh-btn:disabled { opacity: 0.5; cursor: wait; }
.zoom-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}
.zoom-label { white-space: nowrap; }
.zoom-select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.8rem;
  font-family: inherit;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}
.zoom-select:hover { border-color: var(--accent); }
.zoom-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 102, 161, 0.15);
}
.board-zoom {
  width: max-content;
  max-width: 100%;
}
.date-label {
  font-size: 1rem;
  font-weight: 600;
  pointer-events: none;
  white-space: nowrap;
}
.meta {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--muted);
}
.meta.is-stale-mes01 {
  color: #c45a00;
}
.board-wrap {
  flex: 1;
  min-height: 0;
  padding: 12px 16px 24px;
  overflow: auto;
}
.board {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: max-content;
  max-width: 100%;
}
.board-inner {
  display: flex;
  flex-direction: column;
  width: max-content;
}
.board-head {
  display: flex;
  width: max-content;
  position: sticky;
  top: 0;
  z-index: 12;
}
.board-body {
  display: flex;
  width: max-content;
}
.corner {
  flex: 0 0 var(--time-w);
  width: var(--time-w);
  height: calc(var(--counts-h) + var(--header-h));
  position: sticky;
  left: 0;
  z-index: 14;
  background: #eef2f6;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.corner-stack {
  flex: 0 0 var(--time-w);
  width: var(--time-w);
  height: calc(var(--counts-h) + var(--header-h));
  position: sticky;
  left: 0;
  z-index: 14;
  display: flex;
  flex-direction: column;
  background: #eef2f6;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.corner-counts {
  flex: 0 0 var(--counts-h);
  height: var(--counts-h);
  border-bottom: 1px solid var(--border);
}
.corner-spacer {
  flex: 0 0 var(--header-h);
  height: var(--header-h);
}
.head-columns {
  display: flex;
  flex-direction: column;
  flex: none;
}
.appt-counts-bar {
  flex: 0 0 var(--counts-h);
  height: var(--counts-h);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 0 12px;
  font-size: 0.72rem;
  font-weight: 600;
  background: #eef2f6;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.appt-count.total { color: #1a2332; }
.appt-count.svc-revenue { color: #1565c0; }
.appt-count.reg-total { color: #6a1b9a; }
.appt-count.airalle { color: #0066a1; }
.appt-count.headscreen { color: #5c3d8a; }
.appt-count.combout { color: #2e7d32; }
.appt-count.mpp { color: #c62828; }
.appt-count.swl { color: #ef6c00; }
.appt-count.update {
  color: #5c6b7a;
  font-weight: 500;
  margin-left: auto;
}
.emp-headers {
  display: flex;
  flex: none;
}
.emp-header {
  flex: 0 0 var(--emp-col-w);
  width: var(--emp-col-w);
  max-width: var(--emp-col-w);
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 2px;
  font-size: 0.68rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.15;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  box-sizing: border-box;
}
.emp-header:last-child { border-right: none; }
.emp-header.emp-call-center {
  background: #000 !important;
  color: #fff !important;
}
.time-col {
  flex: 0 0 var(--time-w);
  width: var(--time-w);
  position: sticky;
  left: 0;
  z-index: 10;
  background: #fafbfc;
  border-right: 1px solid var(--border);
}
.emp-cols {
  display: flex;
  flex: none;
}
.emp-col {
  position: relative;
  flex: 0 0 var(--emp-col-w);
  width: var(--emp-col-w);
  max-width: var(--emp-col-w);
  border-right: 1px solid var(--border);
}
.emp-col:last-child { border-right: none; }
.time-cell {
  height: var(--row-h);
  padding: 0 6px 0 0;
  font-size: 0.68rem;
  color: var(--muted);
  text-align: right;
  line-height: var(--row-h);
  white-space: nowrap;
  border-bottom: 1px solid #eceff3;
}
.time-cell.hour { font-weight: 600; color: var(--text); border-bottom-color: #d8dee4; }
.grid-line {
  height: var(--row-h);
  border-bottom: 1px solid #eceff3;
}
.grid-line.hour { border-bottom-color: #d8dee4; }
.shift {
  position: absolute;
  left: 2px;
  right: 2px;
  border-radius: 3px;
  padding: 2px 3px;
  font-size: 0.6rem;
  line-height: 1.2;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
}
.shift .role { font-weight: 600; display: block; }
.shift .time { opacity: 0.92; font-size: 0.55rem; }
.shift.shift-break {
  background: #e2e5e9 !important;
  color: #5c6b7a !important;
  box-shadow: none;
}
.shift.shift-call-center {
  padding: 0;
  box-shadow: none;
}
.shift.shift-call-center .role,
.shift.shift-call-center .time {
  display: block;
  background: #000;
  color: #fff;
  padding: 2px 3px;
}
.shift.shift-call-center .role {
  margin: 5pt 5pt 0 5pt;
}
.shift.shift-call-center .time {
  opacity: 1;
}
.shift.shift-slot {
  padding: 0 1px;
  font-size: 0.48rem;
  line-height: 1.05;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: none;
  border-radius: 1px;
  box-sizing: border-box;
  border: 1px solid rgba(26, 35, 50, 0.35);
}
.shift.shift-slot.shift-break {
  border-color: rgba(92, 107, 122, 0.5);
}
.shift.shift-slot.shift-time-off {
  border-color: rgba(255, 255, 255, 0.35);
}
.shift.shift-slot .role {
  font-weight: 600;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}
.shift.shift-slot .time {
  display: none;
}
.schedule-block {
  position: absolute;
  left: 3px;
  right: 3px;
  z-index: 3;
  box-sizing: border-box;
  border: 1px solid #9aa3ad;
  border-radius: 3px;
  padding: 2px 4px;
  font-size: 0.55rem;
  line-height: 1.15;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  pointer-events: none;
}
.schedule-block-type {
  display: block;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.schedule-block-note {
  display: block;
  color: #4b5563;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.appointment {
  position: absolute;
  left: 3px;
  right: 3px;
  z-index: 5;
  box-sizing: border-box;
  background: #fff;
  border: 1px solid #c8ced6; /* overridden inline when clinic color is known */
  border-radius: 3px;
  padding: 2px 4px;
  font-size: 0.55rem;
  line-height: 1.15;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  color: var(--text);
  cursor: pointer;
}
.appointment:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.14);
  z-index: 6;
}
.appointment:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.appointment-cross-clinic {
  border-style: dashed;
  opacity: 0.92;
}
.appointment-split {
  padding: 1px 2px;
  font-size: 0.5rem;
}
.appointment .client {
  display: block;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.appointment .service {
  display: block;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.appointment.appointment-code-el,
.appointment.appointment-code-el .client,
.appointment.appointment-code-el .service {
  color: #1565c0;
}
.appointment.appointment-code-incl,
.appointment.appointment-code-incl .client,
.appointment.appointment-code-incl .service {
  color: #2e7d32;
}
.appointment.appointment-late-noshow,
.appointment.appointment-late-noshow .client,
.appointment.appointment-late-noshow .service {
  color: #c62828;
}
.appointment.appointment-late-noshow {
  border-color: #e57373;
}
.appointment.appointment-checked-in {
  border-color: #2e7d32;
  border-width: 2px;
}
.empty-day {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}
body.appt-modal-open {
  overflow: hidden;
}
.appt-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(26, 35, 50, 0.45);
}
.appt-modal-overlay[hidden] {
  display: none;
}
.appt-modal {
  width: min(420px, 100%);
  max-height: min(80vh, 640px);
  overflow: auto;
  background: var(--panel);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border);
}
.appt-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.appt-modal-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
}
.appt-modal-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.appt-modal-close:hover {
  background: var(--bg);
  color: var(--text);
}
.appt-modal-body {
  padding: 12px 16px 16px;
}
.appt-detail-list {
  margin: 0;
  display: grid;
  gap: 8px;
}
.appt-detail-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px;
  align-items: baseline;
}
.appt-detail-row dt {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}
.appt-detail-row dd {
  margin: 0;
  font-size: 0.875rem;
  word-break: break-word;
}
.appt-related {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.appt-related h3 {
  margin: 0 0 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}
.appt-service-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}
.appt-service-list li {
  display: grid;
  gap: 2px;
}
.appt-service-client {
  font-size: 0.875rem;
  font-weight: 600;
}
.appt-service-client.is-payee,
.appt-detail-row dd.is-payee,
.appt-detail-link.is-payee {
  color: #dc2626;
}
.appt-detail-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.appt-detail-link:hover {
  opacity: 0.85;
}
.appt-service-name {
  font-size: 0.82rem;
  color: var(--text);
}
.appt-service-meta {
  font-size: 0.78rem;
  color: var(--muted);
}
@media print {
  body { height: auto; overflow: visible; display: block; }
  .toolbar { position: static; box-shadow: none; }
  .board-wrap { overflow: visible; }
  .board-zoom { zoom: 1 !important; transform: none !important; }
  .nav-btn, .today-btn, .clinic-btn:not(.active), .refresh-btn, .date-display, .zoom-control { display: none; }
}
