/* douyin_get — Console UI v2（深色监控台 + 浅色主题）
   设计规范见项目根目录 DESIGN.md */

/* douyin_get — 界面重构版：Douyin Admin Management Console（深海军蓝侧边栏 + 浅色内容区）
   视觉 token 对齐设计稿 /stitch/precision_data_console/DESIGN.md
   默认浅色（内容区浅灰白、侧边栏固定深海军蓝）；[data-theme="dark"] 提供深色备选 */

:root {
  /* 内容区（浅色） */
  --bg-deep: #eef1f5;          /* 更深一层内侧（日志台/实时转写底） */
  --bg-canvas: #f0f2f5;        /* 全局内容背景 */
  --bg-elevated: #ffffff;      /* 浮层/列表底层 */
  --bg-card: #ffffff;          /* 卡片 */
  --bg-card-hover: #f5f6f8;
  --bg-sidebar: #1a2233;       /* 深海军蓝侧边栏（两种主题一致） */
  --bg-input: #ffffff;         /* 输入框/内嵌面 */
  --bg-muted: #f2f3f6;         /* 内嵌弱底 */

  --border: #d9d9d9;           /* 主边框 */
  --border-strong: #bfc5d1;
  --border-focus: rgba(22, 119, 255, 0.5);

  --text-primary: #1b1c1c;
  --text-secondary: #414755;
  --text-muted: #727786;
  --text-inverse: #ffffff;

  /* 主色：Ant Design 蓝 */
  --accent: #1677ff;
  --accent-soft: rgba(22, 119, 255, 0.08);
  --accent-glow: rgba(22, 119, 255, 0.16);
  --accent-text: #0958d9;
  --success: #52c41a;
  --success-soft: rgba(82, 196, 26, 0.09);
  --warning: #faad14;
  --warning-soft: rgba(250, 173, 20, 0.1);
  --error: #ff4d4f;
  --error-soft: rgba(255, 77, 79, 0.09);
  --live: #ff4d4f;
  --live-soft: rgba(255, 77, 79, 0.09);

  --ambient-1: rgba(22, 119, 255, 0.05);
  --ambient-2: rgba(82, 196, 26, 0.03);
  --bg-topbar: #ffffff;        /* 白色顶栏 */
  --sidebar-grad-end: #141b28;
  --card-sheen: rgba(255, 255, 255, 0.6);
  --row-divider: rgba(15, 23, 42, 0.06);
  --row-hover: #f5f5f5;
  --track-bg: rgba(15, 23, 42, 0.08);
  --timeline-col-bg: rgba(15, 23, 42, 0.05);
  --topic-bg: #f6f7f9;
  --progress-detail-bg: #f6f7f9;
  --inset-highlight: rgba(255, 255, 255, 0.85);
  --evidence-bg: #f6f7f9;
  --who-text: #0958d9;
  --type-batch-text: #7c3aed;
  --overlay: rgba(15, 23, 42, 0.45);
  --scrollbar-thumb: rgba(15, 23, 42, 0.18);
  --scrollbar-thumb-hover: rgba(15, 23, 42, 0.3);

  /* 侧边栏专属（深海军蓝固定，独立于内容主题） */
  --sb-text: #c3ccdb;
  --sb-text-muted: rgba(255, 255, 255, 0.48);
  --sb-text-active: #ffffff;
  --sb-hover: rgba(255, 255, 255, 0.06);
  --sb-active-bg: rgba(255, 255, 255, 0.09);
  --sb-active-bar: #1677ff;
  --sb-border: rgba(255, 255, 255, 0.1);

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 12px;           /* 卡片改 12px（对齐设计稿） */
  --radius-pill: 999px;

  --shadow-sm: 0 1px 0 rgba(15, 23, 42, 0.02) inset;
  --shadow-card: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-glow: 0 0 0 1px var(--border), 0 0 20px var(--accent-glow);

  --font-sans: "Inter", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans SC", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Cascadia Code", "Consolas", "Roboto Mono", monospace;

  --sidebar-w: 240px;
  --topbar-h: 64px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 180ms;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg-deep: #0b1018;
  --bg-canvas: #0f141c;
  --bg-elevated: #161e2b;
  --bg-card: #1a2233;
  --bg-card-hover: #202a3d;
  --bg-input: #20293a;
  --bg-muted: rgba(255, 255, 255, 0.05);

  --border: #2b3648;
  --border-strong: #3a475c;
  --border-focus: rgba(22, 119, 255, 0.6);

  --text-primary: #e8eef5;
  --text-secondary: #93a1b4;
  --text-muted: #66748a;
  --text-inverse: #0f141c;

  --accent: #3b8cff;
  --accent-soft: rgba(59, 140, 255, 0.14);
  --accent-glow: rgba(59, 140, 255, 0.2);
  --accent-text: #8fc0ff;
  --success: #2fd38b;
  --success-soft: rgba(47, 211, 139, 0.12);
  --warning: #f5b544;
  --warning-soft: rgba(245, 181, 68, 0.12);
  --error: #ff5a5c;
  --error-soft: rgba(255, 90, 92, 0.12);
  --live: #ff5a5c;
  --live-soft: rgba(255, 90, 92, 0.12);

  --ambient-1: rgba(59, 140, 255, 0.07);
  --ambient-2: rgba(47, 211, 139, 0.04);
  --bg-topbar: #121a26;
  --sidebar-grad-end: #141b28;
  --card-sheen: rgba(255, 255, 255, 0.02);
  --row-divider: rgba(255, 255, 255, 0.05);
  --row-hover: rgba(255, 255, 255, 0.03);
  --track-bg: rgba(255, 255, 255, 0.08);
  --timeline-col-bg: rgba(255, 255, 255, 0.04);
  --topic-bg: rgba(0, 0, 0, 0.16);
  --progress-detail-bg: rgba(0, 0, 0, 0.24);
  --inset-highlight: rgba(255, 255, 255, 0.03);
  --evidence-bg: #101722;
  --who-text: #8fc0ff;
  --type-batch-text: #c4b5fd;
  --overlay: rgba(0, 0, 0, 0.55);
  --scrollbar-thumb: rgba(255, 255, 255, 0.12);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.18);

  --shadow-sm: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
  --shadow-card: 0 8px 28px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-canvas);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 70% 45% at 8% -8%, var(--ambient-1), transparent 55%),
    radial-gradient(ellipse 55% 35% at 100% 0%, var(--ambient-2), transparent 50%),
    linear-gradient(180deg, var(--bg-canvas) 0%, var(--bg-canvas) 100%);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ===== App shell ===== */
