/* Governance Live (team only). Uses the dashboard's tokens from styles.css.
   Structure lines use --gl-line (3.5:1 on the card, WCAG 1.4.11); text stays in text tokens. */
:root {
    --gl-line: var(--edge-strong);
    --gl-border: var(--edge);
    --gl-surface: var(--screen);
    --gl-raised: var(--bezel-high);
    --gl-ok: var(--ok);
    --gl-info: var(--info);
    --gl-warn: var(--warn);
    --gl-bad: var(--fail);
    --gl-ease-out: var(--ease-out);
    --gl-ease-in: cubic-bezier(0.7, 0, 0.84, 0);
}

/* Sidebar: the Team group sits apart from the public pages */
.nav-group { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border-light); }
.nav-group-label { display: block; padding: 4px 24px 6px; font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); }

/* The dashboard's energy filters do nothing here */
body.gl-no-filters .top-bar { display: none; }

/* styles.css has no [hidden] rule, so any element here with a display value would ignore `hidden` */
.gl-page [hidden] { display: none !important; }
.gl-page .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.gl-page .mono { font-family: var(--font-data); font-size: 0.86em; }
.gl-page :focus-visible { outline: 2px solid var(--gl-info); outline-offset: 2px; }

.gl-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.gl-header h1 { font-size: 2rem; font-weight: 700; margin: 0 0 6px; letter-spacing: -0.01em; }
.gl-header .subtitle { color: var(--text-secondary); font-size: 1rem; margin: 0; max-width: 70ch; }
.gl-lock-btn { background: var(--gl-surface); border: 1px solid var(--gl-border); color: var(--text-primary); gap: 8px; min-height: 36px; }
.gl-lock-btn:hover { border-color: var(--gl-line); }

/* ---------------------------------------------------------------- gate */
.gl-gate { display: flex; justify-content: center; padding: 48px 0; }
.gl-gate-card { width: 100%; max-width: 440px; background: var(--bg-card); border: 1px solid var(--gl-border); border-radius: 12px; padding: 28px; }
.gl-gate-card h2 { font-size: 1.25rem; margin: 0 0 8px; }
.gl-gate-card > p { color: var(--text-secondary); margin: 0 0 20px; line-height: 1.5; }
.gl-login { display: grid; gap: 8px; }
.gl-login label { font-weight: 600; font-size: 0.875rem; }
.gl-login input { width: 100%; min-height: 40px; box-sizing: border-box; }
.gl-login .btn-primary { justify-content: center; min-height: 40px; margin-top: 8px; }
.gl-login .btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.gl-error { color: var(--gl-bad); font-size: 0.875rem; margin: 0; }
.gl-meta { color: var(--text-secondary); font-size: 0.8125rem; margin: 0; }

/* ---------------------------------------------------------------- split pane */
/* 264 + 16 gap leaves the detail pane exactly the graph's 804 px plus padding inside a 1440 px window */
.gl-app { display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: 16px; align-items: start; }
.gl-list-pane, .gl-detail { background: var(--bg-card); border: 1px solid var(--gl-border); border-radius: 12px; min-width: 0; }
.gl-list-pane { padding: 12px; display: grid; gap: 8px; position: sticky; top: 16px; max-height: calc(100vh - 32px); grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto; }
.gl-detail { padding: 16px; display: grid; gap: 12px; }
.gl-back { display: none; }

.gl-search-label { font-size: 0.8125rem; font-weight: 600; color: var(--text-secondary); }
.gl-search-row { display: flex; gap: 8px; position: relative; }
.gl-search-row > .gl-icon-btn { flex: none; }
.gl-search-field { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; background: var(--gl-surface); border: 1px solid var(--gl-border); border-radius: 8px; padding: 0 10px; min-height: 36px; color: var(--text-secondary); }
.gl-search-field:focus-within { border-color: var(--gl-info); }
.gl-search-field input { flex: 1; min-width: 0; background: none; border: 0; color: var(--text-primary); font: inherit; font-size: 0.875rem; padding: 8px 0; }
.gl-search-field input:focus { outline: none; }
.gl-search-field input::placeholder { color: var(--text-secondary); }

