/* Checking and tracking: the target settings, the over-target tile and badges, the left panel's tabs
   and filter, the tracking list, the heat toggle, the analysis tabs (target tiles, rankings, the
   flow diagram, staffing advice, the day comparison) and presentation mode. */

/* ---------- Target settings (header popover) ---------- */
.targets {
  position: relative;
}

.targets__popover {
  position: absolute;
  z-index: 45;
  top: calc(100% + var(--sp-2));
  right: 0;
  width: 300px;
  max-height: min(80vh, 700px);
  overflow-y: auto;
  padding: var(--sp-3) var(--sp-4) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-float);
  animation: popover-in var(--dur-mid) var(--ease-out);
  scrollbar-width: thin;
  scrollbar-color: var(--ink-600) transparent;
}

.targets__popover[hidden] {
  display: none;
}

@keyframes popover-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.targets__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-1);
}

.targets__title {
  font-size: var(--fs-16);
  font-weight: 600;
}

.targets__group {
  margin: var(--sp-2) 0 var(--sp-1);
  color: var(--text-3);
  font-size: var(--fs-12);
  font-weight: 500;
}

.targets__list {
  display: grid;
}

.targets__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px 36px;
  align-items: center;
  gap: var(--sp-2);
  padding: 2px 0;
}

.targets__name {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
  font-size: var(--fs-13);
  white-space: nowrap;
}

.targets__input {
  width: 64px;
  height: 28px;
  padding: 0 var(--sp-2);
  border-radius: var(--r-xs);
  border: 1px solid var(--line);
  background: rgba(4, 14, 24, 0.6);
  font-size: var(--fs-13);
  text-align: right;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  appearance: textfield;
  transition: border-color var(--dur-fast) var(--ease-out);
}

.targets__input::-webkit-inner-spin-button,
.targets__input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.targets__input:hover {
  border-color: var(--line-strong);
}

.targets__input:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.targets__input[data-changed="true"] {
  border-color: var(--sky-line);
  color: var(--sky-strong);
}

.targets__input[aria-invalid="true"] {
  border-color: var(--signal);
  color: #ffc1bd;
}

.targets__unit {
  color: var(--text-3);
  font-size: var(--fs-12);
}

.targets__total {
  margin-top: var(--sp-2);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--line);
}

.targets__total .targets__name {
  font-weight: 600;
}

.targets__footer {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--sp-3);
}

/* ---------- KPI strip: seven tiles, the over-target tile ---------- */
.kpis {
  grid-template-columns: repeat(7, minmax(0, 1fr));
  transition: box-shadow var(--dur-slow) var(--ease-out);
}

.kpi[data-kpi="alerts"] {
  --kpi-accent: var(--signal);
}

.kpi--alerts.has-alerts .kpi__number {
  color: var(--sev-critical);
}

/* One soft pulse when the count rises; never a loop. */
.kpi--alerts.is-pulsing {
  animation: alert-pulse 1.2s var(--ease-out);
}

@keyframes alert-pulse {
  30% {
    background: var(--signal-wash);
    box-shadow: inset 0 0 0 1px rgba(240, 75, 68, 0.45);
  }
}

/* ---------- Left panel: tabs and the zone/room filter ---------- */
.panel__tabs {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-3) 0;
}

.left-tabs {
  display: flex;
  flex: 1;
  min-width: 0;
  gap: 2px;
  padding: 3px;
  border-radius: var(--r-sm);
  background: rgba(4, 14, 24, 0.55);
  border: 1px solid var(--line);
}

.left-tab {
  display: inline-flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  height: 32px;
  padding: 0 var(--sp-2);
  border-radius: 7px;
  color: var(--text-2);
  font-size: var(--fs-13);
  font-weight: 500;
  white-space: nowrap;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}

.left-tab:hover {
  color: var(--text-1);
  background: rgba(255, 255, 255, 0.05);
}

.left-tab[aria-selected="true"] {
  background: var(--ink-600);
  color: var(--text-1);
  font-weight: 600;
  box-shadow:
    var(--line-inset),
    0 1px 3px rgba(0, 0, 0, 0.35);
}