.app {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100vh;
  height: 100dvh;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(2px);
  z-index: 90;
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 12px 14px;
  background: linear-gradient(180deg, var(--bg-sidebar) 0%, var(--sidebar-grad-end) 100%);
  border-right: 1px solid var(--sb-border);
  overflow-y: auto;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.02em;
  color: #fff;
  background: linear-gradient(135deg, #1677ff 0%, #0958d9 100%);
  box-shadow: 0 2px 10px rgba(22, 119, 255, 0.35);
  flex-shrink: 0;
}

.brand-text {
  min-width: 0;
  line-height: 1.25;
}

.brand-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #ffffff;
}

.brand-sub {
  font-size: 11px;
  color: var(--sb-text-muted);
  margin-top: 2px;
}

.sidebar-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sb-text-muted);
  padding: 12px 10px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 0 10px;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--sb-text);
  user-select: none;
  outline: none;
  position: relative;
  transition:
    background var(--dur) var(--ease),
    color var(--dur) var(--ease),
    border-color var(--dur) var(--ease);
}

.nav-item svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: 0.8;
  stroke: currentColor;
  transition: opacity var(--dur) var(--ease);
}

.nav-item:hover {
  background: var(--sb-hover);
  color: #ffffff;
}

.nav-item:hover svg {
  opacity: 1;
}

.nav-item.active {
  background: var(--sb-active-bg);
  border-color: transparent;
  color: var(--sb-text-active);
  font-weight: 600;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 3px;
  background: var(--sb-active-bar);
  box-shadow: 0 0 8px var(--sb-active-bar);
}

.nav-item.active svg {
  opacity: 1;
  color: var(--sb-active-bar);
}

.nav-item:focus-visible {
  box-shadow: 0 0 0 2px var(--border-focus);
}

.nav-item-settings {
  margin-bottom: 8px;
}

.sidebar-spacer {
  flex: 1;
  min-height: 16px;
}

.help-card {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 0 10px;
  margin-top: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--sb-border);
  background: var(--sb-hover);
  font-size: 12.5px;
  color: var(--sb-text);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease), background var(--dur) var(--ease);
}

.help-card:hover {
  border-color: rgba(255, 255, 255, 0.24);
  color: #ffffff;
}

.help-card svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--text-muted);
}

/* ===== Main ===== */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: transparent;
}

.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-topbar);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.topbar-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-divider {
  color: var(--border-strong);
  user-select: none;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.search-wrap {
  position: relative;
}

.search-wrap .search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-muted);
}

