:root {
  color-scheme: light;
  --canvas: #f2f1ed;
  --surface: #fbfbf8;
  --surface-strong: #ffffff;
  --ink: #1d2523;
  --muted: #69736f;
  --line: #d9ddd8;
  --line-strong: #bcc4be;
  --charcoal: #202725;
  --charcoal-2: #303936;
  --orange: #c65c2b;
  --orange-dark: #93401d;
  --orange-soft: #fff0e8;
  --red: #b53a34;
  --red-soft: #fff0ef;
  --yellow: #a86a13;
  --yellow-soft: #fff7df;
  --blue: #39718b;
  --blue-soft: #edf7fa;
  --green: #33745a;
  --green-soft: #edf7f1;
  --gray: #79827e;
  --gray-soft: #f0f2f0;
  --shadow: 0 14px 34px rgba(28, 36, 33, .08);
  font-family: "SF Pro Display", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body { min-width: 320px; min-height: 100dvh; margin: 0; color: var(--ink); background: var(--canvas); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid rgba(198, 92, 43, .28); outline-offset: 2px; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 7px; color: var(--orange-dark); font-size: 12px; font-weight: 600; letter-spacing: 1.5px; }
.brand-seal { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 13px; color: #fff; background: var(--orange); font-weight: 600; box-shadow: inset 0 -7px 14px rgba(86, 30, 10, .16); }
.brand-seal.small { width: 38px; height: 38px; border-radius: 10px; font-size: 14px; }

.button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; border: 1px solid transparent; border-radius: 9px; cursor: pointer; text-decoration: none; font-size: 13px; font-weight: 600; transition: background .16s, border-color .16s, color .16s, transform .16s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.button.primary { color: #fff; background: var(--orange); }
.button.primary:hover { background: var(--orange-dark); }
.button.secondary { border-color: var(--line-strong); color: var(--ink); background: #fff; }
.button.secondary:hover { border-color: var(--orange); color: var(--orange-dark); }
.button.ghost { border-color: transparent; color: var(--muted); background: transparent; }
.button.compact { min-height: 36px; padding: 7px 11px; font-size: 12px; }
.button.full { width: 100%; margin-top: 10px; }
.text-link { display: block; margin-top: 18px; color: var(--muted); text-align: center; font-size: 12px; }
.icon-button { width: 36px; height: 36px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; cursor: pointer; font-size: 22px; }

.login-screen { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 18% 12%, rgba(198, 92, 43, .11), transparent 33%), linear-gradient(145deg, #eeece6, #f7f6f2); }
.login-card { width: min(450px, 100%); padding: 36px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.95); box-shadow: var(--shadow); }
.login-card h1 { margin: 18px 0 8px; font-size: 30px; letter-spacing: -.8px; }
.login-card > .muted { margin: 0 0 22px; line-height: 1.65; font-size: 13px; }
.field { display: grid; gap: 7px; }
.field > span, .compact-field > span { color: var(--muted); font-size: 12px; font-weight: 600; }
.field input, .field select, .compact-field select { width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 9px; color: var(--ink); background: #fff; }
.code-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px; align-items: end; margin-top: 15px; }
.captcha-container { min-height: 1px; margin-top: 12px; }
.form-error { min-height: 19px; margin: 11px 0; color: var(--red); font-size: 12px; }

.app-shell { min-height: 100dvh; }
.topbar { position: sticky; top: 0; z-index: 40; min-height: 68px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 22px; padding: 10px 22px; border-bottom: 1px solid #39413e; color: #fff; background: rgba(32, 39, 37, .97); backdrop-filter: blur(14px); }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.brand span:last-child { display: grid; }
.brand small { color: #aeb7b2; font-size: 12px; font-weight: 600; letter-spacing: 1.25px; }
.brand strong { margin-top: 2px; font-size: 15px; }
.topbar-center { min-width: 0; display: flex; align-items: center; gap: 12px; }
.live-state { display: inline-flex; align-items: center; gap: 7px; color: #c9d1cd; font-size: 12px; }
.live-state i { width: 8px; height: 8px; border-radius: 50%; background: #60bd8e; box-shadow: 0 0 0 5px rgba(96, 189, 142, .12); }
.live-state.syncing i { background: #d79a46; }
.live-state.stale i { background: #d05a51; }
.stale-banner { min-width: 0; overflow: hidden; color: #ffd6c3; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.topbar .button.secondary { border-color: #59635f; color: #f7f8f7; background: #313a37; }
.topbar .button.ghost { color: #c3cbc7; }
.compact-field { display: flex; align-items: center; gap: 7px; }
.compact-field > span { color: #aeb7b2; white-space: nowrap; }
.compact-field select { min-height: 36px; width: 160px; padding: 6px 9px; border-color: #59635f; color: #fff; background: #313a37; font-size: 12px; }
.identity-label { max-width: 140px; overflow: hidden; color: #cbd2cf; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

.main-view { width: min(1680px, 100%); margin: 0 auto; padding: 24px 26px 46px; }
.loading-state { min-height: 280px; display: grid; place-items: center; align-content: center; gap: 13px; color: var(--muted); font-size: 13px; }
.loading-state span { width: 24px; height: 24px; border: 3px solid var(--line); border-top-color: var(--orange); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: clamp(26px, 3vw, 39px); letter-spacing: -1.3px; }
.page-head p { max-width: 720px; margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.page-meta { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; white-space: nowrap; }
.metric-context { margin: -6px 0 10px; color: var(--muted); font-size: 12px; line-height: 1.5; }

.metric-strip { display: grid; grid-template-columns: repeat(8, minmax(112px,1fr)); overflow: auto; margin-bottom: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-strong); box-shadow: 0 6px 20px rgba(30,39,36,.04); }
.metric { min-height: 92px; min-width: 112px; padding: 16px 15px; border: 0; border-right: 1px solid var(--line); color: inherit; background: transparent; text-align: left; }
.metric:is(button) { cursor: pointer; transition: background .16s; }
.metric:is(button):hover { background: #faf8f3; }
.metric:last-child { border-right: 0; }
.metric span, .fact span { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
.metric strong { display: block; margin-top: 9px; font-size: 25px; font-variant-numeric: tabular-nums; letter-spacing: -.8px; }
.metric.alert strong { color: var(--red); }

.desk-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(330px, .72fr); gap: 18px; align-items: start; }
.section-card { border: 1px solid var(--line); border-radius: 13px; background: var(--surface-strong); box-shadow: 0 5px 18px rgba(31,39,36,.035); }
.section-head { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.section-head h2 { margin: 0; font-size: 15px; }
.section-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.count-label { color: var(--muted); font-size: 12px; }
.account-wall { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 11px; padding: 12px; background: #f8f8f5; }
.account-card { position: relative; min-height: 192px; display: flex; flex-direction: column; padding: 16px; overflow: hidden; border: 1px solid var(--line); border-left: 5px solid var(--gray); border-radius: 10px; color: inherit; background: #fff; text-decoration: none; transition: box-shadow .16s, transform .16s; }
.account-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.account-card.red { border-left-color: var(--red); background: linear-gradient(125deg, var(--red-soft), #fff 34%); }
.account-card.yellow { border-left-color: var(--yellow); background: linear-gradient(125deg, var(--yellow-soft), #fff 34%); }
.account-card.blue { border-left-color: var(--blue); background: linear-gradient(125deg, var(--blue-soft), #fff 34%); }
.account-card.green { border-left-color: var(--green); background: linear-gradient(125deg, var(--green-soft), #fff 34%); }
.account-card.gray { border-left-color: var(--gray); background: linear-gradient(125deg, var(--gray-soft), #fff 34%); }
.account-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.account-title h3 { min-width: 0; margin: 0; overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.account-title small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.tone-label { flex: 0 0 auto; padding: 4px 7px; border-radius: 99px; color: var(--gray); background: var(--gray-soft); font-size: 12px; font-weight: 600; }
.red .tone-label { color: var(--red); background: var(--red-soft); }
.yellow .tone-label { color: var(--yellow); background: var(--yellow-soft); }
.blue .tone-label { color: var(--blue); background: var(--blue-soft); }
.green .tone-label { color: var(--green); background: var(--green-soft); }
.account-facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 20px; }
.fact strong { display: block; margin-top: 5px; font-size: 18px; font-variant-numeric: tabular-nums; }
.account-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 17px; color: var(--muted); font-size: 12px; }
.account-foot b { color: var(--ink); }

.right-rail { display: grid; gap: 18px; }
.event-list, .exception-list { max-height: 690px; overflow: auto; }
.event-row { display: grid; grid-template-columns: 9px minmax(0,1fr) auto; gap: 10px; padding: 13px 15px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.event-row:last-child { border-bottom: 0; }
.event-row:hover { background: #faf8f3; }
.event-dot { width: 9px; height: 9px; margin-top: 4px; border-radius: 50%; background: var(--gray); }
.event-row.red .event-dot { background: var(--red); }
.event-row.yellow .event-dot { background: var(--yellow); }
.event-row.blue .event-dot { background: var(--blue); }
.event-row.green .event-dot { background: var(--green); }
.event-copy { min-width: 0; }
.event-kicker { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .25px; }
.event-copy strong { display: block; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.event-copy small { display: block; margin-top: 5px; overflow: hidden; color: var(--muted); font-size: 12px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.event-time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.empty-state { min-height: 180px; display: grid; place-items: center; align-content: center; gap: 10px; padding: 26px; color: var(--muted); text-align: center; font-size: 12px; line-height: 1.6; }
.empty-state strong { color: var(--ink); font-size: 15px; }

.filter-grid { display: grid; grid-template-columns: repeat(4, minmax(110px,1fr)) minmax(180px,1.5fr); gap: 9px; align-items: end; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fafaf7; }
.filter-grid label, .filter-control { min-width: 0; display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 600; }
.filter-grid select, .filter-grid input { width: 100%; min-width: 0; min-height: 36px; padding: 7px 9px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--ink); background: #fff; font-size: 12px; }
.account-multi { position: relative; }
.filter-label { min-height: 11px; }
.multi-trigger { width: 100%; min-height: 36px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 9px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--ink); background: #fff; cursor: pointer; font-size: 12px; text-align: left; }
.multi-trigger:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
.multi-trigger b { color: var(--muted); font-size: 12px; }
.multi-menu { position: absolute; top: calc(100% + 5px); left: 0; z-index: 30; width: max(100%, 230px); max-width: min(320px, calc(100vw - 40px)); overflow: hidden; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; box-shadow: var(--shadow); }
.multi-all { width: 100%; min-height: 38px; padding: 8px 11px; border: 0; border-bottom: 1px solid var(--line); color: var(--orange-dark); background: #faf8f3; cursor: pointer; font-size: 12px; font-weight: 600; text-align: left; }
.multi-options { max-height: 280px; overflow: auto; padding: 5px 10px; }
.multi-options label { min-height: 38px; display: flex; align-items: center; grid-template-columns: auto 1fr; gap: 9px; border-bottom: 1px solid var(--line); color: var(--ink); cursor: pointer; font-size: 12px; }
.multi-options label:last-child { border-bottom: 0; }
.multi-options input { width: 17px; min-height: 17px; height: 17px; padding: 0; accent-color: var(--orange); }
.compact-filters { grid-template-columns: repeat(2,minmax(110px,1fr)); }
.compact-filters .filter-query { grid-column: 1 / -1; }
.compact-filters .button { grid-column: 1 / -1; }
.handoff-list { max-height: 720px; overflow: auto; }
.handoff-row { display: block; padding: 14px 16px; border-bottom: 1px solid var(--line); border-left: 4px solid var(--yellow); color: inherit; background: #fff; text-decoration: none; }
.handoff-row:hover { background: #faf8f3; }
.handoff-row.failed { border-left-color: var(--red); background: linear-gradient(100deg, var(--red-soft), #fff 38%); }
.handoff-row.completed { border-left-color: var(--gray); }
.handoff-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.handoff-kind { color: var(--orange-dark); font-size: 12px; font-weight: 600; }
.handoff-state { padding: 3px 6px; border-radius: 99px; color: var(--yellow); background: var(--yellow-soft); font-size: 12px; font-weight: 600; }
.handoff-row.failed .handoff-state { color: var(--red); background: var(--red-soft); }
.handoff-row.completed .handoff-state { color: var(--gray); background: var(--gray-soft); }
.handoff-row > strong { display: block; font-size: 13px; }
.handoff-row > small { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.handoff-row p { margin: 9px 0 0; color: var(--ink); font-size: 12px; line-height: 1.55; }
.handoff-row p b { margin-right: 7px; color: var(--muted); font-size: 12px; }
.handoff-error { margin-top: 9px; padding: 8px; border-radius: 7px; color: var(--red); background: var(--red-soft); font-size: 12px; line-height: 1.5; }
.inline-more { padding: 11px; border-top: 1px solid var(--line); }
.event-center { margin-top: 18px; }
.filter-presets { display: flex; flex-wrap: wrap; gap: 7px; padding: 10px 16px 0; }
.filter-presets button { min-height: 30px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); background: #fff; cursor: pointer; font-size: 12px; font-weight: 600; }
.filter-presets button:hover { border-color: var(--orange); color: var(--orange-dark); }
.stream-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); max-height: 720px; margin-top: 10px; border-top: 1px solid var(--line); }
.stream-list .event-row:nth-child(odd) { border-right: 1px solid var(--line); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.search { width: min(380px,100%); min-height: 42px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: #fff; }
.conversation-list { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.conversation-row { display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 16px; align-items: center; padding: 15px 16px; border-bottom: 1px solid var(--line); text-decoration: none; }
.conversation-row:last-child { border-bottom: 0; }
.conversation-row:hover { background: #faf8f3; }
.conversation-row strong, .conversation-row small { display: block; }
.conversation-row small { margin-top: 4px; color: var(--muted); font-size: 12px; }
.conversation-count { color: var(--muted); font-size: 12px; }
.back-link { display: inline-flex; margin-bottom: 16px; color: var(--orange-dark); font-size: 12px; font-weight: 600; text-decoration: none; }

.detail-head-tools { display: grid; justify-items: end; gap: 11px; }
.mode-switch { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: #ebece8; }
.mode-switch button { min-height: 34px; padding: 7px 12px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; font-weight: 600; }
.mode-switch button[aria-pressed="true"] { color: var(--ink); background: #fff; box-shadow: 0 2px 8px rgba(30,39,36,.1); }
.handoff-history { margin-bottom: 14px; overflow: hidden; border: 1px solid #e5c69b; border-radius: 12px; background: #fffdf8; }
.detail-handoff-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
.detail-handoff { padding: 15px 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.detail-handoff:nth-child(even) { border-right: 0; }
.detail-handoff header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.detail-handoff header strong { color: var(--orange-dark); font-size: 12px; }
.detail-handoff header span { color: var(--muted); font-size: 12px; }
.detail-handoff dl, .business-handoff dl { display: grid; gap: 9px; margin: 12px 0 0; }
.detail-handoff dl div, .business-handoff dl div { display: grid; grid-template-columns: 70px minmax(0,1fr); gap: 9px; }
.detail-handoff dt, .business-handoff dt { color: var(--muted); font-size: 12px; font-weight: 600; }
.detail-handoff dd, .business-handoff dd { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 12px; line-height: 1.55; }

.timeline { display: grid; gap: 13px; }
.business-log { overflow: hidden; border: 1px solid var(--line); border-left: 5px solid var(--gray); border-radius: 12px; background: #fff; }
.business-log.red { border-left-color: var(--red); }
.business-log.yellow { border-left-color: var(--yellow); }
.business-log.blue { border-left-color: var(--blue); }
.business-log.green { border-left-color: var(--green); }
.business-log-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fafaf7; }
.business-log-head > div { display: grid; gap: 3px; }
.business-log-head strong { font-size: 12px; }
.business-log-head span:not(.log-status) { color: var(--muted); font-size: 12px; }
.conversation-flow { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 15px; padding: 17px 18px; background: #f7f7f4; }
.message-bubble { max-width: 92%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.message-bubble.outbound { justify-self: end; border-color: #d9c6b8; background: var(--orange-soft); }
.message-bubble span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 600; }
.message-bubble p { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 12px; line-height: 1.65; }
.business-handoff { margin: 0; padding: 14px 18px; border-top: 1px solid #efd39e; border-bottom: 1px solid #efd39e; background: var(--yellow-soft); }
.business-handoff.failed { border-color: #ebbbb6; background: var(--red-soft); }
.business-step-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.business-step-title strong { font-size: 12px; }
.business-step-title span { color: var(--muted); font-size: 12px; }
.business-steps { padding: 15px 18px 17px; }
.send-summary { display: grid; gap: 8px; margin-top: 11px; }
.send-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fbfbf8; }
.send-index { width: 22px; height: 22px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--green); font-size: 12px; font-weight: 600; }
.send-copy { min-width: 0; display: grid; gap: 4px; }
.send-copy strong { font-size: 12px; }
.send-copy small { color: var(--muted); font-size: 12px; line-height: 1.5; word-break: break-word; }
.send-copy .send-error { color: var(--red); }
.business-note { margin: 12px 0 0; color: var(--muted); font-size: 12px; }
.log-card { overflow: hidden; border: 1px solid var(--line); border-left: 5px solid var(--gray); border-radius: 12px; background: #fff; }
.log-card.red { border-left-color: var(--red); }
.log-card.yellow { border-left-color: var(--yellow); }
.log-card.blue { border-left-color: var(--blue); }
.log-card.green { border-left-color: var(--green); }
.log-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); background: #fafaf7; }
.log-head h3 { margin: 0; font-size: 13px; }
.log-head p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.log-status { padding: 5px 8px; border-radius: 99px; color: var(--gray); background: var(--gray-soft); font-size: 12px; font-weight: 600; }
.log-body { display: grid; grid-template-columns: minmax(220px,.75fr) minmax(0,1.25fr); }
.log-column { min-width: 0; padding: 15px 16px; border-right: 1px solid var(--line); }
.log-column:last-child { border-right: 0; }
.log-column h4 { margin: 0 0 8px; color: var(--muted); font-size: 12px; letter-spacing: .5px; }
.message-text { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 12px; line-height: 1.65; }
.data-block { margin-top: 12px; }
.data-block:first-child { margin-top: 0; }
.data-block summary { cursor: pointer; color: var(--orange-dark); font-size: 12px; font-weight: 600; }
.data-block pre { max-height: 320px; overflow: auto; margin: 8px 0 0; padding: 12px; border-radius: 8px; color: #dce5e0; background: var(--charcoal); font: 10px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-word; }
.error-copy { margin-top: 10px; padding: 10px; border-radius: 8px; color: var(--red); background: var(--red-soft); font-size: 12px; line-height: 1.55; }
.load-more { display: flex; justify-content: center; padding-top: 16px; }

.dialog { width: min(620px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 15px; box-shadow: 0 28px 70px rgba(20,28,25,.25); }
.dialog::backdrop { background: rgba(20, 28, 25, .55); backdrop-filter: blur(3px); }
.dialog-card { padding: 0; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 22px 16px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-size: 21px; }
.dialog-head p:not(.eyebrow) { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.watch-options { max-height: 50vh; overflow: auto; padding: 10px 22px; }
.watch-option { min-height: 52px; display: flex; align-items: center; gap: 11px; border-bottom: 1px solid var(--line); cursor: pointer; }
.watch-option:last-child { border-bottom: 0; }
.watch-option input { width: 18px; height: 18px; accent-color: var(--orange); }
.watch-option span { display: grid; }
.watch-option small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.dialog-card > .form-error { margin: 0 22px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; padding: 16px 22px 22px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 80; max-width: 360px; padding: 12px 15px; border-radius: 9px; color: #fff; background: var(--charcoal); box-shadow: var(--shadow); font-size: 12px; transform: translateY(18px); opacity: 0; pointer-events: none; transition: .18s; }
.toast.visible { transform: none; opacity: 1; }
.toast.error { background: var(--red); }

@media (min-width: 1380px) {
  .account-wall { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

@media (max-width: 1050px) {
  .topbar { grid-template-columns: auto 1fr; }
  .topbar-center { grid-column: 1 / -1; grid-row: 2; }
  .desk-grid { grid-template-columns: 1fr; }
  .right-rail { grid-template-columns: 1fr 1fr; }
  .event-list, .exception-list { max-height: 450px; }
  .metric-strip { grid-template-columns: repeat(4, minmax(130px,1fr)); }
  .event-filters { grid-template-columns: repeat(3,minmax(120px,1fr)); }
  .event-filters .filter-query { grid-column: span 2; }
}

@media (max-width: 720px) {
  .topbar { position: static; display: flex; flex-wrap: wrap; align-items: flex-start; padding: 12px 14px; }
  .brand { flex: 1; }
  .topbar-actions { flex-wrap: wrap; }
  .topbar-center { order: 4; width: 100%; }
  .identity-label, #adminLink { display: none !important; }
  .compact-field { order: 3; width: 100%; }
  .compact-field select { flex: 1; width: auto; }
  .main-view { padding: 19px 14px 38px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .page-head h1 { font-size: 28px; }
  .metric-strip { grid-template-columns: repeat(2, minmax(125px,1fr)); }
  .metric { border-bottom: 1px solid var(--line); }
  .account-wall, .right-rail { grid-template-columns: 1fr; }
  .stream-list, .detail-handoff-list, .conversation-flow { grid-template-columns: 1fr; }
  .stream-list .event-row:nth-child(odd) { border-right: 0; }
  .detail-handoff { border-right: 0; }
  .message-bubble { max-width: 94%; }
  .event-filters { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .event-filters .filter-query { grid-column: 1 / -1; }
  .event-filters .button { grid-column: 1 / -1; }
  .account-facts { grid-template-columns: repeat(2,1fr); }
  .log-body { grid-template-columns: 1fr; }
  .log-column { border-right: 0; border-bottom: 1px solid var(--line); }
  .log-column:last-child { border-bottom: 0; }
  .conversation-row { grid-template-columns: minmax(0,1fr) auto; }
  .conversation-row time { display: none; }
  .detail-head-tools { width: 100%; justify-items: start; }
}

@media (max-width: 420px) {
  .login-screen { padding: 14px; }
  .login-card { padding: 27px 20px; }
  .code-row { grid-template-columns: 1fr; }
  .code-row .button { width: 100%; }
  .topbar-actions > .button.ghost { padding-inline: 7px; }
  .brand small { display: none; }
  .metric-strip { grid-template-columns: 1fr 1fr; }
  .metric { min-width: 0; }
  .compact-filters, .event-filters { grid-template-columns: 1fr; }
  .compact-filters .filter-query, .compact-filters .button, .event-filters .filter-query, .event-filters .button { grid-column: auto; }
  .detail-handoff dl div, .business-handoff dl div { grid-template-columns: 1fr; gap: 3px; }
  .dialog-actions .button { flex: 1; }
}

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

/* Ant visual system: teal primary, 14/22 type, 32px controls, 8px spacing. */
:root {
  --canvas: #f3f5f5; --surface: #fafcfc; --surface-strong: #fff;
  --ink: #1f2929; --muted: #627070; --line: #e5eaea; --line-strong: #c9d2d2;
  --orange: #087f80; --orange-dark: #066568; --orange-soft: #e8f6f5;
  --red: #c43838; --red-soft: #fff1f0; --yellow: #946200; --yellow-soft: #fff8e6;
  --blue: #246fb5; --blue-soft: #edf5ff; --green: #327b42; --green-soft: #eff8ee;
  --gray: #687575; --gray-soft: #f0f3f3;
  --shadow: 0 6px 16px rgba(0,0,0,.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px; line-height: 22px;
}
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
.button, .button.compact, .field input, .field select, .compact-field select,
.filter-grid select, .filter-grid input, .multi-trigger, .search {
  min-height: 32px; padding: 4px 12px; border-radius: 6px; font-size: 14px; line-height: 22px; font-weight: 400;
}
.button:hover, .account-card:hover { transform: none; }
.button.primary:hover { background: #199697; }
.button.secondary:hover, .filter-grid :is(input, select):hover, .multi-trigger:hover { border-color: var(--orange); }
.brand-seal { border-radius: 8px; box-shadow: none; }
.brand-seal.small { width: 36px; height: 36px; border-radius: 6px; }
.topbar { min-height: 64px; padding: 12px 24px; gap: 24px; border-bottom-color: var(--line); color: var(--ink); background: #fff; backdrop-filter: none; }
.brand strong { font-size: 16px; margin-top: 0; }
.brand small { color: var(--muted); font-size: 10px; letter-spacing: 1px; line-height: 16px; }
.live-state, .identity-label, .compact-field > span { color: var(--muted); font-size: 12px; }
.live-state i { background: var(--orange); box-shadow: none; }
.stale-banner { color: var(--yellow); font-size: 12px; }
.topbar .button.secondary, .compact-field select { border-color: var(--line-strong); color: var(--ink); background: #fff; }
.topbar .button.ghost { color: var(--muted); }
.topbar .button.secondary:hover { color: var(--orange); border-color: var(--orange); }
.main-view { padding: 24px 24px 48px; }
.page-head { margin-bottom: 24px; align-items: center; }
.page-head h1 { font-size: 28px; line-height: 38px; letter-spacing: 0; font-weight: 600; }
.page-head p { font-size: 14px; line-height: 22px; }
.page-head .eyebrow { display: none; }
.metric-context { margin: 0 0 8px; font-size: 12px; }
.metric-strip { grid-template-columns: repeat(8,minmax(0,1fr)); margin-bottom: 24px; border-radius: 8px; box-shadow: none; }
.metric { min-width: 0; min-height: 104px; padding: 16px; }
.metric span { font-size: 12px; font-weight: 400; }
.metric strong { margin-top: 8px; font-size: 28px; line-height: 36px; letter-spacing: 0; font-weight: 600; }
.metric:is(button):hover { background: var(--orange-soft); }
.desk-grid { grid-template-columns: minmax(0,1.65fr) minmax(360px,1fr); gap: 24px; }
.section-card { min-width: 0; border-radius: 8px; box-shadow: none; }
.section-head { min-height: 72px; padding: 16px 24px; }
.section-head h2 { font-size: 16px; line-height: 24px; font-weight: 600; }
.section-head p { font-size: 12px; margin-top: 4px; }
.account-wall { grid-template-columns: repeat(2,minmax(0,1fr)); padding: 16px; gap: 16px; background: #fff; border-radius: 0 0 8px 8px; }
.account-card { min-height: 196px; padding: 16px; border-radius: 8px; border-left-width: 3px; }
.account-card:is(.red,.yellow,.blue,.green,.gray) { background: #fff; }
.account-card:hover { border-top-color: var(--orange); border-right-color: var(--orange); border-bottom-color: var(--orange); box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.account-title h3 { font-size: 16px; line-height: 24px; }
.account-title > div { min-width: 0; }
.account-title small, .account-foot, .fact span { font-size: 12px; font-weight: 400; }
.account-organization { display: block; max-width: 100%; margin-top: 4px; overflow: hidden; color: var(--orange-dark); font-size: 12px; line-height: 20px; text-overflow: ellipsis; white-space: nowrap; }
.account-facts { gap: 8px; margin-top: 16px; }
.fact strong { font-size: 20px; line-height: 28px; font-weight: 600; }
.account-foot { padding-top: 16px; flex-wrap: wrap; }
.tone-label, .handoff-state, .log-status { padding: 0 7px; border: 1px solid currentColor; border-radius: 4px; font-size: 12px; line-height: 20px; font-weight: 400; }
.filter-grid { padding: 16px 24px; gap: 16px; background: #fafcfc; }
.filter-grid label, .filter-control { gap: 8px; font-size: 14px; font-weight: 400; }
.account-wall-filters { grid-template-columns: minmax(190px,1.4fr) repeat(2,minmax(120px,1fr)) minmax(190px,1.4fr) auto; }
.account-wall-filters .button { align-self: end; }
.filter-label { min-height: 22px; }
.event-filters { grid-template-columns: repeat(4,minmax(120px,1fr)) minmax(180px,1.5fr); }
.handoff-row { padding: 16px 24px; border-left-width: 3px; }
.handoff-row.failed { background: #fff; }
.handoff-row > strong, .handoff-row p, .event-copy strong { font-size: 14px; line-height: 22px; }
.handoff-kind, .handoff-row > small, .handoff-row p b, .handoff-error { font-size: 12px; }
.handoff-row p { margin-top: 8px; }
.handoff-row:hover, .event-row:hover, .conversation-row:hover, .multi-all { background: var(--orange-soft); }
.event-center { margin-top: 24px; }
.event-row { padding: 16px 24px; gap: 12px; }
.event-copy small { line-height: 20px; }
.filter-presets { padding: 16px 24px 0; gap: 8px; }
.filter-presets button { min-height: 32px; padding: 4px 12px; border-radius: 6px; font-size: 14px; font-weight: 400; }
.multi-menu { border-radius: 8px; }
.multi-all, .multi-options label { font-size: 14px; font-weight: 400; }
.login-screen { background: var(--canvas); }
.login-card, .dialog, .conversation-list, .business-log, .log-card { border-radius: 8px; }
.login-card { padding: 32px; }
.dialog-head, .dialog-actions { padding: 24px; }
.mode-switch { border-radius: 6px; background: var(--gray-soft); }
.mode-switch button { border-radius: 4px; font-size: 14px; font-weight: 400; }
.message-bubble.outbound { border-color: #b8dedb; }
@media (max-width: 1200px) {
  .topbar { grid-template-columns: auto 1fr; }
  .topbar-center { grid-column: 1 / -1; grid-row: 2; }
  .metric-strip { grid-template-columns: repeat(4,minmax(0,1fr)); }
  .metric { border-bottom: 1px solid var(--line); }
  .metric:nth-child(4n) { border-right: 0; }
  .metric:nth-child(n+5) { border-bottom: 0; }
  .desk-grid { grid-template-columns: 1fr; }
  .account-wall-filters { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .account-wall-filters .button { width: max-content; }
}
@media (max-width: 720px) {
  .topbar { display: flex; padding: 16px; gap: 16px; }
  .main-view { padding: 24px 16px 32px; }
  .page-head { align-items: flex-start; gap: 8px; }
  .page-head h1 { font-size: 24px; line-height: 32px; }
  .page-meta { white-space: normal; }
  .metric-strip { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .metric:nth-child(n) { border-bottom: 1px solid var(--line); }
  .metric:nth-last-child(-n+2) { border-bottom: 0; }
  .metric:nth-child(2n) { border-right: 0; }
  .account-wall { grid-template-columns: 1fr; }
  .section-head, .filter-grid, .handoff-row, .event-row { padding: 16px; }
  .filter-grid, .event-filters { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
  .account-wall-filters { grid-template-columns: 1fr; }
  .account-wall-filters .button { width: 100%; }
  .filter-query { grid-column: 1 / -1; }
  .button, .button.compact, .field input, .field select, .compact-field select,
  .filter-grid select, .filter-grid input, .multi-trigger, .search, .filter-presets button { min-height: 40px; }
  .filter-presets { padding: 16px 16px 0; }
  .brand { min-width: 0; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Learner monitoring workspace: Ant-style master/detail over persisted records. */
.event-center { margin: 0 0 24px; }
.conversation-page-head { margin-bottom: 16px; }
.conversation-workspace { min-height: min(720px, calc(100dvh - 190px)); display: grid; grid-template-columns: 320px minmax(0,1fr); overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: var(--shadow); }
.learner-pane { min-width: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #fafcfc; }
.learner-pane > header { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fff; }
.learner-pane h2, .conversation-detail-head h2 { margin: 0; font-size: 16px; line-height: 24px; }
.learner-pane header p, .conversation-detail-head p { margin: 2px 0 0; color: var(--muted); font-size: 12px; line-height: 20px; }
.sync-dot { color: var(--red); font-size: 12px; }
.learner-filters { display: grid; gap: 10px; padding: 14px; border-bottom: 1px solid var(--line); background: #fafcfc; }
.learner-filters label { min-width: 0; display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
.learner-filters input, .learner-filters select { width: 100%; min-width: 0; min-height: 32px; padding: 4px 10px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--ink); background: #fff; }
.learner-search { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; }
.learner-selects { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filter-reset-link { width: max-content; padding: 0; border: 0; color: var(--orange-dark); background: transparent; cursor: pointer; font-size: 12px; }
.learner-list-scroll { min-height: 0; flex: 1; max-height: calc(100dvh - 360px); overflow: auto; overscroll-behavior: contain; background: #fff; }
.learner-row { width: 100%; display: grid; gap: 4px; padding: 13px 15px; border: 0; border-bottom: 1px solid var(--line); color: var(--ink); background: #fff; cursor: pointer; text-align: left; }
.learner-row:hover { background: var(--orange-soft); }
.learner-row.selected { position: relative; background: #e8f6f5; }
.learner-row.selected::before { position: absolute; inset: 0 auto 0 0; width: 3px; content: ""; background: var(--orange); }
.learner-row-head, .learner-meta { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.learner-row-head strong { min-width: 0; overflow: hidden; font-size: 14px; line-height: 22px; text-overflow: ellipsis; white-space: nowrap; }
.blacklist-tag { flex: 0 0 auto; padding: 0 6px; border: 1px solid #ffccc7; border-radius: 4px; color: var(--red); background: var(--red-soft); font-size: 11px; line-height: 18px; font-weight: 400; }
.learner-uid { overflow: hidden; color: var(--muted); font-size: 11px; line-height: 18px; text-overflow: ellipsis; white-space: nowrap; }
.learner-meta { color: var(--muted); font-size: 11px; line-height: 18px; }
.learner-meta time { flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.learner-load-more { display: flex; justify-content: center; padding: 14px; }
.conversation-detail-pane { min-width: 0; display: flex; flex-direction: column; background: #f5f7f7; }
.conversation-detail-head { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 18px; border-bottom: 1px solid var(--line); background: #fff; }
.mobile-list-back { display: none; margin: 0 0 5px; padding: 0; border: 0; color: var(--orange-dark); background: transparent; cursor: pointer; font-size: 12px; }
.conversation-sync-warning { padding: 8px 14px; border-bottom: 1px solid #ffccc7; color: var(--red); background: var(--red-soft); font-size: 12px; line-height: 20px; }
.new-records { align-self: center; z-index: 2; margin: 10px 0 -2px; padding: 5px 12px; border: 1px solid #87d7d2; border-radius: 14px; color: var(--orange-dark); background: #fff; cursor: pointer; font-size: 12px; box-shadow: var(--shadow); }
.chat-scroll { min-height: 0; flex: 1; max-height: calc(100dvh - 272px); overflow: auto; overscroll-behavior: contain; padding: 16px 18px 22px; }
.chat-scroll .handoff-history { background: #fff; }
.business-timeline { gap: 16px; }
.business-log.chat-round { border-left-width: 3px; }
.conversation-flow { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; background: #f7f9f9; }
.message-bubble { max-width: min(78%, 720px); }
.message-bubble.inbound { align-self: flex-start; border-radius: 4px 12px 12px 12px; }
.message-bubble.outbound { align-self: flex-end; border-radius: 12px 4px 12px 12px; background: #e8f6f5; }
.message-bubble.outbound.success { border-color: #b7e1c0; background: var(--green-soft); }
.message-bubble.outbound.pending { border-color: #b9d4ef; background: var(--blue-soft); }
.message-bubble.outbound.failed { border-color: #ffccc7; background: var(--red-soft); }
.message-bubble .missing-content { color: var(--muted); }
.message-bubble .media-link { display: inline-flex; margin-top: 8px; color: var(--orange-dark); font-size: 12px; font-weight: 600; }
.message-bubble > .send-error { display: block; margin-top: 8px; color: var(--red); font-size: 12px; line-height: 18px; }
.processing-detail { border-top: 1px solid var(--line); background: #fff; }
.processing-detail > summary { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 18px; cursor: pointer; list-style: none; }
.processing-detail > summary::-webkit-details-marker { display: none; }
.processing-detail > summary span { color: var(--orange-dark); font-size: 13px; font-weight: 600; }
.processing-detail > summary small { color: var(--muted); font-size: 12px; }
.processing-detail-body { display: grid; gap: 10px; padding: 0 18px 16px; }
.processing-detail-body > section:not(.business-handoff) { padding: 11px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fafcfc; }
.processing-detail-body > section > strong { font-size: 12px; }
.processing-detail-body > section > p { margin: 5px 0 0; white-space: pre-wrap; word-break: break-word; font-size: 12px; line-height: 20px; }
.processing-detail .business-handoff { padding: 12px; border: 1px solid #ffe2a8; border-radius: 6px; }

@media (max-width: 720px) {
  .conversation-workspace { min-height: calc(100dvh - 190px); grid-template-columns: minmax(0,1fr); }
  .conversation-workspace.show-list .conversation-detail-pane { display: none; }
  .conversation-workspace.show-detail .learner-pane { display: none; }
  .learner-pane { border-right: 0; }
  .learner-list-scroll, .chat-scroll { max-height: none; }
  .conversation-detail-pane { min-height: calc(100dvh - 190px); }
  .mobile-list-back { display: block; }
  .conversation-detail-head { align-items: flex-start; flex-direction: column; padding: 12px 14px; }
  .conversation-detail-head .detail-head-tools { width: 100%; }
  .chat-scroll { padding: 12px; }
  .message-bubble { max-width: 90%; }
  .processing-detail > summary, .conversation-flow { padding-inline: 14px; }
  .processing-detail-body { padding-inline: 14px; }
}
