:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --text: #1a2332;
  --muted: #6b7785;
  --border: #dce0e6;
  --primary: #1f6feb;
  --primary-hover: #1858c7;
  --danger: #d1242f;
  --danger-hover: #b01e28;
  --success: #1a7f37;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(26, 35, 50, 0.08);
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(ellipse 80% 50% at 100% -20%, #dbe7fb 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 0% 100%, #e8edf5 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 40px;
}

.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 24px 40px;
}

.app-shell .page {
  max-width: none;
  margin: 0;
  padding: 0;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.topbar-brand h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
}

.topbar-brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.tab-nav {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.tab-btn {
  appearance: none;
  border: none;
  background: transparent;
  padding: 9px 16px;
  border-radius: 7px;
  font: inherit;
  font-weight: 650;
  color: var(--muted);
  cursor: pointer;
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
}

.tab-panel[hidden] {
  display: none !important;
}

.page h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.speech-intro {
  margin: 0 0 18px;
  padding: 12px 14px;
  background: #f0f5ff;
  border: 1px solid #d6e4ff;
  border-radius: 8px;
  color: #243447;
  line-height: 1.6;
}

.speech-form {
  max-width: none;
  width: 100%;
}

.speech-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
}

.speech-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 8px;
}

.speech-panel textarea,
.speech-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  resize: vertical;
  min-height: 88px;
  background: #fff;
  color: var(--text);
}

.speech-panel textarea:focus,
.speech-form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.15);
}

.speech-panel textarea.invalid,
.speech-form textarea.invalid {
  border-color: var(--danger);
}

.preview-box {
  margin: 8px 0 16px;
  padding: 14px 16px;
  border-radius: 8px;
  border: 1px dashed #b8c4d4;
  background: #f8fafc;
}

.preview-title {
  font-weight: 650;
  margin-bottom: 10px;
}

.preview-box p {
  margin: 0 0 8px;
  line-height: 1.55;
}

.preview-box p:last-child {
  margin-bottom: 0;
}

.preview-label {
  color: var(--muted);
  margin-right: 6px;
}

@media (max-width: 860px) {
  .speech-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.header-actions {
  display: flex;
  gap: 10px;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 16px;
  font: inherit;
  font-weight: 560;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
  background: #eef2f7;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.btn-link {
  background: transparent;
  border: none;
  padding: 4px 8px;
  color: var(--primary);
  font-weight: 560;
}

.btn-link:hover {
  text-decoration: underline;
}

.btn-link.danger {
  color: var(--danger);
}

.alert {
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: #e8f5ec;
  color: var(--success);
  border: 1px solid #c6e6d0;
}

.alert.alert-error {
  background: #fdecea;
  color: #b42318;
  border-color: #f5c2c0;
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto;
  min-height: 180px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 1080px;
}

.table-resize-hint {
  margin: 0 0 8px;
}

.data-table th,
.data-table td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  overflow: hidden;
}

/* 列表正文（状态/文案/操作）整体缩小，序号列除外 */
.data-table tbody td:not(.col-index) {
  font-size: 12px;
  line-height: 1.4;
  padding: 8px 8px;
}

.data-table tbody td.col-index {
  font-size: 12px;
  padding: 8px 8px;
}

.data-table .btn-link {
  padding: 2px 4px;
  font-size: 12px;
  font-weight: 500;
}

.data-table .status-toggle {
  gap: 5px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
}

.data-table .status-dot {
  width: 6px;
  height: 6px;
}

.data-table .cell-wrap {
  font-size: 12px;
  line-height: 1.4;
}

.data-table .date-range {
  font-size: 12px;
  line-height: 1.3;
}

.data-table .date-sep {
  font-size: 11px;
}

.data-table td.col-name {
  font-weight: 560;
  font-size: 12px;
}

.data-table td.col-plays,
.data-table td.col-priority {
  font-size: 12px;
  font-weight: 600;
}

.data-table td.col-index,
.data-table td.col-status,
.data-table td.col-priority,
.data-table td.col-plays,
.data-table td.col-actions {
  vertical-align: middle;
}

.data-table th {
  background: #f7f9fc;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
  user-select: none;
}

.col-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  z-index: 3;
}