.search-input {
  width: 210px;
  height: 36px;
  padding: 0 12px 0 34px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 12.5px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), width var(--dur) var(--ease);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.icon-btn:hover {
  background: var(--bg-muted);
  border-color: transparent;
  color: var(--text-primary);
}

.icon-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--border-focus);
}

/* ===== Theme toggle ===== */
.theme-toggle {
  position: relative;
}

.theme-toggle svg {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px;
  height: 16px;
  transition: opacity var(--dur) var(--ease), transform 0.45s var(--ease);
}

.theme-toggle .icon-sun {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

.theme-toggle .icon-moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

.mobile-menu-btn {
  display: none;
  font-size: 18px;
  line-height: 1;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-muted);
  font-size: 11.5px;
  color: var(--success);
}

.status-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px rgba(82, 196, 26, 0.6);
  animation: pulse-dot 2s ease-in-out infinite;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #1677ff, #0958d9);
  cursor: default;
}

/* ===== Content ===== */
.content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 22px 26px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.page {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.page.active {
  display: flex;
  animation: page-in 0.24s var(--ease) both;
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur) var(--ease);
}

.card:hover {
  border-color: var(--border-strong);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 32px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.card-desc {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.card-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.section-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 4px;
}

.section-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.section-title {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.section-sub {
  font-size: 13px;
  color: var(--text-muted);
}

.section-head-actions {
  flex-direction: row;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.section-head-actions .section-head-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.section-head-actions .tab-bar {
  margin-left: auto;
  flex-shrink: 0;
}

/* ===== Stats ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.stat-card {
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease), background var(--dur) var(--ease);
}

.stat-card:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg-canvas), 0 0 0 4px var(--border-focus);
}

.stat-card::after {
  content: "";
  position: absolute;
  inset: auto -20% -40% auto;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft), transparent 70%);
  opacity: 0.6;
  pointer-events: none;
}

.stat-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-card-hover);
}

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.stat-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  background: var(--bg-muted);
}

.stat-icon.ok {
  color: var(--success);
  background: var(--success-soft);
  border-color: transparent;
}

.stat-icon.info {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: transparent;
}

.stat-icon.warn {
  color: var(--warning);
  background: var(--warning-soft);
  border-color: transparent;
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.stat-value {
  font-size: 25px;
  font-weight: 800;
  font-family: var(--font-mono);
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.35;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  font-size: 13px;
}

.info-grid .label {
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.info-grid .value {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  word-break: break-all;
}

/* ===== Buttons ===== */
.btn {
  height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  transition:
    background var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    transform 120ms var(--ease);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg-canvas), 0 0 0 4px var(--border-focus);
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.14) inset, 0 4px 12px rgba(22, 119, 255, 0.2);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-text);
}

.btn-success {
  background: var(--success-soft);
  color: var(--success);
  border-color: rgba(82, 196, 26, 0.25);
}

.btn-danger {
  background: var(--error-soft);
  color: var(--error);
  border-color: rgba(255, 77, 79, 0.25);
}

.btn-danger:hover:not(:disabled) {
  background: var(--error);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-muted);
  color: var(--text-primary);
}

.btn-sm {
  height: auto;
  padding: 3px 10px;
  font-size: 12px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ===== Forms ===== */
.form-group {
  margin-bottom: 14px;
}

.form-group > .form-group:last-child,
.form-row .form-group {
  margin-bottom: 0;
}

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-label .hint {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 12px;
}

.form-input,
.form-select {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  appearance: none;
  -webkit-appearance: none;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5l3 3 3-3' stroke='%23727886' stroke-width='1.3' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-input:hover,
.form-select:hover {
  border-color: var(--border-strong);
}

.form-input.tr-path-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-input:focus,
.form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea.form-input {
  height: auto;
  min-height: 88px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.5;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row > * {
  flex: 1;
  min-width: 0;
}

.form-inline-num {
  width: 64px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
}

.check-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-bottom: 14px;
}

.check-row label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.check-row input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

.divider-row {
  padding: 12px 0;
  margin: 12px 0 16px;
  border-top: 1px dashed var(--border);
  border-bottom: 1px dashed var(--border);
}

.divider-row .group-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
  margin-right: 8px;
}

.form-hint {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ===== Tabs / Chips ===== */
.tab-bar {
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
}

.tab-btn {
  height: 30px;
  padding: 0 14px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}

.tab-btn:hover {
  color: var(--text-secondary);
}

.tab-btn.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
  box-shadow: 0 1px 0 var(--inset-highlight) inset;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  transition: all var(--dur) var(--ease);
}

.chip:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.chip.selected {
  background: var(--accent-soft);
  border-color: rgba(22, 119, 255, 0.4);
  color: var(--accent-text);
}

.chip-icon {
  font-size: 13px;
  line-height: 1;
}

.chip-label {
  font-size: inherit;
}

/* ===== Location selector ===== */
.location-selector {
  font: inherit;
  text-align: left;
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-muted);
  font-size: 12px;
  color: var(--text-secondary);
  user-select: none;
  max-width: 100%;
}

