:root {
  --ink: #172033;
  --muted: #64748b;
  --line: #cbd5e1;
  --paper: #f8fafc;
  --panel: #ffffff;
  --ups-brown: #3a2417;
  --ups-gold: #ffb500;
  --title-blue: #1f557f;
  --sheet-blue: #bee6f6;
  --sheet-blue-deep: #9fd3e6;
  --sheet-yellow: #fff200;
  --off-cell: #e7e7e7;
  --good: #0f766e;
  --warn: #b7791f;
  --bad: #b42318;
  --focus: #2563eb;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #edf2f7;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, rgba(255, 181, 0, 0.09), rgba(255, 255, 255, 0) 220px),
    #edf2f7;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
.import-button:focus-visible,
.shift-button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}

.app-shell {
  width: min(100%, 1680px);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) auto auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  color: #fff;
  background: var(--ups-brown);
  border-bottom: 5px solid var(--ups-gold);
  box-shadow: var(--shadow);
}

.identity {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.ups-mark {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  color: var(--ups-gold);
  border: 2px solid rgba(255, 181, 0, 0.75);
  border-radius: 8px;
  font-weight: 900;
  letter-spacing: 0;
}

.identity-copy {
  min-width: 0;
}

.identity h1 {
  margin: 0 0 6px;
  font-size: clamp(1.25rem, 2vw, 1.65rem);
  line-height: 1.1;
  letter-spacing: 0;
}

.store-field {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.85rem;
  font-weight: 700;
}

.store-field input {
  width: min(220px, 44vw);
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 6px;
  padding: 8px 10px;
  font-weight: 800;
}

.week-controls,
.action-controls,
.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.week-controls input[type="date"] {
  min-height: 40px;
  color: var(--ink);
  background: #fff;
  border: 0;
  border-radius: 6px;
  padding: 8px 10px;
  font-weight: 800;
}

.icon-button,
.text-button,
.primary-button,
.danger-button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 9px 12px;
  font-weight: 800;
  line-height: 1;
}

.icon-button {
  display: inline-grid;
  width: 40px;
  place-items: center;
  padding: 0;
  color: var(--ink);
  background: #fff;
}

.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.18);
}

.text-button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #2a1a12;
  background: var(--ups-gold);
  border-color: #f4aa00;
}

.primary-button span {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
}

.danger-button {
  width: 100%;
  color: #fff;
  background: var(--bad);
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 1px;
  margin: 14px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--line);
}

.metric {
  min-height: 74px;
  padding: 14px;
  background: #fff;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 1.45rem;
  line-height: 1;
}

.metric.good strong {
  color: var(--good);
}

.metric.warn strong {
  color: var(--warn);
}

.metric.bad strong {
  color: var(--bad);
}

.planner {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.side-panel {
  position: sticky;
  top: 12px;
  display: grid;
  gap: 12px;
}

.control-section {
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
}

.section-heading {
  margin-bottom: 12px;
  color: var(--ups-brown);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.field-grid,
.time-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.time-grid {
  margin-top: 10px;
}

.stacked-field {
  display: block;
  margin-top: 10px;
}

.no-top-margin {
  margin-top: 0;
}

.side-panel label span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.side-panel input,
.side-panel select,
.side-panel textarea {
  width: 100%;
  min-height: 38px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 9px;
  font-weight: 700;
}

.side-panel textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.35;
}

.side-panel .button-row {
  margin-top: 12px;
}

.side-panel .text-button {
  flex: 1 1 auto;
  color: var(--ink);
  background: #f1f5f9;
  border-color: var(--line);
}

.planner-button {
  flex: 1 1 auto;
  justify-content: center;
}

.draft-card {
  margin-top: 12px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.draft-status {
  margin-bottom: 8px;
  color: var(--ups-brown);
  font-size: 0.82rem;
  font-weight: 900;
}

.draft-card ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.35;
}

.draft-card li.warning {
  color: var(--bad);
}

.draft-actions {
  display: flex;
  margin-top: 12px;
}

.sync-status {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.35;
}

.sync-status.good {
  color: var(--good);
}

.sync-status.bad {
  color: var(--bad);
}

.add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 8px;
}

.sheet-area {
  min-width: 0;
}

.view-tabs {
  display: inline-flex;
  gap: 2px;
  margin-bottom: 10px;
  padding: 4px;
  background: #dbe4ef;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tab-button {
  min-width: 112px;
  min-height: 36px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-weight: 900;
}

.tab-button.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.view-pane[hidden] {
  display: none;
}

.sheet-scroll {
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.schedule-table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  table-layout: fixed;
  background: #fff;
}