.gl-icon-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; min-width: 36px; height: 36px; padding: 0 10px; border-radius: 8px; background: var(--gl-surface); border: 1px solid var(--gl-border); color: var(--text-secondary); cursor: pointer; font: inherit; }
.gl-icon-btn:hover:not(:disabled) { color: var(--text-primary); border-color: var(--gl-line); }
.gl-icon-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.gl-icon-btn[aria-expanded="true"] { color: var(--text-primary); border-color: var(--gl-info); }
.gl-count { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--gl-info); color: var(--screen); font-size: 0.7rem; font-weight: 700; line-height: 18px; text-align: center; }

.gl-popover { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; width: 100%; box-sizing: border-box; background: var(--gl-surface); border: 1px solid var(--gl-line); border-radius: 10px; padding: 12px; display: grid; gap: 6px; }
.gl-popover[hidden] { display: none; }
.gl-popover label { font-size: 0.8125rem; font-weight: 600; color: var(--text-secondary); margin-top: 4px; }
.gl-popover select { background: var(--bg-card); border: 1px solid var(--gl-border); color: var(--text-primary); border-radius: 6px; padding: 6px 8px; font: inherit; font-size: 0.875rem; color-scheme: dark; }
.gl-pop-right { left: auto; right: 0; width: 320px; max-width: calc(100vw - 48px); }
.gl-help h3 { margin: 0 0 4px; font-size: 0.95rem; }
.gl-help p { margin: 0 0 6px; font-size: 0.8125rem; line-height: 1.5; color: var(--text-primary); }
.gl-link { background: none; border: 0; padding: 4px 0; color: var(--gl-info); font: inherit; font-size: 0.875rem; cursor: pointer; text-align: left; text-decoration: underline; text-underline-offset: 3px; }

.gl-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; min-height: 0; }
.gl-item { display: grid; gap: 6px; padding: 10px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; }
.gl-item + .gl-item { margin-top: 2px; }
.gl-item:hover { background: rgba(255, 255, 255, 0.03); }
.gl-item[aria-selected="true"] { background: var(--gl-raised); border-color: var(--gl-info); }
.gl-item-title { font-weight: 600; font-size: 0.875rem; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gl-item-meta { display: flex; align-items: center; gap: 8px; font-size: 0.75rem; color: var(--text-secondary); min-width: 0; }
.gl-item-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.gl-item-time { margin-left: auto; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.gl-list-empty { padding: 16px 10px; color: var(--text-secondary); font-size: 0.875rem; line-height: 1.5; }
.gl-more { background: var(--gl-surface); border: 1px solid var(--gl-border); color: var(--text-primary); justify-content: center; min-height: 36px; }

.gl-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.gl-dot-ok { background: var(--gl-ok); }

.gl-badge { display: inline-flex; align-items: center; gap: 6px; padding: 1px 8px; border-radius: 10px; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; border: 1px solid; flex-shrink: 0; color: var(--text-primary); }
.gl-tone-ok { border-color: var(--gl-ok); background: rgba(63, 185, 80, 0.12); }
.gl-tone-info { border-color: var(--gl-info); background: rgba(88, 166, 255, 0.12); }
.gl-tone-warn { border-color: var(--gl-warn); background: rgba(210, 153, 34, 0.12); }
.gl-tone-bad { border-color: var(--gl-bad); background: rgba(248, 81, 73, 0.12); }
.gl-tone-muted { border-color: var(--text-secondary); background: rgba(139, 148, 158, 0.12); }
.gl-mode { font-size: 0.8125rem; padding: 4px 12px; border-radius: 14px; letter-spacing: 0; text-transform: none; }

/* ---------------------------------------------------------------- detail */
.gl-detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; padding-bottom: 12px; border-bottom: 1px solid var(--gl-border); }
.gl-detail-id { min-width: 0; }
.gl-detail-id h2 { font-size: 1.125rem; margin: 0 0 4px; overflow-wrap: anywhere; }
.gl-detail-id h2:focus { outline: none; }
.gl-detail-id h2:focus-visible { outline: 2px solid var(--gl-info); outline-offset: 2px; }
.gl-mode-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.gl-playback { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.gl-playback input[type="range"] { width: 140px; accent-color: var(--gl-info); }
.gl-step { color: var(--text-secondary); min-width: 4.5em; text-align: right; font-variant-numeric: tabular-nums; }
.gl-speed { background: var(--gl-surface); border: 1px solid var(--gl-border); color: var(--text-primary); border-radius: 8px; height: 36px; padding: 0 6px; font: inherit; font-size: 0.8125rem; color-scheme: dark; }

.gl-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.gl-view button:disabled { opacity: 0.45; cursor: not-allowed; }
.gl-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.gl-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--gl-border); background: transparent; color: var(--text-secondary); font: inherit; font-size: 0.8125rem; cursor: pointer; }
.gl-chip.on { background: var(--gl-raised); border-color: var(--gl-line); color: var(--text-primary); }
.gl-chip:not(.on) .gl-swatch { opacity: 0.35; }
.gl-chip:not(.on) { text-decoration: line-through; }
.gl-chip-count { color: var(--text-secondary); }
.gl-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; vertical-align: -1px; margin-right: 6px; }
.gl-chip .gl-swatch { margin-right: 0; }
.gl-tool-icons { margin-left: auto; display: flex; gap: 8px; position: relative; }