.location-selector:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg-canvas), 0 0 0 4px var(--border-focus);
}

.location-selector span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.location-selector svg {
  flex-shrink: 0;
  color: var(--text-muted);
}

.location-selector.clickable {
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.location-selector.clickable:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.location-selector.clickable:hover svg {
  color: var(--accent);
}

/* ===== Table ===== */
.table-wrap {
  overflow-x: auto;
  margin: 0 -4px;
  padding: 0 4px;
  border-radius: var(--radius-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}

table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--bg-muted);
}

table td {
  padding: 12px;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--row-divider);
  vertical-align: middle;
}

table tr:last-child td {
  border-bottom: none;
}

table tbody tr {
  transition: background var(--dur) var(--ease);
}

table tbody tr:hover td {
  background: var(--row-hover);
}

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge-success {
  background: var(--success-soft);
  color: var(--success);
  border-color: rgba(82, 196, 26, 0.18);
}

.badge-warning {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: rgba(245, 181, 68, 0.18);
}

.badge-error {
  background: var(--error-soft);
  color: var(--error);
  border-color: rgba(255, 77, 94, 0.18);
}

.badge-primary {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-color: rgba(22, 119, 255, 0.18);
}

.badge-muted {
  background: var(--bg-muted);
  color: var(--text-muted);
  border-color: var(--border);
}

.badge-voice {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-color: rgba(22, 119, 255, 0.18);
}

/* ===== Progress bar ===== */
.progress-bar {
  width: 100%;
  height: 5px;
  background: var(--track-bg);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, #1677ff, #4096ff 70%, #69b1ff);
  transition: width 0.4s var(--ease);
  box-shadow: 0 0 8px rgba(22, 119, 255, 0.4);
}

/* ===== Room / live list ===== */
.room-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.room-row:last-child {
  border-bottom: none;
}

.room-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.room-avatar {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 14px;
  color: #fff;
  background: linear-gradient(135deg, #ff6b4a, #f5b544);
  flex-shrink: 0;
}

.room-detail {
  min-width: 0;
  line-height: 1.35;
}

.room-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.room-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: var(--font-mono);
}

.room-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.room-status-dot.live {
  background: var(--live);
  box-shadow: 0 0 8px rgba(255, 77, 94, 0.55);
  animation: pulse-dot 2s ease-in-out infinite;
}

.room-status-dot.offline {
  background: var(--text-muted);
}

.room-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ===== Live / batch logs ===== */
.live-log-card {
  margin-top: 0;
}

.live-log-header {
  align-items: flex-start;
  gap: 12px;
}

.live-log-caption {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 12px;
}

.live-log-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.live-log-status {
  color: var(--success);
  font-size: 12px;
  white-space: nowrap;
}

.live-log-filter-label,
.live-log-follow {
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}

.live-log-follow {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.live-log-follow input {
  accent-color: var(--accent);
}

.live-log-select {
  max-width: 180px;
  height: 32px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
}

.live-log-export,
.live-log-clear {
  height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.live-log-event-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-input);
}

.live-log-event-filter {
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 12px;
}

