/* Time page. Page colours come from style.css tokens; the three chart colours are tokens below, one
   set per theme (validated: working/waiting are one hue light-to-dark, blocked stays apart from both
   for colour-blind readers). Every bar also has words: a legend, a label, a tooltip and a table. */
:root {
  --tm-working: #126b53;
  --tm-waiting: #7ab59c;
  --tm-blocked: #e5603f;
  --tm-parked: #b9c2bf;
  --tm-hatch: rgba(22, 34, 38, .38);
}
:root[data-theme="dark"] {
  --tm-working: #7fd3b0;
  --tm-waiting: #3d7a63;
  --tm-blocked: #f47c5c;
  --tm-parked: #56625f;
  --tm-hatch: rgba(229, 236, 234, .5);
}

.tm-main { width: 100%; max-width: 1200px; margin: 0 auto; padding: 22px clamp(16px, 3vw, 36px) 40px; }
.tm-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 14px; }
.tm-head h1 { margin-bottom: 4px; font-size: clamp(22px, 3vw, 30px); }
.tm-filters-toggle { display: none; }
.tm-filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; padding: 12px 14px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
.tm-filters label { display: grid; gap: 4px; font-size: 11px; color: var(--muted); font-weight: 650; }
.tm-filters select, .tm-sort select { min-width: 130px; border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; color: var(--ink); background: var(--paper); font-size: 12px; }
.tm-filters .tm-check { display: flex; align-items: center; gap: 6px; padding-bottom: 7px; color: var(--ink); font-size: 12px; }
.tm-check input { width: 16px; height: 16px; accent-color: var(--green); }
.tm-visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.tm-loading { display: grid; gap: 10px; margin: 0 0 14px; padding: 18px; }
.tm-loading-text { margin: 0; font-size: 14px; font-weight: 650; color: var(--ink); }
.tm-progress { position: relative; height: 8px; overflow: hidden; border-radius: 999px; background: var(--line); }
.tm-progress-fill { position: absolute; top: 0; bottom: 0; left: 0; width: 0; border-radius: 999px; background: var(--green); transition: width .3s; }
.tm-hint, .tm-sub { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

.tm-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); gap: 10px; margin-bottom: 8px; }
.tm-tile { display: grid; gap: 3px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); box-shadow: var(--shadow); }
.tm-tile-value { font-size: 28px; font-weight: 750; line-height: 1.1; color: var(--ink); }
.tm-tile-label { color: var(--ink); font-size: 12px; font-weight: 650; }
.tm-tile-sub { color: var(--muted); font-size: 11px; line-height: 1.45; }
.tm-notes { margin: 0 0 6px; color: var(--muted); font-size: 12px; line-height: 1.5; }

.tm-section { margin-top: 18px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); box-shadow: var(--shadow); }
.tm-section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 6px 16px; margin-bottom: 10px; }
.tm-section-head h2 { margin: 0; font-size: 17px; }
.tm-section-head .tm-sub { flex: 1 1 100%; }
.tm-subtitle { margin: 16px 0 6px; font-size: 13px; letter-spacing: -.01em; }
.tm-empty { margin: 0; padding: 12px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); font-size: 12px; list-style: none; }

.tm-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 12px; padding: 0; list-style: none; color: var(--ink); font-size: 12px; }
.tm-legend li { display: inline-flex; align-items: center; gap: 6px; }
.tm-legend-small { margin-top: 8px; font-size: 11px; color: var(--muted); }
.tm-swatch { display: inline-block; flex: none; width: 12px; height: 12px; border-radius: 3px; }
.tm-working { background-color: var(--tm-working); }
.tm-waiting { background-color: var(--tm-waiting); }
.tm-blocked { background-color: var(--tm-blocked); }
.tm-parked { background-color: var(--tm-parked); }
.tm-hatched, .tm-hatched-key { background-image: repeating-linear-gradient(45deg, transparent 0 3px, var(--tm-hatch) 3px 5px); }
.tm-hatched-key { background-color: var(--paper); border: 1px solid var(--line); }