.left-tab:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.left-tab__count {
  color: var(--text-3);
  font-size: var(--fs-12);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.left-tab__count:empty {
  display: none;
}

.left-tab__alert,
.queue-row__alert,
.tabbar__badge {
  flex: none;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--signal);
  color: #fff;
  font-size: var(--fs-11);
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.left-tab__alert[hidden],
.queue-row__alert[hidden],
.tabbar__badge[hidden] {
  display: none;
}

.place-filter {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
}

.select {
  position: relative;
  display: block;
  min-width: 0;
}

.select__input {
  width: 100%;
  height: 32px;
  padding: 0 28px 0 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background-color: rgba(17, 42, 64, 0.7);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='m6 8 4 4 4-4' fill='none' stroke='%23b5c7d4' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
  font-size: var(--fs-13);
  text-overflow: ellipsis;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out);
}

.select__input:hover {
  border-color: var(--line-strong);
}

.select__input:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.select__input:disabled {
  color: var(--text-3);
  cursor: not-allowed;
}

.select__input option {
  background: var(--ink-850);
  color: var(--text-1);
}

.select--inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.select--inline .select__input {
  width: auto;
  height: 28px;
}

.select__caption {
  color: var(--text-3);
  font-size: var(--fs-12);
  white-space: nowrap;
}

.left-view {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

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

/* ---------- Tracking list ---------- */
.tracking__filters {
  display: grid;
  gap: var(--sp-2);
  padding: 2px var(--sp-3) var(--sp-2);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 9px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: var(--fs-12);
  font-weight: 500;
  white-space: nowrap;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}

.chip:hover {
  border-color: var(--line-strong);
  color: var(--text-1);
}

.chip[aria-checked="true"] {
  background: var(--sky-wash);
  border-color: var(--sky-line);
  color: var(--sky-strong);
  font-weight: 600;
}

.chip[hidden] {
  display: none;
}

.chip:focus-visible,
.toggle-chip:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.chip__count {
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.chip[aria-checked="true"] .chip__count {
  color: inherit;
  opacity: 0.8;
}

.tracking__options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: var(--fs-12);
  font-weight: 600;
  white-space: nowrap;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out);
}

.toggle-chip__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--sev-critical);
}

.toggle-chip[aria-pressed="true"] {
  background: var(--signal-wash);
  border-color: rgba(240, 75, 68, 0.5);
  color: #ffd2cf;
}

.toggle-chip[aria-pressed="true"] .toggle-chip__dot {
  background: var(--sev-critical);
}

.tracking__list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 var(--sp-2) var(--sp-2);
  scrollbar-width: thin;
  scrollbar-color: var(--ink-600) transparent;
}

.tracking__group {
  padding: var(--sp-2) 10px 4px;
  color: var(--text-3);
  font-size: var(--fs-11);
  font-weight: 600;
}

.tracking__empty {
  padding: var(--sp-6) var(--sp-4);
  color: var(--text-3);
  font-size: var(--fs-13);
  text-align: center;
}

.track-row {
  position: relative;
  display: flex;
  align-items: stretch;
  border-radius: var(--r-sm);
  transition: background-color var(--dur-fast) var(--ease-out);
}

.track-row:hover {
  background: rgba(255, 255, 255, 0.05);
}

.track-row[aria-current="true"] {
  background: var(--sky-wash);
  box-shadow: inset 0 0 0 1px var(--sky-line);
}

.track-row.is-over::before {
  content: "";
  position: absolute;
  top: 9px;
  bottom: 9px;
  left: 2px;
  width: 3px;
  border-radius: 2px;
  background: var(--sev-critical);
}

.track-row__main {
  display: grid;
  flex: 1;
  grid-template-columns: 40px auto minmax(0, 1fr) auto;
  grid-template-areas:
    "queue place place at"
    "queue status who total";
  align-items: center;
  column-gap: var(--sp-2);
  row-gap: 1px;
  min-width: 0;
  padding: 7px 4px 7px 12px;
  border-radius: var(--r-sm);
  text-align: left;
}