.gl-note { margin: 0; padding: 10px 12px; border-radius: 8px; background: rgba(88, 166, 255, 0.08); border: 1px solid rgba(88, 166, 255, 0.35); color: var(--text-primary); font-size: 0.875rem; line-height: 1.5; }
.gl-note-inline { margin: 0 0 8px; color: var(--text-secondary); font-size: 0.8125rem; }

/* ---------------------------------------------------------------- graph (1:1, scrolls instead of shrinking) */
.gl-graph-wrap { overflow-x: auto; }
/* 1:1 when there is room; shrinks to 90% at most (text stays >= 10.8px), then the pane scrolls */
.gl-graph { display: block; width: 100%; max-width: 804px; min-width: 724px; height: auto; }
.gl-graph text { font-family: var(--font-ui); font-size: 12px; fill: var(--text-secondary); }
.gl-graph .glg-title { fill: var(--text-primary); font-size: 13px; font-weight: 600; }
.gl-graph .glg-label { fill: var(--text-primary); }
.gl-graph .glg-muted { fill: var(--text-secondary); }
.glg-host { fill: var(--gl-surface); stroke: var(--gl-line); }
.glg-broker { fill: none; stroke: var(--gl-line); }
.glg-broker.faint { stroke-dasharray: 4 4; }
.glg-bus { fill: var(--gl-border); stroke: var(--gl-line); }
.glg-queue { fill: var(--bg-card); stroke: var(--gl-line); }
.glg-queue.temp { stroke-dasharray: 4 3; }
.glg-wire { stroke: var(--gl-line); stroke-width: 1.5; fill: none; }
.glg-ext { fill: var(--screen); }
.glg-net { stroke: var(--gl-line); stroke-dasharray: 4 4; }
.glg-pill { fill: var(--bg-card); stroke: var(--gl-border); }
.glg-node { cursor: pointer; }
.glg-node rect { fill: var(--gl-raised); stroke: var(--gl-line); transition: stroke 150ms ease; }
.glg-node.temp rect { stroke-dasharray: 4 3; fill: var(--bg-card); }
.glg-node.dim { opacity: 0.45; }
.glg-node:hover rect, .glg-node.focus rect { stroke: var(--gl-info); }
.glg-node:focus { outline: none; }
.glg-node:focus-visible rect { stroke: var(--gl-info); stroke-width: 2; }
.gl-graph .glg-name { fill: var(--text-primary); font-family: var(--font-data); font-size: 13px; font-weight: 600; }
.gl-graph .glg-note { paint-order: stroke; stroke: var(--gl-surface); stroke-width: 6px; stroke-linejoin: round; }
.glg-status circle { fill: var(--gl-ok); }
.glg-status.s-ending circle { fill: var(--gl-warn); }
.glg-status.s-absent circle, .glg-status.s-unknown circle { fill: none; stroke: var(--text-secondary); stroke-width: 1.5; }
.glg-route { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.glg-token rect { stroke-width: 1.5; }
.glg-token.negative rect { fill: var(--bg-card); stroke-dasharray: 4 3; }
.gl-graph .glg-token text { fill: var(--screen); font-weight: 600; }
.gl-graph .glg-token.negative text { fill: var(--text-primary); }

/* ---------------------------------------------------------------- tabs */
.gl-tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--gl-border); }
.gl-tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 2px; margin-bottom: -1px; color: var(--text-secondary); font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer; }
.gl-tab[aria-selected="true"] { color: var(--text-primary); border-bottom-color: var(--gl-info); }
.gl-panel { min-width: 0; }
.gl-summary { margin: 0 0 8px; font-size: 0.9rem; line-height: 1.5; color: var(--text-primary); max-width: 80ch; }
.gl-sequence { overflow-x: auto; }
.gl-sequence svg { display: block; }
.gl-sequence text { font-family: var(--font-ui); font-size: 12px; fill: var(--text-primary); }
.gl-sequence .gls-name, .gl-sequence .gls-time { font-family: var(--font-data); }
.gl-sequence .gls-time { fill: var(--text-secondary); }
.gl-sequence .gls-gap { fill: var(--text-secondary); }
.gls-head { fill: var(--gl-raised); stroke: var(--gl-line); }
.gls-life { stroke: var(--gl-line); stroke-dasharray: 3 4; }
.gls-arrow { stroke-width: 1.5; }
.gls-arrow.neg { stroke-dasharray: 5 4; }
.gls-deadline { stroke: var(--text-secondary); stroke-dasharray: 6 4; }
.gls-row { cursor: pointer; }
.gls-band { fill: transparent; }
.gls-row:hover .gls-band { fill: rgba(255, 255, 255, 0.03); }
.gls-row.current .gls-band { fill: var(--gl-raised); }
.gls-row.current .gls-label { font-weight: 600; }
.gls-row.current .gls-arrow { stroke-width: 2.5; }
.gls-row.current .gls-time { fill: var(--text-primary); }
.gls-row.future { opacity: 0.35; }