.tm-bars { display: grid; gap: 12px; }
.tm-bar-row { display: grid; grid-template-columns: 76px minmax(0, 1fr) 64px; align-items: center; gap: 4px 12px; }
.tm-bar-label { color: var(--ink); font-size: 13px; font-weight: 700; }
.tm-bar-track { height: 20px; background: var(--white); }
.tm-bar-fill { display: flex; gap: 2px; height: 100%; min-width: 2px; }
.tm-bar-fill .tm-seg:last-child, .tm-mini .tm-seg:last-child { border-radius: 0 4px 4px 0; }
.tm-seg { display: block; height: 100%; min-width: 2px; }
.tm-bar-value { color: var(--ink); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tm-bar-detail { grid-column: 2 / -1; color: var(--muted); font-size: 11px; }
.tm-table-details { margin-top: 14px; }
.tm-table-details summary { cursor: pointer; color: var(--green-dark); font-size: 12px; font-weight: 700; padding: 4px 0; }
.tm-blocked-box .tm-facts-list { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 6px; padding: 0; list-style: none; font-size: 12px; color: var(--ink); }

.tm-sort { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 650; }
.tm-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
.tm-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.tm-table th, .tm-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tm-table thead th { background: var(--paper); color: var(--muted); font-size: 11px; white-space: nowrap; }
.tm-table tbody th { font-weight: 650; color: var(--ink); }
.tm-table tr:last-child th, .tm-table tr:last-child td { border-bottom: 0; }
.tm-table .tm-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tm-caption { padding: 8px 10px 0; color: var(--ink); font-size: 12px; font-weight: 700; text-align: left; caption-side: top; }
.tm-card-name { min-width: 220px; }
.tm-card-open { display: inline-flex; align-items: baseline; gap: 6px; padding: 2px 0; border: 0; background: transparent; color: var(--ink); font-size: 12px; font-weight: 650; text-align: left; }
.tm-card-open:hover .tm-card-title { color: var(--green-dark); text-decoration: underline; }
.tm-card-open:focus-visible, .tm-show-all:focus-visible, .tm-filters-toggle:focus-visible, .tm-detail:focus-visible,
.tm-table-details summary:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.tm-number { flex: none; color: var(--muted); font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
.tm-card-title { overflow-wrap: anywhere; }
.tm-flag { display: block; margin-top: 3px; color: var(--amber); font-size: 10px; font-weight: 700; }
.tm-chip { display: inline-block; padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 11px; font-weight: 700; white-space: nowrap; }
.tm-chip-done { border-color: transparent; background: var(--mint); color: var(--green-dark); }
.tm-chip-open { border-color: transparent; background: var(--amber-bg); color: var(--amber); }
.tm-chip-parked { border-style: dashed; }
.tm-split { min-width: 130px; }
.tm-mini { display: flex; gap: 2px; width: 120px; height: 10px; margin-top: 3px; background: var(--white); }
.tm-attempts { color: var(--muted); }
.tm-retired th, .tm-retired td { opacity: .6; }
.tm-show-all { margin-top: 10px; }

.tm-waiting-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.tm-waiting-item { display: grid; gap: 3px; padding: 10px 12px; border-radius: 10px; background: var(--paper); }
.tm-waiting-head, .tm-waiting-line, .tm-waiting-why { margin: 0; font-size: 12px; color: var(--ink); overflow-wrap: anywhere; }
.tm-waiting-line { color: var(--muted); }

.tm-detail { outline: none; }
.tm-detail-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; flex-wrap: wrap; }
.tm-detail-title { margin: 0 0 4px; font-size: 18px; line-height: 1.35; overflow-wrap: anywhere; }
.tm-detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tm-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); gap: 8px; margin: 14px 0 6px; }
.tm-fact { min-width: 0; }
.tm-facts dt { color: var(--muted); font-size: 11px; font-weight: 650; }
.tm-facts dd { margin: 2px 0 0; color: var(--ink); font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
.tm-timeline { margin-bottom: 14px; }
.tm-lanes { display: grid; gap: 6px; }
.tm-lane { display: grid; grid-template-columns: 120px minmax(0, 1fr); align-items: center; gap: 10px; }
.tm-lane-label { color: var(--muted); font-size: 11px; font-weight: 700; }
.tm-lane-track { position: relative; height: 24px; border-radius: 6px; background: var(--paper); }
.tm-lane-stage { position: absolute; top: 3px; bottom: 3px; border-radius: 3px; }
.tm-lane-claim { position: absolute; top: 8px; bottom: 8px; border-radius: 2px; box-shadow: 0 0 0 2px var(--paper); }
.tm-ongoing { border-right: 2px dashed var(--ink); }
.tm-running { animation: tm-pulse 1.8s ease-in-out infinite; }
@keyframes tm-pulse { 50% { opacity: .55; } }
.tm-marker { position: absolute; top: 0; transform: translateX(-50%); font-size: 12px; line-height: 24px; color: var(--ink); cursor: default; }
.tm-mark-block { color: var(--tm-blocked); }
.tm-mark-release { color: var(--green-dark); }
.tm-mark-rework { color: var(--amber); }
.tm-axis { display: flex; justify-content: space-between; margin: 4px 0 0 130px; color: var(--muted); font-size: 11px; }

@media (max-width: 700px) {
  .tm-main { padding-left: 16px; padding-right: 16px; }
  .tm-head { align-items: start; }
  .tm-filters-toggle { display: inline-flex; min-height: 44px; }
  .tm-filters { display: none; }
  .tm-filters.tm-filters-open { display: grid; grid-template-columns: 1fr; }
  .tm-filters select, .tm-sort select { width: 100%; min-width: 0; min-height: 44px; font-size: 16px; }
  .tm-filters .tm-check { min-height: 44px; padding-bottom: 0; }
  .tm-section { padding: 14px 12px; }
  .tm-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tm-tile { padding: 12px; }
  .tm-tile-value { font-size: 22px; }
  .tm-bar-row { grid-template-columns: minmax(0, 1fr) auto; }
  .tm-bar-label { grid-column: 1 / -1; }
  .tm-bar-track { grid-column: 1; }
  .tm-bar-detail { grid-column: 1 / -1; }
  .tm-card-open, .tm-show-all, .tm-detail-actions .button { min-height: 44px; }
  .tm-show-all { width: 100%; }
  .tm-table-wrap { overflow-x: visible; border: 0; background: transparent; }
  .tm-table thead { display: none; }
  .tm-table, .tm-table tbody, .tm-table tr { display: block; width: 100%; }
  .tm-table tr { margin-bottom: 8px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); }
  .tm-table th, .tm-table td { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--line); text-align: right; }
  .tm-table tr > :last-child { border-bottom: 0; }
  .tm-table td[data-label]::before, .tm-table th[data-label]::before { content: attr(data-label); flex: none; color: var(--muted); font-weight: 650; text-align: left; }
  .tm-table .tm-card-name { display: block; min-width: 0; text-align: left; }
  .tm-table th.tm-card-name[data-label]::before { content: none; }
  .tm-table .tm-num { white-space: normal; }
  .tm-caption { padding: 0 0 6px; }
  .tm-lane { grid-template-columns: 1fr; gap: 2px; }
  .tm-axis { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .tm-running, .tm-progress-fill { animation: none; transition: none; }
}