.track-row__main:focus-visible,
.track-row__pin:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.track-row__queue {
  grid-area: queue;
  font-size: var(--fs-16);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.track-row__place {
  grid-area: place;
  min-width: 0;
  overflow: hidden;
  font-size: var(--fs-13);
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.track-row__status {
  grid-area: status;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-2);
  font-size: var(--fs-11);
  font-weight: 600;
  white-space: nowrap;
}

.track-row__status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--chip-color, var(--text-3));
}

.track-row__status[data-phase="waiting"] {
  --chip-color: var(--state-waiting);
}

.track-row__status[data-phase="service"] {
  --chip-color: var(--state-service);
}

.track-row__status[data-phase="walking"] {
  --chip-color: var(--state-walking);
}

.track-row__status[data-phase="left"] {
  --chip-color: var(--state-left);
}

.track-row__who {
  grid-area: who;
  min-width: 0;
  overflow: hidden;
  color: var(--text-3);
  font-size: var(--fs-11);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.track-row__at {
  grid-area: at;
  justify-self: end;
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  font-size: var(--fs-16);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.track-row__unit {
  color: var(--text-3);
  font-size: var(--fs-11);
  font-weight: 500;
}

.track-row__at[data-level="near"] {
  color: var(--sev-warning);
}

.track-row__at[data-level="over"] {
  color: var(--sev-critical);
}

.track-row__at[data-level="none"] {
  color: var(--text-3);
}

.track-row__total {
  grid-area: total;
  justify-self: end;
  color: var(--text-3);
  font-size: var(--fs-11);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.track-row__total.is-over {
  color: #ffb3ae;
}

.track-row__pin {
  display: grid;
  flex: none;
  place-items: center;
  width: 32px;
  border-radius: var(--r-sm);
  color: var(--text-3);
  opacity: 0;
  transition:
    opacity var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}

.track-row__pin .icon {
  width: 16px;
  height: 16px;
}

.track-row:hover .track-row__pin,
.track-row:focus-within .track-row__pin,
.track-row__pin[aria-pressed="true"] {
  opacity: 1;
}

.track-row__pin:hover {
  color: var(--text-1);
}

.track-row__pin[aria-pressed="true"] {
  color: var(--sky-strong);
}

.track-row__pin[aria-pressed="true"] .icon {
  fill: currentColor;
}

.tracking__footer {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3) var(--sp-3);
  border-top: 1px solid var(--line);
}

.tracking__more {
  height: 30px;
}

.tracking__more[hidden] {
  display: none;
}

.tracking__keys {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  color: var(--text-3);
  font-size: var(--fs-11);
}

.tracking__keys span {
  margin-right: 6px;
}

/* Touch screens have no hover to reveal pins and no keys to show. */
@media (hover: none) {
  .track-row__pin {
    opacity: 1;
  }

  .tracking__keys {
    display: none;
  }
}

/* ---------- Heat toggle and legend (3D view tools) ---------- */
/* Over the bright floor a see-through wash loses contrast, so the pressed state sits on solid glass. */
.tool-button--floating[aria-pressed="true"] {
  background:
    linear-gradient(var(--sky-wash), var(--sky-wash)), var(--glass-strong);
}

.heat-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
}

.heat-legend {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: 36px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-pill);
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-panel);
  color: var(--text-2);
  font-size: var(--fs-12);
  font-weight: 500;
}

.heat-legend[hidden] {
  display: none;
}

.heat-legend__item {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.heat-legend__swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.heat-legend__item[data-level="ok"] {
  --swatch: var(--heat-ok);
}

.heat-legend__item[data-level="warn"] {
  --swatch: var(--heat-warn);
}

.heat-legend__item[data-level="over"] {
  --swatch: var(--heat-over);
}

/* ---------- Analysis: target tiles, notes ---------- */
.target-tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-2);
}

.target-tile {
  display: grid;
  align-content: start;
  gap: 2px;
  min-width: 0;
  padding: 12px;
  border-radius: var(--r-md);
  background: rgba(4, 14, 24, 0.5);
  border: 1px solid var(--line);
}

