@font-face {
  font-family: Podkova;
  src: url('fonts/Podkova-variable.ttf') format('truetype');
  font-weight: 400 800;
  font-display: swap;
}

:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  font-size: min(calc(100vw / 120), calc(100vh / 67.5));
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  --display: Podkova, Georgia, serif;
  --cream: #fbf4e3;
  --paper: #fffaf0;
  --ink: #202922;
  --muted: #5c6257;
  --green: #15543c;
  --forest: #133e2f;
  --divider: #e7ddc8;
  --shadow: 0 1px 2px #352c1610, 0 .65rem 2rem -.9rem #3c311921;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--cream); }
h1, h2, h3, h4, p, dl, dd, ul { margin: 0; }
h1, h2, h3, h4 { font-family: var(--display); text-wrap: balance; }
ul { padding: 0; list-style: none; }
button { font: inherit; }

.screen {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 1.6rem;
  height: 100vh;
  padding: 2rem 2.8rem 2.4rem;
  background: radial-gradient(ellipse at top right, #f0e5ca, transparent 54%);
}

.screen-header {
  display: grid;
  grid-template-columns: 1.1fr 1fr auto;
  align-items: center;
  gap: .65rem 2.2rem;
  min-width: 0;
}

.identity, .shift-meta, .header-actions {
  display: flex;
  align-items: center;
}

.identity { gap: 1.05rem; }
.iiko-dates { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .4rem .9rem; }
.iiko-dates a { color: var(--forest); padding: .25rem .45rem; }
.iiko-dates a[aria-current] { background: var(--forest); color: var(--paper); border-radius: .3rem; }
.brand-mark { width: 4.7rem; height: 4.7rem; object-fit: contain; mix-blend-mode: multiply; }
.eyebrow {
  display: block;
  color: var(--muted);
  font-size: .87rem;
  font-weight: 750;
  line-height: 1.2;
  letter-spacing: .105em;
  text-transform: uppercase;
}

h1 { font-size: 3.15rem; line-height: 1; font-weight: 700; white-space: nowrap; }
h1 span { color: var(--green); }
.shift-meta { justify-content: center; gap: 2.6rem; }
.shift-meta .eyebrow { white-space: nowrap; }
.shift-meta time { display: block; margin-top: .3rem; font: 650 1.55rem/1.2 var(--display); }
.header-actions { justify-content: flex-end; gap: .85rem; }
.source { display: flex; align-items: center; gap: .6rem; }
.source-label, .source-warning, .plan-status, .pager {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .51rem .83rem;
  border-radius: 100rem;
  white-space: nowrap;
  font-size: .95rem;
  font-weight: 750;
}

.source-label { color: #184e38; background: #dfebda; }
.source-label::before { content: ''; width: .45rem; height: .45rem; border-radius: 50%; background: currentColor; }
.source-label--offline, .source-warning, .connection-error { color: #782b22; background: #f5e1d6; }

#refresh {
  min-width: 7rem;
  min-height: max(40px, 2.7rem);
  padding: 0 .95rem;
  color: var(--green);
  background: #fffaf09e;
  border: 1px solid #a9b6a5;
  border-radius: 100rem;
  font-size: .95rem;
  font-weight: 750;
  cursor: pointer;
  transition: scale 160ms ease, background-color 160ms ease;
}

#refresh:hover { background: var(--paper); }
#refresh:active { scale: .96; }
#refresh:disabled { opacity: .65; cursor: wait; }
#refresh:focus-visible { outline: .15rem solid var(--green); outline-offset: .2rem; }
.connection-error { grid-column: 1 / -1; padding: .4rem .85rem; border-radius: .55rem; font-size: 1rem; font-weight: 700; }

.dashboard {
  display: grid;
  grid-template:
    "plan stops" minmax(0, .85fr)
    "staff stops" minmax(0, 1.65fr) / minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 1.05rem;
  min-height: 0;
}

.panel {
  min-width: 0;
  min-height: 0;
  padding: 1.25rem 1.7rem;
  border-radius: 1.65rem;
  background: var(--paper);
  box-shadow: var(--shadow), inset 0 0 0 1px #48381a0b;
}

h2 { font-size: 2.35rem; font-weight: 690; line-height: 1.1; letter-spacing: -.026em; }
.panel-header, .plan-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.panel-meta { margin-top: .3rem; color: var(--muted); font-size: 1.12rem; line-height: 1.2; }
.panel-meta--warning, .category-warning { color: #843b2d; font-weight: 750; }
.pager { color: var(--green); background: #e9eddf; }

.plan {
  grid-area: plan;
  --plan-base: #334139;
  --plan-shade: #44534a;
  --plan-accent: #e0eadc;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: .8rem;
  padding: 1.3rem 1.8rem;
  color: #fff9e9;
  background: radial-gradient(ellipse at 100% 0%, var(--plan-shade), transparent 72%), var(--plan-base);
}

.plan--red { --plan-base: #562e28; --plan-shade: #713e31; --plan-accent: #ffd4bd; }
.plan--yellow { --plan-base: #4e3d1d; --plan-shade: #685024; --plan-accent: #ffe6a2; }
.plan--green { --plan-base: var(--forest); --plan-shade: #285943; --plan-accent: #d8eda8; }
.plan-status { color: #143f2b; background: #cfe5a3; }
.plan .eyebrow { color: #fff3e3; font-size: .95rem; }
.plan .panel-meta { color: #fff3e3; }
.plan-numbers, .plan-detail, .plan-detail > div { display: flex; align-items: flex-end; justify-content: space-between; gap: .9rem; }
.plan-numbers p { margin-top: .35rem; font-family: var(--display); font-weight: 700; line-height: .95; white-space: nowrap; }
.sales-number { font-size: 5.65rem; letter-spacing: -.052em; }
.sales-number span { font-size: .61em; }
.completion { text-align: right; }
.completion p { color: var(--plan-accent); font-size: 4.05rem; letter-spacing: -.05em; }
.completion p span { margin-left: .12em; font-size: .53em; }
.plan-detail { align-items: center; }
.plan-detail > div { justify-content: start; align-items: baseline; }
.plan-detail span { font-size: 1.08rem; color: #d0decf; }
.plan-detail strong, .plan-missing { font-family: var(--display); font-size: 1.7rem; line-height: 1.15; }
.plan-missing { padding-top: .55rem; border-top: 1px solid #d0decf43; width: 100%; }

progress { display: block; width: 100%; appearance: none; border: 0; border-radius: 100rem; background: var(--track); color: var(--fill); }
progress::-webkit-progress-bar { border-radius: 100rem; background: var(--track); }
progress::-webkit-progress-value { border-radius: 100rem; background: var(--fill); }
progress::-moz-progress-bar { border-radius: 100rem; background: var(--fill); }
.plan-progress { --track: #ffffff28; --fill: var(--plan-accent); height: .68rem; }

.staff, .stops { display: flex; flex-direction: column; }
.staff { grid-area: staff; }
.stops { grid-area: stops; }
.category-warning { font-size: 1rem; margin-top: .46rem; text-align: right; }
.staff-scroll { min-width: 0; min-height: 0; margin-top: .8rem; overflow: auto; }
.staff-scroll:focus-visible { outline: .12rem solid var(--green); outline-offset: .25rem; }
.staff-slide { display: flow-root; }
.staff-line {
  display: grid;
  grid-template-columns: minmax(0, 1.32fr) minmax(0, .73fr) repeat(2, minmax(0, .55fr)) minmax(0, 1.55fr);
  column-gap: .64rem;
  align-items: center;
  text-align: right;
}

.staff-line > * { min-width: 0; }
.staff-list-header {
  min-height: 2.7rem;
  padding-block: .23rem .42rem;
  color: var(--muted);
  font-size: 1.03rem;
  font-weight: 700;
  line-height: 1.12;
}

.staff-list-header > :first-child, .staff-name { text-align: left; }
.staff-role { margin-top: .58rem; }
.staff-role + .staff-role { margin-top: .48rem; padding-top: .58rem; border-top: 1px solid var(--divider); }
.staff-role-header { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.staff-role-header h3 { color: var(--green); font-size: 1.43rem; line-height: 1.15; }
.staff-footer { display: flex; flex: none; align-items: center; gap: .6rem; margin-top: auto; padding-top: .55rem; }
.staff-footer .pager { margin-inline-start: auto; padding: .23rem .56rem; }
.staff-plan-note { color: var(--muted); font-size: 1rem; text-wrap: pretty; }
.stops .pager { padding: .25rem .62rem; }
.staff-row { min-height: 3.05rem; font: 680 1.51rem/1.12 var(--display); white-space: nowrap; }
.staff-name { overflow: hidden; font-weight: 690; text-overflow: ellipsis; }
.shift-legend { display: flex; flex-wrap: wrap; gap: .25rem .8rem; color: var(--muted); font-size: 1rem; }
.shift-indicator {
  display: inline-block;
  width: .62rem;
  height: .62rem;
  margin-inline-end: .18rem;
  border: .1rem solid #5c6257;
  border-radius: 50%;
  vertical-align: .08em;
}
.shift-indicator--open { border-color: #237044; background: #237044; }
.staff-fact { display: inline-flex; justify-content: flex-end; align-items: baseline; gap: .31rem; }
.staff-fact .traffic-light { align-self: center; }
.staff-fact--live { display: grid; justify-items: end; align-content: center; gap: .1rem; }
.staff-actual { display: inline-flex; align-items: center; gap: .38rem; }
.staff-target { color: var(--muted); font-size: .86em; font-weight: 570; }
.staff-fact--live .staff-target { font-size: .74em; }
.staff-metric { display: inline-flex; justify-content: flex-end; align-items: center; gap: .38rem; }
.staff-role-empty { display: block; padding-block: .45rem; color: var(--muted); font-size: 1.05rem; }
.traffic-light { display: inline-block; flex: none; width: .62rem; height: .62rem; border-radius: 50%; background: #a2a197; box-shadow: 0 0 0 1px #3e35242a; }
.traffic-light--red { background: #c45b48; }
.traffic-light--yellow { background: #c88d15; }
.traffic-light--green { background: #3c8d58; }
.plan .traffic-light { margin-inline-start: .22rem; background: var(--plan-accent); }

.stop-list { display: grid; margin-top: .98rem; }
.stop-item { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 5.8rem; padding: .7rem 0; }
.stop-item + .stop-item { border-top: 1px solid var(--divider); }
.stop-description { min-width: 0; }
.stop-description strong { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font: 670 1.75rem/1.08 var(--display); overflow-wrap: anywhere; }
.stop-description span { display: block; margin-top: .35rem; color: var(--muted); font-size: 1.04rem; }
.stop-badge { flex: none; padding: .39rem .65rem; border-radius: .53rem; color: #822d26; background: #f7e3dc; font-size: .95rem; font-weight: 750; }
.stop-badge--limited { color: #754a1f; background: #f7eacb; }
.empty-state { margin: auto 0; color: var(--muted); font: 650 1.85rem/1.2 var(--display); }

.dashboard--offline { grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
.offline-panel { display: grid; place-content: center; gap: .8rem; text-align: center; }
.offline-panel h2 { color: var(--green); font-size: 3rem; }
.offline-panel p { color: var(--muted); font-size: 1.25rem; }

@media (max-aspect-ratio: 4/3) {
  :root { font-size: clamp(14px, 2.4vw, 18px); }
  .screen { height: auto; min-height: 100vh; padding: 1.2rem; }
  .screen-header { grid-template-columns: 1fr auto; gap: .7rem; }
  .shift-meta { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; flex-wrap: wrap; gap: .65rem 1.2rem; }
  h1 { font-size: clamp(1.65rem, 5.5vw, 3.15rem); }
  .identity { gap: .55rem; }
  .brand-mark { width: 3rem; height: 3rem; }
  .header-actions, .source { flex-wrap: wrap; }
  .dashboard { grid-template: "plan" auto "staff" auto "stops" auto / minmax(0, 1fr); }
  .dashboard--offline { grid-template: auto / minmax(0, 1fr); }
  .panel { padding: 1.15rem; }
  .plan-numbers { flex-wrap: wrap; }
  .sales-number { font-size: clamp(3.5rem, 12vw, 6.95rem); }
  .completion p { font-size: clamp(2.6rem, 9vw, 4.75rem); }
  .plan-detail { flex-wrap: wrap; }
  h2 { font-size: 1.9rem; }
  .staff-scroll { overflow-x: auto; }
  .staff-list { min-width: 54rem; }
  .stop-item { min-height: 0; }
  .stop-description strong { font-size: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  #refresh { transition: none; }
}
