/* ═══════════════════════════════════════════════════════════════
   Trellar — Shared UI Components
   Source: Figma "Trellar — Design System" → Components, plus the
   "Trellar — Redesign" modal / form / selector patterns.

   RULES
   - Every class is namespaced `tl-` so it never clashes with legacy page CSS.
   - Colors, spacing, radius and fonts come ONLY from tokens.css.
   - Load order: tokens.css → components.css → page CSS.
   - Markup + behavior: see templates/components/*.html and
     static/js/base/components.js (opt-in via data-tl-* attributes).

   Sections
     1  Primitives (icon, label, text roles, card)
     2  Controls (button, select, help tooltip, severity badge, tab, toggle, search)
     3  Data display (KPI card, table row, donut)
     4  Navigation (nav item)
     5  Redesign patterns (modal, field, checkbox, setting row)
     6  Derived — NOT in Figma (chip, status badge, danger button)
   ═══════════════════════════════════════════════════════════════ */

/* Pages that do not load a global reset (auth pages, links used as buttons) still get
   predictable sizing: every component is border-box. */
.tl-btn, .tl-chip, .tl-badge, .tl-severity, .tl-tab, .tl-nav-item, .tl-kpi, .tl-card,
.tl-table-row, .tl-search, .tl-input, .tl-textarea, .tl-select, .tl-select__field,
.tl-select__menu, .tl-select__option, .tl-help__pop, .tl-modal, .tl-modal-backdrop,
.tl-check-row, .tl-check-list, .tl-setting, .tl-donut, .tl-legend-row { box-sizing: border-box; }

/* ═══ 1 · PRIMITIVES ═══════════════════════════════════════════ */

.tl-icon {
    width: 16px;
    height: 16px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.tl-icon--muted  { color: var(--ink-muted); }
.tl-icon--danger { color: var(--severity-critical); }   /* delete uses severity-critical */
.tl-icon--brand  { color: var(--brand-primary); }
.tl-icon--lg     { width: 18px; height: 18px; }

.tl-label {
    font-family: var(--font-ui);
    font-size: var(--text-small-size);
    line-height: var(--text-small-line);
    color: var(--ink-primary);
}

/* Type roles (Trellar/Body, Small, Data, Metric) */
.tl-text-body  { font: 400 var(--text-body-size)/var(--text-body-line) var(--font-ui); color: var(--ink-primary); }
.tl-text-small { font: 400 var(--text-small-size)/var(--text-small-line) var(--font-ui); color: var(--ink-muted); }
.tl-text-data  { font: 500 14px/22px var(--font-data); color: var(--ink-primary); }
.tl-text-metric{ font: 700 var(--text-metric-size)/var(--text-metric-line) var(--font-data); color: var(--ink-primary); }
.tl-text-muted { color: var(--ink-muted); }

.tl-visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    margin: -1px; padding: 0; border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* Card surface: card fill / card border / radius-md */
.tl-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}
.tl-card--compact { padding: var(--space-4); gap: var(--space-3); }
.tl-card__head { display: flex; flex-direction: column; gap: var(--space-1); }
.tl-card__head h3 { margin: 0; }
.tl-card__head p { margin: 0; }

/* ═══ 2 · CONTROLS ═════════════════════════════════════════════ */

/* ─── Button · style × state ─── */
.tl-btn {
    --_bg: transparent;
    --_fg: var(--ink-primary);
    --_bd: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    height: 36px;
    padding: var(--space-2) var(--space-4);
    border: 1px solid var(--_bd);
    border-radius: 999px;
    background: var(--_bg);
    color: var(--_fg);
    font: 400 var(--text-body-size)/var(--text-body-line) var(--font-ui);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.tl-btn:focus-visible {
    outline: 2px solid var(--primary-300);
    outline-offset: 2px;
}

.tl-btn--primary   { --_bg: var(--brand-primary); --_fg: #ffffff; }
.tl-btn--primary:hover:not(:disabled):not(.is-disabled)  { --_bg: var(--brand-primary-hover); }
.tl-btn--primary:active:not(:disabled):not(.is-disabled) { --_bg: var(--brand-primary-active); }

.tl-btn--secondary { --_bd: var(--border-light); }
.tl-btn--secondary:hover:not(:disabled):not(.is-disabled),
.tl-btn--ghost:hover:not(:disabled):not(.is-disabled) { --_bg: var(--bg-hover); }

.tl-btn--ghost { }

/* Disabled states remain readable */
.tl-btn:disabled,
.tl-btn.is-disabled,
.tl-btn[aria-disabled="true"] {
    cursor: not-allowed;
    --_fg: var(--disabled-fg);
}
.tl-btn--primary:disabled,
.tl-btn--primary.is-disabled,
.tl-btn--primary[aria-disabled="true"] { --_bg: var(--disabled-bg); }

.tl-btn--sm { height: 28px; padding: var(--space-1) var(--space-3); font-size: var(--text-small-size); line-height: var(--text-small-line); }
.tl-btn--block { width: 100%; }
.tl-btn--icon { width: 36px; padding: 0; }
.tl-btn--icon.tl-btn--sm { width: 28px; }

/* ─── Select / Filter Dropdown ─── */
.tl-select {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-width: 0;
}
.tl-select__field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    width: 100%;
    height: 36px;
    padding: 0 var(--space-3);
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--ink-primary);
    font: 400 var(--text-body-size)/var(--text-body-line) var(--font-ui);
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.tl-select__field:hover { border-color: rgba(var(--ink-primary-rgb), 0.28); }
.tl-select__field:focus-visible,
.tl-select.is-open .tl-select__field {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(var(--brand-primary-rgb), 0.16);
}
.tl-select__value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-select__value.is-placeholder { color: var(--ink-muted); }
.tl-select__chevron { width: 14px; height: 14px; transition: transform 0.15s ease; }
.tl-select.is-open .tl-select__chevron { transform: rotate(180deg); }
.tl-select.is-disabled .tl-select__field {
    background: var(--disabled-bg);
    color: var(--disabled-fg);
    cursor: not-allowed;
}

.tl-select__menu {
    position: absolute;
    top: calc(100% + var(--space-1));
    left: 0;
    right: 0;
    z-index: 60;
    display: none;
    flex-direction: column;
    max-height: 280px;
    overflow-y: auto;
    padding: var(--space-1);
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(var(--ink-primary-rgb), 0.1);
}
.tl-select.is-open .tl-select__menu { display: flex; }
.tl-select__menu--up { top: auto; bottom: calc(100% + var(--space-1)); }

.tl-select__option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    min-height: 36px;
    padding: 0 var(--space-2);
    border-radius: var(--radius-sm);
    color: var(--ink-primary);
    font: 400 var(--text-body-size)/var(--text-body-line) var(--font-ui);
    cursor: pointer;
}
.tl-select__option:hover,
.tl-select__option.is-active { background: var(--bg-hover); }
.tl-select__option .tl-select__check { display: none; width: 13px; height: 13px; }
.tl-select__option[aria-selected="true"] {
    background: var(--bg-hover);
    color: var(--brand-primary);
    font-weight: 600;
}
.tl-select__option[aria-selected="true"] .tl-select__check { display: block; }

