:root {
  --primary: #1e40af;
  --primary-strong: #173483;
  --secondary: #3b82f6;
  --accent: #15803d;
  --background: #f6f8fc;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --text: #172033;
  --muted: #5b667a;
  --border: #dbe3ef;
  --danger: #b91c1c;
  --warning: #9a5b06;
  --warning-bg: #fff8e6;
  --success-bg: #eaf8ef;
  --shadow: 0 12px 32px rgba(30, 64, 175, .08);
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--background);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--background); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid rgba(59, 130, 246, .45); outline-offset: 2px; }
.skip-link { position: fixed; top: -60px; left: 16px; z-index: 100; background: var(--text); color: white; padding: 10px 14px; border-radius: 8px; }
.skip-link:focus { top: 12px; }
.sr-only { position: absolute; left: 0; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); clip-path: inset(50%); white-space: nowrap; }
.hidden { display: none !important; }

.app-shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 16px; color: #dbeafe; background: linear-gradient(180deg, #10254f 0%, #0a1d40 100%); display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { display: grid; flex: 0 0 auto; place-items: center; width: 42px; height: 42px; border: 1px solid rgba(255,255,255,.18); border-radius: 12px; background: linear-gradient(145deg, #60a5fa, #2563eb); color: white; font-weight: 850; box-shadow: 0 8px 20px rgba(37,99,235,.3); }
.brand strong, .brand small { display: block; }
.brand strong { color: white; font-size: 17px; letter-spacing: .03em; }
.brand small { color: #9fb6dc; margin-top: 1px; }
.sidebar-brand { align-items: flex-start; padding: 2px 4px 22px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-brand .brand-title { min-width: 0; max-width: 158px; padding-top: 1px; font-size: 14px; line-height: 1.28; letter-spacing: -.01em; overflow-wrap: normal; }
.nav-list { display: grid; gap: 8px; margin-top: 24px; }
.nav-item { position: relative; width: 100%; min-height: 48px; border: 1px solid transparent; border-radius: 12px; padding: 5px 9px; display: flex; align-items: center; gap: 11px; color: #bed0ec; background: transparent; text-align: left; font-weight: 650; transition: background .18s ease, border-color .18s ease, color .18s ease, transform .18s ease; }
.nav-item::before { content: ''; position: absolute; left: -16px; width: 3px; height: 22px; border-radius: 0 3px 3px 0; background: #60a5fa; opacity: 0; transform: scaleY(.5); transition: opacity .18s ease, transform .18s ease; }
.nav-item:hover { border-color: rgba(255,255,255,.08); background: rgba(255,255,255,.07); color: white; transform: translateX(2px); }
.nav-item.active { color: white; border-color: rgba(96,165,250,.18); background: linear-gradient(90deg, rgba(59,130,246,.24), rgba(96,165,250,.1)); box-shadow: 0 8px 22px rgba(3,10,28,.14); }
.nav-item.active::before { opacity: 1; transform: scaleY(1); }
.nav-item:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }
.nav-icon-wrap { display: grid; flex: 0 0 auto; place-items: center; width: 34px; height: 34px; border: 1px solid rgba(147,197,253,.16); border-radius: 9px; color: #8fbcfb; background: rgba(2,13,35,.2); transition: color .18s ease, background .18s ease, border-color .18s ease; }
.nav-icon { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover .nav-icon-wrap, .nav-item.active .nav-icon-wrap { color: white; border-color: rgba(147,197,253,.3); background: rgba(96,165,250,.2); }
.nav-label { min-width: 0; line-height: 1.25; }

.main-content { min-width: 0; padding: 0 34px 48px; }
.topbar { min-height: 112px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--border); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(22px, 3vw, 30px); letter-spacing: -.025em; }
h2 { margin-bottom: 8px; font-size: clamp(22px, 3vw, 28px); letter-spacing: -.025em; }
h3 { margin-bottom: 8px; font-size: 18px; }
p { color: var(--muted); line-height: 1.6; }
.eyebrow { margin-bottom: 5px; color: var(--primary); font-size: 11px; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }
.topbar-actions, .dialog-actions, .card-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.view { display: none; padding-top: 30px; }
.view.active { display: block; }
#view-chat, #portal-chat-root, #delivery-room-root { min-width: 0; }
.legacy-deliveries { margin-top: 1.25rem; }
.legacy-deliveries > summary { cursor: pointer; font-weight: 700; min-height: 44px; padding: .75rem 0; }
.section-heading { margin-bottom: 22px; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.section-heading p { margin-bottom: 0; }

.button { min-height: 44px; border: 1px solid transparent; border-radius: 9px; padding: 0 15px; font-weight: 700; font-size: 13px; transition: background .18s ease, border-color .18s ease, transform .18s ease; }
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0) scale(.98); }
.button:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.button.primary { color: white; background: var(--primary); }
.button.primary:hover { background: var(--primary-strong); }
.button.secondary { color: var(--primary); border-color: #b9cdf4; background: #eef5ff; }
.button.ghost { color: var(--muted); border-color: var(--border); background: white; }
.button.danger { color: var(--danger); border-color: #fecaca; background: #fff5f5; }
.button.small { min-height: 38px; padding: 0 11px; font-size: 12px; }
.button.full { width: 100%; }
.icon-button { width: 44px; height: 44px; border: 0; border-radius: 50%; color: var(--muted); background: transparent; font-size: 24px; }
.icon-button:hover { background: var(--surface-muted); }
.badge { display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px; border-radius: 999px; font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .04em; }
.badge.success { color: #166534; background: #dcfce7; }
.badge.error { color: #991b1b; background: #fee2e2; }
.badge.warning { color: #854d0e; background: #fef9c3; }
.badge.neutral { color: #475569; background: #e2e8f0; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 22px; }
.metric { min-height: 132px; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.metric small { display: block; color: var(--muted); font-weight: 650; }
.metric strong { display: block; margin: 11px 0 7px; font-size: 32px; letter-spacing: -.04em; }
.metric span { color: var(--accent); font-size: 12px; }
.two-column { display: grid; grid-template-columns: 1.2fr .8fr; gap: 18px; }
.panel { padding: 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.accent-panel { background: linear-gradient(145deg, #edf5ff, #f7fbff); border-color: #c5d8f7; }
.accent-panel .button { margin-top: 10px; }
.flow-list { list-style: none; margin: 18px 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.flow-list li { position: relative; display: flex; gap: 9px; padding: 13px; background: var(--surface-muted); border-radius: 10px; }
.flow-list li > span { flex: 0 0 auto; display: grid; place-items: center; width: 25px; height: 25px; border-radius: 7px; color: white; background: var(--primary); font-size: 11px; font-weight: 800; }
.flow-list strong, .flow-list small { display: block; }
.flow-list small { margin-top: 4px; color: var(--muted); line-height: 1.45; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: white; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 13px 16px; color: var(--muted); background: #f8fafc; text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
td { padding: 15px 16px; border-top: 1px solid #edf1f7; vertical-align: middle; }
td code { display: inline-block; max-width: 440px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agents-table { table-layout: fixed; }
.agents-table th:nth-child(1), .agents-table td:nth-child(1) { width: 110px; }
.agents-table th:nth-child(3), .agents-table td:nth-child(3) { width: 110px; }
.agents-table th:nth-child(4), .agents-table td:nth-child(4) { width: 120px; }
.agents-table th:nth-child(5), .agents-table td:nth-child(5) { width: 230px; }
.agents-table td:last-child .card-actions { justify-content: flex-end; flex-wrap: nowrap; }
.agents-table td code { max-width: 100%; }
.message-preview { display: block; max-height: 7.5rem; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.room-id-cell { min-width: 0; }
.room-id-value { display: block; max-width: 100%; white-space: normal; overflow-wrap: anywhere; user-select: text; }
.button.small.room-id-copy { min-height: 44px; margin-top: 6px; }
.room-id-pending { color: var(--muted); font-style: italic; }
.empty-state { padding: 42px !important; color: var(--muted); text-align: center; }
.connections-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.connections-toolbar-copy { min-width: 0; }
.connections-toolbar-copy p { margin: 0; line-height: 1.5; }
.connections-toolbar-copy .eyebrow { margin-bottom: 4px; }
.connection-count { display: inline-block; margin-left: 6px; color: var(--text); font-size: 12px; font-weight: 700; white-space: nowrap; }
.connections-toolbar-actions { display: flex; flex: 0 0 auto; align-items: center; justify-content: flex-end; gap: 9px; }
.connection-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: stretch; }
.connection-card { display: flex; flex-direction: column; height: 100%; min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: white; box-shadow: 0 3px 14px rgba(30, 64, 175, .06); transition: border-color .18s ease, box-shadow .18s ease; }
.connection-card:hover { border-color: #c2cfe3; box-shadow: 0 7px 20px rgba(30, 64, 175, .09); }
.connection-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 16px 13px; }
.connection-identity { display: flex; min-width: 0; align-items: center; gap: 11px; }
.connection-identity > div { min-width: 0; }
.connection-title { margin: 0; overflow: hidden; color: var(--text); font-size: 15px; line-height: 1.35; letter-spacing: -.01em; text-overflow: ellipsis; white-space: nowrap; }
.connection-subtitle { margin: 3px 0 0; overflow: hidden; color: var(--muted); font-size: 12px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.connection-subtitle span { margin-right: 4px; color: var(--text); font-weight: 650; }
.connection-card-header > .badge { flex: 0 0 auto; min-height: 22px; padding-inline: 8px; font-size: 10px; }
.provider-logo { display: grid; flex: 0 0 auto; place-items: center; width: 34px; height: 34px; border-radius: 8px; color: white; background: #374151; font-size: 9px; font-weight: 850; letter-spacing: .04em; }
.provider-logo.line { background: #15803d; }.provider-logo.whatsapp { background: #0f766e; }.provider-logo.telegram { background: #0369a1; }.provider-logo.teams { background: #4f46a5; }
.connection-metadata { display: grid; gap: 0; margin: 0; padding: 0 16px 14px; font-size: 12px; }
.connection-metadata > div { display: grid; grid-template-columns: 82px minmax(0, 1fr); align-items: center; min-height: 34px; border-top: 1px solid #edf1f7; }
.connection-metadata dt { color: var(--muted); font-size: 11px; font-weight: 650; }
.connection-metadata dd { min-width: 0; margin: 0; }
.provider-name { font-weight: 650; text-transform: capitalize; }
.connection-created dd { color: var(--muted); }
.connection-callback dd { display: flex; min-width: 0; align-items: center; gap: 4px; }
.connection-callback code { display: block; min-width: 0; flex: 1; overflow: hidden; padding: 6px 7px; border-radius: 5px; color: #334155; background: var(--surface-muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.copy-button { display: grid; flex: 0 0 auto; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid transparent; border-radius: 6px; color: var(--muted); background: transparent; transition: color .18s ease, background .18s ease, border-color .18s ease; }
.copy-button:hover { color: var(--primary); border-color: var(--border); background: white; }
.copy-button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.connection-card-footer { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: auto; padding: 12px 16px; border-top: 1px solid var(--border); background: #fafcff; }
.connection-actions { display: flex; min-width: 0; align-items: center; gap: 7px; flex-wrap: wrap; }
.connection-danger-actions { flex: 0 0 auto; padding-left: 11px; border-left: 1px solid var(--border); }
.connection-card-footer .button.small { min-height: 34px; padding-inline: 10px; }
.callout { padding: 14px; border-left: 3px solid var(--primary); border-radius: 8px; background: #f1f6ff; }
.callout p { margin: 5px 0 0; font-size: 13px; }
.callout code { display: inline-block; max-width: 100%; white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
.callout.warning { margin-bottom: 18px; border-left-color: #d97706; background: var(--warning-bg); color: #713f12; }
.lab-layout { align-items: start; }
.form-stack { display: grid; gap: 17px; }
.check-list { padding-left: 20px; color: var(--muted); line-height: 1.9; }
.help-panel .callout { margin-top: 20px; }

.field { display: grid; gap: 7px; }
.provider-fields, .form-grid, .field { min-width: 0; }
.field label, fieldset legend { font-size: 13px; font-weight: 750; }
.field input, .field select, .field textarea { width: 100%; min-height: 44px; border: 1px solid #cbd5e1; border-radius: 9px; padding: 10px 12px; color: var(--text); background: white; }
.field textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.55; }
.field small { color: var(--muted); line-height: 1.45; }
.advanced-settings { margin-top: 16px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-muted); }
.advanced-settings summary { cursor: pointer; font-size: 13px; font-weight: 750; }
.advanced-settings[open] summary { margin-bottom: 10px; }
.advanced-settings .field + .field { margin-top: 14px; }
.advanced-settings p { margin: 0 0 14px; font-size: 13px; }
.check-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.check-row input { width: 18px; height: 18px; }
.field-error { min-height: 20px; margin: 0; color: var(--danger); font-size: 13px; }
.form-error-summary { margin: 0 0 16px; padding: 12px 14px; border-left: 3px solid var(--danger); border-radius: 8px; color: var(--danger); background: #fff1f2; font-size: 13px; line-height: 1.5; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.full-span { grid-column: 1 / -1; }
.provider-fields { margin: 20px 0 0; padding: 18px; border: 1px solid var(--border); border-radius: 10px; }
.provider-fields legend { padding: 0 7px; color: var(--primary); }
.provider-fields legend { max-width: 100%; white-space: normal; }

.modal { width: min(540px, calc(100vw - 28px)); max-height: calc(100dvh - 36px); padding: 0; overflow: hidden; border: 0; border-radius: 16px; color: var(--text); background: var(--surface); box-shadow: 0 30px 80px rgba(15, 23, 42, .25); }
.modal.wide { width: min(720px, calc(100vw - 28px)); }
.modal::backdrop { background: rgba(15, 23, 42, .58); backdrop-filter: blur(3px); }
.dialog-card { max-height: calc(100dvh - 36px); padding: 26px; overflow-y: auto; overscroll-behavior: contain; color: var(--text); background: var(--surface); }
.dialog-header { display: flex; align-items: start; justify-content: space-between; gap: 14px; }
.dialog-actions { justify-content: flex-end; margin-top: 24px; }
.delivery-detail-modal { width: min(1040px, calc(100vw - 32px)); }
.delivery-detail-card { padding: 28px 30px 24px; }
.delivery-detail-header { align-items: flex-start; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.delivery-detail-header h2 { margin: 2px 0 5px; font-size: clamp(1.5rem, 3vw, 2rem); }
.delivery-detail-header p:last-child { margin: 0; color: var(--muted); }
.delivery-trace-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin: 20px 0; overflow: hidden; border: 1px solid var(--border); border-radius: 14px; background: var(--border); }
.delivery-trace-summary div { min-width: 0; padding: 13px 15px; background: var(--surface-soft); }
.delivery-trace-summary dt { margin-bottom: 4px; color: var(--muted); font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.delivery-trace-summary dd { min-width: 0; margin: 0; color: var(--text); font-size: .9rem; font-weight: 650; overflow-wrap: anywhere; }
.delivery-message-flow { display: grid; grid-template-columns: 1fr; gap: 0; }
.delivery-message-card { min-width: 0; padding: 18px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.delivery-message-card.reply-message { border-color: color-mix(in srgb, var(--primary) 28%, var(--border)); background: color-mix(in srgb, var(--primary) 2%, var(--surface)); }
.delivery-message-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.delivery-message-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.delivery-message-title .eyebrow { margin: 0 0 2px; }
.delivery-message-title h3 { margin: 0; font-size: 1.05rem; }
.flow-step { display: inline-grid; flex: 0 0 34px; width: 34px; height: 34px; place-items: center; border-radius: 50%; color: white; background: var(--primary); font-size: .85rem; font-weight: 800; }
.message-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.flow-connector { display: grid; height: 28px; place-items: center; color: var(--primary); }
.flow-connector span { display: inline-grid; width: 24px; height: 24px; place-items: center; border-radius: 50%; background: color-mix(in srgb, var(--primary) 10%, var(--surface)); font-weight: 800; }
.message-detail { min-height: 76px; max-height: 180px; margin: 0; padding: 16px 18px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-soft); color: var(--text); font-family: inherit; font-size: 1rem; font-weight: 400; line-height: 1.65; }
.message-detail.reply-content { min-height: 180px; max-height: 360px; }
.message-detail.expanded { max-height: none; overflow: visible; }
.delivery-detail-actions { position: sticky; bottom: -24px; margin: 20px -30px -24px; padding: 14px 30px; border-top: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 96%, transparent); backdrop-filter: blur(8px); }
.login-brand { margin-bottom: 30px; }.login-brand strong { color: var(--text); }.login-brand small { color: var(--muted); }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 200; max-width: min(420px, calc(100vw - 32px)); padding: 13px 16px; border-radius: 10px; color: white; background: #172033; box-shadow: 0 14px 40px rgba(15,23,42,.25); opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.connection-grid > .empty-state { grid-column: 1 / -1; }

@media (pointer: coarse) {
  .button.small { min-height: 44px; }
  .copy-button { width: 44px; height: 44px; }
}

@media (max-width: 1180px) {
  .connection-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 124px minmax(0,1fr); }
  .sidebar { padding-inline: 12px; }
  .sidebar-brand { justify-content: center; padding-inline: 0; }
  .sidebar-brand .brand-title { display: none; }
  .nav-item { justify-content: center; flex-direction: column; gap: 4px; padding-inline: 5px; font-size: 11px; text-align: center; }
  .nav-item::before { left: -12px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .two-column { grid-template-columns: 1fr; }
  .flow-list { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .responsive-table, .responsive-table tbody, .responsive-table tr, .responsive-table td { display: block; width: 100% !important; }
  .responsive-table { table-layout: auto; }
  .responsive-table thead { display: none; }
  .responsive-table tbody { padding: 0 14px; }
  .responsive-table tr { margin: 14px 0; padding: 12px 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: 0 6px 18px rgba(30,64,175,.06); }
  .responsive-table td { display: grid; grid-template-columns: minmax(88px, 24%) minmax(0,1fr); gap: 12px; align-items: start; padding: 8px 14px; border: 0; overflow-wrap: anywhere; }
  .responsive-table td::before { content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; }
  .responsive-table td code { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
  .responsive-table td:last-child .card-actions { justify-content: flex-start; flex-wrap: wrap; }
  .responsive-table .empty-state { display: block; }
  .responsive-table .button.small { min-height: 44px; }
  .agents-table td[data-label="Actions"] { display: block; }
  .agents-table td[data-label="Actions"]::before { display: block; margin-bottom: 8px; }
  .agents-table td[data-label="Actions"] .card-actions { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
  .agents-table td[data-label="Actions"] .button { width: 100%; padding-inline: 8px; }
}
@media (max-width: 720px) {
  .app-shell { display: block; }.sidebar { position: sticky; z-index: 20; width: 100%; height: auto; padding: 10px 14px; flex-direction: row; align-items: center; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; overscroll-behavior-x: contain; }
  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar .brand { display: none; }.nav-list { display: flex; width: max-content; margin: 0; gap: 5px; }.nav-list::after { content: ''; flex: 0 0 8px; }.nav-item { width: auto; min-width: max-content; min-height: 48px; padding-inline: 10px; flex-direction: row; font-size: 12px; scroll-snap-align: start; }
  .nav-item::before { left: 50%; bottom: -10px; width: 28px; height: 3px; transform: translateX(-50%) scaleX(.5); }
  .nav-item.active::before { transform: translateX(-50%) scaleX(1); }
  .nav-item.active { box-shadow: none; }.main-content { padding: 0 16px 32px; }
  .topbar { min-height: 96px; align-items: flex-start; padding-top: 18px; }.topbar-actions .badge { display: none; }
  .section-heading { align-items: flex-start; flex-direction: column; }.metric-grid, .connection-grid, .two-column, .form-grid { grid-template-columns: 1fr; }
  .connections-toolbar { align-items: stretch; flex-direction: column; gap: 14px; }
  .connections-toolbar-actions { justify-content: flex-start; }
  .full-span { grid-column: auto; }.flow-list { grid-template-columns: 1fr; }.dialog-card { padding: 20px; }
  .delivery-detail-card { padding: 20px; }
  .delivery-trace-summary { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .delivery-detail-actions { bottom: -20px; margin: 18px -20px -20px; padding: 12px 20px; }
}
@media (max-width: 480px) {
  #view-chat { width: 100%; overflow-x: hidden; }
  #portal-chat-root, #delivery-room-root { width: 100%; }
  .topbar { align-items: stretch; flex-direction: column; justify-content: center; gap: 14px; padding: 18px 0; }
  .topbar-actions { justify-content: flex-start; }
  .connections-toolbar-actions { display: grid; grid-template-columns: 1fr; }
  .connections-toolbar-actions .button { width: 100%; }
  .connection-card-footer { align-items: stretch; flex-direction: column; }
  .connection-danger-actions { align-self: stretch; padding: 10px 0 0; border-top: 1px solid var(--border); border-left: 0; }
  .connection-danger-actions .button { width: 100%; }
  .section-heading { gap: 16px; }
  .panel { padding: 18px; }
  .delivery-detail-modal { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .delivery-detail-card { max-height: calc(100dvh - 16px); padding: 16px; }
  .delivery-detail-header { gap: 10px; padding-bottom: 14px; }
  .delivery-detail-header p:last-child { font-size: .9rem; }
  .delivery-trace-summary { grid-template-columns: repeat(2, minmax(0,1fr)); margin: 14px 0; }
  .delivery-trace-summary div:last-child { grid-column: 1 / -1; }
  .delivery-message-card { padding: 14px; }
  .delivery-message-header { align-items: flex-start; flex-direction: column; gap: 10px; }
  .message-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); width: 100%; }
  .message-actions .button { width: 100%; min-height: 44px; }
  .message-detail { padding: 14px; font-size: 1rem; }
  .delivery-detail-actions { bottom: -16px; margin: 16px -16px -16px; padding: 12px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --background: #09111f;
    --surface: #111c2e;
    --surface-muted: #17243a;
    --text: #eef4ff;
    --muted: #b5c2d8;
    --border: #2d3c55;
    --danger: #fca5a5;
    --warning-bg: #35280e;
    --shadow: 0 12px 32px rgba(0, 0, 0, .22);
  }
  .sidebar { background: #07142d; }
  .panel, .metric, .connection-card, .table-wrap, .button.ghost, .field input, .field select, .field textarea { color: var(--text); background: var(--surface); }
  .connection-card-footer { background: #101a2c; }
  .connection-metadata > div { border-top-color: #26354d; }
  .connection-callback code { color: #dbeafe; }
  .accent-panel { background: linear-gradient(145deg, #102343, #101d31); border-color: #34558b; }
  th { color: var(--muted); background: #142037; }
  td { border-top-color: #26354d; }
  .button.secondary { color: #bfdbfe; border-color: #3b5d91; background: #152c50; }
  .button.danger { color: #fecaca; border-color: #7f1d1d; background: #351719; }
  .badge.neutral { color: #d5deeb; background: #334155; }
  .callout { background: #122848; }
  .callout.warning { color: #fde68a; background: #35280e; }
  .form-error-summary { color: #fecaca; background: #351719; }
  code { color: #dbeafe; }
}
