@import url('https://fonts.bunny.net/css?family=dm-sans:wght@400;500;600&family=dm-mono:wght@400;500&display=swap');

:root {
  --bg-base: #131516;
  --bg-raised: #1a1d1f;
  --bg-sunken: #0e1011;
  --bg-hover: #22272a;
  --border: #2a2f33;
  --border-sub: #1f2428;
  --text-1: #e8e3d9;
  --text-2: #7a8088;
  --text-3: #4e545b;
  --accent: #e8a030;
  --accent-dim: rgba(232, 160, 48, 0.12);
  --accent-bdr: rgba(232, 160, 48, 0.35);
  --ok: #4caf6e;
  --ok-dim: rgba(76, 175, 110, 0.12);
  --warn: #d4922b;
  --warn-dim: rgba(212, 146, 43, 0.12);
  --err: #e05252;
  --err-dim: rgba(224, 82, 82, 0.12);
  --err-bdr: rgba(224, 82, 82, 0.35);
  --font-ui: "DM Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "DM Mono", "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  --r: 2px;
  --rm: 3px;
  --pui-bg: var(--bg-base);
  --pui-bg-elev: var(--bg-raised);
  --pui-bg-soft: var(--bg-hover);
  --pui-border: var(--border-sub);
  --pui-border-bright: var(--border);
  --pui-fg: var(--text-1);
  --pui-fg-dim: var(--text-2);
  --pui-fg-mute: var(--text-3);
  --pui-grad-from: var(--accent);
  --pui-grad-mid: var(--ok);
  --pui-grad-to: #5aa9e6;
  --pui-success: var(--ok);
  --pui-danger: var(--err);
  --pui-warn: var(--warn);
  --pui-font-sans: var(--font-ui);
  --pui-font-mono: var(--font-mono);
  --pui-radius-sm: var(--r);
  --pui-radius: var(--rm);
  --pui-radius-lg: 5px;
  --pui-radius-xl: 6px;
  --pui-glow: 0 0 16px rgba(232, 160, 48, 0.18);
  --pui-glow-strong: 0 0 26px rgba(232, 160, 48, 0.22), 0 0 44px rgba(90, 169, 230, 0.12);
  --pui-glass: var(--bg-raised);
  --pui-glass-deep: var(--bg-raised);
  --pui-glass-soft: var(--bg-sunken);
  --pui-overlay: rgba(255, 255, 255, 0.03);
  --pui-overlay-strong: rgba(255, 255, 255, 0.05);
  --pui-overlay-bright: rgba(255, 255, 255, 0.08);
  --pui-button-dark-fill: var(--bg-sunken);
  --pui-button-dark-border: var(--border);
  --pui-wave-text: var(--accent);
  --pui-wave-text-hover: var(--text-1);
  --pui-wave-border: var(--accent-bdr);
  --pui-wave-border-hover: rgba(232, 160, 48, 0.55);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: var(--bg-base); color: var(--text-1); font-family: var(--font-ui); font-size: 14px; }
a { color: var(--accent); text-decoration: none; }

/* App layout */
.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar { width: 220px; min-width: 220px; background: var(--bg-raised); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar-brand { padding: 14px 16px; font-family: var(--font-mono); font-size: 14px; font-weight: 600; color: var(--accent); border-bottom: 1px solid var(--border); letter-spacing: 0.02em; }
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 10px 0; }
.sidebar-group { padding-bottom: 10px; margin-bottom: 6px; border-bottom: 1px solid var(--border-sub); }
.sidebar-group:last-child { border-bottom: none; margin-bottom: 0; }
.sidebar-group-label { padding: 8px 16px 6px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); font-weight: 600; }
.sidebar-item { display: block; padding: 8px 16px; cursor: pointer; color: var(--text-2); font-size: 13px; font-weight: 500; user-select: none; border-left: 2px solid transparent; text-decoration: none; }
.sidebar-item.active { color: var(--text-1); background: var(--bg-hover); border-left-color: var(--accent); font-weight: 600; }
.sidebar-item:hover { color: var(--text-1); background: var(--bg-hover); }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }

