:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --panel2: #243044;
  --border: #2d3a4f;
  --text: #e8edf5;
  --muted: #8b9cb3;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(1200px 600px at 10% -10%, #1e3a5f 0%, transparent 60%),
    radial-gradient(900px 500px at 90% 0%, #1a2f4a 0%, transparent 55%),
    var(--bg);
  color: var(--text);
}

a { color: var(--primary); text-decoration: none; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: rgba(26, 35, 50, 0.95);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.login-card p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14px;
}

.field { margin-bottom: 16px; }
.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted);
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #111827;
  color: var(--text);
  font-size: 15px;
}

.field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s ease;
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }

.error-msg {
  min-height: 20px;
  margin-top: 12px;
  color: var(--danger);
  font-size: 13px;
}

.admin-root { min-height: 100vh; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(26, 35, 50, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
}

.topbar .sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.welcome-msg {
  color: var(--text);
  font-size: 14px;
  white-space: nowrap;
}

.content { padding: 20px 24px 40px; max-width: 1400px; margin: 0 auto; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  text-align: left;
}

.stat-card-clickable {
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s, box-shadow 0.15s;
  width: 100%;
  color: inherit;
  font: inherit;
}

.stat-card-clickable:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.12);
}

.stat-hint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--primary);
  opacity: 0.85;
}

.stat-card .label { color: var(--muted); font-size: 13px; }
.stat-card .value { font-size: 28px; font-weight: 700; margin-top: 6px; }
.stat-fail { color: var(--danger); }

.filter-dot.failed { background: #f87171; }
.filter-chip.active .filter-dot.failed {
  background: #fca5a5;
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.18);
}

.badge-grab-success { background: rgba(34, 197, 94, 0.18); color: #4ade80; }
.badge-grab-failed { background: rgba(239, 68, 68, 0.18); color: #f87171; }
.badge-grab-pending { background: rgba(234, 179, 8, 0.18); color: #facc15; }
.badge-grab-running { background: rgba(59, 130, 246, 0.18); color: #60a5fa; }

.client-item.tone-success { border-left: 3px solid var(--success); }
.client-item.tone-failed { border-left: 3px solid var(--danger); }
.client-item.tone-pending { border-left: 3px solid var(--warning); }
.client-item.tone-running { border-left: 3px solid var(--primary); }

.client-fail-reason,
.client-note {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.45;
}
.client-fail-reason { color: #fca5a5; }
.client-note { color: #93c5fd; }
.client-fail-reason.muted { color: var(--muted); }

.verify-panel { margin-bottom: 20px; }
.verify-desc {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}
.verify-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 14px;
  font-size: 12px;
}
.verify-legend-item.success { color: #4ade80; }
.verify-legend-item.failed { color: #f87171; }
.verify-legend-item.pending { color: #facc15; }
.verify-legend-item.running { color: #60a5fa; }

.verify-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.verify-card {
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--panel2);
  color: inherit;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
}
.verify-card:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
}
.verify-card.tone-success { box-shadow: inset 3px 0 0 var(--success); }
.verify-card.tone-failed { box-shadow: inset 3px 0 0 var(--danger); }
.verify-card.tone-pending { box-shadow: inset 3px 0 0 var(--warning); }
.verify-card.tone-running { box-shadow: inset 3px 0 0 var(--primary); }

.verify-card-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}
.verify-card-top strong {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.verify-dot {
  flex-shrink: 0;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}
.verify-meta {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
.verify-meta.subtle { opacity: 0.8; font-size: 11px; }
.verify-fail {
  margin-top: 8px;
  font-size: 12px;
  color: #fca5a5;
  line-height: 1.45;
}
.verify-note {
  margin-top: 6px;
  font-size: 12px;
  color: #93c5fd;
  line-height: 1.45;
}

.note-highlight {
  color: #93c5fd;
  font-weight: 600;
}

.fail-main-box {
  border: 1px solid rgba(239, 68, 68, 0.25);
  background: rgba(239, 68, 68, 0.08);
  border-radius: 10px;
  padding: 12px 14px;
}
.fail-main-label {
  font-size: 12px;
  color: #fca5a5;
  margin-bottom: 6px;
}
.fail-main-text {
  font-size: 14px;
  line-height: 1.55;
  color: #fecaca;
}
.fail-main-meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}
.fail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.fail-table th,
.fail-table td {
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
}
.empty-inline {
  font-size: 13px;
  color: var(--muted);
  padding: 8px 0;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-danger-ghost {
  background: transparent;
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.45);
}

.btn-danger-ghost:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #fecaca;
}

.detail-actions {
  display: flex;
  gap: 8px;
}

.detail-actions.hidden {
  display: none;
}

.chat-entry-panel {
  margin-bottom: 20px;
}

.chat-entry-desc {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.chat-entry-btn {
  width: auto;
  display: inline-flex;
  padding-inline: 20px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
}

@media (max-width: 960px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.panel-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-head h2 {
  margin: 0;
  font-size: 16px;
}

.panel-search {
  padding: 10px 18px 0;
}

.panel-search input {
  width: 100%;
  border-radius: 9px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.65);
  color: var(--text);
  font-size: 13px;
}

.search-hub {
  margin-bottom: 20px;
  padding: 18px 20px 16px;
  border-radius: 16px;
  border: 1px solid rgba(59, 130, 246, 0.22);
  background:
    linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(26, 35, 50, 0.92) 42%, rgba(17, 24, 39, 0.95) 100%);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.search-hub.compact {
  margin: 0 0 14px;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

.search-hub-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.search-hub-intro {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.search-hub-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.14);
  border: 1px solid rgba(59, 130, 246, 0.28);
  flex-shrink: 0;
}

.search-hub-icon svg,
.search-box-icon {
  width: 18px;
  height: 18px;
}

.search-hub-title {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.search-hub-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.search-result-badge {
  flex-shrink: 0;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  color: #bfdbfe;
  background: rgba(59, 130, 246, 0.14);
  border: 1px solid rgba(59, 130, 246, 0.28);
  white-space: nowrap;
}

.search-result-badge:empty {
  display: none;
}

.search-result-badge.is-empty {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.28);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(8, 13, 24, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}

.search-box:focus-within {
  border-color: rgba(59, 130, 246, 0.55);
  box-shadow:
    0 0 0 3px rgba(59, 130, 246, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
  background: rgba(8, 13, 24, 0.9);
}

.search-box-icon {
  color: #64748b;
  flex-shrink: 0;
}

.search-box:focus-within .search-box-icon {
  color: #93c5fd;
}

.search-box input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  padding: 12px 0;
  outline: none;
  min-width: 0;
}

.search-box input::placeholder {
  color: #64748b;
}

.search-box input::-webkit-search-cancel-button {
  display: none;
}

.search-box-clear {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #94a3b8;
  background: rgba(148, 163, 184, 0.08);
  transition: background 0.15s, color 0.15s;
}

.search-box-clear:hover {
  color: #e2e8f0;
  background: rgba(148, 163, 184, 0.16);
}

.search-box-clear.hidden {
  display: none;
}

.search-box-clear svg {
  width: 14px;
  height: 14px;
}

.search-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(15, 23, 42, 0.55);
  color: #94a3b8;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.16s ease;
}

.filter-chip:hover {
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.32);
  background: rgba(30, 41, 59, 0.75);
}

.filter-chip.active {
  color: #dbeafe;
  border-color: rgba(59, 130, 246, 0.45);
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.2), rgba(37, 99, 235, 0.12));
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.16);
}

.filter-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #64748b;
  box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.15);
}

.filter-chip.active .filter-dot {
  background: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.18);
}

