:root {
  --bg: #0b1220;
  --panel: #121a2b;
  --panel2: #162033;
  --line: #243149;
  --text: #e8eefc;
  --muted: #8b9bb8;
  --green: #3dffa8;
  --blue: #4da3ff;
  --orange: #ffb020;
  --red: #ff5d6c;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif; }
button, textarea { font: inherit; }

.app {
  display: grid;
  grid-template-columns: 320px 1fr 380px;
  height: 100vh;
  gap: 10px;
  padding: 10px;
}

.col { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.card {
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  min-height: 0;
}
.flex1 { flex: 1; display: flex; flex-direction: column; }
.card-h {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; color: var(--muted); margin-bottom: 8px;
}
.tag.live {
  background: rgba(61,255,168,.12); color: var(--green);
  border: 1px solid rgba(61,255,168,.35);
  border-radius: 999px; padding: 2px 8px; font-size: 11px;
}
.muted { color: var(--muted); font-size: 12px; }

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 2px; }
.logo {
  width: 34px; height: 34px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #7dffc5, #1a6bff 60%, #0b1220);
  box-shadow: 0 0 18px rgba(61,255,168,.35);
}
.title { font-weight: 700; }
.sub { font-size: 11px; color: var(--muted); }
.icon-btn {
  margin-left: auto; background: transparent; border: 1px solid var(--line);
  color: var(--text); border-radius: 8px; width: 34px; height: 34px; cursor: pointer;
}
.wx-login-btn {
  margin-left: auto;
  margin-right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid rgba(7,193,96,.45);
  background: rgba(7,193,96,.12);
  color: #07c160;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.wx-login-btn:hover { background: rgba(7,193,96,.22); }
.wx-login-btn.logged {
  border-color: rgba(61,255,168,.4);
  background: rgba(61,255,168,.1);
  color: var(--green);
}
.wx-ico {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: #07c160;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}
.wx-card { width: min(360px, 92vw); text-align: center; }

/* 华为云风格登录卡 */
.hw-login-card {
  position: relative;
  width: min(720px, 94vw);
  background: #fff;
  color: #1a1a1a;
  border-radius: 4px;
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
  padding: 28px 32px 24px;
}
.hw-close {
  position: absolute;
  right: 12px;
  top: 8px;
  border: none;
  background: transparent;
  font-size: 22px;
  color: #999;
  cursor: pointer;
  line-height: 1;
}
.hw-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-right: 24px;
}
.hw-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  color: #1a1a1a;
}
.hw-link {
  border: none;
  background: none;
  color: #0a59f7;
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
  padding: 0;
}
.hw-link.muted { color: #8a8a8a; font-size: 13px; }
.hw-body {
  display: grid;
  grid-template-columns: 240px 1px 1fr;
  gap: 0 28px;
  min-height: 320px;
}
.hw-split { background: #e8e8e8; }
.hw-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.hw-qr-box {
  position: relative;
  width: 180px;
  height: 180px;
  border: 1px solid #e5e5e5;
  display: grid;
  place-items: center;
  background: #fafafa;
}
.hw-qr-box img {
  width: 168px;
  height: 168px;
  object-fit: contain;
}
.hw-qr-mask {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.85);
  display: grid;
  place-items: center;
  color: #0a59f7;
  cursor: pointer;
  font-size: 14px;
}
.hw-qr-label {
  margin-top: 10px;
  font-size: 13px;
  color: #666;
}
.hw-divider {
  width: 100%;
  margin: 18px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #999;
  font-size: 12px;
}
.hw-divider::before, .hw-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e8e8e8;
}
.hw-third {
  display: flex;
  gap: 28px;
  justify-content: center;
}
.hw-third-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  display: grid;
  gap: 6px;
  justify-items: center;
  color: #666;
  font-size: 12px;
  padding: 0;
}
.hw-third-btn .ico {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}
.hw-third-btn .ico.wx { background: #07c160; }
.hw-third-btn .ico.ali { background: #1677ff; }
.hw-right { padding-top: 4px; }
.hw-form-tabs {
  display: flex;
  gap: 28px;
  margin-bottom: 18px;
  border-bottom: 1px solid #eee;
}
.hw-ftab {
  border: none;
  background: none;
  padding: 0 0 10px;
  cursor: pointer;
  font-size: 15px;
  color: #666;
  position: relative;
}
.hw-ftab.active {
  color: #1a1a1a;
  font-weight: 600;
}
.hw-ftab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: #1a1a1a;
}
.hw-field {
  margin-bottom: 14px;
  border: 1px solid #dcdcdc;
  border-radius: 2px;
  background: #fff;
  display: flex;
  align-items: center;
}
.hw-field input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 12px 14px;
  font-size: 14px;
  color: #1a1a1a;
  outline: none;
  width: 100%;
}
.hw-phone .hw-cc {
  padding: 0 10px 0 14px;
  color: #333;
  font-size: 14px;
  border-right: 1px solid #eee;
  white-space: nowrap;
}
.hw-code .hw-getcode {
  border: none;
  background: none;
  color: #0a59f7;
  padding: 0 14px;
  cursor: pointer;
  white-space: nowrap;
  font-size: 13px;
}
.hw-tip {
  margin: -4px 0 12px;
  font-size: 12px;
  color: #999;
}
.hw-submit {
  width: 100%;
  border: none;
  background: #c7000b;
  color: #fff;
  font-size: 16px;
  padding: 12px;
  border-radius: 2px;
  cursor: pointer;
  margin-top: 6px;
}
.hw-submit:hover { background: #a80009; }
.hw-submit:disabled { opacity: .6; cursor: default; }
.hw-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
}
.hw-login-card .status-line {
  color: #c7000b;
  font-size: 13px;
  margin-top: 10px;
  text-align: left;
  min-height: 18px;
}
#btnWxLogout.hidden { display: none !important; }

