/* Timeline grid */
.tl-wrap { overflow: auto; border: var(--rule); border-radius: var(--radius-md); min-height: 320px; }
.tl { display: grid; grid-template-columns: minmax(var(--tl-label-w), var(--tl-label-w)) repeat(var(--months), var(--tl-col-w)); font-size: var(--text-sm); width: max-content; min-width: 100%; }
.tl > div { border-bottom: var(--rule); border-right: var(--rule); min-height: 36px; display: flex; align-items: center; }
.tl .c-label { position: sticky; left: 0; z-index: 2; background: var(--color-paper); padding: var(--space-xs) var(--space-md); gap: var(--space-xs); overflow: hidden; }
.tl .c-label .name { font-weight: 500; color: var(--color-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.tl .c-label .sub { font-size: var(--text-xs); color: var(--color-ink-3); white-space: nowrap; }
.tl .c-label.c-label--item { display: flex; flex-direction: column; align-items: stretch; justify-content: center; gap: 1px; }
.tl .c-label--item .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 450; }
.tl .c-label--item { padding-left: calc(var(--space-md) + 6px); }
.tl .c-label--item .sub { overflow: hidden; text-overflow: ellipsis; }
.ct { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 7px; vertical-align: 0; flex: none; }
.ct--capex { background: var(--color-accent); }
.ct--opex { border: 1.5px solid var(--color-ink-3); background: var(--color-paper); }
.tl .c-label--item .sub--desc { white-space: normal; line-height: 1.25; color: var(--color-ink-2); }

.tl .h-year, .tl .h-month { position: sticky; z-index: 3; background: var(--color-paper-2); justify-content: center; font: 500 var(--text-xs)/1 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-ink-3); min-height: 30px; }
.tl .h-year { top: 0; color: var(--color-ink); border-bottom: var(--rule-2); }
.tl .h-month { top: 30px; }
.tl .h-corner { z-index: 4; background: var(--color-paper-2); }
.tl .h-corner.h-year { top: 0; } .tl .h-corner.h-month { top: 30px; }
.tl .h-month.is-current { color: var(--color-accent); }