/* Native <select> styled to match (for plain forms) */
select.tl-input {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2377748d' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px 14px;
    cursor: pointer;
}

/* ─── Help Tooltip ─── */
.tl-help {
    position: relative;
    display: inline-flex;
    flex: none;
    outline: none;
}
.tl-help__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: 1px solid var(--border-light);
    border-radius: 50%;
    color: var(--ink-muted);
    font: 400 var(--text-small-size)/1 var(--font-ui);
    cursor: help;
    user-select: none;
}
.tl-help:focus-visible .tl-help__icon { border-color: var(--brand-primary); color: var(--brand-primary); }
.tl-help__pop {
    position: absolute;
    top: calc(100% + var(--space-2));
    left: 0;
    z-index: 70;
    display: none;
    flex-direction: column;
    gap: var(--space-1);
    width: 224px;
    padding: var(--space-3);
    background: var(--bg-page);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font: 400 var(--text-small-size)/var(--text-small-line) var(--font-ui);
    color: var(--ink-muted);
    text-align: left;
}
.tl-help__pop strong { font-weight: 400; color: var(--ink-primary); }
.tl-help:hover .tl-help__pop,
.tl-help:focus .tl-help__pop,
.tl-help:focus-within .tl-help__pop,
.tl-help.is-open .tl-help__pop { display: flex; }
.tl-help--right .tl-help__pop { left: auto; right: 0; }

/* ─── Severity Badge (also base for status badge) ─── */
.tl-severity,
.tl-badge {
    --_fg: var(--ink-muted);
    --_bg: var(--disabled-bg);
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    height: 26px;
    padding: var(--space-1) var(--space-3);
    border-radius: 999px;
    background: var(--_bg);
    color: var(--_fg);
    font: 400 var(--text-small-size)/var(--text-small-line) var(--font-ui);
    white-space: nowrap;
}
.tl-severity::before,
.tl-badge--dot::before {
    content: '';
    width: 6px;
    height: 6px;
    flex: none;
    border-radius: 50%;
    background: var(--_fg);
}
.tl-severity--critical { --_fg: var(--severity-critical); --_bg: var(--severity-critical-bg); }
.tl-severity--high     { --_fg: var(--severity-high);     --_bg: var(--severity-high-bg); }
.tl-severity--medium   { --_fg: var(--severity-medium);   --_bg: var(--severity-medium-bg); }
.tl-severity--low      { --_fg: var(--severity-low);      --_bg: var(--severity-low-bg); }

/* Inactive: neutral pill, dot at 45% opacity, label muted */
.tl-severity.is-inactive {
    --_bg: var(--disabled-bg);
    color: var(--ink-muted);
}
.tl-severity.is-inactive::before { opacity: 0.45; background: var(--_fg); }

/* ─── Tab · single item, active indicator only ─── */
.tl-tabs {
    display: flex;
    align-items: stretch;
    gap: var(--space-2);
    flex-wrap: wrap;
}
.tl-tabs--divider { border-bottom: 1px solid var(--border-card); }
.tl-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 var(--space-4);
    background: none;
    border: 0;
    color: var(--ink-muted);
    font: 400 var(--text-body-size)/var(--text-body-line) var(--font-ui);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: color 0.15s ease;
}
.tl-tab:hover { color: var(--ink-primary); }
.tl-tab:focus-visible { outline: 2px solid var(--primary-300); outline-offset: -2px; border-radius: var(--radius-sm); }
.tl-tab.is-active,
.tl-tab[aria-selected="true"] { color: var(--ink-primary); }
.tl-tab.is-active::after,
.tl-tab[aria-selected="true"]::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: var(--brand-primary);
}

/* ─── Toggle · 36 × 20, thumb always bg-card ─── */
.tl-toggle {
    position: relative;
    display: inline-flex;
    flex: none;
    width: 36px;
    height: 20px;
    cursor: pointer;
}
.tl-toggle input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: inherit;
}
.tl-toggle__track {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: var(--border-light);
    transition: background-color 0.15s ease;
    pointer-events: none;
}
.tl-toggle__track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--bg-card);
    transition: transform 0.15s ease;
}
.tl-toggle input:checked + .tl-toggle__track { background: var(--brand-primary); }
.tl-toggle input:checked + .tl-toggle__track::after { transform: translateX(16px); }
.tl-toggle input:focus-visible + .tl-toggle__track { outline: 2px solid var(--primary-300); outline-offset: 2px; }
.tl-toggle input:disabled + .tl-toggle__track { opacity: 0.5; }
.tl-toggle input:disabled { cursor: not-allowed; }

/* ─── Search Field ─── */
.tl-search {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    height: 36px;
    padding: 0 var(--space-3);
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.tl-search:focus-within {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(var(--brand-primary-rgb), 0.16);
}
.tl-search .tl-icon { color: var(--ink-muted); }
.tl-search input {
    flex: 1;
    min-width: 0;
    height: 100%;
    padding: 0;
    background: transparent;
    border: 0;
    outline: none;
    color: var(--ink-primary);
    font: 400 var(--text-body-size)/var(--text-body-line) var(--font-ui);
}
.tl-search input::placeholder { color: var(--ink-muted); }

/* ═══ 3 · DATA DISPLAY ═════════════════════════════════════════ */

/* ─── KPI Card ─── */
.tl-kpi {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    min-width: 0;
}
.tl-kpi__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    font: 400 var(--text-body-size)/var(--text-body-line) var(--font-ui);
    color: var(--ink-primary);
}
.tl-kpi__value {
    font: 700 var(--text-metric-size)/var(--text-metric-line) var(--font-data);
    color: var(--ink-primary);
    overflow-wrap: anywhere;
}
.tl-kpi__link {
    align-self: flex-start;
    color: var(--brand-primary);
    font: 400 var(--text-small-size)/var(--text-small-line) var(--font-ui);
    text-decoration: none;
}
.tl-kpi__link:hover { text-decoration: underline; }

/* ─── Table Row · default / hover / selected ─── */
.tl-table-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-4);
    height: 48px;
    padding: 0 var(--space-4);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-card);
    transition: background-color 0.15s ease;
}
.tl-table-row__name { flex: 1; min-width: 0; font: 400 var(--text-body-size)/var(--text-body-line) var(--font-ui); color: var(--ink-primary); }
.tl-table-row__value { font: 500 14px/22px var(--font-data); color: var(--ink-primary); }
.tl-table-row:hover { background: var(--bg-hover); }
.tl-table-row.is-selected { background: var(--bg-hover); }
.tl-table-row.is-selected::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--brand-primary);
}

