/* Breaker — red/gray theme; primary red #CC0000 */
:root {
  --red: #CC0000;
  --red-dark: #a30000;
  --gray-100: #f5f5f5;
  --gray-200: #e5e5e5;
  --gray-300: #d0d0d0;
  --gray-500: #737373;
  --gray-700: #404040;
  --gray-900: #171717;
  --white: #ffffff;
  /* Role colors (timeline/coverage) */
  --role-opu: #1e3a8a;
  --role-sfs: #0f766e;
  --role-pick: #b45309;
  --role-prep: #6b21a8;
  --role-pack: #c2410c;
  --role-flex: #6b7280;
  --font-sans: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { height: 100%; overflow: hidden; }
body {
  margin: 0;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  background: var(--gray-100);
  color: var(--gray-900);
}

/* Command strip */
.command-strip {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--gray-900);
  color: var(--white);
  flex-wrap: wrap;
  gap: 0.5rem;
}
.strip-left { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.app-name { font-weight: 700; color: var(--red); }
.strip-date, .strip-label { color: var(--gray-300); }
.strip-stat { font-size: 0.9rem; }
.btn-alerts {
  background: var(--red);
  color: var(--white);
  border: none;
  border-radius: 4px;
  min-width: 1.5rem;
  padding: 0.25rem;
  cursor: pointer;
  font-weight: 600;
}
.btn-alerts:hover { background: var(--red-dark); }
.strip-right { display: flex; align-items: center; gap: 0.5rem; }
.strip-check { font-size: 0.85rem; display: flex; align-items: center; gap: 0.35rem; cursor: pointer; }
.warnings-section { font-size: 0.85rem; color: #b45309; }
.warnings-section.empty { display: none; }
.btn-primary { background: var(--red); color: var(--white); border: none; padding: 0.4rem 0.8rem; border-radius: 4px; cursor: pointer; font-weight: 500; }
.btn-primary:hover { background: var(--red-dark); }
.btn-secondary { background: var(--gray-500); color: var(--white); border: none; padding: 0.4rem 0.8rem; border-radius: 4px; cursor: pointer; }
.btn-secondary:hover { background: var(--gray-700); }

/* Hard zero banner */
.hard-zero-banner {
  flex-shrink: 0;
  background: var(--red);
  color: var(--white);
  padding: 0.5rem 1rem;
  text-align: center;
  font-weight: 600;
}
.hard-zero-banner.hidden { display: none; }

/* Main layout */
.main-layout {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: 300px 1fr;
  grid-template-rows: minmax(0, 1fr) minmax(56px, 80px);
  gap: 0;
}
.panel-left {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--gray-100);
  border-right: 1px solid var(--gray-200);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-content: flex-start;
}
.panel-left .panel-block {
  flex-shrink: 0;
}
.panel-block {
  padding: 0.75rem 0.75rem;
  background: var(--white);
  border-radius: 6px;
  border: 1px solid var(--gray-200);
  position: relative;
  overflow: visible;
}
.panel-block:last-of-type { border-bottom: 1px solid var(--gray-200); }
.suggestion-panel.hidden {
  display: none !important;
  pointer-events: none;
  visibility: hidden;
}
.panel-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-500);
  margin-bottom: 0;
}

/* Collapsible panel blocks (left panel) */
.collapsible .panel-header {
  width: 100%;
  border: none;
  background: transparent;
  padding: 0;
  margin: 0 0 0.5rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  cursor: pointer;
  text-align: left;
  position: relative;
  z-index: 2;
}
.collapsible .panel-header:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
  border-radius: 6px;
}
.collapsible .panel-body { min-height: 0; position: relative; z-index: 0; }
.collapsible.collapsed .panel-body { display: none; }
.collapsible.collapsed .panel-header { margin-bottom: 0; }
.panel-chevron {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--gray-500);
  transform: rotate(0deg);
  transition: transform 120ms ease;
  flex-shrink: 0;
}
.collapsible.collapsed .panel-chevron { transform: rotate(-90deg); }
.panel-add .add-row { margin-bottom: 0; }
.add-row { display: flex; gap: 0.5rem; }
.add-row input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.5rem;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font-size: 0.9rem;
}
.add-row input:focus { border-color: var(--red); outline: none; }
.btn-add { flex-shrink: 0; padding: 0.5rem 0.75rem; }

