:root {
  color-scheme: dark;
  --bg: #0b0f12;
  --surface: #11171b;
  --surface-2: #171e23;
  --line: #273138;
  --text: #eef4f5;
  --muted: #8e9ca3;
  --accent: #58d6c2;
  --danger: #ff7a7a;
  --warning: #e6bc67;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); text-decoration: none; }

.topbar {
  height: 58px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; border-bottom: 1px solid var(--line); background: #0d1215;
}
.brand { font-weight: 720; letter-spacing: .04em; }
.top-actions { display: flex; gap: 16px; align-items: center; color: var(--muted); font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--accent); margin-right: 7px; }

.button {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  min-height: 38px; padding: 8px 14px; cursor: pointer; border-radius: 6px;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.button:hover { border-color: #4c5c65; background: #1b252a; }
.button:active { transform: translateY(1px); }
.button.primary { border-color: var(--accent); color: #06110f; background: var(--accent); font-weight: 700; }
.button.danger { color: var(--danger); }
.button.small { min-height: 30px; padding: 5px 9px; font-size: 12px; }
.button:disabled { opacity: .45; cursor: wait; }

.field { display: grid; gap: 7px; }
.field label { font-size: 12px; color: var(--muted); }
input, textarea, select {
  width: 100%; border: 1px solid var(--line); background: #0e1417; color: var(--text);
  border-radius: 6px; padding: 10px 11px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; line-height: 1.65; }

.chat-shell { min-height: calc(100vh - 58px); display: grid; grid-template-columns: minmax(0, 1fr) 360px; }
.chat-main { min-width: 0; display: grid; grid-template-rows: 1fr auto; }
.transcript { padding: 34px clamp(24px, 7vw, 100px); overflow: auto; }
.empty { max-width: 680px; margin: 18vh auto 0; }
.empty h1 { font-size: clamp(28px, 4vw, 48px); margin: 0 0 12px; letter-spacing: -.03em; }
.empty p { color: var(--muted); line-height: 1.75; }
.message { max-width: 820px; margin: 0 auto 28px; animation: rise .24s ease both; }
.message .role { color: var(--accent); font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; margin-bottom: 8px; }
.message.user .role { color: var(--muted); }
.message .content { line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; }
.composer { border-top: 1px solid var(--line); padding: 18px clamp(24px, 7vw, 100px) 22px; background: #0d1215; }
.composer form { max-width: 820px; margin: auto; display: grid; gap: 10px; }
.composer textarea { min-height: 84px; }
.composer-row { display: flex; align-items: center; gap: 10px; }
.composer-row .unit { width: 150px; }
.composer-row .hint { flex: 1; color: var(--muted); font-size: 12px; }
.inspector { border-left: 1px solid var(--line); padding: 24px; overflow: auto; background: #0d1215; }
.inspector h2 { font-size: 14px; margin: 0 0 18px; }
.inspector h3 { margin: 24px 0 10px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.kv { display: grid; grid-template-columns: 112px 1fr; gap: 7px; font-size: 12px; margin-bottom: 7px; }
.kv span:first-child { color: var(--muted); }
.trace-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 7px 0; border-bottom: 1px solid #1b2429; font: 11px ui-monospace, monospace; }
.candidate { padding: 9px 0; border-bottom: 1px solid #1b2429; font-size: 12px; line-height: 1.45; }
.candidate strong { color: var(--accent); font-family: ui-monospace, monospace; }

.admin-layout { min-height: calc(100vh - 58px); display: grid; grid-template-columns: 190px minmax(0,1fr); }
.side-nav { border-right: 1px solid var(--line); padding: 20px 12px; background: #0d1215; }
.side-link { width: 100%; border: 0; background: transparent; color: var(--muted); text-align: left; padding: 11px 12px; border-radius: 6px; cursor: pointer; margin-bottom: 4px; }
.side-link span { display: inline-block; width: 30px; color: #526068; font: 11px ui-monospace,monospace; }
.side-link.active { color: var(--text); background: var(--surface-2); }
.side-link.profile-link { margin-top:16px; border-top:1px solid var(--line); border-radius:0 0 6px 6px; padding-top:15px; }
.admin-shell { min-width: 0; padding: 26px 30px 48px; }
.summary-strip { display: flex; flex-wrap: wrap; gap: 0; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.summary-item { min-width: 150px; padding: 0 28px 18px 0; }
.summary-item strong { display: block; font-size: 25px; margin-bottom: 4px; }
.summary-item span { color: var(--muted); font-size: 12px; }
.summary-item.summary-text { min-width:260px; max-width:440px; }
.summary-item.summary-text strong { font-size:17px; line-height:1.35; overflow-wrap:anywhere; }
.summary-item.summary-text span { display:block; line-height:1.45; }
.tabs { display: flex; gap: 4px; margin-bottom: 18px; }
.tab { border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); padding: 10px 14px; cursor: pointer; }
.tab.active { border-color: var(--accent); color: var(--text); }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; }
.toolbar input { max-width: 420px; }
.toolbar select { width: auto; min-width: 126px; }
.toolbar .spacer { flex: 1; }
.toolbar .button { white-space:nowrap; flex:0 0 auto; }
.filter-bar { display:flex; align-items:center; flex-wrap:wrap; gap:8px; margin:14px 0; }
.filter-bar input { flex:1 1 210px; min-width:150px; }
.filter-bar select { flex:0 1 165px; width:auto; min-width:130px; }
.filter-bar .button { flex:0 0 auto; min-height:38px; }
.filter-bar .quiet { background:transparent; border-color:transparent; color:var(--muted); }
.compact-head { margin-bottom:12px; }
.qa-heading { margin-bottom:14px; }
.qa-library-tabs { margin-bottom:12px; }
.qa-library-context { display:flex; align-items:flex-end; justify-content:space-between; gap:20px; margin-bottom:14px; padding:14px 16px; border:1px solid #2a353a; background:#10171a; border-radius:6px; }
.qa-library-copy { display:grid; gap:4px; min-width:220px; }
.qa-library-copy > span { color:var(--muted); font-size:10px; letter-spacing:.08em; text-transform:uppercase; }
.qa-library-copy strong { font-size:15px; color:var(--accent); }
.qa-library-copy small { color:var(--muted); font-size:11px; }
.qa-library-actions { margin-top:8px; flex-wrap:wrap; }
.qa-library-selectors { display:flex; gap:8px; align-items:flex-end; }
.qa-library-selectors label { display:grid; gap:5px; color:var(--muted); font-size:10px; }
.qa-library-selectors select { min-width:150px; min-height:38px; }
.qa-library-selectors #unitId { min-width:210px; }
.qa-library-selectors #qaDomainId { min-width:240px; }
.qa-filter-bar { display:flex; gap:8px; align-items:center; margin-bottom:8px; min-width:0; }
.qa-filter-bar input, .qa-filter-bar select, .qa-filter-bar .button { min-height:38px; }
.qa-filter-bar #qaSearch { flex:1 1 280px; min-width:190px; }
.qa-filter-bar #qaAnswerStatus, .qa-filter-bar #qaDerivation { flex:0 0 138px; }
.qa-filter-bar .button { flex:0 0 auto; min-width:60px; }
.qa-filter-bar .quiet { background:transparent; border-color:transparent; color:var(--muted); }
.qa-more-filters { margin:0 0 10px; color:var(--muted); font-size:11px; }
.qa-more-filters summary { width:max-content; cursor:pointer; padding:3px 0; }
.qa-more-filters > div { display:flex; gap:8px; padding-top:8px; }
.qa-more-filters select { width:160px; padding:7px 9px; }
.qa-create-actions { display:flex; align-items:center; justify-content:space-between; gap:16px; min-height:48px; padding:8px 0 10px; border-top:1px solid var(--line); }
.qa-create-actions > span { color:var(--muted); font-size:11px; }
.batch-bar { min-height:44px; display:flex; align-items:center; gap:7px; padding:6px 0; margin-bottom:6px; border-top:1px solid var(--line); color:var(--muted); font-size:12px; }
.batch-bar.has-selection { border-color:#315b55; background:#0e1818; color:var(--text); }
.batch-bar.has-selection { padding-left:10px; padding-right:10px; }
.batch-bar .spacer { flex:1; }
.batch-bar strong { color:var(--accent); font:14px ui-monospace,monospace; }
.batch-bar .compact-select { display:flex; align-items:center; gap:6px; white-space:nowrap; }
.batch-bar .compact-select.hidden { display:none; }
.batch-bar .compact-select select { min-width:190px; height:30px; padding:3px 28px 3px 8px; }
.selection-count { min-width:78px; }
.select-col { width:44px; min-width:44px; text-align:center; padding-left:12px; padding-right:8px; }
.table-check { position:relative; display:inline-grid; width:18px; height:18px; place-items:center; cursor:pointer; }
.table-check input { appearance:auto; -webkit-appearance:checkbox; position:absolute; inset:0; width:18px; height:18px; margin:0; padding:0; accent-color:var(--accent); opacity:1; cursor:pointer; }
.table-check span { display:none; }
.qa-table { min-width:960px; }
.qa-table td.question-cell { min-width:230px; max-width:330px; }
.qa-table td:last-child .button { min-width:48px; white-space:nowrap; }
.qa-table-wrap { max-height:calc(100vh - 300px); min-height:380px; border-bottom:1px solid var(--line); }
.qa-table th { top:0; z-index:1; }
.text-action { appearance:none; border:0; padding:0; background:transparent; color:var(--text); text-align:left; cursor:pointer; line-height:1.5; }
.text-action:hover { color:var(--accent); }
.status-stack { display:flex; flex-wrap:wrap; gap:5px; max-width:160px; }
.status-pill { display:inline-flex; align-items:center; border:1px solid currentColor; border-radius:999px; padding:2px 6px; font:10px ui-monospace,monospace; white-space:nowrap; }
.status-pill.neutral { color:var(--muted); }
.derivation-grid { display:grid; grid-template-columns:auto auto; gap:4px 7px; align-items:center; min-width:150px; }
.derivation-grid > span:nth-child(odd) { color:var(--muted); font-size:10px; }
.derivation-summary { margin-top:6px; color:var(--muted); font:10px ui-monospace,monospace; white-space:nowrap; }
.status-toggle { display:inline-flex; align-items:center; gap:7px; border:0; background:transparent; color:var(--muted); padding:3px 0; cursor:pointer; font-size:11px; white-space:nowrap; min-width:62px; }
.status-toggle span { width:26px; height:14px; border:1px solid #445158; border-radius:999px; position:relative; transition:border-color .15s ease,background .15s ease; }
.status-toggle span::after { content:""; position:absolute; width:8px; height:8px; left:2px; top:2px; border-radius:50%; background:#718087; transition:transform .15s ease,background .15s ease; }
.status-toggle.active { color:var(--accent); }
.status-toggle.active span { border-color:#38766c; background:#17322d; }
.status-toggle.active span::after { transform:translateX(12px); background:var(--accent); }
.status-toggle:disabled { opacity:.45; cursor:not-allowed; }
.status-toggle.working { cursor:wait; }
.keyword-cell { min-width:125px; max-width:170px; }
.keyword-cell > span:not(.muted) { display:inline-block; margin:0 4px 4px 0; padding:2px 5px; background:#172126; color:#b9c8cc; border-radius:3px; font-size:10px; }
.inactive-row { opacity:.62; }
.empty-row { text-align:center; padding:42px; }
.table-footer { display:flex; align-items:center; justify-content:space-between; padding:10px 0; color:var(--muted); font-size:12px; }
.handoff-toolbar { display:grid; grid-template-columns:150px minmax(180px,1fr) minmax(220px,1.4fr) auto; }
.table-wrap { overflow: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; min-width: 880px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid #20292e; vertical-align: top; font-size: 12px; }
th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--bg); }
td.question-cell { min-width: 290px; max-width: 460px; line-height: 1.5; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.muted { color: var(--muted); }
.ok { color: var(--accent); }
.warn { color: var(--warning); }
.bad { color: var(--danger); }
.hidden { display: none !important; }
.row-actions { display: flex; gap: 6px; white-space: nowrap; }
.detail-row td { background: var(--surface); }
.detail-json { margin: 0; max-height: 360px; overflow: auto; white-space: pre-wrap; color: #bdc9cd; font: 11px/1.6 ui-monospace, monospace; }

.managed-panel { display:grid; gap:18px; min-width:0; }
.account-scope-bar { display:flex; align-items:flex-end; justify-content:space-between; gap:22px; padding:15px 17px; border:1px solid #31514c; border-radius:8px; background:linear-gradient(120deg,#0f1b1a,#0e1417); }
.account-scope-bar > div { display:grid; gap:4px; min-width:0; }
.account-scope-bar > div > span,.account-scope-bar label > span { color:var(--muted); font-size:10px; letter-spacing:.07em; text-transform:uppercase; }
.account-scope-bar strong { color:var(--accent); font-size:17px; }
.account-scope-bar small { color:var(--muted); font-size:11px; line-height:1.45; }
.account-scope-bar label { display:grid; gap:6px; flex:0 1 360px; min-width:240px; }
.module-tabs { margin-top:0; }
.module-page { min-width:0; animation:rise .16s ease both; }
.module-page > .subsection-head { margin-top:2px; }
.platform-spacer { margin-top:28px; }
.domain-catalog { display:grid; gap:8px; }
.domain-card { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:16px; align-items:center; padding:14px 16px; border:1px solid var(--line); border-radius:7px; background:#0e1417; }
.domain-card-copy { display:grid; gap:5px; min-width:0; }
.domain-card-copy strong { font-size:13px; }
.domain-card-copy p { margin:0; color:var(--muted); font-size:11px; line-height:1.55; }
.domain-card-copy small { color:#68777e; font:10px ui-monospace,monospace; }
.domain-card-meta { display:flex; flex-wrap:wrap; gap:5px 14px; color:#78878e; font:10px/1.45 ui-monospace,monospace; }
.domain-card-meta span { white-space:normal; }
.domain-card-actions { display:flex; align-items:center; gap:8px; }
.permission-grid { display:grid; grid-template-columns:1fr 1fr; gap:7px; padding:9px; border:1px solid var(--line); border-radius:6px; background:#0b1114; }
.permission-choice { display:flex; align-items:flex-start; gap:8px; padding:8px; border-radius:5px; color:var(--text); font-size:12px; cursor:pointer; }
.permission-choice:hover { background:#141e22; }
.permission-choice input { width:16px; height:16px; margin:1px 0 0; accent-color:var(--accent); }
.permission-choice span { display:grid; gap:3px; }
.permission-choice small { color:var(--muted); font-size:10px; }
.domain-multiselect { display:grid; gap:8px; padding:11px; border:1px solid var(--line); border-radius:7px; background:#0b1114; }
.domain-multiselect small { color:var(--muted); }
.unit-domain-choice-list { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:7px; max-height:320px; padding:2px; overflow:auto; }
.unit-domain-choice { display:grid; grid-template-columns:auto minmax(0,1fr) auto; gap:9px; align-items:center; min-width:0; padding:10px 11px; border:1px solid #273237; border-radius:6px; background:#0d1316; color:#68777e; cursor:pointer; transition:border-color .15s ease,background .15s ease,color .15s ease; }
.unit-domain-choice:hover { border-color:#415158; background:#11191d; }
.unit-domain-choice input { width:17px; height:17px; margin:0; accent-color:var(--accent); }
.unit-domain-choice-copy { display:grid; gap:3px; min-width:0; }
.unit-domain-choice-copy strong { color:inherit; font-size:12px; overflow-wrap:anywhere; }
.unit-domain-choice-copy small { color:inherit; opacity:.78; font:10px/1.45 ui-monospace,monospace; overflow-wrap:anywhere; }
.unit-domain-purchase-state { padding:3px 6px; border:1px solid currentColor; border-radius:999px; color:#68777e; font-size:9px; white-space:nowrap; }
.unit-domain-choice.is-purchased { border-color:#315f56; background:#0e1a18; color:#69d2bd; }
.unit-domain-choice.is-purchased .unit-domain-purchase-state { color:#69d2bd; }
.unit-domain-choice.is-unpurchased { color:#68777e; }
@media (max-width:760px) { .unit-domain-choice-list { grid-template-columns:1fr; } }
.user-detail-columns { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:12px; }
.user-detail-columns section { min-width:0; padding:14px; border:1px solid var(--line); border-radius:7px; background:#0d1417; }
.user-detail-columns h3 { margin:0 0 10px; font-size:13px; }
.detail-kv { margin:0; display:grid; }
.detail-kv > div { display:grid; grid-template-columns:96px minmax(0,1fr); gap:10px; padding:7px 0; border-bottom:1px solid #1d272b; }
.detail-kv dt { color:var(--muted); font-size:10px; }
.detail-kv dd { margin:0; font-size:11px; line-height:1.45; white-space:pre-wrap; overflow-wrap:anywhere; }
.drawer-inline-actions { display:flex; flex-wrap:wrap; gap:8px; padding:13px; border:1px solid #31514c; border-radius:7px; background:#0e1918; }

.profile-grid { display:grid; grid-template-columns:repeat(2,minmax(0,520px)); gap:18px; align-items:start; margin-top:22px; }
.settings-card { display:grid; gap:14px; padding:20px; border:1px solid var(--line); border-radius:8px; background:#0e1417; }
.settings-card h2 { margin:0; font-size:16px; }
.settings-card > p { margin:-5px 0 2px; color:var(--muted); font-size:12px; line-height:1.55; }
.settings-card > label { display:grid; gap:6px; color:var(--muted); font-size:12px; }
.settings-card .button { justify-self:start; }

.record-drawer { width:min(700px,100vw); max-width:none; height:100vh; max-height:100vh; margin:0 0 0 auto; border-radius:0; border-width:0 0 0 1px; }
.record-drawer[open] { animation:drawer-in .18s ease both; }
.record-drawer form { height:100%; display:grid; grid-template-rows:auto minmax(0,1fr) auto auto; }
.record-drawer .dialog-head { align-items:flex-start; background:#0d1417; }
.record-drawer-body { max-height:none; overflow:auto; align-content:start; }
.record-drawer .dialog-foot { position:sticky; bottom:0; background:#11171b; }
.drawer-error { padding:0 20px; }
.form-section-title { grid-column:1 / -1; margin:7px 0 0; padding-top:14px; border-top:1px solid var(--line); }
.form-section-title h3 { margin:0 0 5px; font-size:13px; }
.form-section-title p { margin:0; color:var(--muted); font-size:11px; line-height:1.55; }
.qa-reference-list { display:flex; flex-wrap:wrap; gap:5px; min-width:120px; }
.qa-reference-list.detail { gap:7px; }
.qa-reference { max-width:260px; border:1px solid var(--line); border-radius:999px; padding:3px 8px; color:var(--muted); background:#0d1417; cursor:pointer; font:10px/1.35 ui-monospace,monospace; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.qa-reference.allowed { color:#9ce0d4; border-color:#28564f; background:#10201d; }
.qa-reference.allowed:hover { border-color:var(--accent); color:var(--text); }
.qa-reference.denied { color:#718087; cursor:not-allowed; }
.message-detail-thread { display:grid; gap:9px; }
.message-thread-row { max-width:90%; padding:10px 12px; border:1px solid var(--line); border-radius:7px; background:#0d1417; }
.message-thread-row.patient { justify-self:start; }
.message-thread-row.ai,.message-thread-row.human { justify-self:end; }
.message-thread-row.ai { color:#b7c4c8; }
.message-thread-row.human { border-color:#28564f; background:#10201d; }
.message-thread-row strong,.message-thread-row small { display:block; }
.message-thread-row strong { font-size:11px; }
.message-thread-row p { margin:5px 0; white-space:pre-wrap; overflow-wrap:anywhere; font-size:12px; line-height:1.6; }
.message-thread-row small { color:var(--muted); font:9px/1.4 ui-monospace,monospace; }
.message-annotation-list { display:grid; gap:8px; }
.message-annotation-list article { padding:10px 12px; border:1px solid var(--line); border-radius:6px; background:#0d1417; }
.message-annotation-list strong { font-size:11px; }
.message-annotation-list p { margin:5px 0; white-space:pre-wrap; font-size:11px; line-height:1.5; }
.message-annotation-list small { color:var(--muted); font:9px ui-monospace,monospace; }
@keyframes drawer-in { from { opacity:0; transform:translateX(22px); } to { opacity:1; transform:none; } }

.api-panel { display:grid; gap:22px; min-width:0; }
.channel-tabs { display:flex; gap:6px; width:max-content; max-width:100%; padding:4px; border:1px solid var(--line); border-radius:8px; background:#0b1114; }
.channel-tab { border:0; border-radius:5px; padding:9px 16px; background:transparent; color:var(--muted); cursor:pointer; font:600 12px inherit; }
.channel-tab:hover { color:var(--text); background:#141d21; }
.channel-tab.active { color:#071310; background:var(--accent); }
.channel-filter-bar { display:grid; grid-template-columns:minmax(280px,1fr) 170px auto; gap:8px; margin:14px 0 10px; }
.wxkf-accounts .channel-filter-bar { grid-template-columns:minmax(260px,1fr) minmax(190px,260px) 150px auto; }
.channel-filter-bar input, .channel-filter-bar select { min-width:0; }
.api-builder, .api-list-section, .api-docs-card { min-width:0; border:1px solid var(--line); background:#0e1417; border-radius:8px; padding:18px; }
.wxkf-connectors { border-color:#31514c; background:linear-gradient(180deg,#0f1919 0,#0e1417 100%); }
.wxkf-accounts { border-color:#2d4658; }
.connector-security-note { margin:-2px 0 14px; padding:10px 12px; border:1px solid var(--line); border-radius:6px; color:var(--muted); font-size:12px; line-height:1.5; }
.connector-security-note.ok { border-color:#28564f; background:#0c1917; }
.connector-security-note.bad { border-color:#673c3c; background:#1b1112; }
.connector-stepper { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:1px; margin:0 0 18px; padding:0; list-style:none; border:1px solid var(--line); border-radius:6px; overflow:hidden; background:var(--line); }
.connector-stepper li { display:flex; gap:10px; min-width:0; padding:11px 12px; background:#10181b; }
.connector-stepper strong { color:var(--accent); font:600 11px/1.4 ui-monospace,monospace; }
.connector-stepper span { display:grid; gap:3px; font-size:12px; }
.connector-stepper small { color:var(--muted); font-size:10px; line-height:1.35; }
.credential-input { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:7px; }
.connector-secret-form { display:grid; grid-template-columns:minmax(240px,1.2fr) minmax(260px,1fr) auto; gap:16px; align-items:end; margin:18px 0 0; padding:16px; border:1px solid #3a675f; border-radius:6px; background:#0b1716; }
.connector-secret-form p { margin:5px 0 0; color:var(--muted); font-size:11px; line-height:1.5; }
.connector-secret-form label { display:grid; gap:6px; color:var(--muted); font-size:12px; }
.connector-secret-form .error-banner { grid-column:1 / -1; }
.connector-watch { display:flex; align-items:center; justify-content:flex-end; gap:10px; min-height:34px; }
.connector-watch span { font-size:11px; }
.callback-token-input { width:min(100%,260px); }
.callback-aes-input { width:100%; min-width:360px; letter-spacing:.03em; }
.callback-aes-field { min-width:390px; }
.connector-table { min-width:1280px; margin-top:18px; }
.wxkf-account-table { min-width:1380px; margin-top:18px; }
.wxkf-avatar-picker { display:flex; align-items:center; gap:12px; min-height:58px; }
.wxkf-avatar-picker > div:last-child { display:grid; gap:7px; min-width:0; }
.wxkf-avatar-picker input[type="file"] { width:100%; color:var(--muted); font-size:11px; }
.wxkf-avatar-preview { width:52px; height:52px; flex:0 0 52px; display:grid; place-items:center; overflow:hidden; border:1px solid #365b56; border-radius:10px; background:#132724; color:var(--accent); font:700 11px ui-monospace,monospace; }
.wxkf-avatar-preview img { width:100%; height:100%; object-fit:cover; }
.wxkf-avatar-preview.has-custom { border-color:#538d84; background:#0d1719; }
.wxkf-avatar-preview.is-default span { letter-spacing:.02em; }
.wxkf-remote-avatar-status { display:flex; flex-wrap:wrap; align-items:center; gap:5px; margin-top:6px; font-size:10px; }
.wxkf-contact-delivery { display:grid; gap:8px; min-width:290px; max-width:430px; }
.wxkf-contact-url { display:block; padding:7px 8px; border:1px solid #2b393f; border-radius:5px; color:#9ed3cb; background:#0a1012; font:10px/1.45 ui-monospace,SFMono-Regular,Menlo,monospace; overflow-wrap:anywhere; user-select:all; }
.wxkf-delivery-actions { flex-wrap:wrap; white-space:normal; }
.wxkf-delivery-actions .button { text-decoration:none; }
.knowledge-scope-builder { display:grid; gap:14px; padding:15px; border:1px solid #315b55; border-radius:7px; background:#0b1716; }
.knowledge-scope-head { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; }
.knowledge-scope-head > div { display:grid; gap:5px; }
.knowledge-scope-head strong { color:var(--text); font-size:14px; }
.knowledge-scope-head small { color:var(--muted); line-height:1.45; }
.knowledge-picker-grid { display:grid; grid-template-columns:minmax(240px,.85fr) minmax(300px,1.15fr); gap:14px; align-items:start; }
.knowledge-picker-grid .field { min-width:0; }
.knowledge-picker-grid select { width:100%; }
.multi-check-picker { position:relative; min-width:0; border:1px solid #354148; border-radius:5px; background:#0c1215; }
.multi-check-picker summary { display:flex; align-items:center; justify-content:space-between; gap:12px; min-height:40px; padding:9px 11px; cursor:pointer; color:var(--text); list-style:none; }
.multi-check-picker summary::-webkit-details-marker { display:none; }
.multi-check-picker summary span { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.multi-check-picker summary b { flex:0 0 auto; color:var(--accent); font-size:10px; font-weight:600; }
.multi-check-picker[open] summary { border-bottom:1px solid #354148; }
.multi-check-picker[open] summary b::before { content:"收起"; font-size:10px; }
.multi-check-picker[open] summary b { font-size:0; }
.multi-check-picker.disabled { opacity:.55; pointer-events:none; }
.multi-check-options { display:grid; max-height:220px; overflow:auto; padding:6px; }
.multi-check-option { display:flex; align-items:flex-start; gap:9px; padding:8px; border-radius:4px; cursor:pointer; }
.multi-check-option:hover { background:#152025; }
.multi-check-option input { flex:0 0 auto; width:16px; height:16px; margin:2px 0 0; accent-color:var(--accent); }
.multi-check-option span { display:grid; min-width:0; gap:2px; }
.multi-check-option strong { font-size:12px; color:var(--text); font-weight:600; }
.multi-check-option small { color:var(--muted); font:10px ui-monospace,monospace; }
.multi-check-empty { margin:0; padding:16px 10px; color:var(--muted); text-align:center; font-size:11px; }
.channel-dialog { width:min(900px,calc(100vw - 32px)); }
.channel-dialog .connector-stepper { margin:16px 20px 0; }
.channel-dialog .form-grid { max-height:62vh; }
.callback-slug-editor { display:flex; align-items:center; min-width:0; border:1px solid #354148; border-radius:5px; overflow:hidden; background:#0c1215; }
.callback-slug-editor:focus-within { border-color:#527c76; }
.callback-slug-editor span { flex:0 0 auto; padding:9px 0 9px 10px; color:var(--muted); font:11px ui-monospace,monospace; white-space:nowrap; }
.callback-slug-editor input { min-width:150px; border:0; border-radius:0; padding-left:0; box-shadow:none; }
.callback-slug-editor input:focus { outline:0; }
.channel-dialog .api-url { display:block; padding:10px; border:1px solid var(--line); border-radius:5px; color:#9ed3cb; overflow-wrap:anywhere; }
.connector-table .connector-actions { flex-wrap:wrap; min-width:180px; }
.connector-setup-help { margin-top:14px; border-top:1px solid var(--line); padding-top:12px; color:var(--muted); font-size:12px; }
.connector-setup-help summary { width:max-content; color:var(--accent); cursor:pointer; }
.connector-setup-help ol { margin:12px 0 0; padding-left:22px; line-height:1.8; }
.api-builder-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; }
.api-builder-grid > label { display:grid; gap:6px; color:var(--muted); font-size:12px; align-content:start; }
.api-builder-grid > label small { min-height:16px; color:#6f7f86; line-height:1.45; }
.api-builder-grid .wide { grid-column:1 / -1; }
.api-create-row { display:flex; align-items:center; justify-content:space-between; gap:18px; border-top:1px solid var(--line); padding-top:14px; }
.api-table { min-width:1120px; }
.api-table .api-url { display:inline-block; margin-top:5px; max-width:380px; color:#8fbeb7; white-space:normal; overflow-wrap:anywhere; line-height:1.45; }
.api-docs-card h2 { margin:0 0 8px; font-size:15px; }
.api-docs-card > p { color:var(--muted); line-height:1.65; }
.api-contract-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:10px; }
.api-contract-grid > div { display:grid; gap:7px; padding:12px; background:#11191d; border:1px solid #202c31; border-radius:6px; }
.api-contract-grid strong { font-size:11px; color:var(--muted); }
.api-contract-grid code { color:var(--accent); overflow-wrap:anywhere; }
.api-created-dialog { width:min(860px,calc(100vw - 32px)); }
.api-created-body { display:grid; gap:15px; padding:20px; }
.api-created-body label { display:grid; gap:7px; color:var(--muted); font-size:12px; }
.api-created-body textarea[readonly], .api-created-body input[readonly] { color:#cce6e1; background:#0a1012; }

dialog { width: min(760px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); padding: 0; }
dialog::backdrop { background: rgba(0,0,0,.72); }
.dialog-head, .dialog-foot { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dialog-foot { border-top: 1px solid var(--line); border-bottom: 0; justify-content: flex-end; gap: 8px; }
.dialog-head h2 { margin: 0; font-size: 17px; }
.form-grid { padding: 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-height: 70vh; overflow: auto; }
.form-grid .wide { grid-column: 1 / -1; }
.check-field { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.check-field input { width: auto; }
.file-upload-row { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:8px; align-items:center; }
.file-upload-row input[type="file"] { padding:7px; }

@media (max-width: 980px) {
  .api-builder-grid { grid-template-columns:1fr 1fr; }
  .api-contract-grid { grid-template-columns:1fr 1fr; }
  .connector-stepper { grid-template-columns:1fr 1fr; }
  .connector-secret-form { grid-template-columns:1fr 1fr; }
  .connector-secret-form > div:first-child { grid-column:1 / -1; }
  .callback-aes-field { min-width:0; }
  .callback-aes-input { min-width:0; }
}

@media (max-width: 720px) {
  .topbar { padding:0 14px; }
  .top-actions { gap:9px; font-size:11px; }
  .admin-layout { display:block; }
  .side-nav { display:flex; gap:4px; overflow-x:auto; padding:9px 10px; border-right:0; border-bottom:1px solid var(--line); }
  .side-link { flex:0 0 auto; width:auto; margin:0; white-space:nowrap; }
  .side-link span { width:24px; }
  .admin-shell { padding:18px 14px 36px; overflow:hidden; }
  .summary-item { min-width:50%; padding-right:12px; }
  .api-builder-grid, .api-contract-grid { grid-template-columns:1fr; }
  .api-create-row { align-items:stretch; flex-direction:column; }
  .api-builder, .api-list-section, .api-docs-card { padding:14px; }
  .subsection-head { align-items:flex-start; gap:12px; }
  .connector-stepper, .connector-secret-form { grid-template-columns:1fr; }
  .connector-secret-form > div:first-child { grid-column:auto; }
  .connector-watch { align-items:flex-end; flex-direction:column; }
  .channel-tabs { width:100%; }
  .channel-tab { flex:1 1 50%; }
  .channel-filter-bar, .wxkf-accounts .channel-filter-bar { grid-template-columns:1fr; }
  .callback-slug-editor { align-items:stretch; flex-direction:column; }
  .callback-slug-editor span { padding-bottom:3px; white-space:normal; overflow-wrap:anywhere; }
  .callback-slug-editor input { padding:5px 10px 9px; }
}
.source-document-info { min-height:20px; font-size:12px; overflow-wrap:anywhere; }
.source-document-info a { font-weight:650; }
.document-picker-dialog { width:min(920px,calc(100vw - 32px)); }
.document-picker-body { padding:20px; display:grid; gap:12px; }
.document-picker-search { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:8px; }
.document-picker-dialog .table-wrap { max-height:52vh; overflow:auto; }
.document-picker-dialog td:first-child { min-width:260px; overflow-wrap:anywhere; }
.notice { color: var(--muted); font-size: 12px; line-height: 1.6; }
.error-banner { color: var(--danger); min-height: 18px; font-size: 12px; }
.auth-page { min-height:100vh; display:grid; place-items:center; padding:24px; background:radial-gradient(circle at 50% 0,#12201f 0,var(--bg) 42%); }
.auth-card { width:min(420px,100%); border:1px solid var(--line); background:var(--surface); padding:32px; border-radius:8px; box-shadow:0 24px 80px rgba(0,0,0,.3); }
.auth-card h1 { margin:32px 0 8px; font-size:24px; }
.auth-card p { color:var(--muted); margin:0 0 24px; }
.auth-card form { display:grid; gap:17px; }
.auth-card .button { width:100%; }
.panel-title { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-bottom:16px; }
.panel-title h1 { margin:0; font-size:18px; }
.section-head { display:flex; align-items:flex-start; justify-content:space-between; gap:20px; border-bottom:1px solid var(--line); padding-bottom:18px; }
.section-head h1 { margin:0 0 6px; font-size:20px; }
.section-head p { margin:0; color:var(--muted); font-size:12px; }
.strategy-meta { display:flex; gap:22px; flex-wrap:wrap; padding:16px 0 0; color:var(--muted); font:12px ui-monospace,monospace; }
.strategy-form { padding-left:0; padding-right:0; max-height:none; }
.strategy-form small { line-height:1.6; overflow-wrap:anywhere; }
.strategy-visual, .strategy-controls { margin-top:24px; border-top:1px solid var(--line); padding-top:20px; }
.template-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
.template-card { display:grid; gap:7px; border:1px solid var(--line); background:#0e1417; padding:14px; border-radius:6px; cursor:pointer; }
.template-card:has(input:checked) { border-color:#38766c; box-shadow:inset 3px 0 0 var(--accent); }
.template-card.current { border-color:#38766c; background:#101c1a; }
.template-card header { display:flex; align-items:center; gap:9px; }
.template-card strong { font-size:13px; }
.template-card p,.template-card small { margin:0; color:var(--muted); font-size:11px; line-height:1.5; }
.template-card .row-actions { margin-top:4px; }
.template-card .live-indicator { margin-left:auto; }
.strategy-switch-row { display:flex; align-items:end; gap:10px; margin-top:12px; }
.strategy-switch-row label { display:grid; gap:6px; min-width:360px; color:var(--muted); font-size:11px; }
.runtime-profile-selector { display:grid; grid-template-columns:minmax(260px,360px) minmax(0,1fr); gap:12px; align-items:stretch; }
.runtime-profile-selector > label { display:grid; align-content:start; gap:7px; color:var(--muted); font-size:11px; }
.runtime-profile-summary { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:8px; }
.runtime-profile-fact { border:1px solid var(--line); background:#0e1417; border-radius:6px; padding:10px 11px; display:grid; align-content:start; gap:5px; min-height:65px; }
.runtime-profile-fact strong { color:var(--text); font-size:12px; overflow-wrap:anywhere; }
.runtime-profile-fact span { color:var(--muted); font-size:10px; line-height:1.45; }
.runtime-profile-fact.wide { grid-column:span 2; }
.rederive-warning { margin-top:12px; border:1px solid #6c5830; border-left:3px solid var(--warning); background:rgba(201,157,70,.07); padding:11px 13px; border-radius:5px; display:grid; gap:4px; }
.rederive-warning strong { color:#e4bc6c; font-size:12px; }
.rederive-warning span { color:var(--muted); font-size:11px; line-height:1.55; }
.rederive-warning.compact { margin:0 0 12px; }
.chunk-form-section { grid-column:1/-1; border:1px solid #31413f; background:#0d1516; border-radius:6px; padding:14px; display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:13px; }
.chunk-form-section > header { grid-column:1/-1; display:flex; align-items:flex-start; justify-content:space-between; gap:12px; padding-bottom:10px; border-bottom:1px solid var(--line); }
.chunk-form-section > .wide { grid-column:1/-1; }
.chunk-form-section h3 { margin:0 0 4px; font-size:13px; }
.chunk-form-section header p { margin:0; color:var(--muted); font-size:10px; line-height:1.5; }
.chunk-form-section .check-field { min-height:42px; align-content:center; }
.chunk-profile-cell { min-width:245px; }
.chunk-profile-cell strong { display:block; margin-bottom:4px; }
.chunk-profile-cell span { display:block; color:var(--muted); font-size:10px; line-height:1.45; }
.profile-name-line { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.current-runtime-profile { background:color-mix(in srgb,var(--accent) 6%,transparent); }
.policy-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; }
.locked-control b { color:var(--warning); font:10px ui-monospace,monospace; letter-spacing:.08em; }
.attention-row { box-shadow:inset 3px 0 0 var(--danger); background:rgba(164,62,62,.06); }
.subsection-head { display:flex; align-items:flex-start; justify-content:space-between; gap:20px; margin-bottom:16px; }
.subsection-head h2 { margin:0 0 6px; font-size:15px; letter-spacing:.01em; }
.subsection-head p { margin:0; color:var(--muted); font-size:12px; line-height:1.6; max-width:760px; }
.live-indicator { color:var(--accent); border:1px solid #28564f; padding:5px 8px; border-radius:4px; font:10px ui-monospace,monospace; letter-spacing:.08em; }
.strategy-flow { max-width:940px; }
.flow-step { display:grid; grid-template-columns:42px minmax(0,1fr); align-items:start; gap:12px; }
.flow-index { width:34px; height:34px; display:grid; place-items:center; border:1px solid #365048; border-radius:50%; color:var(--accent); font:10px ui-monospace,monospace; background:#0d1616; }
.flow-copy { min-height:34px; padding:7px 0; display:grid; gap:5px; }
.flow-copy > strong { font-size:13px; font-weight:680; }
.flow-copy > span { color:var(--muted); font-size:12px; line-height:1.5; }
.flow-connector { width:42px; height:18px; display:grid; place-items:center; }
.flow-connector span { display:block; width:1px; height:18px; background:#365048; position:relative; }
.flow-connector span::after { content:""; position:absolute; bottom:-1px; left:-3px; width:5px; height:5px; border-right:1px solid var(--accent); border-bottom:1px solid var(--accent); transform:rotate(45deg); }
.flow-options { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; margin-top:4px; }
.flow-option { border-left:2px solid var(--accent); background:#101a1d; padding:10px 12px; display:grid; gap:4px; min-height:62px; }
.flow-option.terminal { border-left-color:var(--warning); }
.flow-option strong { font-size:12px; }
.flow-option span { color:var(--muted); font-size:11px; line-height:1.45; }
.parameter-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; }
.parameter-control { border:1px solid var(--line); background:#0e1417; padding:12px; min-height:94px; display:grid; align-content:space-between; gap:13px; border-radius:6px; }
.parameter-label { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
.parameter-label > span, .toggle-control > span { display:grid; gap:5px; }
.parameter-control strong { font-size:12px; font-weight:650; }
.parameter-control small { color:var(--muted); font-size:10px; line-height:1.4; }
.parameter-control input[type="number"] { width:76px; padding:6px 7px; text-align:right; font:12px ui-monospace,monospace; }
.parameter-range { padding:0; border:0; accent-color:var(--accent); height:18px; }
.toggle-control { display:flex; align-items:center; justify-content:space-between; cursor:pointer; }
.toggle-control input { width:38px; height:20px; accent-color:var(--accent); }
.prompt-field { border-top:1px solid #20292e; padding-top:16px; }
.field-heading { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.field-heading span { color:var(--muted); font:10px ui-monospace,monospace; }
.advanced-settings { border-top:1px solid var(--line); border-bottom:1px solid var(--line); }
.advanced-settings summary { cursor:pointer; padding:14px 2px; color:var(--muted); font-size:12px; }
.advanced-settings[open] summary { color:var(--text); border-bottom:1px solid var(--line); }
.advanced-content { display:grid; gap:18px; padding:18px 0 4px; }

.fullscreen-capable.is-fullscreen { position:fixed; inset:0; z-index:900; overflow:auto; padding:24px 30px; background:var(--bg); }
body.admin-fullscreen-active { overflow:hidden; }
.handoff-dialog { width:min(1380px,calc(100vw - 24px)); height:min(900px,calc(100vh - 24px)); max-width:none; max-height:none; }
.handoff-dialog.is-fullscreen { width:100vw; height:100vh; margin:0; border-radius:0; border:0; }
.handoff-dialog-shell { height:100%; min-height:0; display:grid; grid-template-rows:auto minmax(0,1fr); }
.handoff-dialog-head { display:flex; justify-content:space-between; align-items:flex-start; gap:20px; padding:16px 20px; border-bottom:1px solid var(--line); background:#0c1215; }
.handoff-dialog-head h2 { margin:2px 0 4px; font-size:17px; }
.handoff-dialog-head p { margin:0; color:var(--muted); font-size:11px; }
.handoff-kicker { color:var(--accent) !important; font:10px ui-monospace,monospace; letter-spacing:.1em; text-transform:uppercase; }
.handoff-dialog-main { min-height:0; display:grid; grid-template-columns:minmax(0,1fr) 320px; }
.handoff-chat-column { min-height:0; display:grid; grid-template-rows:auto auto minmax(160px,1fr) auto auto; }
.handoff-risk-strip { display:flex; flex-wrap:wrap; gap:8px 16px; padding:9px 16px; border-bottom:1px solid var(--line); color:var(--muted); font-size:11px; }
#handoffTargetLabel { margin-left:auto; color:var(--accent); }
.handoff-account-cell { min-width:150px; max-width:230px; }
.handoff-account-name { color:var(--accent); font-weight:650; overflow-wrap:anywhere; }
.patient-display-name { color:var(--accent); font-size:14px; font-weight:750; overflow-wrap:anywhere; }
.patient-name-inline { display:inline-block; margin-top:3px; color:var(--accent); font-size:11px; font-weight:700; }
.patient-identity-hero { display:grid; gap:4px; padding:16px 18px; border:1px solid #315f56; border-radius:8px; background:linear-gradient(120deg,#10201d,#0d1618); }
.patient-identity-hero span,.patient-identity-hero small { color:var(--muted); font-size:10px; letter-spacing:.04em; }
.patient-identity-hero strong { color:var(--accent); font-size:24px; line-height:1.25; overflow-wrap:anywhere; }
.handoff-entry-notice { display:flex; align-items:center; justify-content:space-between; gap:16px; margin:10px 0 14px; padding:10px 12px; border:1px solid #315566; border-radius:6px; color:#b8d9e2; background:#0e1a20; font-size:11px; }
.handoff-load-older { justify-self:center; margin:8px 0 0; }
.handoff-feed { overflow:auto; padding:14px clamp(16px,3vw,38px) 26px; scroll-behavior:smooth; }
.handoff-bubble-row { display:flex; align-items:flex-start; gap:8px; margin:10px 0; }
.handoff-bubble-row.patient { justify-content:flex-start; }
.handoff-bubble-row.agent,.handoff-bubble-row.ai,.handoff-bubble-row.assist { justify-content:flex-end; }
.handoff-bubble { max-width:min(78%,720px); padding:10px 12px; border:1px solid var(--line); border-radius:8px; background:#121a1e; white-space:pre-wrap; overflow-wrap:anywhere; line-height:1.6; font-size:12px; }
.handoff-bubble.patient { background:#11191c; cursor:pointer; }
.handoff-bubble.patient.selected { border-color:var(--accent); box-shadow:0 0 0 1px #2b655d; }
.handoff-bubble.agent { border-color:#28564f; background:#10201d; }
.handoff-bubble.ai { color:#b7c4c8; }
.handoff-bubble.assist { border-color:#5d5436; background:#1a1710; }
.handoff-bubble-meta { display:block; margin-top:7px; color:var(--muted); font:9px ui-monospace,monospace; }
.handoff-target-dot { flex:0 0 12px; width:12px; height:12px; margin-top:12px; padding:0; border:1px solid #5c6b72; border-radius:50%; background:transparent; cursor:pointer; }
.handoff-target-dot.replyable { border-color:var(--accent); }
.handoff-target-dot.selected { background:var(--accent); box-shadow:0 0 0 3px rgba(88,214,194,.15); }
.handoff-target-dot.disabled { opacity:.35; cursor:not-allowed; }
.handoff-assist-card { display:grid; gap:8px; padding:12px 16px; border-top:1px solid var(--line); background:#0d1417; }
.handoff-assist-card > div:first-child { display:flex; align-items:baseline; gap:10px; }
.handoff-assist-card strong { font-size:12px; }
.handoff-assist-card small { color:var(--muted); font-size:10px; }
.handoff-assist-row { display:grid; grid-template-columns:minmax(0,1fr) auto auto; gap:7px; }
.handoff-assist-card textarea { min-height:54px; font-size:11px; }
.handoff-composer { display:grid; gap:8px; padding:12px 16px 16px; border-top:1px solid var(--line); background:#0c1215; }
.handoff-composer textarea { min-height:88px; }
.handoff-composer textarea:disabled { color:#7e8b91; border-color:#222c31; background:#0a0f12; cursor:not-allowed; opacity:.72; }
.handoff-reply-guard,.handoff-delivery-status { min-height:30px; padding:7px 10px; border:1px solid var(--line); border-radius:6px; font-size:11px; line-height:1.45; }
.handoff-reply-guard.neutral,.handoff-delivery-status.neutral { color:var(--muted); background:#0d1417; }
.handoff-reply-guard.ok,.handoff-delivery-status.ok { color:var(--accent); border-color:#28564f; background:#10201d; }
.handoff-reply-guard.warn { color:var(--warning); border-color:#5d5436; background:#1a1710; }
.handoff-reply-guard.bad,.handoff-delivery-status.bad { color:var(--danger); border-color:#663b3b; background:#211313; }
.handoff-delivery-status.pending { color:#90cfe1; border-color:#315566; background:#0e1a20; }
.handoff-composer-tools { display:flex; flex-wrap:wrap; align-items:center; gap:8px; }
.handoff-composer-tools .spacer { flex:1; }
.attachment-button { display:inline-flex; align-items:center; cursor:pointer; }
.attachment-button.disabled { opacity:.45; cursor:not-allowed; }
#handoffAttachmentName { max-width:260px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:10px; }
#handoffAttachmentName.has-file { color:var(--text); max-width:340px; }
#handoffAttachmentName.blocked { color:var(--warning); }
.handoff-composer .button:disabled { cursor:not-allowed; }
.handoff-profile-column { min-height:0; overflow:auto; border-left:1px solid var(--line); padding:18px; background:#0c1215; }
.handoff-profile-column h3 { margin:0 0 12px; font-size:12px; }
.handoff-profile-column section { margin-top:22px; padding-top:18px; border-top:1px solid var(--line); }
.handoff-profile-head { display:flex; align-items:flex-start; justify-content:space-between; gap:10px; }
.handoff-profile-grid { display:grid; gap:0; margin:0; }
.handoff-profile-grid > div { display:grid; grid-template-columns:92px minmax(0,1fr); gap:10px; padding:8px 0; border-bottom:1px solid #1b2529; }
.handoff-profile-grid dt { color:var(--muted); font-size:10px; }
.handoff-profile-grid dd { margin:0; font-size:11px; line-height:1.5; white-space:pre-wrap; overflow-wrap:anywhere; }

@keyframes rise { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (max-width: 900px) {
  .template-grid,.policy-grid { grid-template-columns:1fr; }
  .runtime-profile-selector { grid-template-columns:1fr; }
  .runtime-profile-summary { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .chunk-form-section { grid-template-columns:1fr; }
  .chunk-form-section > header,.chunk-form-section > .wide { grid-column:auto; }
  .chat-shell { grid-template-columns: 1fr; }
  .inspector { border-left: 0; border-top: 1px solid var(--line); max-height: 50vh; }
  .admin-shell { padding: 20px 14px 40px; }
  .admin-layout { grid-template-columns:1fr; }
  .side-nav { position:sticky; top:0; z-index:3; border-right:0; border-bottom:1px solid var(--line); display:flex; padding:8px; overflow:auto; }
  .side-link { width:auto; white-space:nowrap; margin:0; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .parameter-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .flow-options { grid-template-columns:1fr; }
  .handoff-toolbar { grid-template-columns:1fr 1fr; }
  .qa-filter-bar { flex-wrap:wrap; }
  .qa-filter-bar #qaSearch { order:3; flex:1 1 100%; }
  .qa-filter-bar #qaAnswerStatus, .qa-filter-bar #qaDerivation { flex:1 1 calc(50% - 4px); }
  .qa-library-context { align-items:stretch; flex-direction:column; }
  .qa-library-selectors { width:100%; }
  .qa-library-selectors label { flex:1 1 0; }
  .qa-library-selectors select, .qa-library-selectors #unitId { width:100%; min-width:0; }
  .knowledge-picker-grid { grid-template-columns:1fr; }
  .knowledge-scope-head { align-items:flex-start; flex-direction:column; }
  .profile-grid { grid-template-columns:1fr; }
  .handoff-dialog-main { grid-template-columns:1fr; }
  .handoff-profile-column { display:none; }
  .permission-grid { grid-template-columns:1fr; }
  .account-scope-bar { align-items:stretch; flex-direction:column; }
  .account-scope-bar label { min-width:0; width:100%; }
  .user-detail-columns { grid-template-columns:1fr; }
  .qa-heading { align-items:stretch; flex-direction:column; }
  .batch-bar { overflow:auto; }
}
@media (max-width: 620px) {
  .topbar { padding:0 16px; }
  .transcript { padding-left:20px; padding-right:20px; }
  .composer { padding-left:20px; padding-right:20px; }
  .composer-row { flex-wrap:wrap; }
  .composer-row .unit { width:calc(50% - 5px); min-width:0; }
  .composer-row .hint { flex:1 1 calc(100% - 74px); }
  .composer-row .button { flex:0 0 auto; }
  .parameter-grid { grid-template-columns:1fr; }
  .runtime-profile-summary { grid-template-columns:1fr; }
  .runtime-profile-fact.wide { grid-column:auto; }
  .section-head { align-items:stretch; flex-direction:column; }
  .section-head .button { width:100%; }
  .handoff-toolbar { grid-template-columns:1fr; }
  .file-upload-row { grid-template-columns:1fr; }
  .document-picker-search { grid-template-columns:1fr; }
  .qa-library-selectors, .qa-create-actions { align-items:stretch; flex-direction:column; }
  .qa-create-actions .row-actions { width:100%; }
  .qa-create-actions .button { flex:1 1 0; }
  .filter-bar { align-items:stretch; flex-direction:column; }
  .filter-bar input,.filter-bar select,.filter-bar .button { width:100%; flex:0 0 auto; }
  .record-drawer { width:100vw; }
  .handoff-dialog { width:100vw; height:100vh; margin:0; border-radius:0; border:0; }
  .handoff-assist-row { grid-template-columns:1fr 1fr; }
  .handoff-assist-row input { grid-column:1 / -1; }
}