.live-log-history {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.live-log-history span {
  color: var(--text-muted);
  font-size: 12px;
}

.live-log-load-more {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.live-realtime-log {
  box-sizing: border-box;
  width: 100%;
  min-height: 220px;
  max-height: 420px;
  margin: 14px 0 0;
  padding: 14px 16px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: inset 0 1px 0 var(--inset-highlight);
}

/* ===== Progress page ===== */
.progress-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.progress-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  transition: border-color var(--dur) var(--ease);
}

.progress-item:hover {
  border-color: var(--border-strong);
}

.progress-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.progress-item-type {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 5px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.progress-item-type.type-single {
  background: var(--success-soft);
  color: var(--success);
}

.progress-item-type.type-user {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.progress-item-type.type-search {
  background: var(--warning-soft);
  color: var(--warning);
}

.progress-item-type.type-batch {
  background: rgba(167, 139, 250, 0.14);
  color: var(--type-batch-text);
}

.progress-item-target {
  flex: 1;
  margin: 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-item-status {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.progress-item-status.status-running {
  color: var(--accent);
}

.progress-item-status.status-completed {
  color: var(--success);
}

.progress-item-status.status-error {
  color: var(--error);
}

.progress-item-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-item-bar .progress-bar {
  flex: 1;
}

.progress-item-pct {
  font-size: 12.5px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  min-width: 40px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.progress-item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: var(--text-muted);
}

.progress-item-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.progress-item-delete {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all var(--dur) var(--ease);
}

.progress-item-delete:hover {
  background: var(--error-soft);
  color: var(--error);
}

.progress-item-cancel {
  cursor: pointer;
  color: var(--warning);
  font-size: 12px;
  line-height: 1;
  padding: 3px 8px;
  border: 1px solid rgba(245, 181, 68, 0.3);
  border-radius: 4px;
  transition: all var(--dur) var(--ease);
}

.progress-item-cancel:hover {
  background: var(--warning-soft);
  color: var(--warning);
}

.progress-item-export {
  cursor: pointer;
  color: var(--accent-text);
  font-size: 12px;
  line-height: 1;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: all var(--dur) var(--ease);
}

.progress-item-export:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.progress-detail {
  margin-top: 8px;
  padding: 12px;
  background: var(--progress-detail-bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.progress-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 8px;
}

.detail-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-stat-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.progress-item-expand {
  font-size: 10px;
  margin-right: 6px;
  color: var(--text-muted);
  transition: transform 0.15s;
  display: inline-block;
  width: 12px;
}

.task-created-at {
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== Empty / toast / spinner ===== */
.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
}

.empty-state p {
  font-size: 13px;
}

.empty-state .empty-icon {
  margin-bottom: 10px;
  opacity: 0.45;
}

#toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 200px;
  max-width: min(360px, 90vw);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  animation: toast-in 0.28s var(--ease);
}

.toast.success {
  background: #f6ffed;
  color: #389e0d;
  border-color: rgba(82, 196, 26, 0.3);
}

.toast.error {
  background: #fff2f0;
  color: #cf1322;
  border-color: rgba(255, 77, 79, 0.3);
}

.toast.info {
  background: #e6f4ff;
  color: #0958d9;
  border-color: rgba(22, 119, 255, 0.3);
}

@keyframes toast-in {
  from {
    transform: translateX(16px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(22, 119, 255, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse-dot {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.55;
    transform: scale(0.85);
  }
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal-overlay.show {
  display: flex;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 24px;
  min-width: min(400px, 92vw);
  max-width: 92vw;
}

/* ===== Scrollbar ===== */
.content::-webkit-scrollbar,
.sidebar::-webkit-scrollbar,
.live-realtime-log::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar,
.transcript-body::-webkit-scrollbar,
.evidence-list::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.content::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb,
.live-realtime-log::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb,
.transcript-body::-webkit-scrollbar-thumb,
.evidence-list::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
}

.content::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover,
.live-realtime-log::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* ===== 实时转写面板 ===== */
#liveTranscriptCard {
  margin-top: 16px;
}

.transcript-body {
  max-height: 420px;
  overflow-y: auto;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-primary);
  background: var(--bg-deep);
}

.transcript-body .transcript-line:last-child {
  border-bottom: none !important;
}

.transcript-panel {
  margin: 10px 0;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
}

.transcript-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}

.transcript-panel-body p {
  margin-bottom: 8px;
}

/* ===== Live insights (session review) ===== */
.insight-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.5;
}

.insight-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 14px;
}

.insight-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  padding: 14px;
  min-width: 0;
}

.insight-panel h4 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.insight-highlights {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.insight-highlight {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-secondary);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--accent-soft);
}

.sentiment-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sentiment-row {
  display: grid;
  grid-template-columns: 42px 1fr 48px;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.sentiment-row .label { color: var(--text-muted); }
.sentiment-row .pct {
  font-family: var(--font-mono);
  text-align: right;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.sentiment-track {
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--track-bg);
  overflow: hidden;
}

.sentiment-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 0.35s var(--ease);
}

.sentiment-fill.pos { background: linear-gradient(90deg, #2f9e6b, var(--success)); }
.sentiment-fill.neu { background: linear-gradient(90deg, #5b6478, #8b95a8); }
.sentiment-fill.neg { background: linear-gradient(90deg, #c45a62, var(--error)); }

.timeline-chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 72px;
  margin-top: 10px;
  padding-top: 4px;
}

.timeline-col {
  flex: 1;
  min-width: 3px;
  max-width: 12px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border-radius: 2px;
  overflow: hidden;
  background: var(--timeline-col-bg);
}

.timeline-seg {
  width: 100%;
  min-height: 0;
}

.timeline-seg.pos { background: rgba(45, 212, 160, 0.85); }
.timeline-seg.neu { background: rgba(155, 163, 181, 0.45); }
.timeline-seg.neg { background: rgba(255, 77, 94, 0.85); }

.topic-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.topic-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--topic-bg);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease);
}

.topic-item:hover,
.topic-item.active {
  border-color: var(--accent);
}

.topic-item .name {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 600;
}

.topic-item .count {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.evidence-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow: auto;
}

.evidence-item {
  font-size: 12px;
  line-height: 1.45;
  padding: 8px 10px;
  border-radius: 7px;
  border-left: 3px solid var(--accent);
  background: var(--evidence-bg);
  color: var(--text-secondary);
}

.evidence-item .who {
  color: var(--who-text);
  font-weight: 600;
}

.evidence-item .when {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  margin-right: 6px;
}

.insight-limitations {
  margin-top: 12px;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}

.insight-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.insight-stat-pill {
  font-size: 11px;
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-muted);
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

/* ===== Dashboard overview ===== */
.module-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.module-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.module-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-card-hover);
}

.module-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.module-card-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-split {
  display: inline-flex;
  gap: 6px;
  font-size: 11px;
  white-space: nowrap;
}

.split-item {
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.split-running { background: var(--accent-soft); color: var(--accent-text); }
.split-done { background: var(--success-soft); color: var(--success); }
.split-failed { background: var(--error-soft); color: var(--error); }

.module-card-body {
  display: grid;
  gap: 6px;
  min-height: 58px;
}

.module-card-empty {
  color: var(--text-muted);
  font-size: 13px;
  padding: 14px 0;
  text-align: center;
}

.module-card-footer {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
}

.active-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--bg-input);
  font-size: 13px;
  min-width: 0;
}