.target-tile__label,
.target-tile__sub {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.target-tile__label {
  color: var(--text-2);
  font-size: var(--fs-12);
  font-weight: 500;
}

.target-tile__value {
  font-size: var(--fs-24);
  font-weight: 600;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.target-tile__sub {
  color: var(--text-3);
  font-size: var(--fs-12);
}

.target-tile[data-level="over"] .target-tile__value {
  color: var(--sev-critical);
}

.analysis-note {
  margin-top: calc(-1 * var(--sp-4));
  color: var(--text-3);
  font-size: var(--fs-12);
}

.chart-legend__key--dash {
  width: 14px;
  height: 0;
  border-top: 2px dashed var(--key-color);
  background: none;
}

/* ---------- Analysis: rankings (bottlenecks) ---------- */
.rank {
  display: grid;
  gap: 2px;
}

.rank__row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: start;
  gap: var(--sp-2);
  width: 100%;
  padding: 8px;
  border-radius: var(--r-sm);
  text-align: left;
}

.rank__row--button {
  transition: background-color var(--dur-fast) var(--ease-out);
}

.rank__row--button:hover {
  background: rgba(255, 255, 255, 0.05);
}

.rank__row--button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.rank__no {
  color: var(--text-3);
  font-size: var(--fs-12);
  font-weight: 600;
  line-height: 22px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.rank__main {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.rank__head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
}

.rank__name {
  min-width: 0;
  overflow: hidden;
  font-size: var(--fs-13);
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.rank__zone {
  color: var(--text-3);
  font-size: var(--fs-12);
  white-space: nowrap;
}

.rank__value {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rank__minutes {
  font-size: var(--fs-16);
  font-weight: 600;
}

.rank__target-text {
  color: var(--text-3);
  font-size: var(--fs-12);
}

.rank__unit {
  color: var(--text-3);
  font-size: var(--fs-11);
}

.rank__row.is-over .rank__minutes {
  color: var(--sev-critical);
}

.rank__bullet {
  position: relative;
  height: 8px;
  border-radius: 4px;
  background: rgba(150, 196, 226, 0.1);
}

.rank__fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: calc(var(--fill, 0) * 100%);
  border-radius: 0 4px 4px 0;
  background: var(--chart-1);
}

.rank__row.is-over .rank__fill {
  background: var(--signal);
}

.rank__target {
  position: absolute;
  top: -3px;
  bottom: -3px;
  left: calc(var(--at, 0) * 100%);
  width: 2px;
  margin-left: -1px;
  border-radius: 1px;
  background: var(--text-1);
}

/* Facts wrap rather than cut: a mixed zone names both of its targets. */
.rank__facts {
  color: var(--text-3);
  font-size: var(--fs-12);
  line-height: var(--lh-ui);
}

/* The bottleneck tile names the metric that chose it and the slowest room: two lines, never cut. */
.insight[data-insight="bottleneck"] .insight__sub {
  white-space: normal;
}

.tag--over {
  color: #ffd2cf;
  background: var(--signal-wash);
}

/* The day's bottleneck (D1) at the top of the ranking, the same answer as the insight tile. */
.tag--bottleneck {
  color: var(--text-on-accent);
  background: var(--signal);
}

.rank__row.is-bottleneck {
  background: var(--signal-wash);
  box-shadow: inset 0 0 0 1px rgba(240, 75, 68, 0.35);
}

/* ---------- Analysis: zone-to-zone flow ---------- */
.flow__arc {
  fill: none;
  stroke: var(--text-2);
  stroke-opacity: 0.5;
  stroke-linecap: round;
  transition:
    stroke var(--dur-fast) var(--ease-out),
    stroke-opacity var(--dur-fast) var(--ease-out);
}

.flow__arc.is-back {
  stroke-dasharray: 4 5;
  stroke-opacity: 0.4;
}

.flow__arc.is-active {
  stroke: var(--sky-strong);
  stroke-opacity: 1;
}

.flow__hit {
  fill: none;
  stroke: transparent;
  pointer-events: stroke;
}

.flow__arrow {
  fill: var(--text-2);
  fill-opacity: 0.75;
}

.flow__node {
  fill: var(--series-color);
  stroke: var(--ink-850);
}

.flow__label {
  fill: var(--text-1);
  font-size: 12px;
  font-weight: 500;
}

.flow__count {
  fill: var(--text-1);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  /* A halo in the panel colour keeps the count readable where arcs cross it. */
  paint-order: stroke;
  stroke: var(--ink-900);
  stroke-width: 3px;
  stroke-linejoin: round;
}

/* ---------- Analysis: staffing advice and the what-if ---------- */
.recommendations {
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--r-md);
  background: rgba(4, 14, 24, 0.5);
  border: 1px solid var(--line);
}

.recommendations > .tool-button {
  justify-self: start;
}

.what-if__group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}

.what-if__group-head .what-if__group-title {
  margin-bottom: 0;
}

.recommendations__note {
  color: var(--text-3);
  font-size: var(--fs-12);
}

.text-button {
  color: var(--sky-strong);
  font-size: var(--fs-12);
  font-weight: 600;
}

.text-button:hover {
  text-decoration: underline;
}

.text-button:focus-visible {
  outline: none;
  border-radius: 4px;
  box-shadow: var(--focus-ring);
}

.progress {
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: rgba(150, 196, 226, 0.12);
}

.progress__fill {
  display: block;
  width: calc(var(--fill, 0) * 100%);
  height: 100%;
  border-radius: 3px;
  background: var(--sky);
  transition: width var(--dur-mid) var(--ease-out);
}

.recommend-list {
  display: grid;
  gap: var(--sp-2);
}

.recommend {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px 10px 10px 8px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
}

.recommend.is-best {
  background: var(--sky-wash);
  border-color: var(--sky-line);
}

.recommend__rank {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--ink-700);
  font-size: var(--fs-13);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.recommend.is-best .recommend__rank {
  background: var(--sky);
  color: var(--text-on-accent);
}

.recommend__body {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.recommend__title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
  font-size: var(--fs-13);
  font-weight: 600;
}

.recommend__zone {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.recommend__staff {
  color: var(--text-2);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.recommend__facts {
  color: var(--text-2);
  font-size: var(--fs-12);
  font-variant-numeric: tabular-nums;
}

.recommend__next {
  color: var(--sev-warning);
  font-size: var(--fs-12);
}

.recommend__try {
  height: 30px;
}

.what-if__custom {
  display: grid;
}

.what-if__subtitle {
  margin: var(--sp-3) 0 var(--sp-1);
  color: var(--text-3);
  font-size: var(--fs-12);
  font-weight: 600;
}

/* ---------- Analysis: another day (real data) ---------- */
.compare {
  display: grid;
  gap: var(--sp-4);
}

.compare__picker {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.compare__picker .select {
  flex: 1;
}

.compare__label {
  color: var(--text-2);
  font-size: var(--fs-13);
  font-weight: 500;
  white-space: nowrap;
}

.compare__state {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-4);
  border-radius: var(--r-md);
  border: 1px dashed var(--line-strong);
  color: var(--text-2);
  font-size: var(--fs-13);
}

.compare__state--error {
  justify-content: space-between;
  border-color: rgba(240, 75, 68, 0.45);
  color: #ffc1bd;
}

/* ---------- Presentation mode ---------- */
/* Fixed above the timeline and the legend, centred in the free canvas area (app.js writes the
   --view-* insets), and above drawers so the caption stays readable when a card opens. */
.present-bar {
  position: fixed;
  z-index: 45;
  left: calc(
    var(--view-left, 0px) +
      (100vw - var(--view-left, 0px) - var(--view-right, 0px)) / 2
  );
  bottom: calc(var(--timeline-space, 0px) + 56px);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  max-width: min(780px, calc(100% - 2 * var(--sp-4)));
  padding: 8px 8px 8px 20px;
  border-radius: var(--r-pill);
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-float);
  transform: translateX(-50%);
  animation: present-in var(--dur-slow) var(--ease-out);
}

.present-bar[hidden] {
  display: none;
}

@keyframes present-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
}

.present-bar__caption {
  min-width: 0;
  overflow: hidden;
  font-size: var(--fs-16);
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.present-bar__steps {
  display: flex;
  flex: none;
  gap: 4px;
}

.present-bar__step {
  position: relative;
  width: 22px;
  height: 4px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--line-strong);
}

.present-bar__step[data-state="done"] {
  background: var(--sky-line);
}

.present-bar__step[data-state="current"]::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--sky);
  transform-origin: left center;
  animation: present-step var(--step-ms, 8s) linear forwards;
}