/* Real <table> using the same row language */
.tl-table { width: 100%; border-collapse: collapse; background: var(--bg-card); }
.tl-table th {
    height: 36px;
    padding: 0 var(--space-4);
    text-align: left;
    font: 400 var(--text-small-size)/var(--text-small-line) var(--font-data);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-muted);
    border-bottom: 1px solid var(--border-light);
}
.tl-table td {
    height: 48px;
    padding: 0 var(--space-4);
    font: 400 var(--text-body-size)/var(--text-body-line) var(--font-ui);
    color: var(--ink-primary);
    border-bottom: 1px solid var(--border-card);
}
.tl-table td.tl-table__data { font: 500 14px/22px var(--font-data); }
.tl-table tbody tr { transition: background-color 0.15s ease; }
.tl-table tbody tr:hover td,
.tl-table tbody tr.is-selected td { background: var(--bg-hover); }
.tl-table tbody tr.is-selected td:first-child { box-shadow: inset 3px 0 0 var(--brand-primary); }

/* ─── Donut Chart + legend ─── */
.tl-donut {
    display: flex;
    align-items: center;
    gap: var(--space-6);
    padding: var(--space-4);
}
.tl-donut__chart {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
    flex: none;
    width: 208px;
}
.tl-donut__ring {
    position: relative;
    width: 208px;
    height: 208px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.tl-donut__svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.tl-donut__segment { fill: none; stroke-width: 22; stroke: var(--series, var(--brand-primary)); }
.tl-donut__value { position: relative; font: 600 32px/40px var(--font-data); color: var(--ink-primary); }
.tl-donut__label { position: relative; font: 400 var(--text-small-size)/var(--text-small-line) var(--font-ui); color: var(--ink-muted); }
.tl-donut__context { font: 400 11px/16px var(--font-data); color: var(--ink-muted); }

.tl-donut__legend { flex: 1; display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.tl-donut__legend-title { font: 400 var(--text-body-size)/var(--text-body-line) var(--font-ui); color: var(--ink-primary); }
.tl-legend-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 62px 145px 106px;
    align-items: center;
    column-gap: var(--space-2);
    min-height: 36px;
    border-top: 1px solid var(--border-light);
}
.tl-legend-row--head {
    min-height: 26px;
    border-top: 0;
    font: 400 10px/18px var(--font-data);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-muted);
}
.tl-legend-row__key { display: flex; align-items: center; gap: var(--space-2); min-width: 0; font: 500 var(--text-small-size)/var(--text-small-line) var(--font-ui); color: var(--ink-primary); }
.tl-legend-row__dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--series, var(--brand-primary)); }
.tl-legend-row__num { font: 400 12px/18px var(--font-data); color: var(--ink-primary); }
.tl-legend-row__dur { font: 400 14px/22px var(--font-data); color: var(--ink-primary); }
.tl-legend-row__link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--ink-muted);
    font: 600 11px/16px var(--font-ui);
    text-decoration: underline;
}
.tl-legend-row__link .tl-icon { width: 13px; height: 13px; }
.tl-legend-row__link:hover { color: var(--brand-primary); }

@media (max-width: 900px) {
    .tl-donut { flex-direction: column; align-items: stretch; }
    .tl-donut__chart { align-self: center; }
    .tl-legend-row { grid-template-columns: minmax(0, 1fr) 48px 96px; }
    .tl-legend-row > :nth-child(4) { display: none; }
}

/* ═══ 4 · NAVIGATION ═══════════════════════════════════════════ */

/* ─── Nav Item · default / active ─── */
.tl-nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    height: 44px;
    padding: 0 var(--space-4);
    border-radius: var(--radius-sm);
    color: var(--ink-muted);
    font: 400 var(--text-body-size)/var(--text-body-line) var(--font-ui);
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.tl-nav-item .tl-icon { width: 18px; height: 18px; }
.tl-nav-item:hover { background: var(--bg-hover); color: var(--ink-primary); }
.tl-nav-item.is-active,
.tl-nav-item[aria-current="page"] { background: var(--bg-hover); color: var(--ink-primary); }
.tl-nav-item.is-active::before,
.tl-nav-item[aria-current="page"]::before {
    content: '';
    position: absolute;
    left: 0;
    top: 12px;
    width: 3px;
    height: 20px;
    border-radius: 999px;
    background: var(--brand-primary);
}
.tl-nav-item__badge {
    margin-left: auto;
    padding: 0 var(--space-2);
    border-radius: 999px;
    background: var(--disabled-bg);
    color: var(--ink-muted);
    font: 500 11px/18px var(--font-data);
}
.tl-nav-section {
    padding: var(--space-4) var(--space-4) var(--space-2);
    font: 400 10px/18px var(--font-data);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-muted);
}

/* ═══ 5 · REDESIGN PATTERNS ════════════════════════════════════ */

/* ─── Modal shell ─── */
.tl-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-5);
    overflow-y: auto;
    background: var(--overlay-backdrop);
}
.tl-modal-backdrop.is-open { display: flex; }
html.tl-modal-lock { overflow: hidden; }

.tl-modal {
    --tl-modal-w: 640px;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: var(--tl-modal-w);
    max-height: calc(100vh - 48px);
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: 0 24px 64px rgba(var(--ink-primary-rgb), 0.18);
    color: var(--ink-primary);
}
.tl-modal--sm { --tl-modal-w: 560px; }
.tl-modal--md { --tl-modal-w: 640px; }
.tl-modal--lg { --tl-modal-w: 760px; }
.tl-modal--xl { --tl-modal-w: 1040px; }

.tl-modal__head {
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    padding: var(--space-5);
    border-bottom: 1px solid var(--border-light);
}
.tl-modal__intro { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.tl-modal__title { margin: 0; font: 500 24px/32px var(--font-heading); color: var(--ink-primary); }
.tl-modal__desc { margin: 0; font: 400 var(--text-body-size)/var(--text-body-line) var(--font-ui); color: var(--ink-muted); }
.tl-modal__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 28px;
    height: 28px;
    margin: -4px -4px 0 0;
    padding: 0;
    background: none;
    border: 0;
    border-radius: var(--radius-sm);
    color: var(--ink-muted);
    cursor: pointer;
}
.tl-modal__close:hover { background: var(--bg-hover); color: var(--ink-primary); }
.tl-modal__body {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    padding: var(--space-5);
    overflow-y: auto;
}
.tl-modal__foot {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border-light);
}