.schedule-table th,
.schedule-table td {
  border: 1px solid rgba(125, 140, 155, 0.35);
}

.title-row th {
  height: 58px;
  color: #fff;
  background: var(--title-blue);
  font-size: 1.55rem;
  font-weight: 900;
  text-align: center;
  letter-spacing: 0;
}

.day-row th {
  height: 34px;
  color: #000;
  background: var(--sheet-yellow);
  font-size: 1rem;
  font-weight: 900;
  text-align: center;
}

.employee-col {
  width: 140px;
}

.day-col {
  width: 150px;
}

.hours-col {
  width: 132px;
}

.employee-name,
.hours-cell,
.schedule-cell {
  height: 104px;
}

.employee-name {
  padding: 10px 12px;
  font-size: 1rem;
  font-weight: 800;
  text-align: center;
  background: #fff;
}

.row-blue .employee-name,
.row-blue .hours-cell,
.row-blue .schedule-cell:not(.off-cell) {
  background: var(--sheet-blue);
}

.row-white .employee-name,
.row-white .hours-cell,
.row-white .schedule-cell:not(.off-cell) {
  background: #fff;
}

.schedule-cell {
  position: relative;
  padding: 0;
  text-align: center;
  vertical-align: middle;
}

.schedule-cell.off-cell {
  background: var(--off-cell);
}

.schedule-cell.draft-change {
  box-shadow: inset 0 0 0 3px var(--ups-gold);
}

.schedule-cell.coverage-gap::after,
.hours-cell.overtime::after,
.schedule-cell.meal-warning::before {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  content: "";
}

.schedule-cell.coverage-gap::after,
.hours-cell.overtime::after {
  background: var(--bad);
}

.schedule-cell.meal-warning::before {
  right: auto;
  left: 7px;
  background: var(--warn);
}

.shift-button {
  display: grid;
  width: 100%;
  height: 104px;
  place-items: center;
  padding: 8px 12px;
  color: inherit;
  text-align: center;
  text-decoration: none;
  background: transparent;
  border: 0;
}

.shift-copy {
  display: grid;
  gap: 3px;
  line-height: 1.25;
}

.shift-copy strong {
  font-size: 1rem;
  font-weight: 900;
}

.shift-copy span {
  font-size: 0.95rem;
  font-weight: 800;
}

.meal-badge {
  justify-self: center;
  width: fit-content;
  margin-top: 2px;
  padding: 3px 6px;
  color: #4a2d00;
  background: #fde68a;
  border: 1px solid #f59e0b;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.off-cell .shift-copy strong {
  color: #666;
  font-size: 1rem;
  text-transform: uppercase;
}

.schedule-cell.selected {
  box-shadow: inset 0 0 0 3px var(--focus);
}

.hours-cell {
  position: relative;
  padding: 12px;
  font-size: 1rem;
  font-weight: 800;
  text-align: center;
  vertical-align: middle;
}

.hours-cell.overtime {
  color: #fff;
  background: var(--bad);
}

.coverage-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(128px, 1fr));
  gap: 1px;
  margin-top: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--line);
}

.coverage-item {
  min-height: 76px;
  padding: 12px;
  background: #fff;
}

.coverage-item strong,
.coverage-item span {
  display: block;
}

.coverage-item span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.coverage-item strong {
  margin-top: 4px;
  font-size: 1.2rem;
}

.coverage-item small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 700;
}

.coverage-item.good {
  border-top: 4px solid var(--good);
}

.coverage-item.bad {
  border-top: 4px solid var(--bad);
}

.timeline-board {
  display: grid;
  gap: 12px;
}

.timeline-day {
  display: grid;
  grid-template-columns: 178px minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
}

.timeline-day-header {
  display: grid;
  align-content: center;
  gap: 5px;
  min-height: 124px;
  padding: 14px;
  border-left: 5px solid var(--good);
  border-right: 1px solid var(--line);
}

.timeline-day.bad .timeline-day-header {
  border-left-color: var(--bad);
}

.timeline-day-header span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.timeline-day-header strong {
  font-size: 1.05rem;
  line-height: 1.15;
}

.timeline-day-header small {
  color: var(--muted);
  font-weight: 800;
}

.timeline-track {
  position: relative;
  min-height: 124px;
  height: var(--track-height);
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(15, 23, 42, 0.08) 1px, transparent 1px) 0 30px / 12.5% calc(100% - 30px),
    #fbfdff;
}