@media (max-width: 720px) {
  .hw-body {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .hw-split { display: none; }
}
.wx-qr-wrap {
  margin: 12px auto;
  width: 220px;
  height: 220px;
  background: #fff;
  border-radius: 12px;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.wx-qr-wrap img { width: 220px; height: 220px; display: block; }
.brand .icon-btn { margin-left: 0; }

.sphere-wrap { display: grid; place-items: center; }
.metrics-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 6px;
}
.metrics-row div {
  background: rgba(255,255,255,.03); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 4px; text-align: center;
}
.metrics-row b { display: block; font-size: 16px; color: var(--green); }
.metrics-row span { font-size: 10px; color: var(--muted); }

.log {
  flex: 1; overflow: auto; font-size: 12px; line-height: 1.45;
  background: rgba(0,0,0,.18); border-radius: 10px; padding: 8px;
  border: 1px solid var(--line);
}
.log .item { padding: 6px 4px; border-bottom: 1px dashed rgba(255,255,255,.06); }
.log .t { color: var(--muted); margin-right: 6px; }

.hands-card {
  min-height: 200px;
  max-height: 320px;
}
.hands-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}
.hands-metrics div {
  background: rgba(0,0,0,.22);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 4px;
  text-align: center;
}
.hands-metrics b {
  display: block;
  font-size: 14px;
  color: var(--green);
  font-variant-numeric: tabular-nums;
}
.hands-metrics span {
  font-size: 10px;
  color: var(--muted);
}
.hands-device-live {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  line-height: 1.4;
}
.hands-device-live .on { color: var(--green); }
.hands-device-live .off { color: #ffb020; }
.hands-log {
  min-height: 90px;
  max-height: 140px;
}
.badge.warn { background: rgba(255,176,32,.15); color: #ffb020; }
.badge.tx { background: rgba(77,163,255,.15); color: var(--blue); }
.badge.rx { background: rgba(61,255,168,.15); color: var(--green); }
.badge {
  display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 999px; margin-left: 6px;
}
.badge.ok { background: rgba(61,255,168,.15); color: var(--green); }
.badge.err { background: rgba(255,93,108,.15); color: var(--red); }
.badge.info { background: rgba(77,163,255,.15); color: var(--blue); }

.row-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.row-btns button, .composer button, .modal-card button {
  background: #1a2438; color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; cursor: pointer;
}
.row-btns button:hover, .composer button:hover { border-color: var(--blue); }
button.primary { background: #2457ff; border-color: #2457ff; font-weight: 600; }

.center {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0;
  overflow: hidden;
  min-height: 0;
}
.mobile-nav { display: none; }
.chat {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 14px;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(36,87,255,.08), transparent 50%),
    #0d1422;
}
/* 消息少时贴在输入框上方（像微信），多时可向上滚动 */
.chat::before {
  content: "";
  flex: 1 0 auto;
}
.msg-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 100%;
}
.msg-row.user {
  flex-direction: row-reverse;
  align-self: stretch;
}
.msg-row.assistant {
  flex-direction: row;
  align-self: stretch;
}
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  user-select: none;
}
.avatar.user {
  background: linear-gradient(135deg, #4da3ff, #2457ff);
}
.avatar.assistant {
  background: radial-gradient(circle at 30% 30%, #7dffc5, #1a6bff 65%, #0b1220);
  box-shadow: 0 0 10px rgba(61,255,168,.25);
}
.msg-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: min(72%, 520px);
  min-width: 0;
}
.msg-row.user .msg-main { align-items: flex-end; }
.msg-row.assistant .msg-main { align-items: flex-start; }
.who {
  font-size: 11px;
  color: var(--muted);
  padding: 0 2px;
}
.bubble {
  padding: 10px 12px;
  border-radius: 8px;
  line-height: 1.55;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
}
.bubble.user {
  background: #95ec69;
  color: #111;
  border-radius: 8px 2px 8px 8px;
}
.bubble.assistant {
  background: #182338;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 2px 8px 8px 8px;
}
.bubble.pending {
  opacity: 0.85;
  color: var(--muted);
  font-style: italic;
}
.bubble.error {
  border-color: var(--red);
  color: #ffb4bc;
}

.composer {
  border-top: 1px solid var(--line);
  padding: 10px 12px 12px;
  background: var(--panel2);
}
.video-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 8px;
  background: rgba(36,87,255,.08);
}
.video-box input {
  flex: 1;
  background: #0e1626;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}
.video-preview {
  display: block;
  width: 100%;
  max-height: 280px;
  margin-top: 8px;
  border-radius: 8px;
  background: #000;
}
.video-preview.hidden { display: none !important; }
.hint { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.input-row { display: flex; gap: 8px; align-items: flex-end; }
.attach-btn {
  flex: 0 0 40px;
  height: 40px;
  margin-bottom: 2px;
}
.attach-btn.recording {
  background: rgba(255, 80, 80, 0.25);
  outline: 1px solid rgba(255, 100, 100, 0.6);
}
.attach-btn.busy {
  opacity: 0.6;
}
.attach-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.attach-preview:empty { display: none; margin: 0; }
.attach-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #0e1626;
}
.attach-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.attach-thumb button {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,.65);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  padding: 0;
  cursor: pointer;
}
.bubble img.chat-img {
  display: block;
  max-width: min(280px, 70vw);
  max-height: 220px;
  border-radius: 8px;
  margin-top: 6px;
  object-fit: contain;
  background: #0a1020;
  cursor: zoom-in;
}
.bubble video.chat-video {
  display: block;
  max-width: min(320px, 75vw);
  max-height: 240px;
  border-radius: 8px;
  margin-top: 6px;
  background: #0a1020;
}
.media-lightbox {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(0,0,0,.78);
  display: grid; place-items: center;
  padding: 24px;
}
.media-lightbox.modal { z-index: 80; background: rgba(0,0,0,.78); }
.media-lightbox.hidden { display: none !important; }
.media-lightbox-inner { position: relative; max-width: min(960px, 96vw); max-height: 90vh; }
.media-lightbox-close {
  position: absolute; top: -12px; right: -12px;
  width: 32px; height: 32px; border-radius: 50%;
  border: none; background: #111; color: #fff; font-size: 20px; cursor: pointer;
}
.media-lightbox-img, .media-lightbox-video {
  max-width: min(960px, 96vw); max-height: 88vh;
  border-radius: 10px; background: #000;
}
.attach-thumb video {
  width: 64px; height: 64px; object-fit: cover; display: block; border-radius: 6px;
}
textarea {
  flex: 1; resize: none; background: #0e1626; color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px;
}

.topbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  font-size: 12px; color: var(--muted); padding: 4px 2px;
}
.topbar b { color: var(--text); }
.dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 8px var(--green); display: inline-block;
}
.sep { opacity: .4; }

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: grid; place-items: center; z-index: 20;
}
.modal.hidden { display: none !important; }
.agents-box {
  flex: 1;
  overflow: auto;
  font-size: 12px;
  line-height: 1.45;
  background: rgba(0,0,0,.18);
  border-radius: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  max-height: 180px;
}
.agent-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px dashed rgba(255,255,255,.06);
}
.agent-row.clickable {
  cursor: pointer;
  border-radius: 6px;
  padding: 6px 6px;
  margin: 0 -4px;
}
.agent-row.clickable:hover {
  background: rgba(77,163,255,.12);
}
.agent-row .on { color: var(--green); }
.agent-row .off { color: var(--orange); }
.agent-row .install-hint {
  font-size: 10px;
  color: var(--blue);
  margin-left: 6px;
}

.settings-card {
  width: min(980px, 96vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.settings-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 10px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(0,0,0,.18);
  border: 1px solid rgba(255,255,255,.06);
}
.settings-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}
.settings-tab:hover {
  color: var(--text);
  background: rgba(255,255,255,.04);
}
.settings-tab.active {
  color: #fff;
  background: #2457ff;
  font-weight: 600;
}
.settings-panel {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}
.settings-panel.hidden { display: none !important; }

