.capacity-popover,
.compare-modal {
  position: fixed;
  inset: 0;
  z-index: 10020;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--schedule-overlay);
  backdrop-filter: blur(1px);
}

.capacity-popover[hidden],
.compare-modal[hidden] {
  display: none;
}

.capacity-popover > section,
.compare-modal > section {
  width: min(100%, 520px);
  overflow: hidden;
  border: 1px solid var(--schedule-border-strong);
  border-radius: 5px;
  background: var(--schedule-panel);
  box-shadow: 0 18px 42px var(--schedule-shadow-strong);
}

.compare-modal > section {
  width: min(100%, 820px);
  max-height: 70vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.capacity-popover header,
.compare-modal header {
  min-height: 54px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border-bottom: 1px solid var(--schedule-border);
  background: var(--schedule-panel-strong);
}

.capacity-popover header > div,
.compare-modal header > div {
  min-width: 0;
  display: grid;
}

.capacity-popover header span,
.compare-modal header span {
  color: var(--schedule-accent);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.capacity-popover h2,
.compare-modal h2 {
  margin: 1px 0 0;
  color: var(--schedule-heading);
  font-size: 15px;
}

.compare-modal header p {
  margin: 2px 0 0;
  color: var(--schedule-muted);
  font-size: 9px;
}

.capacity-context {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 9px 11px 0;
  padding: 7px 8px;
  border: 1px solid var(--schedule-warning-border);
  border-radius: 3px;
  color: var(--schedule-warning);
  background: var(--schedule-warning-soft);
}

.capacity-context i {
  font-size: 19px;
}

.capacity-context > div {
  min-width: 0;
  display: grid;
}

.capacity-context strong {
  color: var(--schedule-heading);
  font-size: 10.5px;
}

.capacity-context small {
  color: var(--schedule-muted);
  font-size: 9px;
}

.capacity-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 8px;
  padding: 10px 11px 12px;
}

.capacity-popover footer,
.compare-modal footer {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  padding: 6px 10px;
  border-top: 1px solid var(--schedule-border);
  background: var(--schedule-panel-strong);
}

.compare-matrix {
  min-height: 0;
  overflow: auto;
  padding: 10px;
}

.compare-grid {
  display: grid;
  grid-template-columns: minmax(150px, 1.2fr) repeat(3, minmax(145px, 1fr));
  border: 1px solid var(--schedule-border);
  border-right: 0;
  border-bottom: 0;
}

.compare-cell {
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border-right: 1px solid var(--schedule-border);
  border-bottom: 1px solid var(--schedule-border);
  color: var(--schedule-text-soft);
  font-size: 9.5px;
}

.compare-cell.is-head {
  min-height: 48px;
  display: grid;
  align-content: center;
  border-top: 0;
  border-left: 0;
  background: var(--schedule-panel-strong);
  color: inherit;
  font: inherit;
  font-weight: 680;
  text-align: left;
  cursor: pointer;
}

.compare-cell.is-head span {
  color: var(--schedule-muted);
  font-size: 9px;
}

.compare-cell.is-selected {
  box-shadow: inset 0 0 0 2px var(--schedule-accent);
  background: var(--schedule-accent-soft);
}

.compare-cell.is-positive {
  color: var(--schedule-success);
  font-weight: 680;
}

.compare-cell.is-negative {
  color: var(--schedule-danger);
  font-weight: 680;
}

.schedule-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10040;
  min-width: 280px;
  max-width: 390px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border: 1px solid var(--schedule-success-border);
  border-radius: 4px;
  color: var(--schedule-success);
  background: var(--schedule-panel);
  box-shadow: 0 12px 28px var(--schedule-shadow-strong);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity .18s ease, transform .18s ease;
}

.schedule-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.schedule-toast i {
  font-size: 19px;
}

.schedule-toast > div {
  min-width: 0;
  display: grid;
}

.schedule-toast strong {
  color: var(--schedule-heading);
  font-size: 10.5px;
}

.schedule-toast span {
  color: var(--schedule-muted);
  font-size: 9px;
}

.omni-scheduling.is-busy .gantt-segment {
  opacity: .55;
}

.omni-scheduling.is-busy [data-action="run-again"] i,
.omni-scheduling.is-busy [data-action="apply-overtime"] i {
  animation: schedule-spin .75s linear infinite;
}

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

@container scheduling-page (max-width: 1320px) {
  .schedule-page-header { grid-template-columns: minmax(270px, 1fr) auto auto; }
  .workbench-command-strip { grid-template-columns: minmax(120px, .8fr) minmax(190px, 1.3fr) minmax(142px, .9fr) minmax(118px, .8fr) minmax(118px, .8fr) auto; }
  .workbench-command-strip .schedule-field:nth-of-type(6) { display: none; }
  .workbench-layout { grid-template-columns: minmax(610px, 68fr) minmax(340px, 32fr); }
  .control-layout { grid-template-columns: 218px minmax(500px, 1fr) 258px; }
  .gantt-legend span:nth-child(3), .gantt-legend span:nth-child(4) { display: none; }
}

