:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --text: #1a2233;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --gold: #d97706;
  --amber: #f59e0b;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  overflow: hidden;
}

#stage { position: relative; width: 100vw; height: 100vh; }
#globe { position: absolute; inset: 0; }
#globe canvas { display: block; }
.geo-labels { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 4; }
.geo-label {
  position: absolute;
  text-align: center;
  color: #eaf3ff;
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0,0,0,.9), 0 0 8px rgba(20,50,160,.6);
  transition: opacity .25s;
  user-select: none;
  opacity: 0;
  visibility: hidden;
}
.geo-label b { display: block; font-weight: 600; font-size: 12px; }
.geo-label i { display: block; font-style: normal; font-size: 9px; opacity: .7; color: #b9d2f5; }
.geo-label.city { font-size: 9px; }
.geo-label.city b { font-size: 10px; }
.globe-hint {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 30;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(15,23,42,.55);
  border: 1px solid rgba(148,163,184,.35);
  color: #cbd5e1;
  font-size: 12px;
  letter-spacing: .04em;
  backdrop-filter: blur(6px);
  pointer-events: none;
}
#fx { position: absolute; inset: 0; pointer-events: none; z-index: 60; }

.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 12px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .04);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 7px;
  background: var(--accent);
  color: #fff; font-weight: 700; font-size: 15px;
}
.brand-text h1 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: .2px; }
.brand-text p { margin: 0; font-size: 11px; color: var(--muted); }

.kpis { display: flex; gap: 20px; flex-wrap: wrap; align-items: baseline; }
.kpi { font-size: 11px; color: var(--muted); white-space: nowrap; }
.kpi b { display: inline-block; min-width: 18px; margin-left: 5px; font-size: 15px; color: var(--text); font-variant-numeric: tabular-nums; }
.kpi-target { font-style: normal; font-size: 10px; color: var(--muted); margin-left: 4px; }
.top-actions { display: flex; align-items: center; gap: 10px; }

.pill {
  font-size: 11px; color: var(--muted);
  border: 1px solid var(--line-strong); border-radius: 999px;
  padding: 3px 11px; white-space: nowrap;
  background: var(--surface);
}
.pill.ok { color: var(--ok); border-color: rgba(22, 163, 74, .4); }
.pill.busy { color: var(--warn); border-color: rgba(217, 119, 6, .4); }

button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 7px;
  padding: 7px 13px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
button:hover { border-color: var(--accent); color: var(--accent); }
button.primary {
  background: var(--accent);
  color: #fff;
  border: none;
  font-weight: 600;
}
button.primary:hover { background: #1d4ed8; color: #fff; }
button.ghost { background: transparent; }
button:disabled { opacity: .45; cursor: not-allowed; }

.voice-rail {
  position: absolute;
  left: 22px; top: 76px;
  width: min(560px, 42vw);
  z-index: 20;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px 15px 11px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .05);
}
.rail-title { font-size: 12px; color: var(--text); font-weight: 600; margin-bottom: 8px; }
.rail-sub { color: var(--muted); font-weight: 400; font-size: 11px; margin-left: 8px; }
.voice-row { display: flex; gap: 8px; }
.voice-row input {
  flex: 1; min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--text);
  padding: 8px 11px;
  font-size: 13px;
  outline: none;
}
.voice-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.mic { width: 38px; display: grid; place-items: center; padding: 0; }
.mic.listening { border-color: var(--danger); color: var(--danger); animation: pulse-red 1.2s infinite; }
@keyframes pulse-red { 0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .25); } 50% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); } }

.voice-result {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 9px 11px;
  font-size: 12.5px;
  line-height: 1.55;
}
.voice-result.confirm { border-left-color: var(--warn); }
.voice-result .meta { color: var(--muted); font-size: 11px; margin-bottom: 4px; font-family: var(--mono); }
.voice-result .actions { margin-top: 9px; display: flex; gap: 8px; }
.hint { margin: 9px 0 0; font-size: 11px; color: var(--muted); }
.hidden { display: none !important; }