.agency-settings {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: min(560px, 68vh);
}
.agency-settings-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.agency-settings-head h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.agency-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.agency-stats span {
  min-width: 64px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.07);
  background: rgba(0,0,0,.16);
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}
.agency-stats b {
  display: block;
  color: var(--text);
  font-size: 16px;
  line-height: 1.2;
  margin-bottom: 2px;
}
.agency-roster-readonly {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 10px;
  max-height: 360px;
  overflow: auto;
}
.agency-norm-bar {
  display: none;
}
.agency-norm-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  min-width: 140px;
}
.agency-norm-field.grow {
  flex: 1;
  min-width: 180px;
}
.agency-norm-field select,
.agency-norm-field input {
  min-height: 36px;
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.22);
  color: var(--text);
}
.agency-alloc-box {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(61,255,168,.22);
  background: rgba(61,255,168,.06);
  font-size: 12px;
  line-height: 1.5;
  color: #cfe7d8;
}
.agency-alloc-box.empty {
  border-color: rgba(255,255,255,.08);
  background: rgba(0,0,0,.14);
  color: var(--muted);
}
.agency-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
}
.agency-search {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.22);
  color: var(--text);
  font-size: 13px;
}
.agency-toolbar-actions {
  flex-shrink: 0;
}
.agency-workspace {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 10px;
  min-height: 360px;
  flex: 1;
}
.agency-dept-rail {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: auto;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.07);
  background: rgba(0,0,0,.18);
  max-height: min(420px, 52vh);
}
.agency-chip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 12px;
  cursor: pointer;
}
.agency-chip:hover {
  color: var(--text);
  background: rgba(255,255,255,.04);
}
.agency-chip.active {
  border-color: rgba(77,163,255,.45);
  color: #dcecff;
  background: rgba(77,163,255,.14);
}
.agency-chip .count {
  color: inherit;
  opacity: .7;
  font-variant-numeric: tabular-nums;
}
.agency-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.07);
  background: rgba(0,0,0,.14);
  overflow: hidden;
}
.agency-main-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.agency-current-div {
  font-size: 13px;
  font-weight: 600;
  color: #c9d6ef;
}
.agency-list {
  flex: 1;
  overflow: auto;
  padding: 8px;
  max-height: min(420px, 52vh);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
  align-content: start;
}
.agency-card-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.07);
  background: rgba(255,255,255,.03);
  cursor: pointer;
  min-height: 108px;
}
.agency-card-item:hover {
  border-color: rgba(77,163,255,.4);
  background: rgba(77,163,255,.08);
}
.agency-card-item .title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.agency-card-item .desc {
  flex: 1;
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.agency-card-item .foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}
.agency-card-item .enable {
  color: var(--green);
  font-weight: 600;
}
.agency-foot {
  margin: 0;
}
.agency-foot code {
  font-size: 11px;
  color: #9ec1ff;
}
@media (max-width: 820px) {
  .agency-workspace {
    grid-template-columns: 1fr;
  }
  .agency-dept-rail {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    max-height: none;
  }
  .agency-chip {
    width: auto;
    white-space: nowrap;
  }
  .agency-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}

