/* Routing and Channels are one design: a rail on the left that lists what you
   can open (routes / channels), one detail card on the right, the same header
   (title · state · actions), the same freshness note, the same "needs
   attention" chip and the same loading behaviour. Page files (pages.css for
   Routing, models.css for Channels) only add what is specific to the page. */

/* ---- page header extras ------------------------------------------------ */
.cfg-help { display: inline-grid; place-items: center; flex: none; width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--border); font-size: 10px; line-height: 1; color: var(--text-tertiary); cursor: help; user-select: none; }
.cfg-help:hover, .cfg-help:focus-visible { color: var(--ink); border-color: var(--text-tertiary); outline: none; }
.cfg-updated { font-size: 11px; color: var(--text-tertiary); white-space: nowrap; font-variant-numeric: tabular-nums; align-self: center; }
.cfg-updated:empty { display: none; }
.el-popper.cfg-help-tip { max-width: 340px; font-size: 11.5px; line-height: 1.5; }

/* ---- picker over detail --------------------------------------------------
   A slim bar (title · counts · attention chip · tools) and, under it, one wrapping
   line of chips: the routes / channels you can open. The chosen one owns the
   full-width card below. */
.routing-workspace, .models-workspace { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.cfg-picker { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.cfg-picker-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; min-width: 0; font-size: 12px; color: var(--text-tertiary); }
.cfg-picker-title { font-size: 13px; font-weight: 600; color: var(--ink); }
.cfg-picker-count { font-size: 11px; font-variant-numeric: tabular-nums; }
.cfg-picker-stat strong { color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }
.cfg-picker-tools { margin-left: auto; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.cfg-picker-filter { width: 200px; }
.routing-summary-pending { font-style: italic; }
.cfg-chips { display: flex; flex-wrap: wrap; align-items: stretch; gap: 6px; margin: 0; padding: 0; border: 0; background: transparent; list-style: none; min-width: 0; }
.cfg-chip-item {
    display: inline-flex; align-items: center; gap: 7px; min-width: 0; max-width: 100%;
    width: auto; min-height: 0; margin: 0; padding: 5px 10px;
    border: 1px solid var(--border); border-radius: 8px; background: var(--card); box-shadow: none;
    color: var(--text-secondary); font: inherit; font-size: 12px; text-align: left; white-space: nowrap; cursor: pointer;
}
.cfg-chip-item:hover { border-color: var(--text-tertiary); color: var(--text-primary); background: var(--card); box-shadow: none; }
.cfg-chip-item:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.cfg-chip-item.active { border-color: var(--ink); background: var(--card); box-shadow: 0 0 0 1px var(--ink); color: var(--ink); }
.cfg-chip-item.is-quiet { background: transparent; border-style: dashed; color: var(--text-tertiary); }
.cfg-chip-item.is-quiet.active { border-style: solid; color: var(--ink); }
.cfg-chip-item.is-disabled { opacity: .6; }
.cfg-chip-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.cfg-chip-meta { font-size: 11px; font-variant-numeric: tabular-nums; color: var(--text-tertiary); }
.cfg-chip-meta small { font-size: 10px; color: var(--text-muted); }
.cfg-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--border); }
.cfg-dot.tone-normal, .cfg-dot.tone-ok { background: var(--green); }
.cfg-dot.tone-warning { background: var(--amber); }
.cfg-dot.tone-danger { background: var(--red); }
.cfg-chip-meter { flex: none; width: 34px; height: 4px; border-radius: 2px; background: var(--secondary); overflow: hidden; }
.cfg-chip-meter > span { display: block; height: 100%; border-radius: inherit; background: var(--accent-blue); }
.cfg-chip-meter.tone-muted, .cfg-chip-meter.tone-none { background: transparent; box-shadow: inset 0 0 0 1px var(--border); }
.cfg-chip-meter.tone-warning > span { background: var(--amber); }
.cfg-chip-meter.tone-danger > span { background: var(--red); }
.cfg-chip-pct { font-size: 11px; font-variant-numeric: tabular-nums; color: var(--text-secondary); min-width: 3ch; text-align: right; }
.cfg-chip-pct.tone-warning { color: var(--amber); }
.cfg-chip-pct.tone-danger { color: var(--red); }
.cfg-chip-live { display: inline-flex; align-items: baseline; gap: 4px; font-size: 11px; color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
.cfg-chip-live strong { font-weight: 500; color: var(--text-primary); }
.cfg-chip-live small { font-size: 10px; margin-left: -3px; color: var(--text-muted); }
.cfg-chip-err { color: var(--red); }
/* Channel cards size to the visible count, not the total (folded groups do
   not take space). Flex basis wraps naturally without viewport measurements. */
.models-channel-nav .settings-service-tabs {
    --channel-card-basis: 260px;
    --channel-card-max: 380px;
    --channel-card-padding: 8px 12px;
    --channel-card-height: 40px;
    --channel-card-font: 12px;
}
.models-channel-nav .settings-service-tabs[data-density="comfortable"] {
    --channel-card-basis: 300px;
    --channel-card-max: 480px;
    --channel-card-padding: 12px 16px;
    --channel-card-height: 48px;
    --channel-card-font: 13px;
}
.models-channel-nav .settings-service-tabs[data-density="compact"] {
    --channel-card-basis: 230px;
    --channel-card-max: 320px;
    --channel-card-padding: 6px 10px;
    --channel-card-height: 34px;
}
.models-channel-nav .settings-service-tabs > .cfg-chip-item {
    box-sizing: border-box;
    flex: 1 1 var(--channel-card-basis);
    max-width: min(100%, var(--channel-card-max));
    min-height: var(--channel-card-height);
    padding: var(--channel-card-padding);
    font-size: var(--channel-card-font);
    flex-wrap: wrap;
    gap: 5px 7px;
}
.models-channel-nav .cfg-chip-name { margin-right: auto; }
.models-channel-nav .cfg-chip-meta,
.models-channel-nav .cfg-chip-pct,
.models-channel-nav .cfg-chip-live { flex-shrink: 0; }
.channel-rail-break { flex-basis: 100%; height: 0; }
@media (max-width: 600px) {
    .models-channel-nav .settings-service-tabs > .cfg-chip-item {
        flex-basis: 100%;
        max-width: 100%;
        min-height: 40px;
        padding: 8px 10px;
        font-size: 12px;
    }
}

/* Sort: quiet segmented control. */
.channel-rail-sort { display: inline-flex; align-items: center; gap: 2px; font-size: 11px; color: var(--text-tertiary); }
.channel-rail-sort > span { margin-right: 6px; }
.channel-rail-sort-option { padding: 2px 8px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--text-secondary); font: inherit; font-size: 11px; cursor: pointer; }
.channel-rail-sort-option:hover { background: var(--fill); color: var(--text-primary); }
.channel-rail-sort-option.active { background: var(--card); border-color: var(--border); color: var(--ink); }
.cfg-chip-fold { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border: 0; border-radius: 8px; background: transparent; color: var(--text-tertiary); font: inherit; font-size: 11.5px; cursor: pointer; }
.cfg-chip-fold:hover { color: var(--text-primary); background: var(--fill); }
.cfg-chip-fold > span:first-child { display: inline-block; transition: transform .15s; }
.cfg-chip-fold.is-open > span:first-child { transform: rotate(90deg); }
.cfg-chip-fold-count { font-variant-numeric: tabular-nums; }
.models-channel-empty, .routing-list-empty { margin: 4px 2px; font-size: 11px; color: var(--text-tertiary); }
/* "N need attention" / "N without headroom": a count that is also the filter. */
.cfg-chip { display: inline-flex; align-items: baseline; gap: 4px; padding: 0 6px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--text-secondary); font: inherit; font-size: 11.5px; cursor: pointer; }
.cfg-chip:hover { background: var(--fill); }
.cfg-chip.tone-warning, .cfg-chip.tone-warning strong { color: var(--amber); }
.cfg-chip.active { background: var(--amber-fill); border-color: var(--amber); }
.cfg-chip:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }

/* ---- detail card ------------------------------------------------------- */
.routing-card, .models-channel-content {
    min-width: 0;
    border: 1px solid var(--border); border-radius: 10px; background: var(--card);
    box-shadow: none; overflow: hidden;
}
.cfg-detail-head { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 14px 16px 8px; }
.cfg-detail-title { margin: 0; min-width: 0; font-size: 16px; font-weight: 600; line-height: 1.25; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cfg-detail-tools { flex: none; margin-left: auto; display: flex; align-items: center; gap: 8px; }
.cfg-detail-badge { flex: none; width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; font-size: 12px; font-weight: 600; background: var(--fill); color: var(--text-secondary); }
.cfg-conn { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--border); }
.cfg-conn.is-on { background: var(--green); }
.cfg-menu-hint { margin-left: 8px; color: var(--text-tertiary); font-size: 10.5px; }
.el-dropdown-menu__item.is-danger { color: var(--red); }

/* Quiet inline meter with its number; the fill takes the tone. */
.cfg-meter { display: block; flex: 1 1 auto; min-width: 24px; height: 4px; border-radius: 2px; background: var(--secondary); overflow: hidden; }
.cfg-meter > span { display: block; height: 100%; border-radius: inherit; background: var(--accent-blue); transition: width .3s; }
.cfg-meter.tone-warning > span { background: var(--amber); }
.cfg-meter.tone-danger > span { background: var(--red); }
.cfg-pct { flex: none; min-width: 3.5ch; font-size: 11px; font-variant-numeric: tabular-nums; text-align: right; color: var(--text-secondary); }
.cfg-pct.tone-warning { color: var(--amber); }
.cfg-pct.tone-danger { color: var(--red); }
.cfg-pct.tone-muted { color: var(--text-muted); }

