:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-2: #eef4ff;
  --text: #172033;
  --muted: #667085;
  --line: #d8e0ee;
  --brand: #0f62fe;
  --brand-2: #0647b8;
  --ok: #0f8b4c;
  --warn: #b54708;
  --danger: #b42318;
  --shadow: 0 12px 34px rgba(18, 37, 63, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  background: var(--brand);
  color: white;
  cursor: pointer;
  font-weight: 600;
}

button:hover {
  background: var(--brand-2);
}

button.secondary {
  background: #e7edf8;
  color: #172033;
}

button.secondary:hover {
  background: #dce5f3;
}

button.active-toggle {
  background: #eaf7ef;
  color: var(--ok);
}

button.active-toggle:hover {
  background: #d9f0e2;
}

button.danger {
  background: var(--danger);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.button-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border-radius: 6px;
  padding: 8px 12px;
  background: var(--brand);
  color: white;
  text-decoration: none;
  font-weight: 600;
}

.button-link.secondary {
  background: #e7edf8;
  color: #172033;
}

.button-link.disabled-link,
.button-link[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.52;
  pointer-events: none;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: white;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 98, 254, 0.12);
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: #0b2545;
  color: white;
}

.topbar-link {
  color: white;
  text-decoration: none;
  font-weight: 600;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  font-weight: 700;
}

.brand-mark {
  min-width: 56px;
  height: 32px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: #ffffff;
  color: #0b2545;
  font-size: 14px;
}

.muted {
  color: var(--muted);
}

.main {
  width: min(1180px, calc(100vw - 32px));
  margin: 24px auto;
  display: grid;
  gap: 18px;
}