.modal-card {
  width: min(760px, 94vw);
  max-height: 86vh;
  overflow: auto;
  background: linear-gradient(180deg, #141c2e, #101827);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 18px 14px;
  box-shadow: 0 18px 50px rgba(0,0,0,.45);
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.modal-card pre {
  background: #0a101c; padding: 10px; border-radius: 8px; overflow: auto; font-size: 12px;
}
.settings-card h3 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 700;
}
.settings-card h4 {
  margin: 0 0 6px;
  font-size: 14px;
  color: #c9d6ef;
}
.settings-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}
.settings-block {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.settings-block:first-of-type {
  border-top: 0;
  margin-top: 4px;
  padding-top: 0;
}
.status-line {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}
.hands-pair-box {
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(0,0,0,.25);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  font-size: 12px;
  white-space: pre-wrap;
  color: #d7e0ff;
}
.hands-steps {
  margin: 10px 0 0;
  padding-left: 18px;
  line-height: 1.6;
}
.hands-steps code {
  font-size: 11px;
  color: #9ec1ff;
}
.hands-device-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}
.hands-device-list li {
  font-size: 12px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.hands-device-list .on { color: #3dffa8; }
.hands-device-list .off { color: var(--muted); }
.recent-video-row, .publish-job-row {
  margin: 4px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.publish-job-row .tag {
  font-size: 11px;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--orange);
}
.btn-link {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 12px;
}
.btn-link:hover { border-color: var(--blue); }
.btn-link.primary-link {
  background: rgba(70, 120, 255, .2);
  border-color: rgba(70, 120, 255, .45);
}
.form-grid {
  display: grid;
  gap: 12px;
  margin: 10px 0 12px;
}
.form-grid label,
.agent-ai-detail label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.form-grid input,
.form-grid select,
.agent-ai-detail input,
.agent-ai-detail select,
.agent-ai-detail textarea,
.coord-item input {
  background: #0e1626;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  width: 100%;
}
.form-grid input:focus,
.form-grid select:focus,
.agent-ai-detail input:focus,
.agent-ai-detail select:focus,
.agent-ai-detail textarea:focus,
.coord-item input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(77,163,255,.15);
}
.form-2 {
  display: grid;
  grid-template-columns: 1.4fr 0.6fr;
  gap: 10px;
}
.coord-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin: 10px 0 12px;
  padding: 10px 12px;
  background: rgba(0,0,0,.18);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.coord-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.coord-item input {
  width: 64px;
  padding: 6px 8px;
}
.coord-check {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  grid-template-columns: none !important;
}
.auth-tabs {
  display: flex;
  gap: 8px;
  margin: 8px 0 12px;
}
.auth-tab {
  flex: 1;
  border: 1px solid rgba(255,255,255,.1);
  background: transparent;
  color: #8b9bb8;
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
}
.auth-tab.active {
  color: #e8eefc;
  border-color: #4da3ff;
  background: rgba(77,163,255,.12);
}
.workflow-status {
  padding: 10px 12px;
  margin-bottom: 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #a8b6d0;
  font-size: 13px;
  line-height: 1.5;
}
.workflow-status b {
  color: #e8eefc;
}
.form-grid-simple {
  grid-template-columns: 1fr !important;
}
.advanced-keys {
  margin: 10px 0 4px;
  color: #8b9bb8;
  font-size: 13px;
}
.advanced-keys summary {
  cursor: pointer;
  user-select: none;
  margin-bottom: 8px;
}
.advanced-keys .form-grid {
  margin-top: 6px;
}
.model-roster-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}
.model-roster-head h4 {
  margin: 0 0 4px;
}
.model-employee-list {
  display: grid;
  gap: 10px;
  margin: 10px 0;
}
.model-employee-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(77,163,255,.1), rgba(21,31,52,.72));
}
.model-employee-card.offline {
  opacity: .7;
  background: rgba(255,255,255,.025);
}
.model-employee-avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: white;
  font-weight: 800;
  background: linear-gradient(135deg, #36d1dc, #2457ff);
}
.model-employee-title {
  color: #edf4ff;
  font-size: 14px;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.model-employee-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}