.active-item:hover {
  background: var(--bg-muted);
}

.active-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
}

.active-dot.run {
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(22, 119, 255, 0.4);
  animation: dashPulse 1.8s infinite;
}

@keyframes dashPulse {
  0% { box-shadow: 0 0 0 0 rgba(22, 119, 255, 0.35); }
  70% { box-shadow: 0 0 0 6px rgba(22, 119, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(22, 119, 255, 0); }
}

.active-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}

.active-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 1 46%;
  min-width: 110px;
}

.active-bar .progress-bar {
  flex: 1;
}

.active-pct {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.active-meta {
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}

.dashboard-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  gap: 14px;
}

.dashboard-recent-card,
.dashboard-sys-card {
  margin: 0;
}

.recent-list {
  display: grid;
  gap: 4px;
}

.recent-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  font-size: 13px;
  transition: background var(--dur) var(--ease);
}

.recent-item:hover {
  background: var(--bg-input);
}

.recent-item .badge {
  flex-shrink: 0;
}

.recent-module {
  flex-shrink: 0;
  color: var(--text-secondary);
  font-size: 12px;
}

.recent-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}

.recent-time {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
  font-family: var(--font-mono);
}

/* ===== 历史记录页面 ===== */
.history-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.history-select, .history-date, .history-input { padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; background: var(--bg-input); color: var(--text-primary); }
.history-input { flex: 1; min-width: 150px; }
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px 16px; cursor: pointer; transition: border-color 0.2s, box-shadow 0.2s; }
.history-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-card); }
.history-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.history-icon { font-size: 18px; flex-shrink: 0; }
.history-target {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--text-primary);
}
.history-status { font-size: 13px; color: var(--text-secondary); flex-shrink: 0; }
.history-card-body { display: flex; gap: 16px; font-size: 13px; color: var(--text-secondary); flex-wrap: wrap; }
.history-time { margin-left: auto; color: var(--text-muted); font-family: var(--font-mono); white-space: nowrap; }
.history-pagination { display: flex; gap: 4px; justify-content: center; align-items: center; margin-top: 16px; }
.history-count { margin-right: 12px; font-size: 13px; color: var(--text-muted); }
.page-btn { padding: 4px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-elevated); color: var(--text-primary); cursor: pointer; }
.page-btn.active { background: var(--accent); color: #ffffff; border-color: var(--accent); font-weight: 600; }
.detail-card { background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; margin: 12px 0; line-height: 1.8; }
.detail-card p { margin-bottom: 6px; font-size: 13px; }
.detail-card p:last-child { margin-bottom: 0; }
.btn-back { margin-bottom: 12px; }
.error-text { color: var(--error); }
.error-message { padding: 16px; text-align: center; color: var(--error); }
#history-app h3,
#history-app h4,
#tr-detail-card h3,
#tr-detail-card h4 {
  font-size: 15px;
  font-weight: 700;
  margin: 6px 0 10px;
  color: var(--text-primary);
}
#history-app h4,
#tr-detail-card h4 {
  font-size: 13.5px;
  margin-top: 14px;
}