.present-bar[data-paused="true"]
  .present-bar__step[data-state="current"]::after {
  animation-play-state: paused;
}

@keyframes present-step {
  from {
    transform: scaleX(0);
  }
}

.present-bar__actions {
  display: flex;
  flex: none;
  gap: var(--sp-2);
}

.present-bar__actions kbd {
  margin-left: 2px;
}

/* The tour is full-bleed (D9): the chrome folds away and the floor takes the screen, with the big
   numbers on top, the caption bar below and the card beside the floor while a patient is followed. */
:root[data-presenting="true"] .shell {
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "stage stage detail";
}

:root[data-presenting="true"] .topbar,
:root[data-presenting="true"] .kpis,
:root[data-presenting="true"] .timeline,
:root[data-presenting="true"] .queues,
:root[data-presenting="true"] #queues-toggle,
:root[data-presenting="true"] #reset-view,
:root[data-presenting="true"] #heat-toggle,
:root[data-presenting="true"] .tabbar,
:root[data-presenting="true"] .hint {
  display: none;
}

.present-figures {
  position: fixed;
  z-index: 44;
  top: calc(var(--gutter) + env(safe-area-inset-top));
  left: calc(
    var(--view-left, 0px) +
      (100vw - var(--view-left, 0px) - var(--view-right, 0px)) / 2
  );
  display: flex;
  align-items: stretch;
  gap: var(--sp-2);
  padding: var(--sp-2);
  border-radius: var(--r-lg);
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-float);
  transform: translateX(-50%);
  animation: present-in var(--dur-slow) var(--ease-out);
}