.model-capabilities {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}
.model-capability {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(61,255,168,.1);
  color: #8df6c1;
  font-size: 11px;
}
.model-employee-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
.model-employee-actions button {
  padding: 6px 9px;
  font-size: 11px;
}
.model-employee-actions .danger {
  color: #ff8f9d;
  border-color: rgba(255,85,110,.35);
}
.model-binding-editor {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(77,163,255,.18);
  border-radius: 10px;
  background: rgba(0,0,0,.12);
}
#modelBindModal {
  z-index: 30;
  background: rgba(3,8,18,.72);
  backdrop-filter: blur(5px);
}
.model-bind-card {
  width: min(720px, 94vw);
  min-height: min(650px, 88vh);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(112,145,205,.24);
  border-radius: 14px;
  background: linear-gradient(180deg, #141d30, #101827);
  box-shadow: 0 24px 70px rgba(0,0,0,.55);
}
.model-bind-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.model-bind-head h3 {
  margin: 0 0 5px;
  font-size: 18px;
}
.model-bind-head .hint {
  margin: 0;
}
.model-bind-body {
  flex: 1;
  overflow: auto;
  padding: 22px 20px;
}
.model-bind-fields {
  gap: 14px;
  margin: 0;
}
.model-bind-fields label {
  font-size: 13px;
}
.model-bind-fields input,
.model-bind-fields select {
  min-height: 40px;
}
.model-media-key {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,.07);
}
.model-media-key .hint {
  margin: -6px 0 0;
}
.dashscope-key-label {
  grid-column: 1 / -1;
}
.dashscope-key-label input {
  border-color: rgba(255, 176, 32, 0.45) !important;
}
#btnOpenDashscopeBind.primary {
  background: linear-gradient(135deg, #ff9f1a, #ff6b1a);
  color: #1a1208;
  border: none;
  font-weight: 600;
}
.model-bind-state {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  color: #dce7fb;
  font-size: 14px;
}
.model-bind-state strong {
  color: var(--green);
  font-size: 12px;
}
.model-bind-check {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 1px solid #6f84a8;
  color: transparent;
  font-size: 12px;
}
.model-bind-state.bound .model-bind-check {
  color: #08140f;
  border-color: var(--green);
  background: var(--green);
}
.model-bind-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid rgba(255,255,255,.06);
  background: rgba(10,16,28,.92);
}
.model-bind-actions button {
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #1a2438;
  color: var(--text);
  cursor: pointer;
}
.model-bind-actions button:hover {
  border-color: var(--blue);
}
.model-bind-actions button.primary {
  color: #fff;
}
.model-bind-actions .danger {
  color: #ff9dab;
  border-color: rgba(255,85,110,.35);
}
@media (max-width: 720px) {
  .settings-card {
    width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
    padding: 14px;
  }
  .settings-head {
    position: sticky;
    top: 0;
    z-index: 2;
    margin: -14px -14px 8px;
    padding: 14px;
    background: #141c2e;
    border-bottom: 1px solid var(--line);
  }
  .settings-nav {
    position: sticky;
    top: 58px;
    z-index: 2;
    background: #141c2e;
  }
  #handsSettingsBlock {
    max-height: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 4px;
  }
  .model-bind-card {
    width: 100vw;
    min-height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
  .model-bind-actions button {
    flex: 1 1 calc(50% - 8px);
  }
}
@media (max-width: 720px) {
  .model-employee-card {
    grid-template-columns: 38px 1fr;
  }
  .model-employee-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}