/* WS status dot */
.ws-status::before { content: ''; display: inline-block; width: 5px; height: 5px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.connected { color: var(--ok); }
.connected::before { background: var(--ok); animation: pulse 2s ease-in-out infinite; }
.disconnected { color: var(--err); }
.disconnected::before { background: var(--err); }
@keyframes pulse { 0%, 100% { opacity: 0.9; } 50% { opacity: 0.4; } }

/* Layout */
.tab-content { flex: 1; min-width: 0; padding: 14px 20px; max-width: 1400px; margin: 0 auto; overflow-x: auto; }

/* Stats */
.stats-row { display: flex; border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; margin-bottom: 14px; background: var(--bg-raised); }
.stat { flex: 1; padding: 12px 14px; border-right: 1px solid var(--border); }
.stat:last-child { border-right: none; }
.stat-label { color: var(--text-2); font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em; }
.stat-value { font-family: var(--font-mono); font-size: 22px; margin-top: 3px; font-weight: 500; }

/* Backend cards */
.backend-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-bottom: 14px; }
.card { padding: 12px; background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--rm); }
.card-header { display: flex; justify-content: space-between; align-items: center; }
.card-name { color: var(--accent); font-weight: 600; font-family: var(--font-mono); font-size: 13px; }
.card-body { margin-top: 8px; color: var(--text-2); font-size: 12px; }

/* Section */
.section-label { color: var(--text-2); font-size: 10px; text-transform: uppercase; margin-bottom: 8px; letter-spacing: 0.07em; font-weight: 500; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

/* Feed */
.feed { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; max-height: 400px; overflow-y: auto; }
.feed-header, .feed-row { display: grid; grid-template-columns: 140px 50px 80px 1fr 65px 55px 55px; padding: 6px 12px; font-size: 12px; }
.feed-header { background: var(--bg-hover); color: var(--text-2); border-bottom: 1px solid var(--border); position: sticky; top: 0; font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; }
.feed-row { border-bottom: 1px solid var(--border-sub); cursor: pointer; }
.feed-row:last-child { border-bottom: none; }
.feed-row:hover { background: var(--bg-hover); }
.feed-detail { padding: 12px 16px; background: var(--bg-sunken); border-bottom: 1px solid var(--border-sub); border-left: 2px solid var(--accent); font-size: 12px; display: grid; grid-template-columns: 120px 1fr; gap: 4px 12px; }
.feed-detail .label { color: var(--text-2); font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; }
.feed-detail .val { color: var(--text-1); font-family: var(--font-mono); word-break: break-all; }
.feed-detail .error-msg { color: var(--err); grid-column: 1 / -1; margin-top: 4px; padding: 6px; background: var(--err-dim); border-left: 2px solid var(--err); border-radius: var(--r); }
.streaming-badge { font-size: 9px; padding: 1px 5px; border-radius: 1px; background: var(--accent-dim); color: var(--accent); border: 1px solid var(--accent-bdr); margin-left: 4px; }
.status-2xx { color: var(--ok); }
.status-4xx { color: var(--warn); }
.status-5xx { color: var(--err); }

/* Forms */
.form-group { margin-bottom: 14px; padding: 12px; background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--rm); }
.form-label { font-weight: 600; margin-bottom: 4px; }
.form-hint { color: var(--text-2); font-size: 11px; margin-bottom: 8px; }
.form-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
input, select { background: var(--bg-sunken); border: 1px solid var(--border); color: var(--text-1); padding: 6px 10px; border-radius: var(--r); font-size: 13px; font-family: var(--font-ui); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }
button[disabled] { opacity: 0.55; cursor: not-allowed; }

/* Buttons */
.btn { padding: 7px 14px; border-radius: var(--r); cursor: pointer; font-size: 13px; border: 1px solid; font-weight: 500; font-family: var(--font-ui); transition: none; }
.btn-primary { background: transparent; border-color: var(--accent); color: var(--accent); }
.btn-primary:hover { background: var(--accent-dim); }
.btn-secondary { background: transparent; border-color: var(--border); color: var(--text-2); }
.btn-secondary:hover { border-color: var(--text-2); color: var(--text-1); }
.btn-danger { background: transparent; border-color: var(--err); color: var(--err); }
.btn-danger:hover { background: var(--err-dim); }
.btn-sm { padding: 3px 7px; font-size: 11px; }

