* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f7f7f8;
  color: #1a1a1a;
}

/* ---- login ---- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: #fff;
  border: 1px solid #e5e5e8;
  border-radius: 12px;
  padding: 32px;
  width: 320px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.login-card h1 {
  font-size: 20px;
  margin: 0 0 20px;
}
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: #555; margin-bottom: 4px; }
.field input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #d7d7db;
  border-radius: 8px;
  font-size: 14px;
}
.field input:focus { outline: 2px solid #4a90d9; border-color: transparent; }
button.primary {
  width: 100%;
  padding: 10px;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  margin-top: 6px;
}
button.primary:hover { background: #333; }
.error-msg {
  background: #fdeceb;
  color: #b3261e;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
}
.success-msg {
  background: #dcf3e7;
  color: #14532d;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
}

/* ---- schedule shell ---- */
header.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 1px solid #e5e5e8;
}
header.app-header .who { font-size: 13px; color: #555; }
header.app-header button {
  background: none;
  border: 1px solid #d7d7db;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
header.app-header button:hover { background: #f0f0f2; }
header.app-header button:disabled { color: #999; cursor: default; }
header.app-header button:disabled:hover { background: none; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 6px;
  gap: 12px;
}
.hint { font-size: 12px; color: #8a8a8f; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

.view-toggle { display: flex; gap: 6px; margin-left: auto; }
.view-toggle button {
  background: #fff;
  border: 1px solid #d7d7db;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  color: #555;
}
.view-toggle button:hover { background: #f0f0f2; }
.view-toggle button.active { background: #1a1a1a; color: #fff; border-color: #1a1a1a; }

.week-nav { display: flex; gap: 8px; align-items: center; padding: 0 20px 10px; }
.week-nav button {
  background: #fff; border: 1px solid #d7d7db; border-radius: 6px;
  padding: 5px 10px; cursor: pointer; font-size: 13px;
}
.week-nav span { font-size: 13px; color: #444; }
.week-nav .week-range-label { font-size: 17px; font-weight: 700; color: #1a1a1a; }

.grid-scroll {
  overflow-x: auto;
  padding: 0 20px 30px;
}
table.schedule {
  border-collapse: collapse;
  min-width: 900px;
  width: 100%;
}
table.schedule th, table.schedule td {
  border: 1px solid #ececee;
  padding: 6px;
  vertical-align: top;
  height: 70px;
}
table.schedule th {
  background: #fafafa;
  font-weight: 500;
  font-size: 13px;
  color: #555;
  text-align: left;
  padding: 8px 10px;
  height: auto;
}
table.schedule td.name-cell {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  background: #fafafa;
  width: 210px;
}
table.schedule th:first-child { width: 210px; }
table.schedule td.day-cell { width: 120px; padding: 0; vertical-align: top; }

tr.facility-divider td {
  background: #f3f3f4;
  height: auto;
  padding: 10px 10px;
  border-top: 1px solid #dcdce0;
}
.facility-divider-inner { display: flex; align-items: center; gap: 8px; }
.facility-divider-inner strong { font-size: 13px; }
table.schedule th:last-child, table.schedule td.action-cell { width: 110px; text-align: right; }
.add-shift-toggle {
  background: #fff;
  border: 1px solid #d7d7db;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.add-shift-toggle:hover { background: #f0f0f2; }

tr.add-shift-row td { background: #fafbfc; height: auto; padding: 10px; }
.inline-shift-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-shift-form select, .inline-shift-form input {
  padding: 6px 8px;
  border: 1px solid #d7d7db;
  border-radius: 6px;
  font-size: 12px;
}
.inline-shift-form button {
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 12px;
  cursor: pointer;
}

tr td.empty-band { text-align: center; color: #999; padding: 14px; height: auto; }

.shift-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  border-radius: 0;
  cursor: grab;
  margin-bottom: 0;
  padding: 2px 6px;
}
.shift-chip-staff {
  display: inline-block;
  max-width: 100%;
  background: rgba(255, 255, 255, 0.85);
  color: #000;
  font-size: 15px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
}
.shift-chip-time {
  font-size: 11px;
  font-weight: 600;
  color: #1a1a1a;
  white-space: nowrap;
}
.shift-chip-staff-tbd {
  font-style: italic;
  font-weight: 500;
  color: #555;
  background: rgba(255, 255, 255, 0.6);
}
.shift-chip.unpublished {
  border: 2px solid rgba(255, 255, 255, 0.7);
}
.shift-chip.published {
  border: 2px solid #1a1a1a;
}
.shift-chip.drag-over { outline: 2px dashed #333; }
.shift-chip-staff { cursor: grab; }
td.day-cell.drag-over { outline: 2px dashed #999; outline-offset: -2px; }

table.month-calendar {
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 14px;
  border: 1px solid #b5b5ba;
  min-width: 700px;
  width: 100%;
  table-layout: fixed;
}
table.month-calendar thead tr:first-child th:first-child { border-top-left-radius: 14px; }
table.month-calendar thead tr:first-child th:last-child { border-top-right-radius: 14px; }
table.month-calendar tbody tr:last-child td:first-child { border-bottom-left-radius: 14px; }
table.month-calendar tbody tr:last-child td:last-child { border-bottom-right-radius: 14px; }
table.month-calendar th {
  background: #fafafa;
  font-weight: 500;
  font-size: 13px;
  color: #555;
  text-align: left;
  padding: 8px 10px;
}
table.month-calendar td {
  border: 1px solid #b5b5ba;
  vertical-align: top;
  height: 100px;
  padding: 6px;
}
.month-day-number { font-size: 12px; font-weight: 600; color: #444; margin-bottom: 4px; }
td.other-month { background: #fafafa; }
td.other-month .month-day-number { color: #ccc; }
.month-shift-chip {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #1a1a1a;
  border-radius: 4px;
  padding: 3px 6px;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
td.empty-month-state { text-align: center; color: #999; padding: 24px; height: auto; }

.hidden { display: none !important; }
.nav-link {
  font-size: 13px;
  color: #1a1a1a;
  text-decoration: none;
  border: 1px solid #d7d7db;
  border-radius: 6px;
  padding: 6px 12px;
}
.nav-link:hover { background: #f0f0f2; }

/* ---- admin shell ---- */
.tabs {
  display: flex;
  gap: 4px;
  padding: 12px 20px 0;
  border-bottom: 1px solid #e5e5e8;
  background: #fff;
}
.tab {
  background: none;
  border: none;
  padding: 10px 14px;
  font-size: 13px;
  color: #666;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: #1a1a1a; }
.tab.active { color: #1a1a1a; font-weight: 500; border-bottom-color: #1a1a1a; }

.admin-main { padding: 20px 12px; max-width: 1500px; margin: 0 auto; }
.panel.hidden { display: none; }

.card {
  background: #fff;
  border: 1px solid #e5e5e8;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}
.card h2 { font-size: 15px; margin: 0 0 14px; }

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px 14px;
  align-items: end;
}
.grid-form .field { margin-bottom: 0; }
.grid-form .field-full { grid-column: 1 / -1; }
.grid-form label { display: block; font-size: 12px; color: #666; margin-bottom: 4px; }
.grid-form input, .grid-form select {
  width: 100%;
  padding: 8px 9px;
  border: 1px solid #d7d7db;
  border-radius: 8px;
  font-size: 13px;
}
.grid-form button.primary {
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  cursor: pointer;
  height: 36px;
}
.grid-form button.primary:hover { background: #333; }

.inline-form { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.inline-form input[type="text"] {
  padding: 8px 9px;
  border: 1px solid #d7d7db;
  border-radius: 8px;
  font-size: 13px;
  flex: 1;
}
.inline-form input[type="color"] { width: 36px; height: 32px; border: none; padding: 0; background: none; }
.inline-form button {
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}

.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f0f0f2;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.table-scroll { overflow-x: auto; }
table.data-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}
table.data-table th, table.data-table td {
  border-bottom: 1px solid #ececee;
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
}
table.data-table th { color: #666; font-weight: 500; font-size: 12px; }
table.data-table td.empty { color: #999; text-align: center; padding: 20px; white-space: normal; }
table.data-table select { padding: 4px 6px; border: 1px solid #d7d7db; border-radius: 6px; font-size: 12px; }

/* Each week's shifts is a separate <table> (one per infinite-scroll block), so
   without fixed shared column widths each one auto-sizes to its own content and
   the columns drift out of alignment with the tables above/below it as you scroll. */
table.shifts-week-table { table-layout: fixed; }
table.shifts-week-table th:nth-child(1), table.shifts-week-table td:nth-child(1) { width: 15%; }
table.shifts-week-table th:nth-child(2), table.shifts-week-table td:nth-child(2) { width: 15%; }
table.shifts-week-table th:nth-child(3), table.shifts-week-table td:nth-child(3) { width: 12%; }
table.shifts-week-table th:nth-child(4), table.shifts-week-table td:nth-child(4) { width: 13%; }
table.shifts-week-table th:nth-child(5), table.shifts-week-table td:nth-child(5) { width: 15%; }
table.shifts-week-table th:nth-child(6), table.shifts-week-table td:nth-child(6) { width: 10%; padding-right: 0; }
table.shifts-week-table th:nth-child(7) { width: 20%; padding-left: 0; }
table.shifts-week-table td { overflow: hidden; text-overflow: ellipsis; }
table.shifts-week-table select { width: 100%; max-width: 100%; }
/* td:nth-child(7) is display:flex (via .row-actions), which makes Chrome wrap it in an
   anonymous table-cell for the fixed layout; a width: 20% here would resolve against that
   wrapper (already 20% of the table) instead of the table, shrinking it drastically. Column
   width is set via the th above; this td just needs to fill its wrapper. */
table.shifts-week-table td:nth-child(7) { width: 100%; padding-left: 0; box-sizing: border-box; }
table.shifts-week-table .row-actions { gap: 4px; }
table.shifts-week-table .row-actions button { padding: 5px 8px; }
/* match the Facility/Surgeon/Staff dropdown text size (table.data-table select, 12px)
   instead of the browser's larger default date-input rendering, so every editable field
   in a row reads at the same size. Chrome's UA stylesheet also renders date inputs in
   `font-family: monospace` by default, which looks visibly thinner than the page's sans-
   serif — override both font-family and color back to the page's normal text. */
table.shifts-week-table .date-input { font-size: 12px; font-family: inherit; color: inherit; }

table.facility-shifts-week-table { table-layout: fixed; }
table.facility-shifts-week-table th:nth-child(1), table.facility-shifts-week-table td:nth-child(1) { width: 16%; }
table.facility-shifts-week-table th:nth-child(2), table.facility-shifts-week-table td:nth-child(2) { width: 17%; }
table.facility-shifts-week-table th:nth-child(3), table.facility-shifts-week-table td:nth-child(3) { width: 20%; }
table.facility-shifts-week-table th:nth-child(4), table.facility-shifts-week-table td:nth-child(4) { width: 17%; }
table.facility-shifts-week-table th:nth-child(5), table.facility-shifts-week-table td:nth-child(5) { width: 17%; padding-right: 0; }
table.facility-shifts-week-table th:nth-child(6) { width: 13%; padding-left: 0; }
table.facility-shifts-week-table td { overflow: hidden; text-overflow: ellipsis; }
table.facility-shifts-week-table select { width: 100%; max-width: 100%; }
/* td:nth-child(6) is display:flex (via .row-actions) on rows the facility user added, which
   makes Chrome wrap it in an anonymous table-cell for the fixed layout — see the equivalent
   comment on shifts-week-table above for why this needs width:100% instead of a percentage. */
table.facility-shifts-week-table td:nth-child(6) { width: 100%; padding-left: 0; box-sizing: border-box; }
table.facility-shifts-week-table .row-actions { gap: 4px; }
table.facility-shifts-week-table .row-actions button { padding: 5px 8px; }
/* match the Surgeon dropdown text size (table.data-table select, 12px) instead of the
   browser's larger default date-input rendering, so every editable field in a row reads
   at the same size. Chrome's UA stylesheet also renders date inputs in
   `font-family: monospace` by default, which looks visibly thinner than the page's sans-
   serif — override both font-family and color back to the page's normal text. */
table.facility-shifts-week-table .date-input { font-size: 12px; font-family: inherit; color: inherit; }
.date-cell { white-space: nowrap; }
.date-cell input { vertical-align: middle; }
.day-label { font-size: 12px; color: #888; font-weight: 500; margin-left: 6px; vertical-align: middle; }
.time-cell { white-space: nowrap; }
.time-cell span { margin: 0 4px; vertical-align: middle; }
.time-cell input {
  width: 52px;
  padding: 4px 6px;
  border: 1px solid #d7d7db;
  border-radius: 6px;
  font-size: 12px;
  vertical-align: middle;
}

.row-actions { display: flex; gap: 6px; }
.row-actions button, table.data-table td button {
  border: 1px solid #d7d7db;
  background: #fff;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}
.row-actions button.ok, table.data-table button.ok { border-color: #2f9e6f; color: #1e7a53; }
.row-actions button.ok:hover, table.data-table button.ok:hover { background: #dcf3e7; }
.row-actions button.danger, table.data-table button.danger { border-color: #d9534f; color: #b3261e; }
.row-actions button.danger:hover, table.data-table button.danger:hover { background: #fdeceb; }
.row-actions button.btn-compact, table.data-table button.btn-compact { padding: 3px 7px; font-size: 11px; }

/* keeps edit-mode inputs/selects from growing wider than the plain text they replace */
#users-table td input[type="text"],
#users-table td input[type="email"],
#users-table td select {
  width: 100%;
  max-width: 140px;
  box-sizing: border-box;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 500;
}
.badge-ok { background: #dcf3e7; color: #14532d; }
.badge-pending { background: #fbe7da; color: #7c3a12; }
.badge-facility { background: #e3dcf9; color: #4a2f8f; }
.badge-you { background: #dbeafe; color: #1e40af; }

.credential-banner {
  background: #eaf4ff;
  border: 1px solid #bcdcfb;
  color: #1a3a5c;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

#toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a1a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  display: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-overlay.hidden { display: none; }
.modal-card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  width: 320px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.modal-card h2 { font-size: 16px; margin: 0 0 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.modal-actions button {
  border: 1px solid #d7d7db;
  background: #fff;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
}
.modal-actions button.primary { background: #1a1a1a; color: #fff; border-color: #1a1a1a; }
.modal-actions button.primary:hover { background: #333; }