/* ===== 音频转写页面 ===== */
.tr-capabilities { margin-bottom: 16px; }
.tr-cap-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tr-cap-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.tr-cap-ok { background: var(--success-soft); color: var(--success); border-color: rgba(82, 196, 26, 0.18); }
.tr-cap-bad { background: var(--warning-soft); color: var(--warning); border-color: rgba(250, 173, 20, 0.18); }
.tr-cap-rec { background: var(--accent-soft); color: var(--accent-text); border-color: rgba(22, 119, 255, 0.18); }

.tr-source-tabs {
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
}
.tr-create-source-tabs { display: flex; flex-wrap: wrap; max-width: 100%; }
.tr-create-source-tabs .tab-btn { white-space: nowrap; }
.tr-local-form { border-top: 1px solid var(--border); padding-top: 16px; }
.tr-local-action-note { margin-bottom: 14px; }

.tr-path-picker { display: flex; align-items: center; gap: 8px; }
.tr-path-picker .form-input { min-width: 0; }
.tr-workflow-card { border-color: rgba(22, 119, 255, 0.32); }
.tr-workflow-list-card .tr-task-pager { display: flex; align-items: center; gap: 8px; padding-top: 8px; }
.tr-workflow-list-card td { vertical-align: middle; }
.tr-workflow-row { cursor: pointer; }
.tr-workflow-row:hover td { background: var(--bg-input); }
.tr-workflow-row.selected td { background: var(--accent-soft); }
.tr-workflow-detail-card { border-color: rgba(22, 119, 255, 0.28); }
.tr-detail-actions { flex-wrap: wrap; }
.tr-workflow-source { min-width: min(100%, 260px); }
.tr-workflow-source .value {
  display: block;
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tr-workflow-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 16px;
}
.tr-workflow-stats span {
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  background: var(--bg-input);
  font-size: 12px;
  white-space: nowrap;
}
.tr-workflow-stats strong { color: var(--text-primary); font-family: var(--font-mono); }
.tr-workflow-items-section { border-top: 1px solid var(--border); padding-top: 4px; }
.tr-workflow-items-table table { min-width: 760px; }
.tr-workflow-items-table td { vertical-align: middle; }
.tr-item-title {
  max-width: 230px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}
.tr-item-meta, .tr-item-task-id {
  display: block;
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 11px;
}
.tr-item-child { min-width: 104px; }
.tr-item-error {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
  font-size: 12px;
}
.tr-btn-sm { height: auto; padding: 3px 9px; font-size: 12px; }
.tr-actions { gap: 6px; }
.tr-btn-danger {
  color: var(--error);
  border: 1px solid rgba(255, 77, 94, 0.35);
  background: transparent;
}
.tr-btn-danger:hover:not(:disabled) {
  background: var(--error-soft);
  color: var(--error);
  border-color: rgba(255, 77, 94, 0.55);
}
.tr-mono { font-family: var(--font-mono); font-size: 12px; }
.tr-muted { color: var(--text-muted); font-size: 12px; }

.tr-task-pager .btn {
  border: 1px solid var(--border);
}
.tr-task-pager .btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-text);
  background: var(--accent-soft);
}

.tr-progress-cell { min-width: 140px; }
.tr-progress-cell .progress-bar { max-width: 120px; display: inline-block; vertical-align: middle; margin-right: 8px; }
.tr-progress-pct { font-size: 12px; color: var(--text-secondary); white-space: nowrap; font-family: var(--font-mono); }

.tr-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px 16px;
  margin-bottom: 16px;
}
.tr-detail-item { display: flex; flex-direction: column; gap: 3px; }
.tr-detail-item .label { font-size: 11px; color: var(--text-muted); }
.tr-detail-item .value { font-size: 13px; color: var(--text-primary); word-break: break-all; }

.tr-progress-block { margin-bottom: 14px; }
.tr-progress-line { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-secondary); margin: 8px 0 4px; }
.tr-progress-block .progress-bar { margin-bottom: 2px; }

.tr-error-box {
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid rgba(255, 77, 94, 0.28);
  border-radius: var(--radius-sm);
  background: var(--error-soft);
}
.tr-error-title { font-weight: 600; color: var(--error); margin-bottom: 6px; }
.tr-error-code { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tr-error-code code { color: var(--error); }
.tr-error-msg { font-size: 13px; color: var(--text-secondary); line-height: 1.6; word-break: break-word; }

.tr-export-row { margin-top: 12px; }

.tr-records-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin: 14px 0 8px; }
.tr-records-tools { display: flex; align-items: center; gap: 8px; }
.tr-records-page { font-size: 12px; color: var(--text-muted); }
.tr-records-table table { min-width: 480px; }