/* Badges */
.badge { font-size: 10px; padding: 2px 5px; border-radius: 1px; font-family: var(--font-mono); }
.badge-override { background: var(--warn-dim); color: var(--warn); }
.badge-active { background: var(--ok-dim); color: var(--ok); }
.badge-revoked { background: var(--err-dim); color: var(--err); }
.badge-expired { background: var(--warn-dim); color: var(--warn); }

/* Misc */
.readonly-section { opacity: 0.75; padding: 12px; background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--rm); }
.model-grid { display: grid; grid-template-columns: 120px 1fr; gap: 8px; align-items: center; margin-top: 8px; }
.model-grid .label { color: var(--text-2); }
.warn { color: var(--warn); }
.error { color: var(--err); }
.empty { text-align: center; padding: 40px; color: var(--text-2); }
.pagination { display: flex; gap: 8px; margin-top: 12px; align-items: center; font-size: 13px; color: var(--text-2); }

/* Operator / Charts */
.operator-controls { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.operator-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1px; margin-bottom: 14px; background: var(--border); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.chart-card { padding: 12px; background: var(--bg-raised); min-height: 210px; }
.chart-card.wide { grid-column: 1 / -1; border-top: 1px solid var(--border); }
.chart-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.chart-title { font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-2); font-weight: 500; }
.chart-value { font-size: 20px; font-weight: 500; color: var(--text-1); font-family: var(--font-mono); }
.chart-subtitle { font-size: 11px; color: var(--text-2); }
.chart-svg { width: 100%; height: 130px; display: block; }
.chart-grid-line { stroke: var(--border-sub); stroke-width: 1; }
.chart-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart-line.secondary { stroke-width: 1.5; opacity: 0.8; }
.chart-area { fill-opacity: 0.08; }
.chart-axis { display: flex; justify-content: space-between; margin-top: 6px; font-size: 10px; color: var(--text-3); font-family: var(--font-mono); }

/* Failure table */
.failure-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.failure-table th, .failure-table td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--border-sub); vertical-align: top; }
.failure-table th { color: var(--text-2); font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500; }
.failure-summary { max-width: 340px; color: var(--text-1); }

/* Timeline */
.timeline-list { display: flex; flex-direction: column; gap: 8px; }
.timeline-item { padding: 10px; border: 1px solid var(--border-sub); border-radius: var(--r); background: var(--bg-sunken); }
.timeline-item:hover { border-color: var(--border); }
.timeline-meta { display: grid; grid-template-columns: 90px 52px 88px 1fr 70px; gap: 8px; align-items: center; font-size: 12px; margin-bottom: 8px; }
.timeline-track { height: 6px; border-radius: 0; background: var(--border); overflow: hidden; }
.timeline-bar { height: 100%; min-width: 4px; border-radius: 0; }
.timeline-caption { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: 11px; color: var(--text-2); }

/* Utility */
.mono { font-family: var(--font-mono); }
.dim { color: var(--text-2); }
.accent { color: var(--accent); }
.ok { color: var(--ok); }

/* Login */
.login-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg-base); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.login-node-bg { position: absolute; inset: 0; opacity: 0.55; }
.login-card { position: relative; background: var(--bg-raised); border: 1px solid var(--border); border-top: 2px solid var(--accent); border-radius: var(--rm); padding: 32px; width: 320px; z-index: 1; }
.login-title { font-family: var(--font-mono); font-size: 15px; font-weight: 500; margin-bottom: 24px; color: var(--text-1); }
.login-title .prompt { color: var(--accent); }
.login-card input[type="password"] { width: 100%; padding: 8px 12px; margin-bottom: 12px; font-size: 14px; background: var(--bg-sunken); border: 1px solid var(--border); color: var(--text-1); border-radius: var(--r); }
.login-card input[type="password"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }
.login-card .btn { width: 100%; padding: 10px; font-size: 14px; }
.login-error { color: var(--err); font-size: 12px; margin-top: 8px; min-height: 16px; }