/* ─── Form field · input · textarea ─── */
.tl-field { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.tl-field__hint  { font: 400 var(--text-small-size)/var(--text-small-line) var(--font-ui); color: var(--ink-muted); }
.tl-field__error { font: 400 var(--text-small-size)/var(--text-small-line) var(--font-ui); color: var(--severity-critical); }

.tl-input,
.tl-textarea {
    width: 100%;
    min-height: 36px;
    padding: var(--space-2) var(--space-3);
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--ink-primary);
    font: 400 var(--text-body-size)/var(--text-body-line) var(--font-ui);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.tl-textarea { min-height: 96px; resize: vertical; }
.tl-input::placeholder,
.tl-textarea::placeholder { color: var(--ink-muted); }
.tl-input:hover,
.tl-textarea:hover { border-color: rgba(var(--ink-primary-rgb), 0.28); }
.tl-input:focus,
.tl-textarea:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(var(--brand-primary-rgb), 0.16);
}
.tl-input.is-invalid,
.tl-textarea.is-invalid { border-color: var(--severity-critical); }
.tl-input.is-invalid:focus,
.tl-textarea.is-invalid:focus { box-shadow: 0 0 0 3px rgba(164, 61, 103, 0.16); }
.tl-input:disabled,
.tl-textarea:disabled { background: var(--disabled-bg); color: var(--disabled-fg); cursor: not-allowed; }

/* ─── Checkbox ─── */
.tl-checkbox {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
    font: 400 var(--text-body-size)/var(--text-body-line) var(--font-ui);
    color: var(--ink-primary);
}
.tl-checkbox input { position: absolute; opacity: 0; width: 18px; height: 18px; margin: 0; cursor: inherit; }
.tl-checkbox__box {
    position: relative;
    display: inline-flex;
    flex: none;
    width: 18px;
    height: 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.tl-checkbox__box::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid #ffffff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0);
    transition: transform 0.12s ease;
}
.tl-checkbox input:checked + .tl-checkbox__box { background: var(--brand-primary); border-color: var(--brand-primary); }
.tl-checkbox input:checked + .tl-checkbox__box::after { transform: rotate(45deg) scale(1); }
.tl-checkbox input:focus-visible + .tl-checkbox__box { outline: 2px solid var(--primary-300); outline-offset: 2px; }
.tl-checkbox input:disabled + .tl-checkbox__box { background: var(--disabled-bg); }

/* ─── Checkbox row list ("N of M selected") ─── */
.tl-check-list__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); }
.tl-check-list__title { font: 400 var(--text-body-size)/var(--text-body-line) var(--font-ui); color: var(--ink-primary); }
.tl-check-list__count { font: 400 var(--text-small-size)/var(--text-small-line) var(--font-ui); color: var(--ink-muted); }
.tl-check-list {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-card);
    border-radius: var(--radius-sm);
}
.tl-check-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 56px;
    padding: 0 var(--space-4);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background-color 0.15s ease;
}
.tl-check-row:last-child { border-bottom: 0; }
.tl-check-row:hover,
.tl-check-row.is-selected,
.tl-check-row:has(input:checked) { background: var(--bg-hover); }
.tl-check-row .tl-checkbox { flex: none; margin-right: var(--space-2); }
.tl-check-row__name  { flex: 1; min-width: 0; font: 400 var(--text-body-size)/var(--text-body-line) var(--font-ui); color: var(--ink-primary); }
.tl-check-row__value { font: 500 14px/22px var(--font-data); color: var(--ink-primary); }

/* ─── Setting row (title + description + toggle) ─── */
.tl-setting { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.tl-setting__text { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.tl-setting__title { font: 400 var(--text-body-size)/var(--text-body-line) var(--font-ui); color: var(--ink-primary); }
.tl-setting__desc  { font: 400 var(--text-small-size)/var(--text-small-line) var(--font-ui); color: var(--ink-muted); }
.tl-setting-group { display: flex; flex-direction: column; gap: var(--space-4); }
.tl-setting-group--divided { padding-top: var(--space-4); border-top: 1px solid var(--border-light); gap: var(--space-5); }
.tl-setting-nested { padding-left: var(--space-4); border-left: 2px solid var(--bg-hover); display: flex; flex-direction: column; gap: var(--space-2); }

/* ═══ 6 · DERIVED — not in Figma (built from Severity Badge + Secondary Button) ═══ */

/* ─── Chip ─── */
.tl-chip-group { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.tl-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 var(--space-3);
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 999px;
    color: var(--ink-primary);
    font: 400 var(--text-small-size)/var(--text-small-line) var(--font-ui);
    white-space: nowrap;
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
button.tl-chip,
a.tl-chip { cursor: pointer; }
button.tl-chip:hover,
a.tl-chip:hover { background: var(--bg-hover); }
.tl-chip:focus-visible { outline: 2px solid var(--primary-300); outline-offset: 2px; }
.tl-chip.is-selected,
.tl-chip[aria-pressed="true"] {
    background: var(--primary-50);
    border-color: var(--primary-300);
    color: var(--primary-700);
}
.tl-chip.is-selected:hover,
.tl-chip[aria-pressed="true"]:hover { background: var(--primary-100); }
.tl-chip--sm { height: 24px; padding: 0 var(--space-2); }
.tl-chip .tl-icon { width: 12px; height: 12px; }
.tl-chip__remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-right: -4px;
    padding: 0;
    background: none;
    border: 0;
    border-radius: 50%;
    color: var(--ink-muted);
    cursor: pointer;
}
.tl-chip__remove:hover { background: rgba(var(--ink-primary-rgb), 0.08); color: var(--severity-critical); }
.tl-chip:disabled,
.tl-chip.is-disabled { background: var(--disabled-bg); color: var(--disabled-fg); cursor: not-allowed; }

/* ─── Status badge (shares shape with severity) ─── */
.tl-badge { height: 22px; padding: 0 var(--space-3); gap: 6px; }
.tl-badge--neutral { --_fg: var(--ink-muted);        --_bg: var(--disabled-bg); }
.tl-badge--brand   { --_fg: var(--primary-700);      --_bg: var(--primary-50); }
.tl-badge--success { --_fg: var(--severity-low);     --_bg: var(--severity-low-bg); }
.tl-badge--warning { --_fg: var(--severity-medium);  --_bg: var(--severity-medium-bg); }
.tl-badge--danger  { --_fg: var(--severity-critical);--_bg: var(--severity-critical-bg); }
.tl-badge--mono { font-family: var(--font-data); }

/* ─── Danger button (destructive actions) ─── */
.tl-btn--danger { --_bg: var(--severity-critical); --_fg: #ffffff; }
.tl-btn--danger:hover:not(:disabled):not(.is-disabled) {
    --_bg: color-mix(in srgb, var(--severity-critical) 86%, #000000);
}
.tl-btn--danger:disabled,
.tl-btn--danger.is-disabled { --_bg: var(--disabled-bg); }
.tl-btn--danger-ghost { --_fg: var(--severity-critical); --_bd: var(--border-light); }
.tl-btn--danger-ghost:hover:not(:disabled):not(.is-disabled) { --_bg: var(--severity-critical-bg); }

/* ═══ 7 · PAGE PATTERNS — from "Trellar — Redesign" (Dashboard Trust / Performance) ═══
   Added with the dashboard redesign. Append-only: add new sections below this one. */

.tl-page-head, .tl-view-bar, .tl-panel, .tl-rank-row, .tl-list-head, .tl-outcome,
.tl-table--panel, .tl-panel__head, .tl-panel__foot { box-sizing: border-box; }

/* ─── Page heading: title + "last updated" + refresh ─── */
.tl-page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-4);
}
.tl-page-title { margin: 0; font: 700 28px/36px var(--font-heading); color: var(--ink-primary); }
.tl-page-head__actions { display: flex; align-items: center; gap: 14px; }
.tl-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.tl-meta__label { font: 400 10px/12px var(--font-data); letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-muted); }
.tl-meta__value { font: 400 11px/14px var(--font-data); color: var(--ink-primary); }
.tl-data-context { font: 400 10px/14px var(--font-data); letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-muted); }