.login-main {
  min-height: calc(100vh - 64px);
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-card h1,
.panel h1,
.panel h2 {
  margin: 0 0 12px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.section-heading h2 {
  margin: 0;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.acceptance-main .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.acceptance-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.acceptance-imports {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.import-status {
  grid-column: 1 / -1;
  color: var(--muted);
  line-height: 1.5;
}

.field-hint {
  color: var(--muted);
  line-height: 1.5;
  margin: -4px 0 12px;
}

.full-width {
  display: block;
  margin-top: 12px;
}

.device-list,
.acceptance-checks {
  display: grid;
  gap: 10px;
}

.device-row {
  display: grid;
  grid-template-columns: 1fr 1fr 0.8fr 0.8fr 1fr auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.device-row button {
  white-space: nowrap;
}

.acceptance-checks {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.acceptance-check {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.acceptance-check input {
  width: auto;
}

.acceptance-completeness {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  border: 1px solid #f1c48d;
  border-radius: 8px;
  padding: 12px;
  background: #fff8ed;
  color: #7a3b00;
}

.acceptance-completeness.ready {
  border-color: #b8dec6;
  background: #f0f9f3;
  color: var(--ok);
}

.acceptance-completeness ul {
  margin: 0;
  padding-left: 18px;
  line-height: 1.6;
}

.json-preview {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.45;
}

.system-readiness {
  display: grid;
  gap: 8px;
  margin: 14px 0 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.readiness-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.readiness-header button {
  padding: 7px 10px;
}

.readiness-summary {
  border-radius: 6px;
  padding: 8px 10px;
  background: #eaf7ef;
  color: var(--ok);
  font-size: 14px;
  font-weight: 600;
}

.readiness-summary.warn {
  background: #fff4e5;
  color: var(--warn);
}

.readiness-list {
  display: grid;
  gap: 6px;
}

.readiness-check {
  display: grid;
  gap: 3px;
  border: 1px solid #b8dec6;
  border-radius: 6px;
  padding: 8px 10px;
  background: #f0f9f3;
  font-size: 13px;
  line-height: 1.45;
}

.readiness-check.warn {
  border-color: #f1c48d;
  background: #fff8ed;
}

.readiness-check strong {
  color: #26364f;
}

.readiness-check span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.qr-panel {
  grid-template-columns: 96px 1fr;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcff;
}

.qr-panel img {
  width: 96px;
  height: 96px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
}

.qr-panel p {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.45;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 4px 18px rgba(18, 37, 63, 0.06);
}

.agent-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 18px;
  align-items: start;
}

.room-list {
  display: grid;
  gap: 10px;
}

.pending-summary {
  margin: 0 0 12px;
  border: 1px solid #f1c48d;
  border-left: 4px solid var(--warn);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff8ed;
  color: #7a3b00;
  font-weight: 700;
  font-size: 14px;
}

.cleanup-panel {
  display: grid;
  gap: 10px;
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcff;
}

.cleanup-panel p {
  margin: 4px 0 0;
  line-height: 1.45;
}

.cleanup-candidates {
  display: grid;
  gap: 8px;
}

.cleanup-stats {
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 8px;
}

.cleanup-stat {
  display: grid;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: white;
}

.cleanup-stat span {
  color: var(--muted);
  font-size: 12px;
}

.cleanup-stat strong {
  font-size: 18px;
}

.cleanup-item {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: white;
  font-size: 14px;
}

.cleanup-item span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.ops-summary-panel {
  display: grid;
  gap: 10px;
  margin: 0 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcff;
}

.ops-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.ops-stat {
  display: grid;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: white;
}

.ops-stat span {
  color: var(--muted);
  font-size: 12px;
}

.ops-stat strong {
  font-size: 18px;
}

.ops-stats-recent {
  display: grid;
  gap: 8px;
}

.ops-recent-row {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: white;
  font-size: 13px;
}

.ops-recent-row span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.room-filter {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px auto auto;
  gap: 8px;
  align-items: center;
  margin: 0 0 12px;
}

.room-filter select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: white;
  color: var(--text);
  font: inherit;
}

.room-filter span {
  font-size: 13px;
  white-space: nowrap;
}

.room-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: white;
  color: var(--text);
  display: grid;
  gap: 8px;
  text-align: left;
}

.room-item:hover {
  background: #f7faff;
}

.room-item.active {
  border-color: var(--brand);
  background: var(--panel-2);
}

.room-item.pending-connect {
  border-color: #f1c48d;
  background: #fff8ed;
}

.room-item.pending-stale {
  border-color: var(--warn);
  box-shadow: inset 4px 0 0 var(--warn);
}

.room-item.has-unread-chat {
  border-color: #f1c48d;
  box-shadow: inset 4px 0 0 #d97706;
}

.room-item .unread-chat {
  width: fit-content;
  border-radius: 999px;
  padding: 3px 8px;
  background: #ffead5;
  color: var(--warn);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

.room-item.pending-connect strong::after {
  content: "待接入";
  display: inline-block;
  margin-left: 8px;
  border-radius: 999px;
  padding: 2px 7px;
  background: #ffead5;
  color: var(--warn);
  font-size: 12px;
  font-weight: 700;
}

.meta-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.meta-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fbfcff;
}

.meta-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.meta-item strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.caller-progress-panel {
  margin-top: 12px;
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcff;
}

.caller-progress-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #26364f;
}

.caller-progress-title span {
  color: var(--muted);
  font-size: 13px;
}

.caller-progress-item {
  display: grid;
  grid-template-columns: 112px 118px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.caller-progress-item span {
  color: var(--muted);
  font-size: 12px;
}

.caller-progress-item strong {
  color: #1f4d7a;
  font-size: 13px;
}

.caller-progress-item em {
  color: #31445f;
  font-size: 13px;
  font-style: normal;
  overflow-wrap: anywhere;
}

.caller-progress-item.warn strong,
.caller-progress-item.warn em {
  color: var(--warn);
}

.diagnostic-panel {
  margin-top: 12px;
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcff;
}

.diagnostic-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #26364f;
}

.diagnostic-title span {
  color: var(--muted);
  font-size: 13px;
}

.diagnostic-summary {
  display: grid;
  gap: 3px;
  border-radius: 6px;
  padding: 8px 10px;
  background: #eef4ff;
  color: #194185;
}

.diagnostic-summary.ok {
  background: #eaf7ef;
  color: var(--ok);
}

.diagnostic-summary.warn {
  background: #fff4e5;
  color: var(--warn);
}

.diagnostic-summary span {
  color: inherit;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.diagnostic-item {
  display: grid;
  grid-template-columns: 112px 150px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.diagnostic-item span {
  color: var(--muted);
  font-size: 12px;
}

.diagnostic-item strong {
  color: #1f4d7a;
  font-size: 13px;
}

.diagnostic-item em {
  color: #31445f;
  font-size: 13px;
  font-style: normal;
  overflow-wrap: anywhere;
}

.diagnostic-item.warn strong,
.diagnostic-item.warn em {
  color: var(--warn);
}

.note-panel {
  margin-top: 12px;
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcff;
}

.note-panel label {
  display: grid;
  gap: 6px;
  color: #26364f;
  font-weight: 600;
}

.note-panel textarea {
  min-height: 88px;
  resize: vertical;
  font-weight: 400;
}

.compact-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compact-form .toolbar {
  grid-column: 1 / -1;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 10px;
  background: #eef4ff;
  color: #194185;
  font-size: 13px;
  width: fit-content;
}

.status.ok {
  background: #eaf7ef;
  color: var(--ok);
}

.status.warn {
  background: #fff4e5;
  color: var(--warn);
}

.video-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.video-tile {
  background: #101828;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  min-height: 260px;
  aspect-ratio: 16 / 10;
}

video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #101828;
}

.video-label {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.62);
  color: white;
  font-size: 13px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.media-controls {
  margin-top: 12px;
}

.connection-recovery {
  margin-top: 12px;
  display: grid;
  gap: 8px;
  border: 1px solid #f1c48d;
  border-left: 4px solid var(--warn);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff8ed;
  color: #7a3b00;
  line-height: 1.45;
}

.connection-recovery span {
  overflow-wrap: anywhere;
  font-size: 14px;
}

.end-reason-input {
  width: min(220px, 100%);
  min-width: 180px;
}

.link-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.link-expiry {
  border: 1px solid #cfd8e6;
  border-radius: 6px;
  padding: 8px 10px;
  background: #fbfcff;
  color: var(--muted);
  font-size: 14px;
}

.link-expiry.warn {
  border-color: #f1c48d;
  background: #fff8ed;
  color: var(--warn);
}

.access-code-panel {
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid #b8dec6;
  border-radius: 6px;
  padding: 9px 10px;
  background: #f0f9f3;
  color: var(--ok);
}

.access-code-panel div {
  display: grid;
  gap: 2px;
}

.access-code-panel span {
  font-size: 12px;
  color: var(--muted);
}

.access-code-panel strong {
  font-size: 20px;
}

.send-details {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fbfcff;
  gap: 4px;
  font-size: 14px;
  line-height: 1.45;
}

.send-details div {
  display: grid;
  gap: 2px;
}

.send-details span,
.send-details small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.send-details.ok {
  border-color: #b8dec6;
  background: #f0f9f3;
}

.send-details.warn {
  border-color: #f1c48d;
  background: #fff8ed;
}

.send-history {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fbfcff;
}

.send-history summary {
  cursor: pointer;
  font-weight: 700;
  color: #26364f;
}

.send-history #sendHistoryList {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.send-history-item {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: white;
  font-size: 13px;
  line-height: 1.45;
}

.send-history-item.ok {
  border-color: #b8dec6;
  background: #f0f9f3;
}

.send-history-item.warn {
  border-color: #f1c48d;
  background: #fff8ed;
}

.send-history-item span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.chat {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.chat-log {
  height: 260px;
  overflow-y: auto;
  padding: 12px;
  display: grid;
  align-content: start;
  gap: 8px;
  background: #fbfcff;
}

.message {
  max-width: 86%;
  padding: 8px 10px;
  border-radius: 8px;
  background: #e7edf8;
  line-height: 1.5;
}

.message.mine {
  justify-self: end;
  background: #dbeafe;
}

.message-meta {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 2px;
}

.quick-phrases {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.quick-phrase {
  flex: 1 1 180px;
  min-height: 36px;
  text-align: left;
  white-space: normal;
  line-height: 1.35;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
}

.call-layout {
  display: grid;
  grid-template-columns: 1.35fr 0.65fr;
  gap: 18px;
}

.notice {
  border-left: 4px solid var(--brand);
  padding: 10px 12px;
  background: #eef4ff;
  color: #18345d;
  border-radius: 6px;
}

.readiness-panel {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.readiness-item {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fbfcff;
  font-size: 14px;
  line-height: 1.45;
}

.readiness-item strong {
  color: #26364f;
}

.readiness-item span {
  color: var(--muted);
}

.readiness-item.ok {
  border-color: #b8dec6;
  background: #f0f9f3;
}

.readiness-item.warn {
  border-color: #f1c48d;
  background: #fff8ed;
}

.link-security {
  font-size: 14px;
  line-height: 1.55;
}

.link-security.warn {
  border-left-color: var(--warn);
  background: #fff4e5;
  color: #7a3b00;
}

.error {
  color: var(--danger);
  min-height: 20px;
}

@media (max-width: 860px) {
  .topbar {
    padding: 0 16px;
  }

  .agent-grid,
  .call-layout,
  .video-grid {
    grid-template-columns: 1fr;
  }

  .video-tile {
    min-height: 210px;
  }

  .panel h1 {
    font-size: 26px;
    line-height: 1.25;
  }

  .link-box,
  .chat-form,
  .readiness-item,
  .room-filter,
  .meta-grid,
  .caller-progress-item,
  .diagnostic-item,
  .compact-form,
  .acceptance-grid,
  .acceptance-imports,
  .device-row,
  .acceptance-checks {
    grid-template-columns: 1fr;
  }

  .call-layout .toolbar button {
    flex: 1 1 calc(50% - 10px);
  }
}
