:root {
  --bg: #f4f6f7;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e9ec;
  --accent: #0d7a68;
  --accent-soft: #e6f2ef;
  --blue: #3b82a0;
  --danger: #c2410c;
  --danger-soft: #fdeee9;
  --ok: #15803d;
  --ok-soft: #e7f5eb;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}

.login-card {
  width: min(420px, 92vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 12px 32px rgba(16, 24, 40, 0.08);
}

.login-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.login-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
}

.login-remember {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 9px;
  font-size: 12px;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}

.login-remember input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  flex: none;
}

.login-hint {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(13, 122, 104, .06);
  border: 1px solid rgba(13, 122, 104, .12);
}

.login-advanced {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.login-advanced > summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  padding: 4px 0;
  user-select: none;
}

.login-advanced > summary:hover {
  color: var(--ink);
}

.login-error {
  color: var(--danger);
  font-size: 12px;
  min-height: 18px;
  margin-top: 10px;
}

.login-connecting {
  display: none;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 12px 0;
}

.login-screen.connecting .login-fields,
.login-screen.connecting .login-btn,
.login-screen.connecting .login-error {
  display: none;
}

.login-screen.connecting .login-connecting {
  display: block;
}

.login-btn {
  width: 100%;
  height: 40px;
  margin-top: 12px;
}

body.logged-in .login-screen {
  display: none;
}

body:not(.logged-in) .layout {
  display: none;
}

button {
  font: inherit;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 224px;
  flex: none;
  background: #ffffff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.nav {
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: #4b5563;
  text-decoration: none;
  font-size: 14px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex: none;
}

.nav-item:hover {
  background: #f3f6f5;
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-foot {
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}

.source-badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
}

.source-badge.live {
  background: var(--ok-soft);
  color: var(--ok);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 20px 24px 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.page-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.btn:hover {
  background: #f3f6f5;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.btn.danger {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.warn-banner {
  margin-bottom: 14px;
  padding: 10px 14px;
  border: 1px solid #f3d9c4;
  border-radius: 8px;
  background: #fdf3e3;
  color: #92400e;
  font-size: 13px;
  line-height: 1.6;
}

/* 批量额度操作区（音色复刻 / 识别额度两页共用） */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 14px 0;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.bulk-bar .bulk-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.bulk-bar .footnote {
  font-size: 12px;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}

.kpi-label {
  font-size: 12px;
  color: var(--muted);
}

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  margin-top: 6px;
  line-height: 1;
}

.kpi-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

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

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card.pane {
  padding: 14px;
}

.col-4 {
  grid-column: span 4;
}

.col-5 {
  grid-column: span 5;
}

.col-6 {
  grid-column: span 6;
}

.col-7 {
  grid-column: span 7;
}

.col-8 {
  grid-column: span 8;
}

.col-12 {
  grid-column: span 12;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
}

.card-body {
  padding: 14px;
}

.chart {
  width: 100%;
  height: 220px;
  display: block;
}

.chart-sm {
  height: 180px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 3px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.toolbar .grow {
  flex: 1;
}

.input,
.select {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  font-size: 13px;
  min-width: 120px;
}

.input:focus,
.select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  background: #fafbfc;
}

tbody tr:hover {
  background: #f8faf9;
}

td .sub {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
}

