:root {
  color-scheme: light;
  --navy: #0b2e46;
  --navy-deep: #071f31;
  --navy-soft: #153d57;
  --orange: #f26a35;
  --yellow: #f2bd27;
  --teal: #178d8a;
  --paper: #ffffff;
  --canvas: #dfe8ed;
  --ink: #102434;
  --muted: #607584;
  --line: #7c909c;
  --row-count: 8;
  font-family: Inter, Aptos, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { color: var(--ink); background: var(--canvas); }

.display {
  width: 100vw;
  height: 100vh;
  min-width: 1024px;
  padding: clamp(7px, .75vw, 14px);
  display: grid;
  grid-template-rows: clamp(66px, 7.7vh, 92px) minmax(0, 1fr) clamp(100px, 13.2vh, 148px);
  gap: clamp(5px, .55vw, 10px);
  background:
    radial-gradient(circle at 20% -20%, rgba(255,255,255,.92), transparent 37%),
    linear-gradient(135deg, #eef3f6, var(--canvas));
}

.topbar {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(250px, 1.35fr) minmax(260px, .9fr) minmax(250px, .85fr) minmax(130px, .5fr);
  align-items: center;
  gap: clamp(12px, 1.2vw, 25px);
  padding: 9px clamp(13px, 1.1vw, 22px);
  overflow: hidden;
  color: #fff;
  background: linear-gradient(110deg, var(--navy-deep), var(--navy-soft) 78%, #0e5360);
  border-bottom: 4px solid var(--orange);
  border-radius: 8px;
  box-shadow: 0 7px 22px rgba(10,40,59,.16);
}

.eyebrow, .period span, .sync small {
  display: block;
  color: #a9c0cf;
  font-size: clamp(9px, .65vw, 13px);
  font-weight: 850;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.identity h1 { margin: 2px 0 0; font-size: clamp(20px, 1.55vw, 32px); line-height: 1.04; }
.period { text-align: center; }
.period strong { display: block; margin-top: 3px; font-size: clamp(17px, 1.2vw, 26px); white-space: nowrap; }
.sync { min-width: 0; display: flex; align-items: center; gap: 9px; }
.sync i { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 0 5px rgba(242,189,39,.12); }
.sync[data-state="ok"] i { background: #54d18b; box-shadow: 0 0 0 5px rgba(84,209,139,.12); }
.sync[data-state="stale"] i, .sync[data-state="error"] i { background: var(--orange); }
.sync strong { display: block; overflow: hidden; font-size: clamp(10px, .72vw, 15px); text-overflow: ellipsis; white-space: nowrap; }
.sync small { margin-top: 3px; letter-spacing: 0; text-transform: none; }
.clock { text-align: right; }
.clock strong { display: block; font-size: clamp(23px, 2vw, 39px); line-height: .95; font-variant-numeric: tabular-nums; }
.clock span { display: block; margin-top: 5px; color: #d6e3ea; font-size: clamp(9px, .65vw, 13px); text-transform: capitalize; white-space: nowrap; }

.schedule {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(100px, .7fr) minmax(0, 7fr);
  grid-template-rows: clamp(47px, 5.3vh, 63px) minmax(0, 1fr);
  overflow: hidden;
  background: var(--paper);
  border: 2px solid #253b49;
  box-shadow: 0 7px 20px rgba(16,48,67,.1);
}
.cell { min-width: 0; border-right: 1px solid var(--line); border-bottom: 1px solid #98a8b1; }
.corner { display: grid; place-items: center; padding: 4px; color: #fff; background: var(--navy); font-size: clamp(9px, .66vw, 14px); font-weight: 950; }
.day-headers { min-width: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.day { display: grid; align-content: center; justify-items: center; padding: 3px 4px; overflow: hidden; color: #fff; background: var(--navy); text-align: center; }
.day:last-child { border-right: 0; }
.day > div { line-height: 1.05; white-space: nowrap; }
.day-name { font-size: clamp(9px, .62vw, 14px); letter-spacing: .025em; }
.day-number { margin-left: 5px; color: #ff9b6b; font-size: clamp(12px, .78vw, 18px); font-weight: 950; }
.day-note { display: -webkit-box; max-width: 100%; margin-top: 3px; overflow: hidden; color: #fff; font-size: clamp(7px, .45vw, 10px); font-weight: 700; line-height: 1.05; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.day-note:empty { display: none; }

.schedule-body {
  min-width: 0;
  min-height: 0;
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(100px, .7fr) repeat(7, minmax(0, 1fr));
  grid-template-rows: repeat(var(--row-count), minmax(0, 1fr));
}
.driver { display: flex; align-items: center; padding: 2px 8px; overflow: hidden; background: #f8fafb; font-size: clamp(9px, .65vw, 15px); font-weight: 950; white-space: nowrap; text-overflow: ellipsis; }
.assignment { display: flex; align-items: center; padding: 1px 4px; overflow: hidden; background: #fff; }
.assignment.alt { background: #f2f6f8; }
.assignment.unavailable { color: #fff; background: #46535e; }
.assignment.warning { background: #ffe0df; box-shadow: inset 0 0 0 2px #c83a36; }
.empty-state { width: 100%; overflow: hidden; font-size: clamp(7px, .46vw, 11px); font-weight: 850; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.work-pieces { width: 100%; max-height: 100%; display: flex; align-content: center; flex-wrap: wrap; gap: 1px 5px; overflow: hidden; font-size: clamp(7.4px, .5vw, 11.5px); font-weight: 800; line-height: 1.05; }
.work-piece { min-width: 0; display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; }
.order { flex: 0 0 auto; width: 12px; height: 12px; display: grid; place-items: center; color: #fff; background: var(--navy); border-radius: 50%; font-size: 7px; font-style: normal; line-height: 1; }
.service { min-width: 0; overflow: hidden; font-style: normal; text-overflow: ellipsis; }
.service.school { padding: 1px 3px; color: #533b77; background: #eee5ff; border-radius: 4px; }
.service.mfq { padding: 1px 3px; color: #75456e; background: #fde5f6; border-radius: 4px; }
.bus { color: var(--orange); font-size: .92em; font-weight: 950; }

.density-high .work-pieces { font-size: clamp(7.2px, .47vw, 10.25px); gap: 0 4px; }
.density-high .order { width: 10px; height: 10px; font-size: 6px; }
.density-compact .display { grid-template-rows: clamp(62px, 7vh, 78px) minmax(0, 1fr) clamp(88px, 11vh, 118px); }
.density-compact .work-pieces { font-size: clamp(7px, .45vw, 10px); gap: 0 3px; line-height: 1; }
.density-compact .order { width: 9px; height: 9px; font-size: 5.5px; }
.density-compact .driver { font-size: clamp(8px, .54vw, 12px); }

.lower-panels { min-height: 0; display: grid; grid-template-columns: 1.45fr 1fr; gap: clamp(5px, .55vw, 10px); }
.info-panel { min-width: 0; display: grid; grid-template-columns: clamp(34px, 2.5vw, 48px) minmax(0, 1fr); overflow: hidden; background: #fff; border: 2px solid #253b49; }
.info-panel h2 { margin: 0; display: grid; place-items: center; padding: 4px; color: #fff; background: var(--orange); font-size: clamp(9px, .68vw, 15px); letter-spacing: .08em; writing-mode: vertical-rl; transform: rotate(180deg); }
.pieces { min-width: 0; min-height: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); gap: 5px; padding: 6px; overflow: hidden; }
.give-piece { min-width: 0; display: grid; align-content: center; padding: 4px 7px; overflow: hidden; background: #fff8df; border-left: 4px solid var(--yellow); }
.give-piece strong, .give-piece span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.give-piece strong { font-size: clamp(8px, .6vw, 13px); }
.give-piece span { margin-top: 2px; color: #586a76; font-size: clamp(7px, .49vw, 11px); }
.notes-panel p { align-self: center; margin: 0; padding: clamp(7px, .75vw, 14px); overflow: hidden; font-size: clamp(9px, .7vw, 15px); font-weight: 750; line-height: 1.25; }
.fatal { grid-column: 1 / -1; display: grid; place-items: center; padding: 30px; color: #a2312e; background: #fff; font-weight: 850; text-align: center; }

@media (max-width: 1180px) {
  .topbar { grid-template-columns: minmax(230px, 1.2fr) minmax(230px, .9fr) minmax(210px, .8fr) 120px; }
  .sync small, .clock span { display: none; }
  .display { padding: 6px; gap: 5px; }
}

@media (max-height: 720px) {
  .display { grid-template-rows: 58px minmax(0, 1fr) 70px; padding: 5px; gap: 4px; }
  .topbar { padding-top: 5px; padding-bottom: 5px; }
  .pieces { padding: 3px; gap: 2px; }
  .give-piece { padding: 2px 5px; }
  .give-piece span { margin-top: 1px; }
  .notes-panel p { padding: 5px 7px; line-height: 1.15; }
}

@media print {
  @page { size: legal landscape; margin: .18in; }
  html, body { width: 14in; height: 8.5in; overflow: hidden; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .display { width: 13.64in; height: 8.14in; min-width: 0; }
}