.tl .c-group { background: var(--color-paper-2); font-family: var(--font-display); font-weight: 600; font-size: var(--text-base); color: var(--color-ink); min-height: 40px; }
.tl .c-group.c-label { z-index: 2; }
.tl .c-group .sub { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-weight: 500; margin-left: auto; }
.tl .c-group[role=button], .tl .c-vendor[role=button] { cursor: pointer; }
.tl .c-group[role=button]:hover, .tl .c-vendor[role=button]:hover { background: var(--color-accent-soft); }
.tl .c-vendor { background: color-mix(in oklch, var(--cat, var(--color-paper-2)) 6%, var(--color-paper)); font-weight: 600; color: var(--color-ink); min-height: 32px; }
.tl .c-vendor.c-label { z-index: 2; padding-left: calc(var(--space-md) + 24px); }
.tl .c-vendor .name::after { content: 'vendor'; margin-left: 8px; font: 500 9px/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-ink-4); vertical-align: 1px; }
.tl .c-vendor .sub { margin-left: auto; font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.tl .c-label--item.is-indented { padding-left: calc(var(--space-md) + 34px); }
.tl .c-label--item.is-indented { position: sticky; }
.tl .bar--sum { background: var(--color-paper-3); color: var(--color-ink-2); border: 1px dashed var(--color-ink-4); }
.tl .bar--sum.tier-2 { background: var(--color-paper-3); border-style: solid; }
.tl .bar--sum.tier-3 { background: var(--color-rule-2); border-style: solid; color: var(--color-ink); font-weight: 600; }
.tl .bar--sum-vendor { height: 20px; }
.caret { display: inline-block; width: 0; height: 0; border: 4px solid transparent; border-left: 6px solid var(--color-ink-3); margin-right: 6px; transition: transform var(--dur-fast) var(--ease-out); flex: none; }
.caret.is-open { transform: rotate(90deg); }
.tl .c-cell { justify-content: center; position: relative; padding: 4px; }
.tl .c-cell.year-start, .tl .h-month.year-start, .tl .c-total.year-start { border-left: 2px solid var(--color-rule-2); }
.tl .bar { width: 100%; height: 24px; border-radius: 4px; display: flex; align-items: center; justify-content: center; font: 600 var(--text-xs) var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: 0; white-space: nowrap; }
.tl .bar--capex { background: var(--color-capex-3); color: var(--color-capex-ink); }
.tl .bar--capex.tier-1 { background: var(--color-capex-1); }
.tl .bar--capex.tier-2 { background: var(--color-capex-2); }
.tl .bar--opex { background: var(--color-opex-1); border: 1px solid var(--color-ink-4); color: var(--color-opex-ink); }
.tl .bar--opex.tier-2 { background: var(--color-opex-2); border-color: var(--color-ink-3); }
.tl .bar--opex.tier-3 { background: var(--color-opex-3); border-color: var(--color-ink-2); font-weight: 600; }
.tl .bar.tier-3 { font-weight: 600; }
/* bars coloured by item type; capex solid, opex tinted */
.tl .bar--capex.type-hardware { background: var(--color-type-hardware); }
.tl .bar--capex.type-software { background: var(--color-type-software); }
.tl .bar--capex.type-licensing { background: var(--color-type-licensing); }
.tl .bar--capex.type-services { background: var(--color-type-services); }
.tl .bar--capex.tier-1 { opacity: 0.75; }
.tl .bar--capex.tier-2 { opacity: 0.9; }
.tl .bar--opex.type-hardware { background: var(--color-type-hardware-soft); border-color: var(--color-type-hardware); color: var(--color-type-hardware); }
.tl .bar--opex.type-software { background: var(--color-type-software-soft); border-color: var(--color-type-software); color: var(--color-type-software); }
.tl .bar--opex.type-licensing { background: var(--color-type-licensing-soft); border-color: var(--color-type-licensing); color: var(--color-type-licensing); }
.tl .bar--opex.type-services { background: var(--color-type-services-soft); border-color: var(--color-type-services); color: var(--color-type-services); }
.tl .bar--opex.tier-1 { border-style: dashed; }
.tl .bar--opex.tier-3 { border-width: 2px; }
/* month heat map */
.tl .c-cell.heat-1, .tl .h-month.heat-1 { background: var(--color-heat-1); }
.tl .c-cell.heat-2, .tl .h-month.heat-2 { background: var(--color-heat-2); }
.tl .c-cell.heat-3, .tl .h-month.heat-3 { background: var(--color-heat-3); }
.tl .h-month.heat-3 { color: var(--color-warn); font-weight: 600; }
/* category stripes */
.tl .c-group.c-label { border-left: 6px solid var(--cat, var(--color-ink-4)); padding-left: var(--space-sm); }
.tl .c-group { background: color-mix(in oklch, var(--cat, var(--color-paper-2)) 16%, var(--color-paper-2)); }
.tl .c-label--item, .tl .c-vendor.c-label { position: sticky; }
.tl .c-label--item::after, .tl .c-vendor.c-label::after { content: ""; position: absolute; top: 0; bottom: 0; left: var(--stripe-x, 0); width: 6px; background: color-mix(in oklch, var(--cat, transparent) 30%, transparent); }
.tl .c-vendor.c-label, .tl .c-label--item.is-indented { --stripe-x: 18px; }
.tl .c-vendor.c-label::after, .tl .c-label--item.is-indented::after { background: color-mix(in oklch, var(--cat, transparent) 55%, transparent); }
.tl .yoy { font: 600 var(--text-xs) var(--font-num); color: var(--color-warn); margin-left: 4px; white-space: nowrap; }
/* YoY step-up: second line inside the bar */
.tl .bar--up { height: auto; min-height: 24px; flex-direction: column; gap: 0; padding: 2px 0; line-height: 1.15; }
.tl .bar .up { font: 700 10px/1.1 var(--font-num); color: var(--color-warn); }
.tl .bar--capex .up { color: var(--color-warn-soft); }
/* today rule */
.tl .is-today { box-shadow: inset 2px 0 0 var(--color-accent); }
.tl .h-month.is-current { color: var(--color-accent); box-shadow: inset 2px 0 0 var(--color-accent); }
/* peak spend */
.tl .c-total.is-peak { background: var(--color-warn-soft); color: var(--color-ink); font-weight: 600; }
.tl .r-grand.is-peak { box-shadow: inset 0 -2px 0 var(--color-warn); }
.tl .bar--run { border-radius: 0; }
.tl .bar--run.run-start { border-top-left-radius: 4px; border-bottom-left-radius: 4px; }
.tl .bar--run.run-end { border-top-right-radius: 4px; border-bottom-right-radius: 4px; }
.tl .c-cell.is-eos::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--color-accent); }
.tl .c-cell.is-eos--soon::before { background: var(--color-warn); }
.tl .c-cell.is-eos--soon::after { color: var(--color-warn); font-weight: 600; }
.tl .c-cell.is-eos--past::before { background: var(--color-past); }
.tl .c-cell.is-eos--past::after { color: var(--color-past); }
.tl .c-cell.is-eos::after { content: attr(data-eos); position: absolute; top: 1px; left: 5px; font: 500 9px/1 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-accent); }
.tl .c-cell.c-empty { color: transparent; }

.tl .c-total { justify-content: flex-end; padding: 0 var(--space-xs); font-family: var(--font-num); font-variant-numeric: tabular-nums; font-weight: 500; font-size: var(--text-xs); color: var(--color-ink-2); background: var(--color-paper); }
.tl .r-total > div { border-top: var(--rule-2); }
.tl .r-grand > div, .tl .r-grand .c-label { font-weight: 600; color: var(--color-ink); background: var(--color-paper-2); }
.tl .c-total.c-label { justify-content: flex-start; font-family: var(--font-body); }
.tl-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); flex-wrap: wrap; margin-top: var(--space-md); }
.tl-zoom { display: inline-flex; gap: 2px; }
.tl-foot .btn--sm, #ctrl-extra .btn--sm { height: 24px; padding: 0 8px; font-size: 11px; }

@media (max-width: 768px) {
  :root { --tl-label-w: 180px; --tl-col-w: 48px; }
  .tl .c-label--item .sub { display: none; }
}