.panel-presets .presets { margin-top: 0; }
.presets { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.preset-btn {
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  cursor: pointer;
  color: var(--gray-700);
}
.preset-btn:hover { background: var(--gray-200); border-color: var(--gray-500); }

.panel-settings .settings-row { margin-bottom: 0.4rem; }
.panel-settings .settings-row:last-child { margin-bottom: 0; }
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.settings-row .setting-label { font-size: 0.85rem; color: var(--gray-700); flex: 1; }
.settings-row input[type="number"] {
  width: 3.5rem;
  padding: 0.35rem 0.4rem;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font-size: 0.9rem;
  text-align: center;
}
.settings-row input:focus { border-color: var(--red); outline: none; }

.time-blocks-wrap { margin-top: 0.5rem; }
.time-blocks-wrap .setting-label { display: block; margin-bottom: 0.25rem; }
#timeBlocksList { margin-bottom: 0.35rem; }
.time-block-row { display: flex; align-items: center; gap: 0.25rem; margin-bottom: 0.25rem; font-size: 0.85rem; }
.time-block-row .tb-start, .time-block-row .tb-end { width: 4rem; padding: 0.2rem; border: 1px solid var(--gray-300); border-radius: 4px; }
.time-block-row .tb-min { width: 2.5rem; padding: 0.2rem; text-align: center; border: 1px solid var(--gray-300); border-radius: 4px; }
.time-block-row .tb-del { background: none; border: none; color: var(--gray-400); cursor: pointer; padding: 0; font-size: 1rem; }
.time-block-row .tb-del:hover { color: var(--red); }
.btn-sm { font-size: 0.8rem; padding: 0.25rem 0.5rem; margin-top: 0.25rem; }

.panel-batch .role-suggestion { font-size: 0.8rem; color: var(--gray-600); margin-top: 0.25rem; }

.panel-team { flex: 1 1 0; min-height: 120px; display: flex; flex-direction: column; overflow: hidden; }
.panel-team .panel-label { flex-shrink: 0; }
.panel-team .tm-list { margin-top: 0; overflow-y: auto; overflow-x: hidden; min-height: 60px; flex: 1; -webkit-overflow-scrolling: touch; }
.tm-list { display: flex; flex-direction: column; gap: 0.5rem; }
.tm-list-empty { padding: 0.75rem; text-align: center; color: var(--gray-500); font-size: 0.85rem; }
.tm-row {
  padding: 0.5rem 0.5rem 0.5rem 0.35rem;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 0.85rem;
  background: var(--gray-50, #fafafa);
}
.tm-row[draggable="true"] { cursor: grab; }
.tm-row.dragging { opacity: 0.6; }
.tm-row-top {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}
.tm-row .drag-handle { cursor: grab; color: var(--gray-400); padding: 0 0.15rem; font-size: 0.9rem; user-select: none; }
.tm-row input.name {
  flex: 1;
  min-width: 0;
  padding: 0.25rem 0.35rem;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 500;
}
.tm-row input.name:focus { border-color: var(--red); outline: none; background: var(--white); }
.tm-row select {
  padding: 0.2rem 0.35rem;
  font-size: 0.8rem;
  min-width: 0;
  max-width: 5rem;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  background: var(--white);
}
.tm-row .btn-del {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  padding: 0.2rem;
  font-size: 1.1rem;
  line-height: 1;
  border-radius: 2px;
}
.tm-row .btn-del:hover { color: var(--red); background: var(--gray-100); }
.tm-row-bottom {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
  padding-left: 1.5rem;
}
.tm-row-bottom .start, .tm-row-bottom .end {
  width: 4rem;
  padding: 0.2rem 0.3rem;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  font-size: 0.8rem;
}
.tm-row-bottom .start:focus, .tm-row-bottom .end:focus { border-color: var(--red); outline: none; }
.tm-sep { color: var(--gray-400); font-size: 0.8rem; }
.tm-row .break-pkg { font-size: 0.75rem; color: var(--gray-500); margin-left: 0.35rem; }

/* Role colors on rows */
.tm-row[data-role="OPU"] { border-left: 4px solid var(--role-opu); }
.tm-row[data-role="SFS"] { border-left: 4px solid var(--role-sfs); }
.tm-row[data-role="Pick"] { border-left: 4px solid var(--role-pick); }
.tm-row[data-role="Prep"] { border-left: 4px solid var(--role-prep); }
.tm-row[data-role="Pack"] { border-left: 4px solid var(--role-pack); }
.tm-row[data-role="Flex"] { border-left: 4px solid var(--role-flex); border-left-style: dashed; }

.panel-warnings.panel-block { padding: 0.5rem 0; }
.panel-warnings #warningsContent { font-size: 0.85rem; color: #b45309; }
.panel-warnings #warningsContent p { margin: 0.25rem 0 0 0; }
.panel-warnings.empty { display: none; }

.panel-next-up #nextUpList { font-size: 0.85rem; color: var(--gray-700); }
#nextUpList { margin-top: 0; }
#nextUpList > div { padding: 0.2rem 0; border-bottom: 1px solid var(--gray-100); }
#nextUpList > div:last-child { border-bottom: none; }
#nextUpList .next-up-empty { color: var(--gray-400); font-style: italic; }

/* Timeline */
.timeline-wrap { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; min-height: 0; background: var(--white); }
.timeline-toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem;
  border-bottom: 1px solid var(--gray-200);
  font-size: 0.85rem;
}
.timeline-toolbar .toolbar-group { margin: 0; }
.timeline-toolbar .toolbar-sep { color: var(--gray-300); }
.timeline-toolbar .toolbar-zoom { display: flex; align-items: center; gap: 0.25rem; }
.timeline-toolbar .zoom-label { color: var(--gray-600); }
.timeline-toolbar .zoom-btn {
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  background: var(--white);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.timeline-toolbar .zoom-btn:hover { border-color: var(--red); color: var(--red); background: var(--gray-100); }
.timeline-toolbar .zoom-value { min-width: 2.5rem; text-align: center; font-weight: 500; }
.timeline-scroll { flex: 1; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; }
.timeline-inner { position: relative; min-width: 100%; min-height: min-content; }
.timeline-now {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--red);
  z-index: 10;
  pointer-events: none;
}
.timeline-rows { display: flex; flex-direction: column; }
.timeline-row {
  display: flex;
  align-items: center;
  min-height: 28px;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
}
.timeline-row .row-label { min-width: 100px; padding: 0 0.4rem; font-size: 0.8rem; flex-shrink: 0; }
.timeline-row .row-bar-wrap { flex: 1; position: relative; min-height: 24px; }
.timeline-bar {
  position: absolute;
  top: 2px; bottom: 2px;
  border-radius: 4px;
  display: flex;
  align-items: stretch;
  padding-left: 10px;
  font-size: 0.75rem;
  color: var(--white);
  overflow: visible;
}
.bar-resize-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 8px;
  z-index: 3;
  cursor: ew-resize;
}
.bar-resize-handle.bar-resize-start { left: 0; }
.bar-resize-handle.bar-resize-end { right: 0; }
.bar-resize-handle:hover { background: rgba(255,255,255,0.3); }
.timeline-bar.past { opacity: 0.5; }
.timeline-bar.future { opacity: 0.6; }
.timeline-bar.on-break { box-shadow: 0 0 0 2px var(--red); animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.9; } }
.break-marker {
  position: absolute;
  top: 2px; bottom: 2px;
  width: 4px;
  background: var(--white);
  border-radius: 2px;
  cursor: ew-resize;
  z-index: 2;
}
.break-marker.meal { width: 8px; background: repeating-linear-gradient(90deg, var(--white), var(--white) 2px, var(--gray-300) 2px, var(--gray-300) 4px); }
.break-marker.conflict { box-shadow: 0 0 0 2px var(--red); }
.break-marker.warning { box-shadow: 0 0 0 2px #ca8a04; }
.conflict-badge {
  position: absolute;
  top: -4px;
  width: 14px; height: 14px;
  background: var(--red);
  color: var(--white);
  font-size: 0.65rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
}
.conflict-badges-row {
  display: flex;
  align-items: center;
  min-height: 20px;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
}
.conflict-badges-row .row-label { min-width: 100px; padding: 0 0.4rem; font-size: 0.75rem; color: var(--red); }
.conflict-badges-wrap { position: relative; flex: 1; min-height: 18px; }
.conflict-badges-wrap .conflict-badge { top: 0; }
.timeline-bar.end-soon::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 30%;
  background: linear-gradient(to right, transparent, rgba(0,0,0,0.25));
  border-radius: 0 4px 4px 0;
  pointer-events: none;
}