/* Keys tab */
.keys-grid { width: 100%; border-collapse: collapse; font-size: 12px; }
.keys-grid th, .keys-grid td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border-sub); }
.keys-grid th { background: var(--bg-hover); color: var(--text-2); font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500; position: sticky; top: 0; }
.keys-grid tr:hover td { background: var(--bg-hover); }

/* Budget bar */
.budget-bar { height: 4px; border-radius: 0; background: var(--border); margin-top: 4px; overflow: hidden; min-width: 60px; }
.budget-bar-fill { height: 100%; background: var(--ok); transition: width 0.3s; }
.budget-bar-fill.warn { background: var(--warn); }
.budget-bar-fill.danger { background: var(--err); }

/* Tag chips */
.tag-input-area { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--r); min-height: 34px; align-items: center; cursor: text; }
.tag-input-area:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; background: var(--bg-hover); border: 1px solid var(--border); border-radius: var(--r); font-size: 11px; color: var(--text-1); }
.chip-remove { cursor: pointer; color: var(--text-3); font-size: 13px; line-height: 1; }
.chip-remove:hover { color: var(--err); }
.tag-input-bare { background: none; border: none; outline: none; color: var(--text-1); font-size: 13px; min-width: 80px; padding: 2px 4px; flex: 1; font-family: var(--font-ui); }

/* Key result */
.key-result { background: var(--bg-sunken); border: 1px solid var(--border); border-left: 3px solid var(--ok); border-radius: var(--r); padding: 12px; margin-bottom: 12px; font-family: var(--font-mono); font-size: 12px; word-break: break-all; }
.key-result-label { color: var(--ok); font-size: 11px; margin-bottom: 4px; font-weight: 600; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: var(--bg-raised); border: 1px solid var(--border); border-top: 2px solid var(--accent); border-radius: var(--rm); padding: 20px; width: 460px; max-width: 95vw; max-height: 90vh; overflow-y: auto; }
.modal-title { font-weight: 600; font-size: 15px; margin-bottom: 16px; color: var(--text-1); }

/* Traffic tab */
.route-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.route-table th, .route-table td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--border-sub); }
.route-table th { background: var(--bg-hover); color: var(--text-2); font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500; position: sticky; top: 0; }
.route-table tr:hover td { background: var(--bg-hover); }
.route-table td.mono { font-family: var(--font-mono); }

/* Uptime tab */
.uptime-proxy { padding: 14px; background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--rm); margin-bottom: 16px; }
.uptime-proxy-stats { display: flex; gap: 24px; margin-bottom: 10px; font-size: 13px; }
.uptime-pct { font-family: var(--font-mono); font-size: 22px; font-weight: 500; color: var(--ok); }
.history-bar { display: flex; gap: 2px; margin-top: 8px; height: 16px; }
.history-day { flex: 1; border-radius: 1px; min-width: 4px; }
.history-day.up { background: var(--ok); }
.history-day.down { background: var(--err); }
.history-day.degraded { background: var(--warn); }
.history-day.no-data { background: var(--border); }
.backend-health-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.backend-health-table th, .backend-health-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border-sub); }
.backend-health-table th { background: var(--bg-hover); color: var(--text-2); font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500; }

/* Route scope selector */
.route-scope-list { display: flex; flex-direction: column; gap: 4px; max-height: 160px; overflow-y: auto; border: 1px solid var(--border-sub); border-radius: var(--r); padding: 8px; background: var(--bg-sunken); }
.route-scope-item { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; padding: 2px 0; }
.route-scope-item:hover { color: var(--accent); }
.hint { color: var(--text-3); font-size: 11px; font-weight: 400; }

/* Button disabled state (shared across all variants) */
.btn:disabled { cursor: not-allowed; opacity: 0.5; }
.btn:disabled:hover { background: transparent; color: inherit; border-color: inherit; }