@container scheduling-page (max-width: 1050px) {
  .schedule-page-header { grid-template-columns: minmax(220px, 1fr) auto auto; }
  .schedule-header-actions { display: flex; }
  .schedule-header-actions [data-action="compare"] { display: none; }
  .workbench-command-strip { grid-template-columns: minmax(110px, .75fr) minmax(180px, 1.3fr) minmax(135px, .9fr) minmax(116px, .8fr) auto; }
  .workbench-command-strip .schedule-field:nth-of-type(3) { display: none; }
  .workbench-readiness { grid-template-columns: minmax(180px, auto) 1fr; }
  .readiness-stamp { display: none; }
  .workbench-readiness dl > div { min-width: 82px; }
  .workbench-layout { grid-template-columns: minmax(520px, 1fr) minmax(315px, 37%); }
  .control-layout { grid-template-columns: 194px minmax(0, 1fr); }
  .evaluation-panel { position: absolute; top: 0; right: 0; bottom: 0; z-index: 20; width: 252px; transform: translateX(calc(100% - 28px)); transition: transform .18s ease; box-shadow: -8px 0 18px var(--schedule-shadow); }
  .evaluation-panel:hover, .evaluation-panel:focus-within { transform: translateX(0); }
  .gantt-panel { grid-template-rows: 64px minmax(0, 1fr) 34px; }
  .gantt-toolbar { grid-template-columns: minmax(140px, 1fr) auto auto; grid-template-rows: 29px 28px; align-content: center; }
  .gantt-legend { grid-column: 1 / -1; grid-row: 2; display: flex; }
}

@container scheduling-page (max-width: 860px) {
  .omni-scheduling {
    height: 100%;
    grid-template-rows: auto minmax(0, 1fr);
    padding-inline: 8px;
    overflow: auto;
  }
  .schedule-page-header { grid-template-columns: minmax(0, 1fr) auto; }
  .schedule-header-actions { display: none; }
  .schedule-page-identity p { display: none; }
  .schedule-view-switch button span { display: none; }
  .schedule-view-switch button { padding-inline: 9px; }
  .schedule-view[data-schedule-view="workbench"] {
    grid-template-rows: auto auto auto;
    overflow: visible;
  }
  .workbench-command-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .workbench-command-strip .schedule-field:nth-of-type(1),
  .workbench-command-strip .schedule-field:nth-of-type(2),
  .workbench-command-strip .schedule-field:nth-of-type(3),
  .workbench-command-strip .schedule-field:nth-of-type(6) {
    display: none;
  }
  .workbench-command-strip .schedule-field:nth-of-type(4),
  .workbench-command-strip .schedule-field:nth-of-type(5) {
    display: grid;
  }
  .workbench-command-actions { grid-column: 1 / -1; }
  .workbench-readiness { grid-template-columns: 1fr auto; }
  .workbench-readiness dl > div:nth-child(n+3) { display: none; }
  .workbench-layout {
    grid-template-columns: minmax(0, 1fr);
    overflow: visible;
  }
  .workbench-grid-shell { min-height: 360px; }
  .parameter-workspace {
    position: static;
    width: auto;
    min-height: 440px;
    transform: none;
    box-shadow: 0 1px 2px var(--schedule-shadow-soft);
  }
  .scenario-strip { grid-template-columns: minmax(160px, 1fr) auto; padding-block: 6px; }
  .scenario-strip dl { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .scenario-strip dl > div { min-height: 35px; padding-block: 3px; }
  .schedule-view[data-schedule-view="control"] {
    grid-template-rows: auto auto auto;
    overflow: visible;
  }
  .control-layout {
    grid-template-columns: minmax(0, 1fr);
    overflow: visible;
  }
  .control-left {
    position: static;
    width: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    transform: none;
    box-shadow: none;
  }
  .gantt-panel { grid-column: 1; }
  .evaluation-panel {
    position: static;
    width: auto;
    min-height: 420px;
    transform: none;
    box-shadow: none;
  }
}

@container scheduling-page (max-width: 560px) {
  .schedule-page-title-line h1 { font-size: 15px; }
  .schedule-state-badge { display: none; }
  .workbench-readiness { grid-template-columns: 1fr; }
  .workbench-readiness dl { display: none; }
  .control-left { grid-template-columns: minmax(0, 1fr); }
  .scenario-strip { grid-template-columns: minmax(0, 1fr); }
  .scenario-actions { justify-content: stretch; }
  .scenario-actions .schedule-button { flex: 1 1 0; }
  .kpi-ribbon { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .capacity-form { grid-template-columns: minmax(0, 1fr); }
  .capacity-form .is-span-2 { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .gantt-segment,
  .evaluation-panel,
  .parameter-workspace,
  .control-left,
  .schedule-toast {
    transition-duration: .01ms !important;
  }
}