.col-resizer::after {
  content: "";
  position: absolute;
  top: 20%;
  bottom: 20%;
  left: 3px;
  width: 1px;
  background: transparent;
}

.col-resizer:hover::after,
body.is-col-resizing .col-resizer:hover::after {
  background: var(--primary);
}

body.is-col-resizing {
  cursor: col-resize !important;
  user-select: none !important;
}

body.is-col-resizing iframe {
  pointer-events: none;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: #f8fafc;
}

.col-index {
  width: 52px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.col-status {
  width: 100px;
}

.col-name {
  width: 110px;
  font-weight: 600;
  word-break: break-word;
}

.col-prefix {
  width: 22%;
}

.col-plays {
  width: 72px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.col-targets {
  width: 18%;
}

.field-full,
.form-grid .field-full {
  grid-column: 1 / -1;
}

.segment-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.segment-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  line-height: 1.35;
}

.segment-chip .seg-label {
  font-weight: 500;
}

.segment-chip .seg-sub {
  font-size: 11px;
  color: #9a6700;
}

.segment-chip.selected {
  border-color: var(--primary);
  background: #eaf1ff;
  color: var(--primary);
}

.segment-chip.selected .seg-label {
  font-weight: 650;
}

.segment-chip.is-free:not(.selected):hover {
  border-color: #9db7f0;
  background: #f5f8ff;
}

.segment-chip.is-occupied,
.segment-chip:disabled {
  cursor: not-allowed;
  background: #f0f2f5;
  border-color: #e2e5ea;
  color: #9aa3ad;
  opacity: 0.92;
}

.segment-chip.is-occupied .seg-label {
  text-decoration: line-through;
  text-decoration-color: #c5ccd4;
}

.col-date {
  width: 132px;
}

.col-priority {
  width: 64px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.col-remark {
  width: 18%;
}

.col-time {
  width: 118px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.col-actions {
  width: 108px;
  white-space: nowrap;
}

.data-table th.col-priority,
.data-table td.col-priority,
.data-table th.col-plays,
.data-table td.col-plays {
  text-align: center;
}

.stats-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stats-summary-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

.stat-value {
  margin-top: 6px;
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-value .stat-sub {
  margin-left: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.stat-value.is-vip {
  color: #f97316;
}

.users-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.users-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.select-input {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text);
}

.btn-success {
  background: #10b981;
  color: #fff;
  border: none;
}

.btn-success:hover {
  background: #059669;
}

.chart-wrap {
  position: relative;
  max-width: 360px;
  margin: 0 auto;
}

.style-chips {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.style-chip {
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.4;
}

.style-chip.c0 { background: #eff6ff; color: #1e3a8a; }
.style-chip.c1 { background: #ecfdf5; color: #065f46; }
.style-chip.c2 { background: #f5f3ff; color: #5b21b6; }
.style-chip.c3 { background: #fffbeb; color: #92400e; }
.style-chip.c4 { background: #f3f4f6; color: #374151; }
.style-chip.c5 { background: #f3f4f6; color: #374151; }

.vip-insights {
  background: #fff7ed;
  border: 1px solid #fed7aa;
}

.vip-insights h3 {
  color: #c2410c;
}

.vip-insights-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
  font-size: 14px;
  line-height: 1.7;
  color: #9a3412;
}

.vip-insights-list li::before {
  content: "✅ ";
}

.mini-table thead th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 0;
  border-bottom: 1px solid #eef1f5;
  background: transparent;
}

.mini-table thead th.num,
.mini-table td.num {
  text-align: right;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.stats-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 12px;
}

.stats-panel h3 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 650;
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
}

.mini-table td {
  padding: 8px 0;
  border-bottom: 1px solid #eef1f5;
  vertical-align: top;
}

.mini-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  width: 64px;
}

.mini-table td.is-empty {
  color: var(--muted);
  text-align: center;
}

@media (max-width: 820px) {
  .stats-summary,
  .stats-summary-4,
  .stats-grid,
  .style-chips {
    grid-template-columns: 1fr;
  }
}

.cell-wrap {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.55;
  color: var(--text);
}

.cell-wrap.is-empty {
  color: #b0b8c2;
}

.date-range {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.date-sep {
  color: var(--muted);
  font-size: 12px;
}

.status-toggle {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.status-toggle.on {
  background: #e6f6eb;
  border-color: #9fd5b0;
  color: #146c2e;
}

.status-toggle.on:hover {
  background: #d7f0df;
}

.status-toggle.off {
  background: #eef1f4;
  border-color: #cfd6de;
  color: #5b6672;
}

.status-toggle.off:hover {
  background: #e4e8ed;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.on {
  background: #1a7f37;
}

.status-dot.off {
  background: #9aa5b1;
}

.status-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 20px;
  padding: 16px 18px;
  border-radius: 10px;
  border: 1px solid #9fd5b0;
  background: linear-gradient(135deg, #eaf8ef 0%, #f4fbf6 100%);
}

.status-banner.is-off {
  border-color: #cfd6de;
  background: linear-gradient(135deg, #f2f4f7 0%, #f7f8fa 100%);
}

.status-banner-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.status-banner-text strong {
  font-size: 15px;
}

.status-banner-text span {
  color: var(--muted);
  font-size: 12px;
}

.status-seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.status-seg-btn {
  appearance: none;
  border: none;
  background: transparent;
  padding: 8px 18px;
  border-radius: 6px;
  font: inherit;
  font-weight: 650;
  color: var(--muted);
  cursor: pointer;
}

.status-seg-btn.active[data-status-set="1"] {
  background: #1a7f37;
  color: #fff;
}

.status-seg-btn.active[data-status-set="0"] {
  background: #5b6672;
  color: #fff;
}

.empty-state {
  padding: 56px 24px;
  text-align: center;
  color: var(--muted);
}

.page-footer {
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.site-beian {
  text-align: center;
  padding: 20px 16px 28px;
  font-size: 13px;
  color: var(--muted);
}

.site-beian a {
  color: var(--muted);
  text-decoration: none;
}

.site-beian a:hover {
  text-decoration: underline;
}

.form,
.form-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.form-grid .field {
  margin-bottom: 0;
}

.form-span-2 {
  grid-column: 1 / -1;
}

.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-weight: 560;
}

.req {
  color: var(--danger);
}

.field input[type="text"],
.field input[type="number"],
.field input[type="date"],
.field input[type="tel"],
.field input[type="url"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: #fff;
  color: var(--text);
  box-sizing: border-box;
}

.field input.input-phone {
  max-width: 360px;
  letter-spacing: 0.04em;
}

.field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.15);
}

.field input.invalid {
  border-color: var(--danger);
}

.hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.hint-inline {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

#prefix-count {
  margin-left: 8px;
  color: var(--primary);
  font-weight: 600;
}

#prefix-count.count-over {
  color: var(--danger);
}

.prefix-compose {
  display: flex;
  align-items: stretch;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}

.prefix-compose:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
}

.prefix-compose:has(input.invalid) {
  border-color: var(--danger);
}

.prefix-compose input {
  flex: 1 1 auto;
  min-width: 0;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: transparent;
}

.prefix-compose input:focus {
  border: none !important;
  box-shadow: none !important;
}

.prefix-suffix {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  max-width: 48%;
  padding: 0 12px;
  background: #f3f6ff;
  color: #1f6feb;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  border-left: 1px solid var(--border);
}

.field-error {
  margin: 6px 0 0;
  color: var(--danger);
  font-size: 12px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.inline {
  display: flex;
  align-items: center;
  gap: 12px;
}

.inline input {
  width: 140px;
}

@media (max-width: 640px) {
  .status-banner {
    flex-direction: column;
    align-items: stretch;
  }

  .status-seg {
    width: 100%;
  }

  .status-seg-btn {
    flex: 1;
  }
}

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 10px 18px;
  border-radius: 6px;
  background: #1a2332;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  font-size: 13px;
}

.modal[hidden],
.page[hidden],
[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 35, 50, 0.45);
}

.modal-panel {
  position: relative;
  width: min(420px, 100%);
  background: var(--surface);
  border-radius: 10px;
  padding: 22px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
}

.modal-text {
  margin: 0 0 20px;
  font-size: 15px;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.cities-meta {
  margin: 16px 0 8px;
  display: grid;
  gap: 8px;
}

.cities-meta p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

@media (max-width: 640px) {
  .page {
    padding: 18px 14px 32px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .field-row {
    grid-template-columns: 1fr;
  }
}
