:root {
  color-scheme: light;
  --navy: #0a3554;
  --navy-2: #123f61;
  --teal: #08a7a5;
  --teal-soft: #e1f5f4;
  --yellow: #f4b91f;
  --ink: #102a3b;
  --muted: #607789;
  --line: #d5e1e8;
  --paper: #ffffff;
  --canvas: #eaf1f5;
  --danger: #a13b32;
  --shadow: 0 10px 26px rgba(13, 48, 73, .12);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }
body {
  overflow: hidden;
  color: var(--ink);
  background: #dce7ed;
  font-family: Inter, Aptos, "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; }

.display-shell {
  width: 100vw;
  height: 100vh;
  min-height: 560px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  gap: clamp(7px, .8vh, 11px);
  padding: clamp(10px, 1.2vw, 18px);
  background:
    radial-gradient(circle at 15% -20%, rgba(255,255,255,.95), transparent 30%),
    linear-gradient(135deg, #f3f7fa 0%, var(--canvas) 100%);
}

.topbar {
  min-height: 82px;
  display: grid;
  grid-template-columns: minmax(260px, 1.25fr) minmax(240px, .95fr) minmax(260px, 1fr) minmax(180px, .7fr);
  align-items: center;
  gap: 16px;
  padding: 11px 16px;
  color: #fff;
  background: linear-gradient(110deg, #082e4a 0%, var(--navy-2) 72%, #0b5d6b 100%);
  border-bottom: 4px solid var(--yellow);
  border-radius: 15px;
  box-shadow: var(--shadow);
}
.identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  color: var(--navy);
  background: var(--yellow);
  border-radius: 13px;
  font-weight: 950;
  font-size: 1rem;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.12);
}
.eyebrow { display: block; color: #c8dde9; font-size: .68rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.identity h1 { margin: 1px 0 0; font-size: clamp(1.15rem, 1.7vw, 1.7rem); line-height: 1.05; }
.identity p { margin: 3px 0 0; color: #dce9f1; font-size: .76rem; white-space: nowrap; }
.period-heading { min-width: 0; padding-left: 16px; border-left: 1px solid rgba(255,255,255,.2); }
.period-heading span { display: block; color: #bcd4e1; font-size: .66rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 800; }
.period-heading strong { display: block; margin-top: 3px; font-size: clamp(.95rem, 1.35vw, 1.25rem); white-space: nowrap; }
.period-heading small { display: block; margin-top: 2px; color: #d1e1e9; font-size: .7rem; }
.sync-state { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 9px 12px; border-radius: 11px; background: rgba(255,255,255,.08); }
.sync-dot { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; background: #f0c644; box-shadow: 0 0 0 5px rgba(240,198,68,.15); }
.sync-state[data-state="ok"] .sync-dot { background: #43d6a4; box-shadow: 0 0 0 5px rgba(67,214,164,.15); }
.sync-state[data-state="cached"] .sync-dot { background: #f0c644; }
.sync-state[data-state="error"] .sync-dot { background: #ff796f; box-shadow: 0 0 0 5px rgba(255,121,111,.15); }
.sync-state strong, .sync-state small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync-state strong { font-size: .76rem; }
.sync-state small { margin-top: 2px; color: #cfe0e9; font-size: .66rem; }
.clock { text-align: right; min-width: 0; }
.clock strong { display: block; font-size: clamp(1.35rem, 2.1vw, 2rem); line-height: 1; font-variant-numeric: tabular-nums; }
.clock span { display: block; margin-top: 5px; color: #d9e8ef; font-size: .68rem; text-transform: capitalize; }

.period-nav {
  min-height: 45px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 9px;
  border: 1px solid #cfdee6;
  border-radius: 12px;
  background: rgba(255,255,255,.9);
}
.period-copy { flex: 1; min-width: 0; }
.period-copy strong { display: block; color: var(--navy); font-size: .86rem; }
.period-copy span { display: block; color: var(--muted); font-size: .66rem; margin-top: 1px; }
.period-nav button { min-height: 31px; border-radius: 8px; border: 1px solid #c8d8e1; color: var(--navy); background: #fff; font-weight: 850; cursor: pointer; }
.nav-arrow { width: 35px; font-size: 1.25rem; line-height: 1; }
.today-button { padding: 0 13px; font-size: .72rem; }
.period-nav button:disabled { opacity: .35; cursor: default; }

.days-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(8px, .8vw, 13px);
}
.day-card {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid #cbdbe4;
  border-radius: 14px;
  background: var(--paper);
  box-shadow: 0 6px 18px rgba(15,56,82,.09);
}
.day-card.today { border: 2px solid var(--teal); box-shadow: 0 7px 20px rgba(8,167,165,.16); }
.day-heading { display: grid; grid-template-columns: 78px minmax(0,1fr); min-height: 67px; color: #fff; background: var(--navy); }
.date-block { display: grid; place-items: center; align-content: center; padding: 5px; color: var(--navy); background: var(--yellow); text-align: center; }
.day-name { font-size: .62rem; font-weight: 950; letter-spacing: .09em; text-transform: uppercase; }
.day-number { margin: -1px 0; font-size: 1.55rem; line-height: 1; }
.day-month { font-size: .6rem; font-weight: 850; text-transform: lowercase; }
.day-title { display: flex; flex-direction: column; justify-content: center; min-width: 0; padding: 8px 10px; }
.day-title strong { font-size: .83rem; white-space: nowrap; }
.dispatcher { margin-top: 4px; color: #c9dce8; font-size: .64rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sections { min-height: 0; display: flex; flex-direction: column; gap: 5px; padding: 7px; overflow: hidden; }
.route-section { flex: 0 0 auto; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: #fbfdfe; }
.route-section header { min-height: 25px; display: flex; align-items: center; justify-content: space-between; gap: 7px; padding: 4px 7px; color: #fff; background: linear-gradient(90deg, var(--navy-2), #19557d); }
.section-title { font-size: .68rem; }
.section-caption { color: #d2e4ed; font-size: .56rem; white-space: nowrap; }
.route-rows { display: grid; }
.route-row { min-width: 0; display: grid; grid-template-columns: minmax(58px,.72fr) minmax(78px,1.28fr) minmax(38px,.48fr); align-items: center; gap: 5px; min-height: 25px; padding: 3px 6px; border-top: 1px solid #e0e8ed; font-size: .62rem; }
.route-row:first-child { border-top: 0; }
.route-label { min-width: 0; font-weight: 900; color: var(--ink); }
.route-driver { min-width: 0; overflow: hidden; color: #17364b; text-overflow: ellipsis; white-space: nowrap; }
.route-driver.missing { color: #83939e; font-style: italic; font-weight: 700; }
.route-vehicle { justify-self: end; min-width: 34px; padding: 3px 4px; color: #087374; background: var(--teal-soft); border-radius: 6px; font-weight: 950; text-align: center; }
.route-note { grid-column: 1 / -1; display: none; margin: -1px 0 2px; padding: 3px 5px; overflow: hidden; color: #725600; background: #fff5cf; border-radius: 5px; text-overflow: ellipsis; white-space: nowrap; font-size: .56rem; }
.route-row.has-note .route-note { display: block; }
.route-section.charters { flex: 1 1 auto; min-height: 51px; }
.route-section.charters .route-row { grid-template-columns: minmax(45px,.45fr) minmax(88px,1fr) minmax(44px,.45fr); }
.empty-row { padding: 8px; color: #82929d; font-size: .61rem; font-style: italic; }

.general-notes {
  min-height: 46px;
  display: grid;
  grid-template-columns: auto minmax(0,1fr);
  align-items: stretch;
  overflow: hidden;
  border: 1px solid #d5bd65;
  border-radius: 11px;
  background: #fff9df;
}
.notes-heading { display: flex; align-items: center; gap: 7px; padding: 8px 11px; color: var(--navy); background: var(--yellow); }
.notes-heading span { width: 21px; height: 21px; display: grid; place-items: center; border: 2px solid var(--navy); border-radius: 50%; font-weight: 950; font-size: .72rem; }
.notes-heading h2 { margin: 0; font-size: .72rem; white-space: nowrap; }
.general-notes p { align-self: center; margin: 0; padding: 8px 12px; overflow: hidden; color: #4e440f; font-size: .72rem; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }

.screen-footer { display: flex; justify-content: space-between; color: var(--muted); font-size: .59rem; padding: 0 3px; }
.fatal-state { grid-column: 1 / -1; display: grid; place-items: center; min-height: 180px; color: var(--danger); background: #fff; border: 1px solid #e7bab5; border-radius: 14px; font-weight: 850; text-align: center; }

@media (max-width: 1050px) {
  .display-shell { min-width: 900px; }
  .topbar { grid-template-columns: minmax(250px,1.2fr) minmax(210px,.9fr) minmax(220px,1fr) minmax(150px,.65fr); gap: 10px; }
  .identity p, .period-copy span { display: none; }
}

@media (max-height: 720px) {
  .display-shell { gap: 6px; padding-top: 8px; padding-bottom: 8px; }
  .topbar { min-height: 70px; padding-top: 7px; padding-bottom: 7px; }
  .brand-mark { width: 42px; height: 42px; }
  .day-heading { min-height: 58px; }
  .sections { gap: 3px; padding: 5px; }
  .route-section header { min-height: 21px; padding-top: 2px; padding-bottom: 2px; }
  .route-row { min-height: 21px; padding-top: 2px; padding-bottom: 2px; }
  .general-notes { min-height: 40px; }
}