.right-rail {
  position: absolute;
  right: 22px; top: 76px; bottom: 116px;
  width: 320px;
  z-index: 20;
  display: flex; flex-direction: column; gap: 10px;
}
.presenter-panel, .feed-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .05);
}
.presenter-panel { flex: 0 0 auto; }
.feed-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.panel-head-line { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.panel-head-line h2 { margin: 0; font-size: 13px; font-weight: 600; }

.avatar-slot {
  height: 96px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(180deg, #eef4ff, #f8fafc);
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}
.avatar-slot canvas { position: absolute; inset: 0; }
.orb {
  width: 58px; height: 58px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff7e0, #fbbf24 45%, #b45309 90%);
  box-shadow: 0 4px 18px rgba(217, 119, 6, .3);
  animation: orb-float 3.4s ease-in-out infinite;
}
.avatar-slot.speaking .orb { animation: orb-float 1.1s ease-in-out infinite, orb-glow 1.1s ease-in-out infinite; }
@keyframes orb-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes orb-glow { 0%, 100% { box-shadow: 0 4px 18px rgba(217, 119, 6, .3); } 50% { box-shadow: 0 4px 34px rgba(217, 119, 6, .55); } }

.transcript {
  margin-top: 9px;
  min-height: 36px;
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.55;
  border-left: 2px solid var(--accent);
  padding-left: 10px;
}
.waveform { display: flex; gap: 3px; align-items: center; height: 20px; margin-top: 5px; }
.waveform i { width: 3px; height: 4px; border-radius: 2px; background: var(--accent); opacity: .3; }
.waveform.playing i { animation: wave 0.7s ease-in-out infinite; }
.waveform.playing i:nth-child(2n) { animation-delay: .12s; }
.waveform.playing i:nth-child(3n) { animation-delay: .24s; }
@keyframes wave { 0%, 100% { height: 4px; opacity: .3; } 50% { height: 16px; opacity: 1; } }

.feed-list {
  list-style: none; margin: 0; padding: 0;
  overflow-y: auto; flex: 1;
  font-family: var(--mono);
  font-size: 11px;
}
.feed-list li {
  padding: 5px 2px;
  border-bottom: 1px dashed var(--line);
  color: #334155;
  line-height: 1.5;
}
.feed-list li .t { color: var(--muted); font-size: 10px; }
.feed-list li.deal { color: var(--gold); border-left: 2px solid var(--gold); padding-left: 7px; }
.feed-list li.human { color: var(--danger); border-left: 2px solid var(--danger); padding-left: 7px; }
.feed-list li.signal { color: var(--accent); border-left: 2px solid var(--accent); padding-left: 7px; }

.data-wall {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 100px;
  z-index: 20;
  background: linear-gradient(0deg, #ffffff, rgba(255, 255, 255, .88) 75%, rgba(255, 255, 255, 0));
  border-top: 1px solid var(--line);
  padding: 16px 0 6px;
  overflow: hidden;
}
.ticker-row { overflow: hidden; white-space: nowrap; margin: 4px 0; }
.ticker {
  display: inline-block;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 11.5px;
  color: #475569;
  animation: scroll-left linear infinite;
  will-change: transform;
}
.ticker span { margin-right: 44px; }
.ticker b { color: var(--accent); font-weight: 600; }
.ticker-row:nth-child(2) .ticker { color: #64748b; animation-direction: reverse; }
@keyframes scroll-left { from { transform: translateX(0); } to { transform: translateX(-50%); } }

.tooltip {
  position: absolute;
  z-index: 50;
  pointer-events: none;
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 12px;
  max-width: 240px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .12);
}
.tooltip .tt-name { color: var(--text); font-weight: 600; }
.tooltip .tt-sub { color: var(--muted); font-size: 11px; }

.modal {
  position: absolute; inset: 0;
  z-index: 70;
  display: grid; place-items: center;
  background: rgba(15, 23, 42, .35);
  backdrop-filter: blur(2px);
}
.modal-card {
  width: min(460px, 92vw);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, .18);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.modal-head h3 { margin: 0; color: var(--text); font-size: 15px; }
.modal-body { font-size: 13px; line-height: 1.7; color: #334155; }
.modal-body .row { display: flex; gap: 8px; margin: 4px 0; }
.modal-body .row span:first-child { color: var(--muted); min-width: 74px; }
.modal-actions { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.modal-actions label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.modal-actions select {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 7px; padding: 6px 8px;
}

.drawer {
  position: absolute; inset: 0;
  z-index: 80;
  background: rgba(15, 23, 42, .4);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
}
.drawer-inner {
  width: min(1120px, 94vw);
  height: min(760px, 88vh);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 18px 20px;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .22);
  overflow: hidden;
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer-head h2 { margin: 0; font-size: 16px; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin: 12px 0; }
.tab { background: transparent; border: none; border-radius: 8px 8px 0 0; padding: 9px 15px; color: var(--muted); }
.tab:hover { color: var(--accent); }
.tab.active { color: var(--accent); border-bottom: 2px solid var(--accent); }
.panel { display: none; flex: 1; min-height: 0; flex-direction: column; }
.panel.active { display: flex; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.panel-head h3 { margin: 0; font-size: 14px; }
.panel-head.sub-head { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 12px; }
.panel-head.sub-head h4 { margin: 0; font-size: 13px; color: var(--muted, #7d8590); font-weight: 600; }
.table-wrap {
  flex: 1; overflow: auto;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface);
}
table { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 720px; }
th {
  text-align: left; color: var(--muted); font-weight: 500;
  padding: 9px 11px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--surface-2);
}
td { padding: 8px 11px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:hover td { background: var(--surface-2); }
.grade { font-weight: 700; }
.grade-A { color: var(--gold); }
.grade-B { color: var(--ok); }
.grade-C { color: var(--muted); }
.grade-D { color: var(--danger); }
.status { font-size: 11px; border-radius: 999px; padding: 2px 9px; border: 1px solid var(--line-strong); background: var(--surface); }
.status.running { color: var(--ok); border-color: rgba(22, 163, 74, .4); }
.status.paused { color: var(--warn); border-color: rgba(217, 119, 6, .4); }

.inline-form { position: relative; }
.inline-form summary { cursor: pointer; color: var(--accent); font-size: 12.5px; }
.mini-form {
  position: absolute; right: 0; top: 30px; z-index: 30;
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  width: 440px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 14px 40px rgba(15, 23, 42, .18);
}
.mini-form input, .mini-form select {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 7px;
  padding: 8px 10px; font-size: 12.5px;
}
.mini-form button { grid-column: 1 / -1; }

.wa-card {
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2); padding: 14px 16px; margin-bottom: 12px;
}
.wa-card h4 { margin: 0 0 10px; font-size: 13px; }
.wa-grid { display: grid; grid-template-columns: 1fr 1.6fr 1fr; gap: 8px; margin-bottom: 10px; }
.wa-grid input {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 7px; padding: 8px 10px; font-size: 12.5px;
}
.wa-actions { display: flex; align-items: center; gap: 10px; }
.wa-actions .pill.ok { color: var(--ok); border-color: rgba(22, 163, 74, .4); }
.wa-actions .pill.bad { color: var(--danger); border-color: rgba(220, 38, 38, .4); }

@media (max-width: 900px) {
  .wa-grid { grid-template-columns: 1fr; }
}

.metrics-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.metric-card {
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2); padding: 14px 16px;
}
.metric-card.north { border-color: var(--line-strong); }
.metric-label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.metric-big { display: block; font-size: 30px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.metric-sub { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }
.bar { height: 6px; border-radius: 4px; background: var(--line); margin-top: 9px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width .5s; }
.metrics-bottom { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; }
.table-wrap.half { flex: none; max-height: 260px; }
.spend-form {
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2); padding: 14px 16px;
}
.spend-form h4 { margin: 0 0 10px; font-size: 13px; font-weight: 600; }
.spend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.spend-grid label { font-size: 11px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.spend-grid input {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 7px; padding: 7px 9px;
}

@media (max-width: 980px) {
  .kpis { display: none; }
  .voice-rail { width: calc(100vw - 44px); top: 68px; }
  .right-rail {
    left: 22px; right: 22px; top: auto; bottom: 112px;
    width: auto; flex-direction: row;
  }
  .presenter-panel { flex: 1; }
  .feed-panel { flex: 1.3; }
  .avatar-slot { height: 74px; }
  .orb { width: 44px; height: 44px; }
  .data-wall { height: 104px; }
}

@media (max-width: 900px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .metrics-bottom { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .right-rail { display: none; }
  .voice-rail { bottom: 112px; top: auto; }
}