.badge.success {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge.fail,
.badge.blocked {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.pending,
.badge.muted {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge.running {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge.done {
  background: var(--ok-soft);
  color: var(--ok);
}

.text-ellipsis {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-scroll {
  max-height: 120px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  min-width: 260px;
  line-height: 1.6;
  padding-right: 6px;
}

.empty {
  padding: 36px 16px;
  text-align: center;
  color: var(--muted);
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.setting-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 14px;
  align-items: center;
}

.setting-label {
  font-size: 13px;
  color: var(--muted);
}

.setting-value {
  display: flex;
  align-items: center;
  gap: 10px;
}

.setting-value .input {
  width: 100%;
}

.radio-group {
  display: flex;
  gap: 8px;
}

.radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
}

.radio.on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.ann-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 18px;
  align-items: start;
}

.ann-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8faf9;
}

.ann-preview-title {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

.ann-preview-scene {
  background: #e8efec;
  border-radius: 12px;
  padding: 18px 14px;
  display: flex;
  justify-content: center;
}

.ann-preview-modal {
  width: 100%;
  max-width: 260px;
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 18px 40px rgba(16, 24, 40, 0.2), 0 2px 8px rgba(13, 122, 104, 0.1);
  overflow: hidden;
  animation: annPreviewIn 0.25s ease both;
}

@keyframes annPreviewIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.ann-preview-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #0a5f52, #0d7a68 55%, #14a184);
  color: #ffffff;
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.ann-preview-icon {
  font-size: 16px;
  line-height: 1;
}

.ann-preview-body {
  padding: 16px;
  text-align: center;
  font-size: 13px;
  line-height: 1.7;
  color: #334155;
  min-height: 90px;
  max-height: 240px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  white-space: pre-wrap;
  background: #fbfcfb;
}

/* 正文含 HTML 标签时切到 normal：pre-wrap 会把标签之间的换行也显示出来，撑出一堆空行。
   选择器只认 .ann-rich 这个标记类本身 —— 它可能落在容器上，也可能落在内容 div 上。 */
.ann-rich { white-space: normal; }
.ann-preview-body.ann-rich,
.ann-preview-body .ann-rich { text-align: left; }
.ann-rich > *:first-child { margin-top: 0; }
.ann-rich > *:last-child { margin-bottom: 0; }
.ann-rich p { margin: 0 0 8px; }
.ann-rich img { max-width: 100%; height: auto; border-radius: 6px; }
.ann-rich a { color: var(--brand); text-decoration: underline; }
.ann-rich table { border-collapse: collapse; max-width: 100%; }
.ann-rich th,
.ann-rich td { border: 1px solid var(--line); padding: 6px 8px; }
.ann-rich ul,
.ann-rich ol { margin: 6px 0; padding-left: 22px; }
.ann-rich pre {
  white-space: pre-wrap;
  background: #f4f6f5;
  padding: 8px;
  border-radius: 6px;
}

.ann-preview-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: #fbfcfb;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.ann-preview-optout {
  font-size: 12px;
  color: #64748b;
}

.ann-preview-btn {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, #0d7a68, #14a184);
  color: #ffffff;
  font-size: 12px;
  box-shadow: 0 6px 14px rgba(13, 122, 104, 0.24);
}

.ann-preview-modal.off {
  opacity: 0.45;
  filter: grayscale(1);
}

.footnote {
  color: var(--muted);
  font-size: 12px;
}

.progress {
  width: 90px;
  height: 6px;
  background: #eef1f2;
  border-radius: 999px;
  overflow: hidden;
}

.progress > i {
  display: block;
  height: 100%;
  background: var(--accent);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 16px);
  max-width: min(560px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: 8px;
  background: #1f2937;
  color: #ffffff;
  font-size: 13px;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.18);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  background: #c2410c;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: none;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 150px;
}

.user-cell > span:last-child {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

.mini-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mini-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}

.mini-row:last-child {
  border-bottom: 0;
}

.rank {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: #eef1f2;
  color: #6b7280;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.mini-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.mini-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-sub {
  font-size: 12px;
  color: var(--muted);
}

.mini-num {
  font-size: 12px;
  color: var(--muted);
  flex: none;
}

.drawer-wrap {
  position: fixed;
  inset: 0;
  z-index: 60;
}

.drawer-mask {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
}

.drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(640px, 92vw);
  background: #ffffff;
  box-shadow: -12px 0 32px rgba(15, 23, 42, 0.14);
  display: flex;
  flex-direction: column;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.drawer-body {
  flex: 1;
  overflow: auto;
  padding: 16px;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.profile-item {
  background: #f8faf9;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.profile-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.profile-value {
  display: block;
  margin-top: 6px;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.drawer-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 14px;
}

.drawer-section .card-head {
  background: #fafbfc;
}

.modal-wrap {
  position: fixed;
  inset: 0;
  z-index: 70;
}

.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
}

.modal {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, 92vw);
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.modal-title {
  font-weight: 600;
}

.modal-body {
  padding: 16px;
}

.modal-textarea {
  width: 100%;
  min-height: 160px;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  color: var(--ink);
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}

@media (max-width: 1080px) {
  .kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .col-4,
  .col-5,
  .col-6,
  .col-7,
  .col-8 {
    grid-column: span 12;
  }
}

@media (max-width: 760px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
  }

  .brand {
    padding: 14px 16px 10px;
  }

  .nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 8px 10px;
  }

  .nav-item {
    flex: none;
  }

  .sidebar-foot {
    display: none;
  }

  .main {
    padding: 14px 12px 28px;
  }

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

  .setting-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

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

  .ann-layout {
    grid-template-columns: 1fr;
  }
}