/* performative-ui adapter */
.admin-button { border-radius: var(--r); font-family: var(--font-ui); font-weight: 500; letter-spacing: 0; }
.admin-button.pui-btn { min-height: 31px; padding: 7px 14px; font-size: 13px; }
.admin-button.pui-btn--sm { min-height: 23px; padding: 3px 7px; font-size: 11px; }
.admin-button-primary.pui-btn--wave { border-radius: var(--r); box-shadow: none; }
.admin-button-primary.pui-btn--wave::before { opacity: 0.45; bottom: -3px; height: 3px; filter: blur(6px); }
.admin-button-secondary.pui-btn--ghost { color: var(--text-2); border-color: var(--border); background: transparent; }
.admin-button-secondary.pui-btn--ghost:hover { color: var(--text-1); border-color: var(--text-2); background: var(--bg-hover); }
.admin-button-danger.pui-btn--ghost { color: var(--err); border-color: var(--err); background: transparent; }
.admin-button-danger.pui-btn--ghost:hover { background: var(--err-dim); }
.admin-button-icon.pui-btn { min-width: 24px; padding: 1px 5px; font-size: 10px; gap: 0; }
.admin-status-dot { width: 7px; height: 7px; vertical-align: middle; margin-right: 6px; box-shadow: 0 0 8px currentColor; }
.admin-surface.pui-glass-card { padding: 12px; background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--rm); box-shadow: none; color: var(--text-1); transform: none; }
.admin-surface.pui-glass-card:hover { transform: none; border-color: var(--border); }
.stats-row .admin-surface.stat { border: 0; border-right: 1px solid var(--border); border-radius: 0; }
.stats-row .admin-surface.stat:last-child { border-right: 0; }
.operator-grid .admin-surface.chart-card { border: 0; border-radius: 0; min-height: 210px; }
.operator-grid .admin-surface.chart-card.wide { border-top: 1px solid var(--border); }
.backend-cards .admin-surface.card { padding: 12px; }
.login-card.admin-surface.pui-glass-card { padding: 32px; border-top: 2px solid var(--accent); }
.settings-restart-banner.admin-surface.pui-glass-card { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; padding: 8px 12px; background: var(--warn-dim); border-left: 3px solid var(--warn); font-size: 13px; }
.admin-loading { color: var(--text-2); }
.admin-loading .pui-wibble__verb { color: var(--text-2); }
.admin-loading .pui-wibble__info { color: var(--text-3); }

/* Modal */
.modal-backdrop-v2 { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px; z-index: 100; overflow-y: auto; }
.modal-v2 { background: var(--bg-raised); border: 1px solid var(--border); border-top: 2px solid var(--accent); border-radius: var(--rm); width: 100%; max-height: calc(100vh - 16vh); display: flex; flex-direction: column; outline: none; }
.modal-sm { max-width: 380px; }
.modal-md { max-width: 520px; }
.modal-lg { max-width: 780px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border-sub); }
.modal-header .modal-title { font-weight: 600; font-size: 14px; color: var(--text-1); margin: 0; }
.modal-close { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 20px; line-height: 1; padding: 0 4px; font-family: var(--font-ui); }
.modal-close:hover { color: var(--text-1); }
.modal-close:disabled { cursor: not-allowed; opacity: 0.4; }
.modal-body { padding: 16px; overflow-y: auto; font-size: 13px; color: var(--text-1); }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border-sub); background: var(--bg-sunken); }

/* Confirm dialog specifics */
.confirm-message { line-height: 1.5; color: var(--text-1); }
.confirm-error { margin-top: 12px; padding: 8px 10px; background: var(--err-dim); border: 1px solid var(--err-bdr); color: var(--err); font-size: 12px; border-radius: var(--r); }

/* Toast */
.toast-stack { position: fixed; top: 12px; right: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 200; max-width: 360px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 8px; padding: 9px 11px; background: var(--bg-raised); border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--r); font-size: 12px; color: var(--text-1); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35); }
.toast-success { border-left-color: var(--ok); }
.toast-error { border-left-color: var(--err); }
.toast-warn { border-left-color: var(--warn); }
.toast-info { border-left-color: var(--accent); }
.toast-message { flex: 1; line-height: 1.4; word-break: break-word; }
.toast-close { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; font-family: var(--font-ui); }
.toast-close:hover { color: var(--text-1); }