.present-figures[hidden] {
  display: none;
}

.present-figure {
  display: grid;
  align-content: center;
  gap: 2px;
  min-width: 150px;
  padding: var(--sp-2) var(--sp-5);
  border-left: 1px solid var(--line);
}

.present-figure:first-child {
  border-left: 0;
}

.present-figure__number {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: var(--fs-44);
  font-weight: 600;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.present-figure__unit {
  color: var(--text-2);
  font-size: var(--fs-16);
  font-weight: 500;
  letter-spacing: 0;
}

.present-figure__label {
  color: var(--text-2);
  font-size: var(--fs-14);
  font-weight: 500;
}

.present-figure.has-alerts .present-figure__value {
  color: var(--sev-critical);
}

.present-figures__clock {
  align-self: center;
  padding: 0 var(--sp-4) 0 var(--sp-3);
  border-left: 1px solid var(--line);
  color: var(--text-2);
  font-size: var(--fs-24);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  .kpi--alerts.is-pulsing {
    animation: none;
  }

  .present-bar__step[data-state="current"]::after {
    animation: none;
  }
}

/* ---------- Medium widths ---------- */
@media (max-width: 1279.98px) {
  /* One column below 1280 px: the detail is a drawer, so the floor alone fills the grid. */
  :root[data-presenting="true"] .shell {
    grid-template-areas: "stage";
  }

  /* Icon-only tool buttons; the label stays for screen readers. */
  #targets-button .tool-button__label,
  #present-button .tool-button__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  #targets-button,
  #present-button {
    padding: 0 9px;
  }
}