/* ─── View bar: view tabs on the left, shared filters on the right ─── */
.tl-view-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-4);
    min-height: 52px;
}
.tl-filters { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.tl-filters__label { font: 400 10px/12px var(--font-data); letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-muted); }

/* View tabs: icon + label, 3px underline (taller variant of .tl-tab) */
.tl-tabs--view { gap: 28px; align-self: stretch; }
.tl-tabs--view .tl-tab { height: auto; min-height: 52px; padding: 0 var(--space-1); gap: var(--space-2); font-weight: 600; }
.tl-tabs--view .tl-tab.is-active::after,
.tl-tabs--view .tl-tab[aria-selected="true"]::after { height: 3px; }
.tl-tabs--view .tl-tab.is-active,
.tl-tabs--view .tl-tab[aria-selected="true"] { color: var(--brand-primary); }
.tl-tabs--compact { gap: 20px; }
.tl-tabs--compact .tl-tab { height: 28px; padding: 0 2px; gap: 6px; font-size: var(--text-small-size); font-weight: 600; }
.tl-tabs--compact .tl-tab.is-active,
.tl-tabs--compact .tl-tab[aria-selected="true"] { color: var(--brand-primary); }
.tl-tabs--compact .tl-tab.is-active::after,
.tl-tabs--compact .tl-tab[aria-selected="true"]::after { height: 3px; }
.tl-tab .tl-icon { width: 16px; height: 16px; }

/* ─── Inline-label filter control: "Time Range  Last 7 days  v" ─── */
.tl-select--inline { display: inline-block; }
.tl-select--inline .tl-select__field {
    display: inline-flex;
    gap: var(--space-2);
    width: auto;
    min-width: 0;
    height: 36px;
    padding: 0 var(--space-3);
}
.tl-select__inline-label { font: 400 11px/16px var(--font-ui); color: var(--ink-muted); white-space: nowrap; }
.tl-select--inline .tl-select__value { font-weight: 500; font-size: var(--text-small-size); }
.tl-select--inline .tl-select__menu { min-width: 100%; width: max-content; }

/* ─── Destination link: "Decisions · scores ↗" ─── */
.tl-destination {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--ink-muted);
    font: 600 12px/16px var(--font-ui);
    text-decoration: underline;
    white-space: nowrap;
}
.tl-destination .tl-icon { width: 13px; height: 13px; }
.tl-destination:hover { color: var(--brand-primary); }
.tl-destination--sm { font-size: 11px; }

/* ─── KPI extras: dashboard size, icon slot, sub-line ─── */
.tl-kpi { position: relative; }
.tl-kpi--md .tl-kpi__value { font-size: 30px; line-height: 32px; }
.tl-kpi--md .tl-kpi__head { font-weight: 500; font-size: 13px; }
.tl-kpi__icon { position: absolute; right: var(--space-5); top: 47px; width: 28px; height: 28px; color: var(--ink-primary); opacity: 0.85; }
.tl-kpi__icon.tl-icon { stroke-width: 1.4; }
.tl-kpi__sub { font: 400 11px/16px var(--font-ui); color: var(--ink-muted); }
.tl-kpi .tl-help .tl-help__pop { z-index: 80; }

/* ─── Panel: card with headed / footed sections ─── */
.tl-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
}
.tl-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-3);
    padding: 20px var(--space-5);
}
.tl-panel__title { display: flex; align-items: center; gap: var(--space-2); margin: 0; font: 600 16px/24px var(--font-ui); color: var(--ink-primary); }
.tl-panel__sub { font: 400 10px/14px var(--font-data); letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-muted); }
.tl-panel__body { padding: 0 var(--space-5) var(--space-5); }
.tl-panel__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 14px var(--space-5);
    border-top: 1px solid var(--border-light);
    margin-top: auto;
}
.tl-panel__foot-text { font: 400 10px/14px var(--font-data); letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-muted); }

/* ─── Ranked list (rank + name + proportion bar + value + destination) ─── */
.tl-list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 32px;
    padding: 0 var(--space-5);
    font: 400 10px/14px var(--font-data);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-muted);
}
.tl-rank-row {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 53px;
    padding: 0 var(--space-5);
    border-top: 1px solid var(--border-light);
    transition: background-color 0.15s ease;
}
.tl-rank-row:hover { background: var(--bg-hover); }
.tl-rank-row__rank { flex: none; width: 20px; font: 400 11px/16px var(--font-data); color: var(--ink-muted); }
.tl-rank-row__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.tl-rank-row__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 500 12px/16px var(--font-ui); color: var(--ink-primary); }
.tl-rank-row__bar { display: block; height: 2px; max-width: 100%; border-radius: 1px; background: var(--brand-primary); transition: width 0.6s ease; }
.tl-rank-row__value { flex: none; min-width: 58px; text-align: right; font: 400 12px/18px var(--font-data); color: var(--ink-primary); }
.tl-rank-row__value--strong { font-weight: 600; font-size: 13px; }
.tl-rank-row .tl-destination { flex: none; width: 110px; font-size: 11px; justify-content: flex-start; }
.tl-rank-empty { padding: var(--space-5); text-align: center; color: var(--ink-muted); font: 400 var(--text-small-size)/var(--text-small-line) var(--font-ui); border-top: 1px solid var(--border-light); }