/* Async boundary error */
.async-error { padding: 20px; text-align: center; background: var(--bg-raised); border: 1px solid var(--err-bdr); border-left: 3px solid var(--err); border-radius: var(--rm); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.async-error-title { font-weight: 600; color: var(--err); font-size: 13px; }
.async-error-message { color: var(--text-2); font-size: 12px; max-width: 480px; word-break: break-word; }

/* Skeleton loader */
.skeleton-stack { display: flex; flex-direction: column; gap: 6px; padding: 2px 0; }
.skeleton { background: var(--bg-hover); border-radius: var(--r); position: relative; overflow: hidden; }
.skeleton::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.04), transparent); animation: skeleton-shimmer 1.4s linear infinite; }
.skeleton-row { height: 28px; }
@keyframes skeleton-shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ── Per-tab polish ──────────────────────────────────────────────────────── */

/* Toolbar above tables */
.toolbar { display: flex; gap: 10px; align-items: center; margin: 10px 0 8px; }
.toolbar-search { flex: 1; max-width: 340px; }
.toolbar-count { font-size: 11px; white-space: nowrap; }

/* Empty-state CTA card */
.empty-cta { padding: 28px 20px; background: var(--bg-raised); border: 1px dashed var(--border); border-radius: var(--rm); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 12px 0; }
.empty-cta-title { font-weight: 600; color: var(--text-1); font-size: 14px; }
.empty-cta-body { color: var(--text-2); font-size: 12px; max-width: 520px; line-height: 1.5; }
.empty-cta .btn { margin-top: 6px; }

/* Inline error (non-modal) */
.inline-error { margin-top: 8px; padding: 6px 10px; background: var(--err-dim); border-left: 3px solid var(--err); border-radius: var(--r); font-size: 12px; }

/* Route detail (extracted from inline styles) */
.route-detail { padding: 12px 16px; background: var(--bg-sunken); border-top: 1px solid var(--border); }
.route-detail-header { display: flex; justify-content: space-between; margin-bottom: 12px; }
.route-detail-title { font-weight: 600; }
.route-detail-desc { margin-left: 8px; }
.route-detail-meta { display: flex; gap: 8px; align-items: center; font-size: 12px; }
.route-detail-subhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.route-detail-subhead-label { margin-bottom: 0; }
.route-detail-add { display: flex; gap: 8px; align-items: center; padding: 8px 10px; margin-bottom: 10px; background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--r); }
.route-detail-add-select { flex: 1; }
.route-detail-add-models { width: 160px; }
.route-detail-empty { padding: 8px 0; font-size: 13px; }
.route-provider-row { display: grid; grid-template-columns: 24px 1fr auto auto auto auto; gap: 0 8px; align-items: center; padding: 6px 8px; background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--r); margin-bottom: 4px; font-size: 13px; }
.route-provider-name { font-weight: 500; }
.route-provider-id { margin-left: 6px; font-size: 11px; }
.route-provider-models { font-size: 11px; }
.route-provider-reorder { display: flex; gap: 2px; }
.route-provider-toggle { font-size: 10px; }
.route-provider-remove { font-size: 10px; }
.btn-icon { padding: 1px 4px; font-size: 10px; }

/* Route row */
.route-row { cursor: pointer; }
.route-row-name { font-weight: 500; }
.route-row-desc { margin-left: 6px; font-size: 11px; }
.route-row-actions { text-align: right; }
.route-row-detail-cell { padding: 0; }

/* Audit detail cell clipping */
.audit-detail { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Provider pick grid (inside AddProviderModal) */
.provider-pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; max-height: 400px; overflow-y: auto; }
.provider-pick-card { padding: 10px 12px; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--rm); cursor: pointer; font-size: 13px; font-weight: 500; text-align: left; color: var(--text-1); font-family: inherit; }
.provider-pick-card:hover { border-color: var(--accent); background: var(--bg-hover); }
.provider-pick-name { display: block; }
.provider-pick-proto { display: block; font-size: 10px; color: var(--text-3); margin-top: 2px; text-transform: uppercase; }

/* Provider group */
.provider-group { margin-bottom: 20px; }
.provider-group-label { margin-bottom: 8px; }
.provider-card-meta { display: grid; grid-template-columns: auto 1fr; gap: 3px 8px; font-size: 12px; }
.provider-card-actions { display: flex; gap: 6px; margin-top: 10px; }