/* ===== 配置中心 ===== */
.settings-tabs { display: flex; gap: 4px; margin-bottom: 14px; }
.settings-api-layout { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: 14px; align-items: start; }
.settings-profile-list-card, .settings-profile-editor { margin: 0; }
.settings-profile-list { display: grid; gap: 6px; }
.settings-profile-row {
  width: 100%; min-height: 58px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-primary); background: transparent;
  text-align: left; cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.settings-profile-row:hover, .settings-profile-row.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.settings-profile-row span:first-child { min-width: 0; display: grid; gap: 3px; }
.settings-profile-row strong, .settings-profile-row small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-profile-row strong { font-size: 13.5px; }
.settings-profile-row small { color: var(--text-muted); }
.settings-model-head { margin-top: 8px; padding: 12px 0; border-top: 1px solid var(--border); }
.settings-model-list { display: grid; gap: 8px; margin-bottom: 8px; }
.settings-model-row { display: grid; grid-template-columns: minmax(170px, 1fr) minmax(150px, 1fr) auto 36px; gap: 8px; align-items: center; }
.settings-model-row .model-enabled { white-space: nowrap; color: var(--text-secondary); font-size: 13px; display: inline-flex; align-items: center; gap: 5px; }
.settings-model-row .model-enabled input { accent-color: var(--accent); }
.settings-capabilities { display: flex; flex-wrap: wrap; gap: 16px; }
.settings-capabilities label { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-secondary); cursor: pointer; user-select: none; }
.settings-capabilities input { accent-color: var(--accent); }
.settings-editor-actions { margin-top: 16px; justify-content: flex-end; }
.api-model-select { min-width: 220px; max-width: 360px; }

/* ===== Responsive ===== */
@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1024px) {
  .module-grid {
    grid-template-columns: 1fr;
  }
  .dashboard-bottom {
    grid-template-columns: 1fr;
  }
  .settings-api-layout {
    grid-template-columns: 1fr;
  }
  .insight-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .form-row .form-group {
    margin-bottom: 14px;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar-backdrop {
    display: block;
    pointer-events: none;
  }

  .app.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(280px, 86vw);
    transform: translateX(-105%);
    transition: transform 0.24s var(--ease);
    box-shadow: 16px 0 48px rgba(0, 0, 0, 0.45);
  }

  .app.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .mobile-menu-btn {
    display: inline-flex;
  }

  .topbar {
    padding: 0 14px;
  }

  .topbar-right .search-wrap {
    display: none;
  }

  .topbar-right .status-pill {
    display: none;
  }

  .topbar-subtitle,
  .topbar-divider {
    display: none;
  }

  .content {
    padding: 14px 14px 28px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .card {
    padding: 16px;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .live-log-header {
    flex-direction: column;
  }

  .live-log-controls {
    justify-content: flex-start;
  }

  .live-log-select {
    max-width: 100%;
    width: 100%;
  }

  .live-log-event-filters {
    width: 100%;
  }

  .room-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .room-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .room-actions .btn {
    flex: 1;
  }

  .section-head-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .section-head-actions .tab-bar {
    margin-left: 0;
    align-self: flex-start;
    max-width: 100%;
    overflow-x: auto;
  }
}

@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .module-card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .active-item {
    flex-wrap: wrap;
  }

  .active-bar {
    flex: 1 1 100%;
    order: 3;
  }

  .active-meta {
    order: 4;
  }

  .recent-item {
    flex-wrap: wrap;
    row-gap: 4px;
  }

  .recent-time {
    margin-left: auto;
  }

  .settings-model-row {
    grid-template-columns: 1fr 36px;
  }

  .settings-model-row [data-display-name],
  .settings-model-row .model-enabled {
    grid-column: 1;
  }

  .settings-model-row .icon-btn {
    grid-column: 2;
    grid-row: 1;
  }

  .api-model-select {
    min-width: 0;
    width: 100%;
    max-width: none;
  }

  .tr-detail-grid {
    grid-template-columns: 1fr 1fr;
  }

  .tr-create-source-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .tr-create-source-tabs .tab-btn {
    min-width: 0;
    padding-left: 8px;
    padding-right: 8px;
  }

  .tr-workflow-source .value {
    max-width: min(100%, 280px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .page.active {
    animation: none;
  }
}