/* ─── Outcome legend (dot + label + mono count, destination below) ─── */
.tl-outcomes { display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; flex: 1; }
.tl-outcome {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: var(--space-1) var(--space-2);
    margin: calc(var(--space-1) * -1) calc(var(--space-2) * -1);
    border-radius: var(--radius-sm);
    transition: background-color 0.15s ease;
}
.tl-outcome:hover, .tl-outcome.is-highlighted { background: var(--bg-hover); }
.tl-outcome__row { display: flex; align-items: center; gap: 7px; }
.tl-outcome__dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--series, var(--brand-primary)); }
.tl-outcome__label { flex: 1; min-width: 0; font: 400 var(--text-small-size)/var(--text-small-line) var(--font-ui); color: var(--ink-primary); }
.tl-outcome__value { font: 600 14px/22px var(--font-data); color: var(--ink-primary); }
.tl-outcome .tl-destination { font-size: 11px; align-self: flex-start; padding-left: 15px; }

/* Ring segments reacting to hover (donut linked to a legend) */
.tl-donut__segment { transition: stroke-width 0.15s ease, stroke-dashoffset 0.6s ease, stroke-dasharray 0.6s ease; }
.tl-donut__segment.is-highlighted, .tl-donut__segment--hover:hover { stroke-width: 26; }
.tl-donut__segment--hover { cursor: pointer; pointer-events: stroke; }

/* ─── Table, panel style: heading row, totals row, selection, sorting ─── */
.tl-table--panel { table-layout: auto; }
.tl-table--panel thead th {
    height: 34px;
    background: var(--bg-page);
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
    font: 400 10px/14px var(--font-data);
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.tl-table--panel tbody td { font-size: 12px; height: 48px; }
.tl-table--panel .tl-table__num { text-align: right; font: 400 12px/18px var(--font-data); white-space: nowrap; }
.tl-table--panel thead th.tl-table__num { text-align: right; font: 400 10px/14px var(--font-data); }
.tl-table--panel .tl-table__strong { font-weight: 600; }
.tl-table--panel .tl-table__name { font-weight: 500; max-width: 0; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-table--panel tbody tr.is-selected td { background: var(--bg-hover); }
.tl-table--panel tbody tr.is-selected td:first-child { box-shadow: inset 3px 0 0 var(--brand-primary); }
.tl-table--panel tbody tr.is-clickable { cursor: pointer; }
.tl-table--panel tfoot td {
    height: 42px;
    padding: 0 var(--space-4);
    background: var(--bg-page);
    border-top: 1px solid var(--border-light);
    border-bottom: 0;
    font: 600 12px/18px var(--font-data);
    white-space: nowrap;
}
.tl-table--panel tfoot td.tl-table__num { text-align: right; }
.tl-table__affordance { display: inline-flex; align-items: center; gap: var(--space-2); font: 500 11px/16px var(--font-ui); color: var(--ink-muted); white-space: nowrap; }
.tl-table__affordance .tl-icon { width: 13px; height: 13px; }
tr.is-selected .tl-table__affordance { color: var(--brand-primary); font-weight: 600; }
.tl-table th.is-sortable { cursor: pointer; user-select: none; transition: color 0.15s ease; }
.tl-table th.is-sortable:hover { color: var(--ink-primary); }
.tl-table th.is-sortable.is-sorted { color: var(--brand-primary); }
.tl-table th.is-sortable::after { content: '\2195'; margin-left: 4px; opacity: 0; }
.tl-table th.is-sortable:hover::after { opacity: 0.5; }
.tl-table th.is-sortable.is-sorted::after { opacity: 1; }
.tl-table th.is-sortable.is-sorted[data-sort-dir="asc"]::after { content: '\2191'; }
.tl-table th.is-sortable.is-sorted[data-sort-dir="desc"]::after { content: '\2193'; }
.tl-table__scroll { max-height: 360px; overflow: auto; }

/* ─── View bar divider + right-aligned menus ─── */
.tl-view-bar { border-bottom: 1px solid var(--border-light); }
.tl-select--align-right .tl-select__menu { left: auto; right: 0; }

/* ─── Multi-select (filter dropdown with a checkbox list; behavior lives in the page JS) ─── */
.tl-multi__menu { min-width: 260px; max-height: none; padding: 0; overflow: hidden; }
.tl-multi__head { display: flex; justify-content: flex-end; padding: var(--space-1) var(--space-2); border-bottom: 1px solid var(--border-card); }
.tl-multi__list { display: flex; flex-direction: column; max-height: 280px; overflow-y: auto; padding: var(--space-1); }
.tl-multi__group { padding: var(--space-2) var(--space-2) var(--space-1); font: 400 10px/14px var(--font-data); letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-muted); }
.tl-multi__row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 34px;
    padding: 0 var(--space-2);
    border-radius: var(--radius-sm);
    font: 400 var(--text-small-size)/var(--text-small-line) var(--font-ui);
    color: var(--ink-primary);
    cursor: pointer;
}
.tl-multi__row:hover { background: var(--bg-hover); }
.tl-multi__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-multi__hint { font: 400 11px/16px var(--font-data); color: var(--ink-muted); }
.tl-multi__empty { padding: var(--space-3); text-align: center; font: 400 var(--text-small-size)/var(--text-small-line) var(--font-ui); color: var(--ink-muted); }

/* ─── Dashboard-pattern details ─── */
.tl-list-head__end { margin-right: 124px; }   /* aligns the heading with .tl-rank-row__value (destination 110 + gap 14) */
.tl-kpi--md { padding: var(--space-5); gap: var(--space-3); }
.tl-kpi--md .tl-kpi__icon { right: var(--space-5); }
.tl-legend-row { transition: background-color 0.15s ease; }
.tl-legend-row.is-highlighted { background: var(--bg-hover); }
.tl-badge--outline { --_fg: var(--ink-muted); --_bg: var(--bg-card); box-shadow: inset 0 0 0 1px var(--border-light); }
.tl-btn[hidden] { display: none; }

/* ═══ 8 · DECISIONS PATTERNS — from "Trellar — Redesign" (Decisions list / detail / records / map) ═══
   Append-only. Feed rows, breadcrumb, pagination, step cards, workspace + info panel, banners. */

.tl-breadcrumb, .tl-feed__head, .tl-feed__row, .tl-step, .tl-workspace, .tl-info-panel, .tl-banner { box-sizing: border-box; }

/* ─── Breadcrumb: "Decisions / Network / All Records" ─── */
.tl-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font: 400 13px/18px var(--font-ui);
    color: var(--ink-muted);
}
.tl-breadcrumb a { color: inherit; text-decoration: none; transition: color 0.15s ease; }
.tl-breadcrumb a:hover { color: var(--brand-primary); text-decoration: underline; }
.tl-breadcrumb__sep { color: var(--ink-muted); }
.tl-breadcrumb [aria-current="page"] { color: var(--ink-primary); }