.filter-dot.online { background: #22c55e; }
.filter-dot.scheduled { background: #f59e0b; }
.filter-dot.success { background: #38bdf8; }

.filter-chip.active .filter-dot.online {
  background: #4ade80;
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.18);
}

.filter-chip.active .filter-dot.scheduled {
  background: #fbbf24;
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.18);
}

.filter-chip.active .filter-dot.success {
  background: #7dd3fc;
  box-shadow: 0 0 0 3px rgba(125, 211, 252, 0.18);
}

.mark-hit {
  background: linear-gradient(180deg, rgba(250, 204, 21, 0.28), rgba(245, 158, 11, 0.18));
  color: #fde68a;
  border-radius: 4px;
  padding: 0 3px;
  box-shadow: inset 0 0 0 1px rgba(250, 204, 21, 0.18);
}

.phone-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.phone-input-row input {
  flex: 0 0 auto;
  width: 72px;
  text-align: center;
}

.phone-input-row input:last-of-type {
  width: 88px;
}

.phone-mask-sep {
  color: var(--muted);
  user-select: none;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-online { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.badge-offline { background: rgba(139, 156, 179, 0.15); color: var(--muted); }
.badge-scheduled { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-running { background: rgba(59, 130, 246, 0.15); color: var(--primary); }
.badge-success { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.badge-fail { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

.client-list { list-style: none; margin: 0; padding: 0; }
.client-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.client-item:hover, .client-item.active { background: var(--panel2); }
.client-item:last-child { border-bottom: none; }

.client-item-main {
  flex: 1;
  min-width: 0;
  padding: 14px 18px;
  cursor: pointer;
}

.client-item-actions {
  display: flex;
  gap: 4px;
  padding-right: 12px;
  flex-shrink: 0;
}

.btn-icon {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #111827;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  display: grid;
  place-items: center;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.btn-icon:hover {
  background: var(--panel2);
  color: var(--text);
  border-color: var(--primary);
}

.btn-icon.danger:hover {
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.1);
}

.client-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.client-meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.detail-body { padding: 18px; }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kv {
  background: #111827;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.kv .k { font-size: 12px; color: var(--muted); }
.kv .v { margin-top: 4px; font-size: 14px; word-break: break-all; }

.check-list { display: grid; gap: 8px; margin-bottom: 16px; }
.check-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #111827;
  border-radius: 8px;
  font-size: 13px;
}

.log-box {
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.5;
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.event-list { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow: auto; }
.event-item {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.event-item time { color: var(--muted); font-size: 12px; }

.empty {
  padding: 40px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* Admin modals */
.admin-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 300;
  padding: 20px;
}

.admin-modal.hidden {
  display: none;
}

.admin-modal-card {
  width: min(480px, 100%);
  max-height: 90vh;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.admin-modal-wide {
  width: min(720px, 100%);
}

.admin-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.history-modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.admin-modal-head h3 {
  margin: 0;
  font-size: 17px;
}

.admin-modal-head p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.admin-modal-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: #111827;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  flex-shrink: 0;
}

.admin-modal-close:hover {
  color: var(--text);
  background: var(--panel2);
}

.history-list-wrap {
  overflow: auto;
  max-height: calc(90vh - 90px);
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.history-item-body {
  flex: 1;
  min-width: 0;
}

.history-delete-btn {
  flex-shrink: 0;
}

.history-item:last-child {
  border-bottom: none;
}

.history-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.history-item-meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.history-item time {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}

.admin-form {
  padding: 18px 20px 20px;
}

.form-field {
  margin-bottom: 14px;
}

.form-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted);
}

.form-field input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #111827;
  color: var(--text);
  font-size: 14px;
}

.form-field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-tip {
  margin: 0 0 16px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.admin-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