.hidden {
  display: none !important;
}
.role-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px 28px;
  padding: 8px 4px 4px;
  max-height: none;
  overflow: visible;
}
.role-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  transition: opacity .15s;
  white-space: nowrap;
}
.role-row:hover {
  border-color: transparent;
  background: transparent;
  opacity: 0.88;
}
.role-row.active .role-name {
  color: var(--blue);
}
.role-row .role-name {
  flex: none;
  font-weight: 500;
  color: var(--text);
  font-size: 14px;
}
.role-row .role-meta {
  display: none;
}
.role-row input.role-enable {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: #fff;
  cursor: pointer;
  flex-shrink: 0;
}
.role-badge {
  font-size: 13px;
  font-weight: 500;
  min-width: 0;
  text-align: left;
}
.role-badge.todo { color: var(--orange); }
.role-badge.ok { color: var(--green); }
.role-badge.off { color: #6b7a94; }
.role-editor {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(77,163,255,.35);
  border-radius: 12px;
  background: rgba(36,87,255,.08);
}
.role-editor.hidden { display: none; }
.role-editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.linkish {
  background: transparent !important;
  border: none !important;
  color: var(--blue) !important;
  padding: 0 !important;
  cursor: pointer;
}
.agent-ai-detail {
  display: grid;
  gap: 10px;
}
.agent-ai-detail textarea { min-height: 72px; resize: vertical; }
.modules-block summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

#customRoleModal {
  z-index: 40;
  background: rgba(0,0,0,.65);
}
.prompt-card {
  width: min(440px, 92vw);
  background: #2b2b2b;
  border: 1px solid #3d3d3d;
  border-radius: 10px;
  padding: 16px 18px 14px;
  box-shadow: 0 16px 40px rgba(0,0,0,.5);
  color: #eee;
}
.prompt-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #f0f0f0;
}
.prompt-label {
  display: grid;
  gap: 8px;
  font-size: 13px;
  color: #ddd;
  margin-bottom: 12px;
}
.prompt-label input,
.prompt-grid input,
.prompt-grid select,
.prompt-grid textarea {
  width: 100%;
  background: #1e1e1e;
  color: #fff;
  border: 1px solid #5a9fd4;
  border-radius: 4px;
  padding: 8px 10px;
  font: inherit;
}
.prompt-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}
.prompt-grid label {
  display: grid;
  gap: 5px;
  font-size: 12px;
  color: #aaa;
}
.prompt-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.prompt-actions button {
  min-width: 72px;
  border-radius: 6px;
  padding: 7px 14px;
}
.prompt-actions .primary {
  background: #8ab4f8;
  border-color: #8ab4f8;
  color: #1a1a1a;
}
.prompt-actions button:not(.primary) {
  background: #3a3a3a;
  border: 1px solid #8ab4f8;
  color: #8ab4f8;
}

@media (max-width: 1100px) {
  html, body { min-width: 0; overflow-x: hidden; }
  .app {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100dvh;
    padding: 6px;
    overflow: hidden;
  }
  .center {
    order: 1;
    flex: 1;
    width: 100%;
    min-width: 0;
    min-height: 0;
  }
  .left, .right {
    display: none;
    order: 2;
    width: 100%;
    min-width: 0;
    max-height: 52dvh;
    overflow-y: auto;
  }
  body.mobile-left-open .left,
  body.mobile-right-open .right { display: flex; }
  .mobile-nav {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 10px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
  }
  .mobile-nav button {
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #1a2438;
    color: var(--text);
    padding: 5px 10px;
  }
  .composer {
    position: sticky;
    bottom: 0;
    z-index: 5;
    max-width: 100%;
  }
  .input-row { min-width: 0; }
  .input-row textarea { min-width: 0; }
  .msg-main { max-width: calc(100% - 50px); }
  .card, .log, .agents-box, pre { max-width: 100%; overflow-wrap: anywhere; }
  .form-2 { grid-template-columns: 1fr; }
}