.gl-table td { vertical-align: top; font-size: 0.8125rem; }
.gl-table tbody tr[data-step] { cursor: pointer; }
.gl-table tbody tr.current td { background: var(--gl-raised); }
.gl-cell-muted { color: var(--text-secondary); }
.gl-empty-cell { color: var(--text-secondary); padding: 16px; }
.gl-dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0; font-size: 0.875rem; }
.gl-dl dt { color: var(--text-secondary); }
.gl-dl dd { margin: 0; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- drawer: one message, every field */
.gl-drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 50; width: min(480px, 100vw); box-sizing: border-box; background: var(--gl-surface); border-left: 1px solid var(--gl-line); display: flex; flex-direction: column; transform: translateX(16px); opacity: 0; transition: transform 200ms var(--gl-ease-out), opacity 200ms var(--gl-ease-out); }
.gl-drawer.open { transform: none; opacity: 1; }
.gl-drawer[hidden] { display: none; }
.gl-drawer-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px; padding-top: calc(16px + env(safe-area-inset-top, 0px)); border-bottom: 1px solid var(--gl-border); }
.gl-drawer-head h2 { font-size: 1rem; margin: 0; }
.gl-drawer-body { padding: 16px; overflow-y: auto; display: grid; gap: 12px; align-content: start; }
.gl-drawer-h { font-size: 0.875rem; margin: 4px 0 0; }
.gl-json { margin: 0; padding: 12px; background: var(--screen); border: 1px solid var(--gl-border); border-radius: 8px; font-family: var(--font-data); font-size: 0.75rem; line-height: 1.5; color: var(--text-primary); overflow-x: auto; white-space: pre; }

/* ---------------------------------------------------------------- narrow screens: list, then detail */
@media (max-width: 1023px) {
    .gl-app { grid-template-columns: minmax(0, 1fr); }
    .gl-list-pane { position: static; max-height: none; }
    .gl-app.gl-show-detail .gl-list-pane { display: none; }
    .gl-app:not(.gl-show-detail) .gl-detail { display: none; }
    .gl-back { display: inline-flex; gap: 6px; align-items: center; justify-self: start; }
    .gl-tool-icons { margin-left: 0; }
    .gl-pop-right { right: auto; left: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .gl-drawer { transform: none; transition: opacity 100ms ease; }
    .glg-node rect { transition: none; }
}