/* Provider catalog (redesigned tab) */
.provider-catalog { display: flex; flex-direction: column; gap: 18px; }
.provider-tier-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-2); font-weight: 600; margin-bottom: 2px; }
.provider-tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.provider-tile-grid.tier-top { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.provider-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 8px 10px; background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--rm); cursor: pointer; text-align: center; position: relative; }
.provider-tile:hover { border-color: var(--accent); background: var(--bg-hover); }
.provider-tile.has-backends { border-left: 2px solid var(--accent); }
.provider-tile-name { font-size: 12px; font-weight: 500; color: var(--text-1); line-height: 1.3; }
.provider-tile-count { font-size: 10px; color: var(--text-3); font-family: var(--font-mono); }

/* Provider detail panel (lightbox overlay) */
.provider-scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.65); z-index: 50; }
.provider-panel { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(640px, 90vw); max-height: 80vh; overflow-y: auto; z-index: 51; background: var(--bg-raised); border: 1px solid var(--border); border-top: 2px solid var(--accent); border-radius: var(--rm); }
.provider-panel-header { display: flex; align-items: center; gap: 12px; padding: 16px 16px 12px; border-bottom: 1px solid var(--border-sub); }
.provider-panel-header h3 { flex: 1; font-size: 16px; font-weight: 600; margin: 0; }
.provider-panel-close { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 20px; line-height: 1; padding: 0 4px; font-family: var(--font-ui); }
.provider-panel-close:hover { color: var(--text-1); }
.provider-panel-caps { display: flex; flex-wrap: wrap; gap: 5px; padding: 10px 16px; border-bottom: 1px solid var(--border-sub); align-items: center; }
.badge-cap { font-size: 10px; padding: 2px 6px; border-radius: 1px; background: var(--bg-hover); color: var(--text-2); border: 1px solid var(--border); font-family: var(--font-mono); }
.badge-cap.active { background: var(--accent-dim); color: var(--accent); border-color: var(--accent-bdr); }
.provider-panel-meta { display: flex; gap: 16px; padding: 8px 16px; font-size: 12px; color: var(--text-2); border-bottom: 1px solid var(--border-sub); flex-wrap: wrap; }
.provider-panel-meta .mono { font-family: var(--font-mono); }

/* Backend rows within panel */
.provider-panel-section { padding: 12px 16px; }
.provider-panel-section-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-2); font-weight: 500; margin-bottom: 8px; }
.provider-backend-row { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: var(--bg-sunken); border: 1px solid var(--border-sub); border-radius: var(--r); margin-bottom: 4px; font-size: 13px; }
.provider-backend-row .backend-name { font-family: var(--font-mono); font-weight: 500; flex: 1; }
.provider-backend-row .backend-status { font-size: 11px; color: var(--text-2); }

/* Add backend form within panel */
.provider-add-toggle { margin-top: 8px; }
.provider-add-form { margin-top: 8px; padding: 12px; background: var(--bg-sunken); border: 1px solid var(--border-sub); border-radius: var(--r); }
.provider-add-form .form-group { margin-bottom: 10px; padding: 8px 10px; background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--r); }
.provider-add-form .form-label { font-size: 12px; font-weight: 600; margin-bottom: 3px; }
.provider-add-form .form-hint { font-size: 10px; }
.provider-add-form input { font-size: 12px; padding: 5px 8px; }
.provider-add-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.provider-empty-hint { color: var(--text-3); font-size: 12px; padding: 8px 0; }

/* Models: discover section */
.models-discover { margin-bottom: 20px; }
.models-discover-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.models-discover-hint { font-size: 12px; }
.models-discover-count { margin-top: 8px; font-size: 12px; }
.models-discover-results { margin-top: 8px; }
.models-discover-list { max-height: 200px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--r); font-size: 12px; }
.models-discover-item { padding: 4px 8px; cursor: pointer; border-bottom: 1px solid var(--border); }
.models-discover-item:hover { background: var(--bg-hover); }
.models-discover-item.is-selected { background: var(--accent-dim); }
.models-discover-item-name { margin-left: 8px; }

