/* ── Grid & Tables ─────────────────────────────────────────────────– */
.grid-wrap {
  flex: 1;
  overflow: auto;
  position: relative;
}

table.schedule {
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 100%;
}

table.schedule th,
table.schedule td {
  border: 1px solid var(--border-hairline);
  text-align: center;
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

table.schedule th {
  background: #f8fafc;
  color: #1a202c;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 4px 2px;
  font-size: 0.73rem;
}

table.schedule th.sticky-col {
  left: 0;
  z-index: 20;
  min-width: 160px;
  max-width: 160px;
  text-align: left;
  padding-left: 8px;
}

table.schedule th.col-team {
  min-width: 38px;
  max-width: 38px;
}

table.schedule th.col-hrs {
  min-width: 42px;
  max-width: 42px;
}

table.schedule th.col-day {
  min-width: 42px;
  max-width: 42px;
}

table.schedule td.sticky-col {
  position: sticky;
  left: 0;
  background: var(--surface);
  font-weight: 600;
  text-align: left;
  padding: 4px 8px;
  z-index: 5;
  font-size: 0.8rem;
}

table.schedule td.col-team {
  font-size: 0.7rem;
  font-weight: 700;
}

table.schedule td.col-hrs {
  color: var(--muted);
  font-size: 0.76rem;
}

table.schedule td.day-cell {
  color: #1a202c;
  cursor: pointer;
  height: 30px;
  font-size: 0.76rem;
  font-weight: 600;
  transition: opacity 0.1s;
}

table.schedule td.day-cell:hover {
  opacity: 0.75;
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

table.schedule td.day-cell.cell-conflict {
  outline: 2px dashed var(--danger);
  outline-offset: -2px;
}

/* Status chip — always visible: green when clean, red when conflicts.
   Replaces the permanent 280px conflicts column as the at-a-glance signal. */
#conflict-chip {
  background: var(--success-soft);
  border: 1px solid var(--success);
  color: var(--success);
}

#conflict-chip.on {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

table.schedule th.weekend {
  background: #fef9c3;
  color: #92400e;
}

table.schedule td.weekend-row {
  background: #fffbeb !important;
}

table.schedule tr:hover td:not(.sticky-col) {
  filter: brightness(0.95);
}

/* ── Summary Table ─────────────────────────────────────────────────– */
.summary-wrap {
  padding: 20px;
  overflow: auto;
}

table.summary {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.83rem;
}

table.summary th {
  background: var(--thead);
  border: 1px solid var(--border-hairline);
  padding: 8px 10px;
  font-weight: 700;
  text-align: center;
  position: sticky;
  top: 0;
}

table.summary th:first-child {
  text-align: left;
}

table.summary td {
  border: 1px solid var(--border-hairline);
  padding: 6px 10px;
  text-align: center;
}

table.summary td:first-child {
  font-weight: 600;
  text-align: left;
}

table.summary tr:nth-child(even) {
  background: var(--thead);
}

table.summary .high {
  color: var(--danger);
  font-weight: 700;
}

/* ── Coverage Table ──────────────────────────────────────────────────– */
.cov-grouphdr {
  background: var(--thead, #eef2f7);
  font-weight: 700;
  font-size: 0.72rem;
  color: var(--primary);
  text-align: center;
  padding: 4px 6px;
}

.cov-slothdr {
  text-align: center;
  padding: 3px 4px;
  background: var(--thead, #eef2f7);
}

.cov-datecell {
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  text-align: left;
}

.cov-daynum {
  font-weight: 700;
}

.cov-dow {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.66rem;
}

.cov-chip {
  display: inline-block;
  min-width: 22px;
  text-align: center;
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  font-weight: 700;
  font-size: 0.66rem;
  color: #1a202c;
}

.cov-cell {
  font-size: 0.66rem;
  font-weight: 600;
  text-align: center;
  color: #1a202c;
}

#coverage-table th.sticky-col,
#coverage-table td.sticky-col {
  min-width: 88px;
  max-width: 88px;
  padding: 2px 8px;
  font-size: 0.74rem;
}

#coverage-table th.cov-slothdr,
#coverage-table td.cov-cell {
  min-width: 50px;
}

#coverage-table td.day-cell.cov-cell {
  height: 26px;
  padding: 1px 2px;
}

#coverage-table .cov-dow {
  margin-left: 4px;
}

#coverage-table td.cov-cell.cov-blocked {
  background: #fecaca !important;
  color: #991b1b;
  font-weight: 700;
}

#coverage-table td.cov-cell.cov-clickable {
  cursor: pointer;
}

#coverage-table td.cov-cell.cov-clickable:hover {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.cov-toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 4px 0 8px;
}

.cov-print-title {
  display: none;
}

/* ── Modals ────────────────────────────────────────────────────────– */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 16px;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  max-height: 90vh;
  overflow-y: auto;
}

.modal h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 12px 0 4px;
}

.modal input,
.modal select {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 0.9rem;
  outline: none;
}

.modal input:focus,
.modal select:focus {
  border-color: var(--primary);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.btn-cancel {
  padding: 8px 16px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 0.87rem;
  cursor: pointer;
}

.btn-ok {
  padding: 8px 18px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 0.87rem;
  font-weight: 600;
  cursor: pointer;
}

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

.modal-err {
  color: var(--danger);
  font-size: 0.82rem;
  margin-top: 8px;
  min-height: 18px;
}

/* ── Manual Assign pin list ────────────────────────────────────– */
.manual-list-head {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-top: 18px;
}

.manual-list {
  max-height: 180px;
  overflow-y: auto;
  margin-top: 2px;
  padding-right: 2px;
}

/* ── Leave List ──────────────────────────────────────────────────────– */
.leave-item {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  margin-top: 6px;
  gap: 8px;
  font-size: 0.82rem;
}

.leave-item .leave-name {
  font-weight: 600;
  flex: 1;
}

.leave-del {
  margin-left: auto;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
}

.leave-del:hover {
  color: var(--danger);
}

/* ── Toast ──────────────────────────────────────────────────────────– */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--toast-bg);
  color: var(--toast-fg);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.87rem;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
}

/* ── Spinner ────────────────────────────────────────────────────────– */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 5px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Dark-mode grid palette (Phase 3 M3.4b) ──────────────────────────
   Schedule/coverage cells use fixed light fills (inline per-code bg +
   hardcoded header/weekend colours). In dark mode, mute them via an inset
   dark overlay + light text so the grid harmonises with the dark chrome
   while each code's hue stays identifiable. */
html[data-theme="dark"] table.schedule th {
  background: var(--thead);
  color: var(--text);
}
html[data-theme="dark"] table.schedule th.weekend {
  background: #3a3320;
  color: #fbbf24;
}
html[data-theme="dark"] table.schedule td.day-cell {
  color: #e5e7eb;
  box-shadow: inset 0 0 0 100px rgba(15, 23, 42, 0.58);
}
html[data-theme="dark"] table.schedule td.weekend-row {
  background: #232a3a !important;
}
