/* Legacy screen styles. Tokens live in styles/tokens.css; the reset,
   element defaults, app shell, and content-width system live in
   styles/base.css; shared components in styles/components.css. Rules here
   are deleted screen-by-screen as the Phase 3 rebuilds land. */

.staff-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0.5rem;
  background: var(--surface);
}

.staff-row .name {
  font-weight: 500;
}

.staff-row .tags {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.125rem;
}

.staff-row .tag {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  margin-right: 0.25rem;
}

/* ---- Staff table -------------------------------------------------------- */

.screen-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.win-tentative {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.win-tentative input {
  width: auto;
  margin: 0;
}

.staff-add-panel {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  padding: 1rem;
  margin-bottom: 1.25rem;
}

/* Horizontal scroll so the capability matrix can outgrow the page; the Name
   column is pinned (sticky) so it stays visible while the rest scrolls. */

/* Pinned Name column. Header corner sits above both the column and the row
   stripes (z-index 3 > sticky body cell 1 / thead 2). */

details summary::-webkit-details-marker { display: none; }
details summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.15s;
}
details[open] summary::before {
  content: "▾ ";
}

.caps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
}

.caps-grid:has(.cap-pip-row) {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.cap-pip-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.cap-pip-name {
  font-size: 0.875rem;
}

.cap-pip-group {
  display: inline-flex;
  gap: 0.25rem;
}

.cap-pip {
  width: 30px;
  height: 28px;
  padding: 0;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 4px;
  cursor: pointer;
}

.cap-pip.selected {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.cap-pip[data-level="0"].selected {
  background: var(--border);
  color: var(--text);
  border-color: var(--border);
}

.tag.cap {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

.day-block {
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0.5rem;
  background: var(--surface);
}

.day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 500;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.day-windows {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.window-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.window-row input[type="time"] {
  flex: 1;
  margin: 0;
  padding: 0.4rem 0.5rem;
  font-size: 0.875rem;
}

.holiday-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0.375rem;
  background: var(--surface);
  font-size: 0.875rem;
}

.fixed-shift-row {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0.5rem;
  background: var(--surface);
  font-size: 0.875rem;
}

.fs-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.fs-line + .fs-line {
  margin-top: 0.5rem;
}

.fs-time {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-variant-numeric: tabular-nums;
}

.fs-strict-label {
  font-size: 0.75rem;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.fs-caps-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.fs-caps-label {
  font-size: 0.75rem;
  color: var(--muted);
  flex: 0 0 auto;
}

.fs-caps-trigger {
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.55rem 0.4rem 0.75rem;
  font-size: 0.8rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}

.fs-caps-trigger:hover:not(.disabled):not(.invalid) {
  border-color: var(--muted);
}

.fs-caps-trigger.disabled {
  cursor: not-allowed;
  background: var(--bg);
  color: var(--muted);
}

.fs-caps-trigger.invalid {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.fs-caps-trigger-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fs-caps-any {
  color: var(--muted);
  font-style: italic;
}

.fs-caps-invalid-text {
  color: var(--danger);
  font-weight: 500;
}

.fs-caps-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.15rem 0.5rem;
  background: #2b2b30;
  color: #fff;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1;
  flex: 0 0 auto;
  cursor: pointer;
}

.fs-caps-chip:hover {
  background: #1a1a1f;
}

.fs-caps-chip-x {
  font-size: 0.85rem;
  line-height: 1;
  opacity: 0.85;
}

.fs-caps-chevron {
  color: var(--muted);
  font-size: 0.7rem;
  flex: 0 0 auto;
}

.fs-caps-error {
  margin-top: 0.375rem;
  color: var(--danger);
  font-size: 0.72rem;
}

.fixed-shift-row.has-error {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.fs-caps-popover {
  position: absolute;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 15, 20, 0.12), 0 2px 6px rgba(15, 15, 20, 0.06);
  padding: 0.375rem;
  max-height: 320px;
  overflow-y: auto;
}

.fs-caps-popover.hidden {
  display: none;
}

.fs-caps-list {
  display: flex;
  flex-direction: column;
}

.fs-caps-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.45rem 0.625rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  user-select: none;
}

.fs-caps-item:hover {
  background: var(--bg);
}

.fs-caps-item.selected {
  background: var(--bg);
}

.fs-caps-item-cb,
.fs-caps-select-all-cb {
  width: 16px;
  height: 16px;
  accent-color: var(--text);
  cursor: pointer;
  flex: 0 0 auto;
}

.fs-caps-item-name {
  flex: 1;
  min-width: 0;
}

.fs-caps-select-all {
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.25rem;
  border-radius: 6px 6px 0 0;
}

.fs-caps-divider {
  height: 1px;
  background: var(--border);
  margin: 0.25rem 0.625rem;
}

.fs-warnings {
  margin-top: 0.375rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.fs-warning {
  color: var(--danger, #b85100);
  font-size: 0.75rem;
}

/* ---- Staff detail: identity sidebar + availability main ----------------- */
/* Two columns that each flow their own sections top-to-bottom, so a short
   section never leaves ragged whitespace beside a tall sibling. Collapses to a
   single column on narrow viewports. */
.sd-layout {
  display: grid;
  grid-template-columns: minmax(300px, 360px) 1fr;
  gap: 1rem;
  align-items: start;
  margin-top: 1.25rem;
}

.sd-col {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

@media (max-width: 720px) {
  .sd-layout { grid-template-columns: 1fr; }
}

.sd-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.125rem 1.25rem 1.25rem;
}

.sd-section h2 {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0 0 0.875rem;
  padding-bottom: 0.625rem;
  border-bottom: 1px solid var(--border);
}

.sd-hint {
  font-size: 0.825rem;
  color: var(--muted);
  margin: -0.25rem 0 0.75rem;
  line-height: 1.4;
}

.sd-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem 0 0;
  font-weight: normal;
}

.sd-check input {
  width: auto;
  margin: 0;
}

/* Weekly day blocks tile two-up when there's room, halving the section height. */
.sd-weekly-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.5rem;
}

.sd-weekly-grid .day-block { margin-bottom: 0; }

/* Shared "date input(s) + add button" footer used by overrides and holidays. */
.sd-add-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.sd-add-row > input[type="date"] { flex: 1 1 130px; margin: 0; min-width: 0; }

.sd-field {
  flex: 1 1 130px;
  min-width: 0;
}

.sd-field label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.sd-field input {
  width: 100%;
  margin: 0;
}

.sd-add-row button {
  flex: 0 0 auto;
  padding: 0.5rem 1rem;
}

.sd-save-bar {
  position: sticky;
  bottom: 0;
  margin-top: 1.25rem;
  padding-top: 1rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.sd-save-bar button {
  margin: 0;
}

/* ---- Calendar grid (Availability month view) -------------------------- */

.hol-grid-head,
.hol-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
}

.hol-grid-head {
  margin-bottom: 1px;
}

.hol-dow {
  padding: 0.4rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.hol-grid {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--border);
}

.hol-cell {
  background: var(--surface);
  min-height: 6.5rem;
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.hol-cell-out {
  background: var(--bg);
}

.hol-cell-out .hol-cell-num {
  color: var(--muted);
}

.hol-cell-today .hol-cell-num {
  background: var(--accent);
  color: #fff;
}

.hol-cell-num {
  font-size: 0.78rem;
  font-weight: 600;
  align-self: flex-start;
  min-width: 1.4rem;
  height: 1.4rem;
  line-height: 1.4rem;
  text-align: center;
  border-radius: 999px;
}

@media (max-width: 720px) {
  .hol-cell {
    min-height: 4.5rem;
  }
}

/* ---- Add-holiday modal ------------------------------------------------- */

.hol-modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.hol-modal {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.5rem;
  width: 100%;
  max-width: 24rem;
  box-shadow: var(--shadow-modal);
}

.hol-modal h2 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
}

.hol-modal label {
  display: block;
  margin: 0.75rem 0 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.hol-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

/* ---- Availability tab ------------------------------------------------- */

.av-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.av-modes {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.av-mode {
  border: none;
  background: var(--surface);
  color: var(--text);
  padding: 0.4rem 0.95rem;
  font-size: 0.9rem;
  cursor: pointer;
  border-right: 1px solid var(--border);
}

.av-mode:last-child {
  border-right: none;
}

.av-mode.active {
  background: var(--accent);
  color: #fff;
}

.av-navbar {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.av-navbar h2 {
  font-size: 1rem;
  margin: 0;
  min-width: 11rem;
  text-align: center;
}

.av-navbtn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.25rem 0.7rem;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

/* Week grid */
.av-week-wrap {
  overflow-x: auto;
}

table.av-week {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
  font-variant-numeric: tabular-nums;
}

table.av-week th,
table.av-week td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.5rem;
  text-align: center;
  vertical-align: top;
  font-size: 0.85rem;
}

table.av-week th {
  background: var(--bg);
  font-weight: 600;
}

.av-th-date {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.78rem;
}

.av-name-col {
  text-align: left !important;
  white-space: nowrap;
  position: sticky;
  left: 0;
  background: var(--surface);
  font-weight: 500;
}

.av-cell {
  cursor: pointer;
  line-height: 1.35;
}

.av-cell:hover {
  background: var(--bg);
}

.av-cell-hol {
  background: var(--warn-soft);
}

.av-cell-empty .av-dash,
.av-dash {
  color: var(--muted);
}

.av-hol-badge {
  white-space: nowrap;
  font-size: 0.8rem;
}

.av-ov-dot {
  color: var(--accent);
  font-weight: 700;
}

.av-inactive {
  color: var(--muted);
  font-size: 0.75rem;
}

/* Day view */
.av-day {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.av-axis,
.av-day-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: center;
}

.av-axis {
  height: 1.1rem;
  margin-bottom: 0.15rem;
}

.av-axis-track {
  position: relative;
  height: 100%;
}

.av-tick {
  position: absolute;
  transform: translateX(-50%);
  font-size: 0.7rem;
  color: var(--muted);
}

.av-day-name {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 0.5rem;
}

.av-day-row {
  cursor: pointer;
}

.av-bar-track {
  position: relative;
  height: 1.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.av-bar {
  position: absolute;
  top: 2px;
  bottom: 2px;
  background: var(--accent);
  opacity: 0.85;
  border-radius: 3px;
}

.av-bar-hol {
  display: flex;
  align-items: center;
  padding-left: 0.5rem;
  background: var(--warn-soft);
}

.av-bar-empty {
  display: flex;
  align-items: center;
  padding-left: 0.5rem;
}

.av-bar-empty .av-dash {
  font-size: 0.8rem;
}

/* Month counts (reuses .hol-cal / .hol-grid / .hol-cell) */
.av-month-cell[data-date] {
  cursor: pointer;
}

.av-month-cell[data-date]:hover {
  background: var(--bg);
}

.av-m-counts {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.15rem 0.25rem;
  font-size: 0.8rem;
}

.av-m-avail {
  color: var(--accent);
}

.av-m-off {
  color: var(--warn);
}

/* Edit popover extras (modal chrome reuses .hol-modal) */
.ave-holiday-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0 0.75rem;
  font-weight: 500;
}

.ave-holiday-row input {
  width: auto;
}

.ave-windows-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
  font-weight: 500;
}

.ave-win {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

.ave-win input[type="time"] {
  width: auto;
}

.ave-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0.25rem 0 0;
}

.ave-scope {
  border-top: 1px solid var(--border);
  margin-top: 0.75rem;
  padding-top: 0.75rem;
}

.ave-scope-q {
  margin: 0 0 0.5rem;
  font-weight: 500;
}

@media (max-width: 720px) {
  .av-axis,
  .av-day-row {
    grid-template-columns: 84px 1fr;
  }
}

/* ---- Requests queue + status chips + stale-rota chip ------------------- */

