:root {
  --bg: #eef3fb;
  --bg2: #e6eefc;
  --panel: #ffffff;
  --ink: #1f2430;
  --muted: #8a94a6;
  --line: #e8edf5;
  --line2: #eef2f8;
  --brand: #2f68ff;
  --brand-weak: #eef3ff;
  --brand-ink: #2f68ff;
  --ok: #16a34a;
  --warn: #e04b4b;
  --radius: 16px;
  --shadow: 0 20px 50px rgba(40, 70, 130, .10);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(120deg, var(--bg) 0%, var(--bg2) 100%);
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
input, select { font-family: inherit; }

/* ---------- app shell ---------- */
#app { min-height: 100vh; padding: 26px; }
.shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 0;
  max-width: 1480px;
  margin: 0 auto;
  background: var(--panel);
  border-radius: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
  min-height: calc(100vh - 52px);
}

/* ---------- sidebar ---------- */
.side { border-right: 1px solid var(--line); padding: 22px 18px; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 22px; }
.brand .logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, #2f68ff, #6aa0ff);
  display: grid; place-items: center; color: #fff; font-size: 20px;
}
.brand .name { font-weight: 800; font-size: 18px; letter-spacing: .5px; }
.brand .sub { font-size: 10px; color: var(--muted); letter-spacing: 3px; }
.nav { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 12px; border-radius: 14px; color: var(--ink);
  transition: background .15s;
}
.nav a .ic { width: 34px; height: 34px; border-radius: 10px; background: var(--brand-weak); display: grid; place-items: center; font-size: 17px; }
.nav a .t { font-weight: 700; font-size: 14px; line-height: 1.15; }
.nav a .d { font-size: 11px; color: var(--muted); }
.nav a:hover { background: #f6f9ff; }
.nav a.active { background: var(--brand-weak); }
.nav a.active .t { color: var(--brand-ink); }
.side .foot { margin-top: auto; padding: 14px 8px 2px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line2); }

/* ---------- main ---------- */
.main { padding: 30px 34px; overflow: auto; }
.eyebrow { color: var(--brand); font-size: 12px; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; }
.h1 { font-size: 26px; font-weight: 800; margin: 2px 0 4px; }
.lead { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--brand-weak); color: var(--brand); display: grid; place-items: center; font-weight: 800; }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; background: #fff; }
.card.hover:hover { border-color: #cfe0ff; box-shadow: 0 10px 24px rgba(47,104,255,.08); }
.card .ic { width: 44px; height: 44px; border-radius: 12px; background: var(--brand-weak); color: var(--brand); display: grid; place-items: center; font-size: 20px; margin-bottom: 14px; }
.card h3 { margin: 0 0 6px; font-size: 17px; }
.card p { margin: 0 0 14px; color: var(--muted); font-size: 13px; min-height: 34px; }
.card .go { color: var(--brand); font-weight: 700; font-size: 13px; }

.section { border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; }
.section .eyebrow { margin-bottom: 2px; }
.section h2 { margin: 0 0 16px; font-size: 18px; }

.grid { display: grid; gap: 16px; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }

.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field select, .field input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px;
  font-size: 14px; background: #fff; color: var(--ink); outline: none;
}
.field select:focus, .field input:focus { border-color: var(--brand); }

/* toggle */
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; }
.toggle .tt { font-weight: 700; font-size: 14px; }
.toggle .td { font-size: 11px; color: var(--muted); }
.sw { width: 46px; height: 26px; border-radius: 20px; background: #d5deec; position: relative; transition: background .2s; border: none; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.sw.on { background: var(--brand); }
.sw.on::after { left: 23px; }

/* buttons */
.btn { padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-weight: 700; font-size: 14px; color: var(--ink); }
.btn:hover { background: #f7f9ff; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.primary:disabled { background: #b9c8e8; border-color: #b9c8e8; cursor: not-allowed; }
.btn.ghost { background: #fff; }
.btn.danger { color: var(--warn); }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; }
.spacer { flex: 1; }

/* chips */
.chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chip { padding: 7px 16px; border-radius: 20px; border: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 13px; font-weight: 600; }
.chip.on { background: var(--brand-weak); color: var(--brand); border-color: #cfe0ff; }

/* stat tiles */
.stat { border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 24px; font-weight: 800; margin-top: 4px; }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.statrow { display: flex; gap: 26px; }
.statrow .k { font-size: 12px; color: var(--muted); }
.statrow .v { font-size: 22px; font-weight: 800; }

/* streams */
.streams { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stream { border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.stream h4 { margin: 0 0 10px; font-size: 14px; }
.stream .list { height: 320px; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; }
.bubble { background: #f6f8fc; border: 1px solid var(--line2); border-radius: 10px; padding: 10px 12px; font-size: 14px; line-height: 1.4; }
.bubble.tr { background: var(--brand-weak); border-color: #dbe7ff; }
.bubble.partial { opacity: .6; font-style: italic; }

/* feed */
.feed { border: 1px dashed var(--line); border-radius: 14px; min-height: 380px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.feed .empty { margin: auto; text-align: center; color: var(--muted); }
.feed .msg { background: #f6f8fc; border: 1px solid var(--line2); border-radius: 10px; padding: 10px 12px; }
.feed .msg .meta { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.feed .msg .tr { color: var(--brand); font-size: 13px; margin-top: 3px; }

/* voice list */
.vlist { display: flex; flex-direction: column; gap: 10px; }
.vitem { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.vitem .nm { font-weight: 700; }
.badge { font-size: 11px; padding: 3px 9px; border-radius: 10px; background: var(--brand-weak); color: var(--brand); font-weight: 700; }
.badge.gray { background: #eef1f6; color: var(--muted); }
.tip { background: #fff5f5; border: 1px solid #ffd9d9; color: #c0392b; border-radius: 12px; padding: 12px 14px; font-size: 13px; line-height: 1.6; }

.pill-status { display:inline-flex; align-items:center; gap:6px; font-size:12px; color:var(--muted); }
.dot { width:8px; height:8px; border-radius:50%; background:#c7d0de; }
.dot.live { background: var(--ok); box-shadow: 0 0 0 3px rgba(22,163,74,.15); }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth {
  width: 400px; max-width: 100%; background: #fff; border-radius: 20px; padding: 34px;
  box-shadow: var(--shadow);
}
.auth .brand { justify-content: center; padding-bottom: 10px; }
.auth h2 { text-align: center; margin: 6px 0 2px; }
.auth p.sub { text-align: center; color: var(--muted); margin: 0 0 20px; font-size: 13px; }
.auth .field { margin-bottom: 14px; }
.auth .btn { width: 100%; text-align: center; }
.auth .switch { text-align: center; margin-top: 14px; font-size: 13px; color: var(--muted); }
.auth .switch a { color: var(--brand); font-weight: 700; }
.auth .err { background:#fff5f5;border:1px solid #ffd9d9;color:#c0392b;border-radius:10px;padding:10px 12px;font-size:13px;margin-bottom:12px; display:none; }

.toast { position: fixed; top: 22px; left: 50%; transform: translateX(-50%); background: #1f2430; color: #fff; padding: 12px 20px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow); z-index: 99; opacity: 0; transition: opacity .2s, top .2s; pointer-events: none; }
.toast.show { opacity: 1; top: 30px; }

.hidden { display: none !important; }

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .side { flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--line); }
  .cards, .g3, .g2, .g4, .streams { grid-template-columns: 1fr; }
  .side .foot { display: none; }
}