/* Role bar colors */
.timeline-bar[data-role="OPU"] { background: var(--role-opu); }
.timeline-bar[data-role="SFS"] { background: var(--role-sfs); }
.timeline-bar[data-role="Pick"] { background: var(--role-pick); }
.timeline-bar[data-role="Prep"] { background: var(--role-prep); }
.timeline-bar[data-role="Pack"] { background: var(--role-pack); }
.timeline-bar[data-role="Flex"] { background: var(--role-flex); border: 2px dashed var(--gray-700); }

/* Coverage section */
.coverage-section {
  grid-column: 1 / -1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0.35rem 1rem 0.5rem;
  background: var(--gray-100);
  border-top: 1px solid var(--gray-200);
}
.coverage-section h3 { margin: 0 0 0.25rem 0; font-size: 0.85rem; flex-shrink: 0; }
.coverage-graph-wrap { flex: 1; min-height: 0; overflow-x: auto; overflow-y: hidden; }
.coverage-graph {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 100%;
  min-height: 44px;
  padding: 0.25rem 0;
}
.coverage-bar {
  flex: 1;
  min-width: 20px;
  border-radius: 2px 2px 0 0;
  position: relative;
}
.coverage-bar.critical { background: var(--red); }
.coverage-bar.at-min { background: #ca8a04; }
.coverage-bar.healthy { background: #16a34a; }
.coverage-bar.well { background: #2563eb; }
.coverage-section-header { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.coverage-stack-toggle { font-size: 0.9rem; font-weight: normal; display: flex; align-items: center; gap: 0.35rem; cursor: pointer; }
.coverage-bar-stacked { display: flex; flex-direction: column-reverse; padding: 0; overflow: hidden; }
.coverage-bar-segment { min-height: 2px; flex: none; }
.coverage-segment-OPU { background: var(--role-opu); }
.coverage-segment-SFS { background: var(--role-sfs); }
.coverage-segment-Pick { background: var(--role-pick); }
.coverage-segment-Prep { background: var(--role-prep); }
.coverage-segment-Pack { background: var(--role-pack); }
.coverage-segment-Flex { background: var(--role-flex); }
.coverage-threshold-line { stroke: var(--gray-700); stroke-width: 1; stroke-dasharray: 4; }

/* Suggestion panel */
.suggestion-panel {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.suggestion-content {
  background: var(--white);
  padding: 1.5rem;
  border-radius: 8px;
  max-width: 400px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.suggestion-content h3 { margin: 0 0 0.5rem 0; color: var(--red); }
.suggestion-content .btn-primary { margin-right: 0.5rem; }

/* Footer */
.app-footer {
  flex-shrink: 0;
  padding: 0.35rem 1rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--gray-500);
  border-top: 1px solid var(--gray-200);
  background: var(--white);
}
.app-footer a { color: var(--red); text-decoration: none; }
.app-footer a:hover { text-decoration: underline; }

/* Time axis (shared) */
.time-axis {
  display: flex;
  align-items: center;
  font-size: 0.65rem;
  color: var(--gray-500);
  border-bottom: 1px solid var(--gray-200);
  min-height: 20px;
  flex-shrink: 0;
}
.time-axis .row-label { min-width: 100px; flex-shrink: 0; }
.time-axis .time-tick-wrap { flex: 1; display: flex; min-width: 0; }
.time-axis .time-tick { flex: 1; text-align: center; min-width: 0; }

/* Print view (hidden on screen) */
.print-view { padding: 1rem; }
.print-view.hidden { display: none !important; }
.print-view h1, .print-view h2, .print-view h3 { margin: 0 0 0.5rem 0; font-size: 1rem; }
.print-timeline { margin: 0.5rem 0; }
.print-row { display: flex; align-items: center; margin-bottom: 2px; font-size: 0.75rem; }
.print-name { width: 100px; flex-shrink: 0; }
.print-bar-wrap { flex: 1; position: relative; height: 14px; background: var(--gray-200); }
.print-bar { position: absolute; top: 0; bottom: 0; border-radius: 2px; }
.print-bar.OPU { background: var(--role-opu); }
.print-bar.SFS { background: var(--role-sfs); }
.print-bar.Pick { background: var(--role-pick); }
.print-bar.Prep { background: var(--role-prep); }
.print-bar.Pack { background: var(--role-pack); }
.print-bar.Flex { background: var(--role-flex); }
.print-break { position: absolute; top: 0; bottom: 0; background: white; }
.print-break.meal { background: repeating-linear-gradient(90deg, #fff, #fff 2px, #ccc 2px, #ccc 4px); }
.print-coverage { margin-top: 0.5rem; }
.print-coverage-bars { display: flex; align-items: flex-end; gap: 2px; height: 40px; }
.print-cov-bar { flex: 1; min-width: 8px; border-radius: 1px 1px 0 0; }
.print-legend { font-size: 0.7rem; color: var(--gray-500); margin-top: 0.25rem; }
.print-conflicts { font-size: 0.75rem; color: var(--red); margin-top: 0.5rem; }
.print-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; margin-top: 0.5rem; }
.print-table th, .print-table td { border: 1px solid var(--gray-700); padding: 0.25rem; text-align: left; }
.print-table th { background: var(--gray-200); }
.print-notes-lines { min-height: 120px; background: repeating-linear-gradient(transparent, transparent 19px, var(--gray-300) 19px, var(--gray-300) 20px); margin: 0.5rem 0; }

/* Print: show only print view */
@media print {
  .command-strip, .hard-zero-banner, .main-layout, .suggestion-panel, .app-footer { display: none !important; }
  .print-view { display: block !important; }
  .print-view.hidden { display: block !important; }
  body { background: white; }
  .print-page { page-break-after: always; }
  .print-page:last-child { page-break-after: auto; }
  .print-view .timeline-bar.on-break { animation: none; box-shadow: 0 0 0 1px #333; }
  @page { size: landscape; margin: 0.5in; }
}