/* ─── Context bar: totals on the left, data context on the right ─── */
.tl-context-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-4);
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-light);
}
.tl-context-bar__totals { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-5); }
.tl-context-bar__strong { font: 400 var(--text-body-size)/var(--text-body-line) var(--font-ui); color: var(--ink-primary); }
.tl-context-bar__muted { font: 400 var(--text-small-size)/var(--text-small-line) var(--font-ui); color: var(--ink-muted); }

/* ─── Hint line: "Select a network to open ... ↗" ─── */
.tl-hint { display: flex; align-items: center; gap: var(--space-2); font: 400 var(--text-small-size)/var(--text-small-line) var(--font-ui); color: var(--ink-muted); }
.tl-hint .tl-icon { width: 13px; height: 13px; }

/* ─── Feed: heading row + clickable rows, columns from --cols ───
   <div class="tl-feed" style="--cols: minmax(0,1fr) 140px 16px">
     <div class="tl-feed__head"><span>…</span></div>
     <div class="tl-feed__item [is-open]"><a|div class="tl-feed__row">…</a><div class="tl-feed__detail">…</div></div> */
.tl-feed { display: flex; flex-direction: column; min-width: 0; }
.tl-feed__head,
.tl-feed__row {
    display: grid;
    grid-template-columns: var(--cols, minmax(0, 1fr) auto);
    align-items: center;
    column-gap: var(--space-5);
    padding: 0 var(--space-5);
}
.tl-feed__head {
    height: 32px;
    font: 400 10px/14px var(--font-data);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-muted);
}
.tl-feed__item { border-bottom: 1px solid var(--border-card); }
.tl-feed__row {
    min-height: 64px;
    color: var(--ink-primary);
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease;
}
.tl-feed__row:hover,
.tl-feed__item.is-open > .tl-feed__row { background: var(--bg-hover); }
.tl-feed__row:focus-visible { outline: 2px solid var(--primary-300); outline-offset: -2px; }
.tl-feed__title { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 500 20px/28px var(--font-heading); color: var(--ink-primary); }
.tl-feed__trace { font: 500 14px/28px var(--font-heading); color: var(--ink-primary); white-space: nowrap; }
.tl-feed__data { font: 400 14px/22px var(--font-ui); color: var(--ink-primary); }
.tl-feed__muted { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 400 13px/18px var(--font-ui); color: var(--ink-muted); }
.tl-feed__go { width: 16px; height: 16px; color: var(--ink-primary); justify-self: end; transition: transform 0.15s ease; }
.tl-feed__item.is-open .tl-feed__go { transform: rotate(180deg); }
.tl-feed__detail {
    display: none;
    padding: var(--space-5);
    background: color-mix(in srgb, var(--bg-hover) 40%, var(--bg-card));
    border-top: 1px solid var(--border-card);
}
.tl-feed__item.is-open > .tl-feed__detail { display: block; }
.tl-feed__empty { padding: var(--space-6) var(--space-5); text-align: center; color: var(--ink-muted); font: 400 var(--text-body-size)/var(--text-body-line) var(--font-ui); border-bottom: 1px solid var(--border-card); }
.tl-feed__empty strong { display: block; margin-bottom: var(--space-1); color: var(--ink-primary); font-weight: 500; }
.tl-feed__foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-3); font: 400 var(--text-small-size)/var(--text-small-line) var(--font-ui); color: var(--ink-muted); }

/* Skeleton rows while a feed loads */
.tl-feed__skeleton { height: 64px; border-bottom: 1px solid var(--border-card); background: linear-gradient(90deg, var(--bg-card) 0%, var(--bg-hover) 50%, var(--bg-card) 100%); background-size: 200% 100%; animation: tl-shimmer 1.2s linear infinite; opacity: 0.6; }
@keyframes tl-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ─── Record detail blocks (inside .tl-feed__detail or a panel) ─── */
.tl-detail { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: var(--space-5) var(--space-6); }
.tl-detail__main { display: flex; flex-direction: column; gap: var(--space-5); min-width: 0; }
.tl-detail__side { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3); }
.tl-detail__label { font: 600 12px/18px var(--font-ui); color: var(--ink-muted); margin: 0 0 var(--space-2); }
.tl-detail__text { margin: 0; font: 400 13px/20px var(--font-ui); color: var(--ink-primary); overflow-wrap: anywhere; }
.tl-detail__rows { display: flex; flex-direction: column; gap: var(--space-2); }
.tl-detail__row { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); font: 400 13px/20px var(--font-ui); color: var(--ink-primary); }
.tl-detail__context { margin: var(--space-2) 0 0; padding: var(--space-3); max-height: 260px; overflow: auto; background: var(--bg-card); border: 1px solid var(--border-card); border-radius: var(--radius-sm); font: 400 11px/16px var(--font-data); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink-primary); }
@media (max-width: 900px) { .tl-detail { grid-template-columns: 1fr; } }

/* ─── Execution step card ─── */
.tl-steps { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.tl-step {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 220px;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-sm);
}
.tl-step__name { font: 600 12px/18px var(--font-ui); color: var(--ink-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-step__meta { font: 400 11px/16px var(--font-ui); color: var(--ink-muted); }
.tl-step--root { border-color: var(--severity-critical); box-shadow: inset 3px 0 0 var(--severity-critical); }
.tl-steps__summary { font: 400 12px/18px var(--font-ui); color: var(--ink-muted); }

/* ─── Pagination ─── */
.tl-pagination { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-3); }
.tl-pagination__info { font: 400 var(--text-small-size)/var(--text-small-line) var(--font-ui); color: var(--ink-muted); }
.tl-pagination__controls { display: flex; align-items: center; gap: var(--space-1); }
.tl-pagination__page { min-width: 84px; text-align: center; font: 400 12px/18px var(--font-data); color: var(--ink-primary); }

/* ─── Toggle with a caption above it (header controls) ─── */
.tl-toggle-field { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.tl-toggle-field__label { font: 400 12px/18px var(--font-ui); color: var(--ink-muted); }

/* The `hidden` attribute must win over any component `display` (feed rows, banners, panels...). */
[class*="tl-"][hidden] { display: none !important; }

/* ─── Banner (derived): inline notice with an action ─── */
.tl-banner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-sm);
    background: var(--severity-medium-bg);
    color: var(--severity-medium);
    font: 400 var(--text-body-size)/var(--text-body-line) var(--font-ui);
}
.tl-banner strong { font-weight: 600; }
.tl-banner__body { flex: 1; min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); }
.tl-banner--info { background: var(--primary-50); color: var(--primary-700); }
.tl-banner--critical { background: var(--severity-critical-bg); color: var(--severity-critical); }