/* Responsive shell */
@media (max-width: 980px) {
  .app-layout { flex-direction: column; min-height: 100svh; }
  .sidebar { width: 100%; min-width: 0; height: auto; position: sticky; top: 0; z-index: 20; border-right: 0; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: auto minmax(0, 1fr); }
  .sidebar-brand { padding: 10px 14px; border-bottom: 1px solid var(--border-sub); border-right: 1px solid var(--border-sub); }
  .sidebar-footer { justify-content: flex-end; padding: 8px 10px; border-top: 0; border-bottom: 1px solid var(--border-sub); min-width: 0; }
  .sidebar-scroll { grid-column: 1 / -1; display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden; padding: 6px; }
  .sidebar-group { display: flex; flex: 0 0 auto; padding-bottom: 0; margin-bottom: 0; border-bottom: 0; }
  .sidebar-group-label { display: none; }
  .sidebar-item { white-space: nowrap; padding: 8px 10px; border-left: 0; border-bottom: 2px solid transparent; border-radius: var(--r); }
  .sidebar-item.active { border-left-color: transparent; border-bottom-color: var(--accent); }
  .tab-content { width: 100%; max-width: none; margin: 0; padding: 12px; overflow-x: hidden; }

  .stats-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat, .stats-row .admin-surface.stat { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
  .stats-row .stat:nth-child(2n) { border-right: 0; }
  .stats-row .stat:nth-last-child(-n + 2) { border-bottom: 0; }

  .feed { overflow-x: auto; }
  .feed-header, .feed-row { min-width: 680px; grid-template-columns: 110px 52px 72px minmax(180px, 1fr) 48px 48px 60px; }
  .feed-detail { grid-template-columns: 96px minmax(0, 1fr); }

  .keys-grid, .route-table, .failure-table, .backend-health-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .route-detail-header, .route-detail-subhead { gap: 8px; align-items: flex-start; }
  .route-detail-add { flex-wrap: wrap; align-items: stretch; }
  .route-detail-add-select { min-width: 180px; }
  .route-provider-row { grid-template-columns: 24px minmax(0, 1fr) auto auto; }
  .route-provider-models { grid-column: 2 / -1; white-space: normal; word-break: break-word; }

  .form-row { flex-wrap: wrap; align-items: stretch; }
  .form-row > input, .form-row > select { min-width: 140px; }

  .login-overlay { min-height: 100svh; padding: 16px; }
  .login-card { width: min(320px, 100%); padding: 24px; }
}

@media (max-width: 640px) {
  .section-header { align-items: flex-start; flex-direction: column; gap: 8px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-search { max-width: none; width: 100%; }
  .toolbar-count { align-self: flex-start; }
  .modal-backdrop-v2 { padding: 12px; }
  .modal-v2 { max-height: calc(100svh - 24px); }
  .modal-footer { flex-wrap: wrap; }

  .stats-row { grid-template-columns: 1fr; }
  .stat, .stats-row .admin-surface.stat { border-right: 0; border-bottom: 1px solid var(--border); }
  .stats-row .stat:last-child { border-bottom: 0; }

  .route-detail { padding: 10px; }
  .route-detail-header, .route-detail-meta, .route-detail-subhead, .route-detail-add { flex-direction: column; align-items: stretch; }
  .route-detail-desc { display: block; margin-left: 0; margin-top: 3px; }
  .route-detail-add-select, .route-detail-add-models { width: 100%; min-width: 0; }
  .route-provider-row { grid-template-columns: 20px minmax(0, 1fr); gap: 6px 8px; align-items: start; }
  .route-provider-models, .route-provider-reorder, .route-provider-toggle, .route-provider-remove { grid-column: 2; justify-self: start; }
  .route-provider-id { display: block; margin-left: 0; margin-top: 2px; }

  .provider-panel { width: calc(100vw - 24px); max-height: calc(100svh - 24px); }
  .login-title { margin-bottom: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }

  .connected::before,
  .skeleton::after,
  .admin-button-primary.pui-btn--wave::before {
    animation: none !important;
    transform: none !important;
  }

  .skeleton::after { display: none; }
  .budget-bar-fill { transition: none; }
  .login-node-bg { display: none; }
  .admin-surface.pui-glass-card { transform: none !important; }
}

/* Misc */
.key-icon-inline { vertical-align: -1px; margin-right: 3px; }