/* ---- the shared body of a detail card ----------------------------------
   title row → one stats line → one guidance strip → a list section (title,
   count, Expand all) → rows that are one line and open on demand. */
.models-summary { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 20px; padding: 0 16px 12px; border: 0; border-bottom: 1px solid var(--border); color: var(--text-tertiary); font-size: 11px; }
.models-summary strong { color: var(--ink); font-size: 13px; font-weight: 500; margin-right: 4px; font-variant-numeric: tabular-nums; }
.models-summary small { font-size: 10px; }
.models-summary .live-latency { font-size: 13px; }
.models-error, .models-error strong { color: var(--red); }
.cfg-strip { display: flex; align-items: center; flex-wrap: nowrap; gap: 8px; min-width: 0; padding: 8px 16px; border-bottom: 1px solid var(--border); font-size: 11px; color: var(--text-tertiary); overflow: hidden; white-space: nowrap; }
.cfg-strip code { padding: 1px 6px; border-radius: 4px; background: var(--fill); color: var(--ink); font-size: 11px; }
.cfg-strip .routing-protocol-name { color: var(--text-secondary); }
.cfg-strip.is-bridged .routing-protocol-note { color: var(--amber); }
.cfg-section-head, .models-ledger-page .models-ledger > .ui-surface-card-header {
    display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; min-height: 0;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.cfg-section-head h3, .models-ledger-page .models-ledger .ui-surface-card-heading h3 { margin: 0; font-size: 13px; font-weight: 600; color: var(--ink); }
.cfg-section-note { font-size: 11px; color: var(--text-tertiary); }
.cfg-section-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.models-result-count { font-size: 11px; color: var(--text-tertiary); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---- narrow screens: the picker's tools drop under the title ---- */
@media (max-width: 720px) {
    .cfg-picker-tools { margin-left: 0; width: 100%; }
    .cfg-picker-filter { flex: 1 1 140px; width: auto; }
    .cfg-updated { display: none; }
    .cfg-detail-head { flex-wrap: wrap; }
}