@media (max-width: 1023.98px) {
  .kpis {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .kpi:nth-child(4) {
    border-left: 1px solid var(--line);
  }

  .kpi:nth-child(5) {
    border-left: 0;
  }
}

/* ---------- Phones ---------- */
@media (max-width: 767.98px) {
  .tabbar {
    grid-template-columns: repeat(4, 1fr);
  }

  .tabbar__item {
    position: relative;
  }

  .tabbar__badge {
    position: absolute;
    top: 6px;
    left: calc(50% + 4px);
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 10px;
    line-height: 16px;
  }

  .kpi:nth-child(5) {
    border-left: 1px solid var(--line);
  }

  #heat-toggle > span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  #heat-toggle {
    padding: 0 9px;
  }

  .heat-legend {
    gap: var(--sp-2);
    height: 32px;
    padding: 0 10px;
    font-size: var(--fs-11);
  }

  .target-tiles {
    gap: 6px;
  }

  .target-tile {
    padding: 8px 10px;
  }

  .target-tile__value {
    font-size: var(--fs-16);
  }

  .target-tile__sub {
    white-space: normal;
  }

  .recommend {
    grid-template-columns: 26px minmax(0, 1fr);
  }

  .recommend__try {
    grid-column: 2;
    justify-self: start;
  }

  .present-bar {
    bottom: calc(var(--timeline-space, 0px) + 52px);
    flex-wrap: wrap;
    gap: var(--sp-2);
    width: calc(100% - 2 * var(--sp-2));
    padding: 10px 12px;
    border-radius: var(--r-lg);
  }

  .present-bar__caption {
    flex-basis: 100%;
    font-size: var(--fs-14);
    white-space: normal;
  }

  .present-bar__actions {
    margin-left: auto;
  }

  :root[data-presenting="true"] .shell {
    padding-bottom: calc(var(--gutter) + env(safe-area-inset-bottom));
  }

  :root[data-presenting="true"] .detail {
    bottom: env(safe-area-inset-bottom);
  }
}

/* ---------- What-if and day comparison: the verdict and the before/after toggle ---------- */
.verdict {
  margin-bottom: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--sky-wash);
  border: 1px solid var(--sky-line);
  font-size: var(--fs-14);
  font-weight: 600;
  line-height: var(--lh-ui);
}

.before-after {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.before-after__label {
  color: var(--text-2);
  font-size: var(--fs-13);
  font-weight: 500;
}

.deltas tr.is-changed th,
.deltas tr.is-changed td {
  color: var(--sev-warning);
  font-weight: 600;
}

.compare__result {
  display: grid;
}

/* ---------- Analysis drawer: clear of the KPI strip and the timeline (RL-17) ---------- */
@media (min-width: 768px) {
  .drawer {
    top: calc(var(--view-top, var(--topbar-bottom, 0px)) + var(--gutter));
    bottom: calc(var(--timeline-space, 0px) + var(--gutter));
  }
}

/* ---------- Date list quick picks and the jump to the busiest time (RL-19) ---------- */
.date-picker__quick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--line);
}

.date-picker__quick[hidden] {
  display: none;
}

.date-picker__quick-label {
  margin-right: var(--sp-1);
  color: var(--text-3);
  font-size: var(--fs-12);
  font-weight: 500;
}

.date-picker__quick .chip[aria-pressed="true"] {
  background: var(--sky-wash);
  border-color: var(--sky-line);
  color: var(--sky-strong);
}

/* Above the slider and its thumb, so the busiest time can be clicked wherever the thumb is. */
.scrubber__peak {
  z-index: 3;
  pointer-events: auto;
  cursor: pointer;
}

.scrubber__peak:hover .scrubber__peak-label,
.scrubber__peak:focus-visible .scrubber__peak-label {
  background: rgba(255, 182, 72, 0.22);
  color: #ffe6bf;
}

.scrubber__peak:focus-visible {
  outline: none;
  border-radius: var(--r-pill);
  box-shadow: var(--focus-ring);
}

@media (max-width: 767.98px) {
  /* The source row scrolls sideways on phones and would clip the date list; the list hangs from the
     top bar instead (the panel's backdrop filter makes it the containing block), full width. */
  .date-picker {
    position: static;
  }

  .date-picker__popover {
    left: var(--sp-2);
    right: var(--sp-2);
    top: calc(100% + var(--sp-2));
    width: auto;
    max-height: min(60vh, 480px);
  }

  .present-figure {
    min-width: 0;
    padding: var(--sp-1) var(--sp-3);
  }

  .present-figure__number {
    font-size: var(--fs-24);
  }

  .present-figure__label {
    font-size: var(--fs-11);
  }

  .present-figures {
    width: calc(100% - 2 * var(--sp-2));
    justify-content: space-between;
  }

  .present-figures__clock {
    display: none;
  }
}

/* A what-if run that failed says so beside its buttons (FC-7). */
.what-if__error {
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  border: 1px solid rgba(240, 75, 68, 0.45);
  background: var(--signal-wash);
  color: #ffc1bd;
  font-size: var(--fs-13);
}