.timeline-axis {
  position: absolute;
  inset: 0 0 auto;
  height: 30px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.timeline-tick {
  position: absolute;
  top: 0;
  left: var(--x);
  height: 30px;
  transform: translateX(-1px);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  white-space: nowrap;
}

.timeline-tick::before {
  display: block;
  width: 1px;
  height: 8px;
  margin-bottom: 2px;
  background: var(--line);
  content: "";
}

.timeline-tick.end {
  transform: translateX(-100%);
  text-align: right;
}

.timeline-tick.end::before {
  margin-left: auto;
}

.timeline-bar {
  position: absolute;
  top: var(--top);
  left: var(--left);
  width: var(--width);
  min-width: 68px;
  height: 28px;
  overflow: hidden;
  color: #fff;
  background: var(--bar);
  border: 0;
  border-radius: 6px;
  box-shadow: 0 7px 14px rgba(15, 23, 42, 0.15);
}

.timeline-bar.selected {
  outline: 3px solid rgba(37, 99, 235, 0.45);
  outline-offset: 2px;
}

.timeline-bar span {
  display: block;
  overflow: hidden;
  padding: 5px 8px;
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-empty {
  position: absolute;
  top: 56px;
  left: 18px;
  color: var(--muted);
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  color: #fff;
  background: #111827;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

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

@media (max-width: 1120px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .planner {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding: 10px;
  }

  .metric-strip,
  .coverage-grid,
  .side-panel {
    grid-template-columns: 1fr;
  }

  .field-grid,
  .time-grid {
    grid-template-columns: 1fr;
  }

  .timeline-day {
    grid-template-columns: 1fr;
  }

  .timeline-day-header {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .title-row th {
    font-size: 1.2rem;
  }
}

@media print {
  @page {
    size: landscape;
    margin: 0.35in;
  }

  body.print-schedule,
  body.print-schedule * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  html,
  body {
    background: #fff;
  }

  body.print-schedule .topbar,
  body.print-schedule .metric-strip,
  body.print-schedule .side-panel,
  body.print-schedule .view-tabs,
  body.print-schedule .coverage-grid,
  body.print-schedule #timelineView,
  body.print-schedule .toast {
    display: none !important;
  }

  body.print-schedule .app-shell {
    width: 100%;
    max-width: none;
    padding: 0;
  }

  body.print-schedule .planner {
    display: block;
  }

  body.print-schedule .sheet-area,
  body.print-schedule .view-pane,
  body.print-schedule .sheet-scroll {
    display: block !important;
    overflow: visible;
    border: 0;
    box-shadow: none;
  }

  body.print-schedule .schedule-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
    page-break-inside: avoid;
    background: #fff !important;
  }

  body.print-schedule .title-row th {
    height: 42px;
    color: #fff !important;
    background: var(--title-blue) !important;
    font-size: 18px;
  }

  body.print-schedule .day-row th {
    height: 26px;
    color: #000 !important;
    background: var(--sheet-yellow) !important;
    font-size: 11px;
  }

  body.print-schedule .row-blue .employee-name,
  body.print-schedule .row-blue .hours-cell,
  body.print-schedule .row-blue .schedule-cell:not(.off-cell) {
    background: var(--sheet-blue) !important;
  }

  body.print-schedule .row-white .employee-name,
  body.print-schedule .row-white .hours-cell,
  body.print-schedule .row-white .schedule-cell:not(.off-cell) {
    background: #fff !important;
  }

  body.print-schedule .schedule-cell.off-cell {
    background: var(--off-cell) !important;
  }

  body.print-schedule .hours-cell.overtime {
    color: #fff !important;
    background: var(--bad) !important;
  }

  body.print-schedule .meal-badge {
    color: #4a2d00 !important;
    background: #fde68a !important;
    border-color: #f59e0b !important;
  }

  body.print-schedule .schedule-cell.selected:not(.draft-change),
  body.print-schedule .timeline-bar.selected {
    box-shadow: none !important;
    outline: 0 !important;
  }

  body.print-schedule .schedule-cell.selected.draft-change {
    box-shadow: inset 0 0 0 3px var(--ups-gold) !important;
  }

  body.print-schedule .shift-button:focus,
  body.print-schedule .shift-button:focus-visible {
    outline: 0 !important;
  }

  body.print-schedule .employee-name,
  body.print-schedule .hours-cell,
  body.print-schedule .schedule-cell,
  body.print-schedule .shift-button {
    height: 72px;
  }

  body.print-schedule .shift-copy strong,
  body.print-schedule .shift-copy span,
  body.print-schedule .employee-name,
  body.print-schedule .hours-cell {
    font-size: 10px;
  }

  body.print-schedule button {
    color: inherit;
  }
}
