  :root {
    --bg: #f1f4f7;
    --panel: #ffffff;
    --panel-2: #f1f4f7;
    --border: #d8dee5;
    --fg: #1f2937;
    --muted: #6b7280;
    --good: #16a34a;
    --good-bg: #14532d;
    --bad: #ef4444;
    --bad-bg: #7f1d1d;
    --accent: #16a34a;
    --accent-dim: #dcfce7;
    --warn: #a16207;
    --warn-dim: #fef3c7;
    --bad-dim: #fee2e2;
  }
  * { box-sizing: border-box; }
  body {
    margin: 0;
    font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--fg);
  }
  header {
    padding: 0.9rem 1.25rem;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
  }
  h1 { margin: 0; font-size: 1.1rem; font-weight: 600; }
  nav { display: flex; gap: 0.5rem; }
  nav a {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
  }
  nav a.active { color: var(--accent); background: var(--accent-dim); font-weight: 600; }

  /* Value Streams sub-nav */
  .sub-nav { display: flex; gap: 0.25rem; padding: 0.55rem 1.25rem 0; border-bottom: 1px solid var(--border); background: var(--panel); }
  .sub-nav a {
    color: var(--muted); text-decoration: none;
    font-size: 0.88rem;
    padding: 0.5rem 0.85rem;
    border-radius: 8px 8px 0 0;
    border: 1px solid transparent;
    border-bottom: none;
    margin-bottom: -1px;
  }
  .sub-nav a:hover { color: var(--fg); }
  .sub-nav a.active { color: var(--accent); background: var(--bg); border-color: var(--border); font-weight: 600; }
  form { display: flex; gap: 0.5rem; align-items: center; }
  label { color: var(--muted); font-size: 0.85rem; }
  input[type=date] {
    background: var(--panel-2);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.55rem;
    font: inherit;
  }
  button {
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid var(--accent-dim);
    border-radius: 6px;
    padding: 0.4rem 0.8rem;
    font: inherit;
    cursor: pointer;
    font-weight: 600;
  }
  main { padding: 0.75rem 1rem 1rem; }

  /* Gridstack theme overrides */
  .grid-stack { background: transparent; }
  .grid-stack-item-content {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: clamp(0.4rem, 3cqh, 1rem) clamp(0.5rem, 2.5cqw, 1.1rem);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: clamp(0.2rem, 2cqh, 0.6rem);
    container-type: size;
    container-name: widget;
  }
  .grid-stack-item-content > h3 {
    margin: 0;
    font-size: clamp(0.9rem, 6.5cqh, 1.3rem);
    flex: 0 0 auto;
  }
  .grid-stack-item-content .widget-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: stretch;
    gap: 3px;
  }
  /* KPI values scale with container height; clamp keeps them readable at extremes */
  .grid-stack-item-content .val {
    font-size: clamp(1.56rem, 49cqh, 8rem);
    line-height: 1.05;
    flex: 0 0 auto;
  }
  .grid-stack-item-content .label {
    font-size: clamp(0.78rem, 10cqh, 1.25rem);
    flex: 0 0 auto;
  }
  /* Bar rows expand vertically; tracks thicken to fill available height.
     Small margin gives a visible gap between bars at any widget size. */
  .grid-stack-item-content .bar-row {
    align-items: center;
    flex: 1 1 0;
    min-height: 0;
    padding: 0;
    margin-block: 2px;
  }
  .grid-stack-item-content .bar-track,
  .grid-stack-item-content .stacked-track {
    height: 100%;
    min-height: 14px;
    max-height: 200px;
  }
  .grid-stack-item-content .bar-row .name,
  .grid-stack-item-content .bar-row .val {
    font-size: clamp(0.9rem, 3.9cqh, 1.25rem);
  }
  /* Name column doesn't overflow / wrap into the bar at small widget sizes. */
  .grid-stack-item-content .bar-row .name { min-width: 0; overflow: hidden; }
  .grid-stack-item-content .bar-row .name .name-primary,
  .grid-stack-item-content .bar-row .name .name-secondary {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    display: block;
  }
  .grid-stack-item-content .bar-row .val .pct,
  .grid-stack-item-content .vbar-val .pct {
    color: var(--muted); font-weight: 400; font-size: 0.8em; margin-left: 0.15em;
  }
  .grid-stack-item.ui-draggable-dragging .grid-stack-item-content,
  .grid-stack-item.ui-resizable-resizing .grid-stack-item-content {
    outline: 2px solid var(--accent);
  }
  /* Gridstack placeholder (drop target) */
  .grid-stack > .grid-stack-placeholder > .placeholder-content {
    background: var(--accent-dim);
    border: 1px dashed var(--accent);
    border-radius: 12px;
  }
  .edit-bar { display: flex; gap: 0.5rem; align-items: center; justify-content: flex-end; padding: 0.5rem 1rem 0; font-size: 0.8rem; color: var(--muted); }
  .edit-bar button { background: transparent; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 0.35rem 0.7rem; font: inherit; font-size: 0.8rem; cursor: pointer; }
  .edit-bar button:hover { color: var(--fg); border-color: var(--muted); }
  .edit-bar .save-indicator { font-style: italic; opacity: 0.7; }

  /* Per-widget edit button + panel */
  .grid-stack-item-content { position: relative; }
  /* People-count badge in widget header (top-right, left of edit controls). */
  .grid-stack-item-content .people-count {
    position: absolute;
    top: 0.55rem;
    right: 2.5rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
    background: var(--panel-2);
    border: 1px solid var(--border);
    padding: 2px 8px;
    border-radius: 999px;
    z-index: 2;
  }
  .grid-stack-item-content .people-count::before {
    content: "";
    width: 11px;
    height: 11px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2'/><circle cx='9' cy='7' r='4'/><path d='M22 21v-2a4 4 0 0 0-3-3.87'/><path d='M16 3.13a4 4 0 0 1 0 7.75'/></svg>") center/contain no-repeat;
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2'/><circle cx='9' cy='7' r='4'/><path d='M22 21v-2a4 4 0 0 0-3-3.87'/><path d='M16 3.13a4 4 0 0 1 0 7.75'/></svg>") center/contain no-repeat;
  }
  .widget-edit-btn {
    position: absolute; top: 0.35rem; right: 0.4rem;
    width: 22px; height: 22px; line-height: 18px;
    background: transparent; color: var(--muted);
    border: 1px solid transparent; border-radius: 999px;
    font-size: 1rem; cursor: pointer; padding: 0; z-index: 5;
    display: grid; place-items: center;
  }
  .widget-edit-btn:hover { color: var(--fg); border-color: var(--border); background: var(--panel-2); }
  .widget-edit {
    position: absolute; inset: 0;
    background: var(--panel-2);
    border-radius: 12px;
    padding: 0.7rem 0.9rem;
    display: flex; flex-direction: column; gap: 0.5rem;
    z-index: 10;
  }
  .widget-edit[hidden] { display: none !important; }
  .widget-edit h4 { margin: 0 0 0.2rem; font-size: 0.85rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
  .widget-edit label { font-size: 0.8rem; color: var(--muted); display: flex; flex-direction: column; gap: 0.2rem; }
  .widget-edit input[type=text] {
    background: var(--bg); color: var(--fg); border: 1px solid var(--border); border-radius: 6px;
    padding: 0.35rem 0.5rem; font: inherit; font-size: 0.9rem;
  }
  .widget-edit input[type=color] {
    width: 100%; height: 32px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; padding: 2px;
  }
  .widget-edit .row { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: auto; }
  .widget-edit button {
    background: var(--panel); color: var(--fg); border: 1px solid var(--border); border-radius: 6px;
    padding: 0.35rem 0.7rem; font: inherit; font-size: 0.8rem; cursor: pointer;
  }
  .widget-edit button.primary { background: var(--accent); color: white; border-color: var(--accent); font-weight: 700; }
  .widget-edit button.danger  { color: var(--bad); border-color: var(--bad-bg); }
  .widget-edit button:hover { filter: brightness(1.1); }

  /* Number placement in horizontal bars. Name column scales with widget
     width so longer WC names ("Hand Build #1") fit cleanly on a wide
     widget but compress on a narrow one. */
  .grid-stack-item-content .bar-row.numpos-widget { grid-template-columns: clamp(6rem, 22cqw, 11rem) 1fr 4rem; }
  .grid-stack-item-content .bar-row.numpos-bar,
  .grid-stack-item-content .bar-row.numpos-inside,
  .grid-stack-item-content .bar-row.numpos-hidden { grid-template-columns: clamp(6rem, 22cqw, 11rem) 1fr; }
  .grid-stack-item-content .bar-fill { position: relative; overflow: visible; display: flex; align-items: center; justify-content: flex-end; }
  .grid-stack-item-content .bar-fill .in {
    color: white; font-weight: 700; font-variant-numeric: tabular-nums;
    padding-right: 0.5rem; font-size: clamp(0.75rem, 3cqh, 1rem);
  }
  .grid-stack-item-content .bar-fill .edge {
    position: absolute; left: 100%; top: 50%; transform: translateY(-50%);
    padding-left: 0.5rem; color: var(--fg); font-weight: 600;
    font-variant-numeric: tabular-nums; font-size: clamp(0.75rem, 3cqh, 1rem);
    white-space: nowrap;
  }

  /* Vertical bars */
  .grid-stack-item-content .vbars {
    display: flex; align-items: stretch; justify-content: space-evenly;
    gap: clamp(4px, 2cqw, 14px);
    flex: 1 1 auto; min-height: 0;
  }
  .grid-stack-item-content .vbar-col {
    display: flex; flex-direction: column; align-items: stretch;
    flex: 1 1 0; min-width: 0; gap: 4px;
  }
  .grid-stack-item-content .vbar-val,
  .grid-stack-item-content .vbar-name {
    text-align: center; font-variant-numeric: tabular-nums;
    font-size: clamp(0.75rem, 3cqh, 1rem);
    flex: 0 0 auto;
  }
  .grid-stack-item-content .vbar-val { font-weight: 600; color: var(--fg); }
  .grid-stack-item-content .vbar-name { color: var(--muted); font-size: clamp(0.7rem, 2.6cqh, 0.9rem); }
  .grid-stack-item-content .vbar-track {
    flex: 1 1 auto; min-height: 0;
    background: var(--panel-2); border-radius: 4px;
    display: flex; align-items: flex-end; overflow: hidden;
  }
  .grid-stack-item-content .vbar-fill {
    width: 100%; background: var(--good); border-radius: 0 0 4px 4px;
    display: flex; flex-direction: column; align-items: center;
  }
  .grid-stack-item-content .vbar-fill .in {
    color: white; font-weight: 700; padding-top: 0.3rem;
    font-size: clamp(0.7rem, 3cqh, 1rem); font-variant-numeric: tabular-nums;
  }
  .grid-stack-item-content .vbar-fill .edge {
    position: relative; top: -1.2em; color: var(--fg); font-weight: 600;
    font-size: clamp(0.7rem, 3cqh, 1rem); font-variant-numeric: tabular-nums;
  }

  /* KPI alignment */
  .grid-stack-item-content.align-left   .label,
  .grid-stack-item-content.align-left   .val { text-align: left; }
  .grid-stack-item-content.align-center .label,
  .grid-stack-item-content.align-center .val { text-align: center; }
  .grid-stack-item-content.align-right  .label,
  .grid-stack-item-content.align-right  .val { text-align: right; }

  /* Progress show/hide */
  .progress.no-legend .legend { display: none; }
  .progress.no-target .target-line { display: none; }

  /* Downtime number placement (stacked track) */
  .grid-stack-item-content .stacked-track { overflow: visible; position: relative; }
  .grid-stack-item-content .stacked-track .bad {
    position: relative; display: flex; align-items: center; justify-content: flex-end;
  }
  .grid-stack-item-content .stacked-track .in {
    color: white; font-weight: 700; padding-right: 0.5rem;
    font-size: clamp(0.75rem, 3cqh, 0.95rem); font-variant-numeric: tabular-nums;
  }
  .grid-stack-item-content .stacked-track .edge {
    position: absolute; left: 100%; top: 50%; transform: translateY(-50%);
    padding-left: 0.5rem; color: var(--fg); font-weight: 600;
    font-size: clamp(0.75rem, 3cqh, 0.95rem); font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  .kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.75rem; }
  .kpi {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.1rem;
  }
  .kpi .label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.8px; }
  .kpi .val {
    font-size: 2.4rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--bad);
    margin-top: 0.25rem;
  }

  .panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.1rem;
    margin-top: 0.75rem;
  }
  .panel h3 { margin: 0 0 0.75rem; font-size: 0.85rem; font-weight: 600; color: var(--fg); }
  .panel .sub { font-size: 0.7rem; color: var(--muted); margin-left: 0.4rem; font-weight: 400; text-transform: none; letter-spacing: 0; }

  .bar-row {
    display: grid;
    grid-template-columns: 7rem 1fr 4rem;
    align-items: center;
    gap: 0.75rem;
    padding: 0.3rem 0;
  }
  .bar-row .name { font-size: 0.85rem; }
  .bar-row .name { display: flex; flex-direction: column; line-height: 1.15; }
  .name-primary  { font-weight: 500; }
  .name-secondary{ color: var(--muted); font-size: 0.78em; }
  .name-secondary em { font-style: italic; }
  .no-assign-btn {
    background: var(--warn-dim); color: var(--warn);
    border: 1px solid var(--warn); border-radius: 4px;
    padding: 0 0.4rem; font: inherit; font-size: 0.7rem; font-weight: 700;
    cursor: pointer; align-self: flex-start;
  }
  .no-assign-btn:hover { background: var(--warn); color: white; }
  .assign-popover {
    background: var(--panel); color: var(--fg);
    border: 1px solid var(--border); border-radius: 8px;
    padding: 0.5rem 0.6rem; box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    z-index: 9500;
    display: inline-flex; gap: 0.4rem; align-items: center; flex-wrap: wrap;
    max-width: min(360px, 90vw);
  }
  .assign-popover .assign-pick {
    background: var(--panel-2); color: var(--fg);
    border: 1px solid var(--border); border-radius: 6px;
    padding: 0.25rem 0.4rem; font: inherit; font-size: 0.85rem;
    min-width: 10rem;
  }
  .assign-popover .assign-save {
    background: var(--accent); color: white; border: 1px solid var(--accent);
    border-radius: 6px; padding: 0.25rem 0.7rem; font: inherit; font-weight: 600; cursor: pointer;
  }
  .assign-popover .assign-save:disabled { opacity: 0.6; cursor: not-allowed; }
  .assign-popover .assign-status { font-size: 0.8rem; color: var(--accent); }
  .vbar-name     { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
  .bar-row .val  { font-size: 0.9rem; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
  .bar-track { height: 20px; background: var(--panel-2); border-radius: 4px; overflow: hidden; position: relative; }
  .bar-fill  { height: 100%; background: var(--good); border-radius: 4px; }
  .bar-target-line {
    position: absolute;
    top: -2px; bottom: -2px;
    width: 2px;
    margin-left: -1px;
    background: var(--fg);
    box-shadow: 0 0 0 1px rgba(14, 17, 22, 0.85);
    pointer-events: none;
    z-index: 2;
  }
  /* Axis row + time marker below the bars */
  .bar-row.axis-row { border-bottom: none; padding: 0; min-height: 0; flex: 0 0 auto; margin-top: 0.15rem; }
  .axis-track { position: relative; height: 1.1em; }
  .axis-tick {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    font-size: clamp(0.62rem, 2.2cqh, 0.78rem);
    color: var(--muted);
    background: var(--panel);
    padding: 0 0.3rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
  }
  .axis-tick::before {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 100%;
    width: 1px;
    height: 4px;
    margin-left: -0.5px;
    background: var(--muted);
  }
  .axis-tick.axis-start { transform: translateX(0); }
  .axis-tick.axis-start::before { left: 0; margin-left: 0; }
  .widget-total {
    flex: 0 0 auto;
    margin-top: 0.45rem;
    font-size: clamp(0.72rem, 2.6cqh, 0.9rem);
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    text-align: right;
  }
  .widget-total b { color: var(--fg); font-weight: 700; }
  .widget-total-pct { color: var(--muted); }

  .vbar-track { position: relative; }
  .vbar-target-line {
    position: absolute;
    left: -2px; right: -2px;
    height: 2px;
    margin-bottom: -1px;
    background: var(--fg);
    box-shadow: 0 0 0 1px rgba(14, 17, 22, 0.85);
    pointer-events: none;
    z-index: 2;
  }

  .stacked-track { height: 22px; display: flex; border-radius: 4px; overflow: hidden; background: var(--panel-2); }
  .stacked-track .good { background: var(--good-color, var(--good)); height: 100%; }
  .stacked-track .bad  { background: var(--bad);  height: 100%; }

  /* 15-min progress chart */
  .progress {
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
  }
  .progress .plot {
    position: relative;
    flex: 1 1 auto;
    min-height: 60px;
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--border);
  }
  .progress .x-ticks { font-size: clamp(0.72rem, 2.6cqh, 0.97rem); }
  .progress .legend  { font-size: clamp(0.78rem, 2.85cqh, 1.04rem); }
  .progress .bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 100%;
  }
  .progress .col {
    flex: 1 1 0;
    display: flex;
    flex-direction: column-reverse;  /* bar grows from bottom up */
    height: 100%;
    min-width: 0;
    position: relative;  /* anchor for the per-bucket target tick */
  }
  .progress .col .bar {
    width: 100%;
    border-radius: 2px 2px 0 0;
    position: relative;
  }
  .progress .col.hit  .bar { background: var(--hit, var(--good)); }
  .progress .col.miss .bar { background: var(--bad); }
  .progress .col.in-progress .bar { opacity: 0.55; }
  .progress .col .bar-label {
    position: absolute;
    top: 2px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.7rem;
    color: #fff;
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
    line-height: 1;
  }
  /* Per-bucket target — a dashed segment per col so the goal line steps up
     and down as stations get transferred away or come back online. */
  .progress .col .target-tick {
    position: absolute;
    left: 0; right: 0;
    border-top: 1px dashed var(--muted);
    pointer-events: none;
  }
  .progress.no-target .col .target-tick { display: none; }
  .progress .target-line {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 1px dashed var(--muted);
    pointer-events: none;
  }
  .progress .target-line::after {
    content: attr(data-label);
    position: absolute;
    right: 0;
    top: -1.1rem;
    font-size: 0.68rem;
    color: var(--muted);
    background: var(--panel);
    padding: 0 0.25rem;
  }
  .progress .x-ticks {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--muted);
    margin-top: 0.3rem;
  }
  .progress .x-ticks span { flex: 1 1 0; text-align: center; font-variant-numeric: tabular-nums; }
  .progress .legend { display: flex; gap: 1rem; font-size: 0.75rem; color: var(--muted); margin-bottom: 0.5rem; }
  .progress .legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 0.35rem; vertical-align: middle; }

  .footer { color: var(--muted); font-size: 0.75rem; margin-top: 1.5rem; text-align: center; padding-bottom: 1rem; }

  /* Intermediate breakpoint: shave padding + KPI font on 13" laptops
     (1280-1400px). Gridstack widgets are already container-query driven
     so they self-scale; this targets the static (non-Gridstack) sections. */
  @media (max-width: 1400px) {
    header { padding: 0.7rem 0.9rem; }
    .sub-nav { padding-left: 0.9rem; padding-right: 0.9rem; }
    main { padding: 0.6rem 0.85rem 0.85rem; }
    .edit-bar { padding-left: 0.85rem; padding-right: 0.85rem; }
    .kpi { padding: 0.75rem 0.85rem; }
    .kpi .val { font-size: clamp(1.6rem, 2.6vw, 2.4rem); }
    .panel { padding: 0.75rem 0.85rem; }
  }

  @media (max-width: 600px) {
    .kpi .val { font-size: 1.8rem; }
    .bar-row { grid-template-columns: 5.5rem 1fr 3.5rem; gap: 0.5rem; }
    .progress .bars { height: 110px; }
  }

  /* ---- Cumulative progress widget ---- */
  .cum-progress {
    display: flex;
    flex-direction: column;
    height: 100%;
    font-size: 0.78rem;
    color: var(--fg);
  }
  .cum-progress .legend {
    display: flex;
    gap: 1.25rem;
    align-items: center;
    justify-content: center;
    padding: 0 0 0.4rem 0;
    color: var(--muted);
    font-size: 0.72rem;
  }
  .cum-progress .legend .swatch-line {
    display: inline-block;
    width: 18px;
    height: 0;
    border-top: 1.5px solid var(--muted);
    margin-right: 4px;
    vertical-align: middle;
  }
  .cum-progress .legend .swatch-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--fg);
    margin-right: 4px;
    vertical-align: middle;
  }
  .cum-progress .plot {
    position: relative;
    flex: 1 1 auto;
    min-height: 80px;
    margin-top: 14px;
    border-bottom: 1px solid var(--border);
  }
  .cum-progress .bars {
    display: grid;
    grid-template-columns: repeat(var(--n-cols, 24), 1fr);
    gap: 2px;
    height: 100%;
    align-items: end;
  }
  .cum-progress .col {
    position: relative;
    height: 100%;
    display: flex;
    align-items: end;
  }
  .cum-progress .bar {
    width: 100%;
    background: var(--good);
    border-radius: 2px 2px 0 0;
    min-height: 1px;
    position: relative;
  }
  .cum-progress .col.miss .bar { background: var(--bad); }
  .cum-progress .col.in-progress .bar { opacity: 0.7; }
  .cum-progress .bar-label {
    position: absolute;
    top: 2px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.72rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: #fff;
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
    line-height: 1;
  }
  .cum-progress .target-line {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: visible;
  }
  .cum-progress .target-line svg {
    width: 100%;
    height: 100%;
    overflow: visible;
  }
  .cum-progress .target-line polyline {
    fill: none;
    stroke: var(--muted);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
  }
  .cum-progress .target-line .end-label {
    font-size: 9px;
    fill: var(--muted);
  }
  .cum-progress .x-ticks {
    display: grid;
    grid-template-columns: repeat(var(--n-cols, 24), 1fr);
    gap: 2px;
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.65rem;
  }
  .cum-progress .x-ticks span {
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
  }

  /* ---- Range chip toolbar ---- */
  .rc-toolbar {
    display: inline-flex; flex-wrap: wrap; gap: 0.4rem; align-items: center;
    margin-left: 1rem;
    font-size: 0.85rem;
  }
  .rc-tool-label { color: var(--muted); margin-right: 0.2rem; }
  .rc-chip {
    display: inline-block; padding: 0.25rem 0.6rem; border-radius: 999px;
    background: var(--panel-2); color: var(--fg);
    border: 1px solid var(--border); text-decoration: none;
    font: inherit; font-size: 0.82rem; cursor: pointer;
  }
  .rc-chip:hover { border-color: var(--accent); color: var(--accent); }
  .rc-chip-on { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); font-weight: 600; }
  .rc-custom-popover { position: relative; }
  .rc-custom-popover > summary {
    list-style: none;
    cursor: pointer;
  }
  .rc-custom-popover > summary::-webkit-details-marker { display: none; }
  .rc-custom-panel {
    position: absolute;
    top: calc(100% + 0.3rem);
    right: 0;
    left: auto;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.6rem 0.7rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    z-index: 10;
    white-space: nowrap;
  }
  .rc-custom-panel label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    color: var(--muted);
  }
  .rc-custom-panel input[type=date] {
    background: var(--panel-2); color: var(--fg); border: 1px solid var(--border);
    border-radius: 4px; padding: 0.25rem 0.4rem; font: inherit; font-size: 0.85rem;
    color-scheme: light;
  }
  .rc-custom-panel input[type=date]::-webkit-calendar-picker-indicator {
    cursor: pointer; filter: brightness(0.4);
  }
  .rc-custom-apply { align-self: flex-end; }