/* ─── Status key: label + dots (map legend) ─── */
.tl-key { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-5); }
.tl-key__label { font: 400 10px/14px var(--font-data); letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-muted); }
.tl-key__item { display: inline-flex; align-items: center; gap: 7px; font: 400 12px/18px var(--font-ui); color: var(--ink-primary); }
.tl-key__dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--_dot, var(--ink-primary)); }
.tl-key__dot--ran { --_dot: var(--ink-primary); }
.tl-key__dot--root { --_dot: var(--severity-critical); }
.tl-key__dot--idle { --_dot: var(--ink-primary); opacity: 0.35; }
.tl-key__dot--pending { width: 9px; height: 9px; background: transparent; border: 1.5px dashed var(--brand-primary); }
.tl-key__dot--inferred { --_dot: var(--brand-primary); }

/* ─── Workspace: canvas on the left, info panel docked on the right ─── */
.tl-workspace { display: flex; align-items: stretch; min-width: 0; background: var(--bg-card); border: 1px solid var(--border-card); border-radius: var(--radius-md); overflow: hidden; }
.tl-workspace__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tl-workspace__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: 56px; padding: 0 var(--space-5); border-bottom: 1px solid var(--border-light); }
.tl-workspace__title { margin: 0; font: 600 14px/22px var(--font-ui); color: var(--ink-primary); }
.tl-workspace__canvas { position: relative; flex: 1; min-height: 560px; background: var(--bg-card); }
.tl-workspace__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: 36px; padding: 0 var(--space-5); border-top: 1px solid var(--border-light); font: 400 11px/16px var(--font-ui); color: var(--ink-muted); }

/* ─── Info panel (Node Info) ─── */
.tl-info-panel { flex: none; width: 360px; display: flex; flex-direction: column; border-left: 1px solid var(--border-light); background: var(--bg-card); overflow-y: auto; }
.tl-info-panel[hidden] { display: none; }
.tl-info-panel__head { display: flex; align-items: center; justify-content: space-between; min-height: 56px; padding: 0 var(--space-5); border-bottom: 1px solid var(--border-light); font: 600 16px/24px var(--font-ui); color: var(--ink-primary); }
.tl-info-panel__body { display: flex; flex-direction: column; gap: var(--space-5); padding: var(--space-5); }
.tl-info-panel__identity { display: flex; align-items: center; gap: var(--space-3); }
.tl-info-panel__symbol { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 40px; height: 40px; border-radius: var(--radius-sm); background: var(--brand-primary); color: #ffffff; }
.tl-info-panel__symbol .tl-icon { width: 22px; height: 22px; }
.tl-info-panel__name { margin: 0; font: 600 16px/22px var(--font-ui); color: var(--ink-primary); overflow-wrap: anywhere; }
.tl-info-panel__field { display: flex; flex-direction: column; gap: var(--space-2); }
.tl-info-panel__label { font: 400 11px/16px var(--font-ui); color: var(--ink-muted); }
.tl-info-panel__value { font: 400 13px/20px var(--font-ui); color: var(--ink-primary); overflow-wrap: anywhere; }
.tl-info-panel__value--brand { color: var(--brand-primary); font-weight: 600; }
.tl-info-panel__value--critical { color: var(--severity-critical); font-weight: 600; }
.tl-info-panel__section { display: flex; flex-direction: column; gap: var(--space-4); padding: var(--space-5); border-top: 1px solid var(--border-light); }
.tl-info-panel__section-title { margin: 0; font: 600 14px/22px var(--font-ui); color: var(--ink-primary); }
.tl-info-panel__link { display: flex; align-items: center; gap: var(--space-2); padding: 0; background: none; border: 0; color: var(--brand-primary); font: 600 12px/18px var(--font-ui); text-decoration: underline; text-align: left; cursor: pointer; }
.tl-info-panel__link .tl-icon { width: 13px; height: 13px; flex: none; }
.tl-info-panel__direction { font: 400 9px/14px var(--font-data); letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-muted); }
.tl-connection { display: flex; flex-direction: column; gap: 6px; padding-bottom: var(--space-3); border-bottom: 1px solid var(--border-light); }
.tl-connection:last-child { border-bottom: 0; padding-bottom: 0; }
@media (max-width: 1100px) { .tl-workspace { flex-direction: column; } .tl-info-panel { width: auto; border-left: 0; border-top: 1px solid var(--border-light); } }

/* ─── Page shell + intro (Figma "Page introduction": H1 + muted body line) ─── */
.tl-page { display: flex; flex-direction: column; gap: 24px; min-width: 0; padding: 30px 36px 36px; box-sizing: border-box; }
.tl-page-intro { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.tl-page-intro .tl-page-title { font-size: 32px; line-height: 40px; font-weight: 500; }
.tl-page-sub { margin: 0; font: 400 var(--text-body-size)/var(--text-body-line) var(--font-ui); color: var(--ink-muted); }
@media (max-width: 768px) { .tl-page { padding: 16px; } }

/* ═══ 9 · ALERTS PATTERNS — from "Trellar — Redesign" (Alerts · List view) ═══
   Append-only. Sortable feed headings, status text, non-interactive feed rows. */

/* ─── Sortable feed heading: <button class="tl-feed__sort [is-sorted]" data-sort-dir="asc|desc"> ─── */
.tl-feed__sort {
    justify-self: start;
    padding: 0;
    background: none;
    border: 0;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    color: inherit;
    cursor: pointer;
    user-select: none;
    transition: color 0.15s ease;
}
.tl-feed__sort:hover { color: var(--ink-primary); }
.tl-feed__sort:focus-visible { outline: 2px solid var(--primary-300); outline-offset: 2px; }
.tl-feed__sort::after { content: '\2195'; margin-left: 4px; opacity: 0; }
.tl-feed__sort:hover::after { opacity: 0.5; }
.tl-feed__sort.is-sorted { color: var(--brand-primary); }
.tl-feed__sort.is-sorted::after { opacity: 1; }
.tl-feed__sort.is-sorted[data-sort-dir="asc"]::after { content: '\2191'; }
.tl-feed__sort.is-sorted[data-sort-dir="desc"]::after { content: '\2193'; }

/* ─── Status as colored text (alerts: Open / Acknowledged / Closed) ─── */
.tl-feed__status { font: 500 13px/18px var(--font-ui); color: var(--_status, var(--ink-primary)); white-space: nowrap; }
.tl-feed__status--open { --_status: var(--severity-critical); }
.tl-feed__status--acknowledged { --_status: var(--severity-medium); }
.tl-feed__status--closed { --_status: var(--severity-low); }

/* A feed row that goes nowhere (no link target) */
.tl-feed__row--static { cursor: default; }
.tl-feed__row--static:hover { background: transparent; }
