:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f0f0f2;
  --glass: rgba(255, 255, 255, 0.82);
  --glass-border: rgba(0, 0, 0, 0.06);
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #aeaeb2;
  --accent: #007aff;
  --accent-soft: rgba(0, 122, 255, 0.08);
  --green: #34c759;
  --green-soft: rgba(52, 199, 89, 0.1);
  --red: #ff3b30;
  --red-soft: rgba(255, 59, 48, 0.08);
  --yellow: #ff9500;
  --yellow-soft: rgba(255, 149, 0, 0.1);
  --purple: #af52de;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', system-ui, sans-serif;
  --mono: 'SF Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
  --transition: 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.page-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: linear-gradient(180deg, #ffffff 0%, #f5f5f7 100%);
}

.card {
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 36px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  animation: fadeUp 0.4s ease-out;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.brand {
  text-align: center;
  margin-bottom: 32px;
}
.brand h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
  color: var(--text);
}
.brand p {
  color: var(--text-secondary);
  font-size: 14px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  margin-top: 16px;
}

input, textarea, select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 120px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--text-tertiary); }

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #0066d6; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--glass-border); }
.btn-secondary:hover:not(:disabled) { background: #e8e8ed; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #e0342a; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: var(--radius-xs); }

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mt-16 { margin-top: 16px; }
.mt-8 { margin-top: 8px; }

.status-dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
  animation: dotPulse 2s infinite;
}
.status-dot.green { background: var(--green); }
.status-dot.yellow { background: var(--yellow); }
.status-dot.red { background: var(--red); }
.status-dot.blue { background: var(--accent); }
.status-dot.gray { background: var(--text-tertiary); }

@keyframes dotPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}
.badge-success { background: var(--green-soft); color: #1a8d3a; }
.badge-failed, .badge-cancelled { background: var(--red-soft); color: var(--red); }
.badge-running { background: var(--accent-soft); color: var(--accent); }
.badge-queued, .badge-retry { background: var(--yellow-soft); color: #b36800; }
.badge-default { background: var(--surface-2); color: var(--text-secondary); }

.notice {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
}
.notice-info { background: var(--accent-soft); color: var(--accent); }
.notice-success { background: var(--green-soft); color: #1a8d3a; }
.notice-error { background: var(--red-soft); color: var(--red); }

pre {
  background: var(--surface-2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: var(--mono);
  font-size: 12px;
  overflow: auto;
  max-height: 600px;
  color: var(--text-secondary);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
}

.admin-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--glass-border);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
}
.sidebar-brand {
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 12px;
}
.sidebar-brand h2 { font-size: 16px; font-weight: 600; }
.sidebar-brand p { font-size: 12px; color: var(--text-tertiary); margin-top: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font);
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }

.main-content {
  padding: 32px;
  overflow-y: auto;
  background: var(--bg);
}

.section { display: none; animation: fadeUp 0.3s ease-out; }
.section.active { display: block; }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.section-header h2 { font-size: 22px; font-weight: 600; letter-spacing: -0.3px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 16px;
  box-shadow: var(--shadow);
}
.kpi-card .kpi-label { font-size: 12px; color: var(--text-tertiary); margin-bottom: 4px; }
.kpi-card .kpi-value { font-size: 28px; font-weight: 700; letter-spacing: -1px; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-tertiary);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--glass-border);
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--glass-border);
  vertical-align: middle;
}
.data-table tr:hover td { background: var(--surface-2); }
.data-table code { font-family: var(--mono); font-size: 12px; color: var(--text-secondary); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.form-grid label { margin-top: 0; }

.panel-card {
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.hidden { display: none !important; }

.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: linear-gradient(180deg, #ffffff 0%, #f5f5f7 100%);
}

.footer-link {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-tertiary);
}

@media (max-width: 768px) {
  .admin-layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: -260px; width: 260px; height: 100vh; z-index: 100;
    transition: left 0.3s ease;
  }
  .sidebar.open { left: 0; }
  .main-content { padding: 20px; }
  .card { padding: 24px; }
}

.announcement {
  max-width: 480px;
  width: 100%;
  margin-bottom: 16px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.announcement a { color: var(--accent); text-decoration: underline; }

.token-hint {
  margin: 8px 0 10px;
  padding: 12px 14px;
  background: var(--accent-soft);
  border: 1px solid rgba(0, 122, 255, 0.15);
  border-radius: var(--radius-xs);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text-secondary);
}
.token-hint-steps {
  display: flex;
  align-items: center;
  gap: 8px;
}
.token-hint-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.token-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 6px 0 8px 28px;
  padding: 6px 14px;
  background: var(--accent);
  color: #fff !important;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none !important;
  transition: opacity var(--transition);
}
.token-link:hover { opacity: 0.85; }

.step-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 16px 0 8px;
}
.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  position: relative;
}
.step-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 2px solid var(--glass-border);
  transition: all 0.3s ease;
}
.step-item.done .step-dot {
  background: var(--green);
  border-color: var(--green);
  box-shadow: 0 0 6px rgba(52, 199, 89, 0.3);
}
.step-item.active .step-dot {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 6px rgba(0, 122, 255, 0.4);
  animation: stepPulse 1.5s infinite;
}
.step-item.error .step-dot {
  background: var(--red);
  border-color: var(--red);
  box-shadow: 0 0 6px rgba(255, 59, 48, 0.3);
}
.step-text {
  font-size: 11px;
  color: var(--text-tertiary);
  text-align: center;
  white-space: nowrap;
}
.step-item.done .step-text { color: #1a8d3a; }
.step-item.active .step-text { color: var(--accent); font-weight: 500; }
.step-item.error .step-text { color: var(--red); }

@keyframes stepPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

.step-status {
  text-align: center;
  font-size: 13px;
  padding: 8px 0;
  color: var(--text-secondary);
}
.step-status.step-success { color: #1a8d3a; font-weight: 500; }
.step-status.step-error { color: var(--red); }
.step-status.step-active { color: var(--accent); }

.queue-info {
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
  padding: 8px 0;
  margin-top: 8px;
  border-top: 1px solid var(--glass-border);
}

.phone-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xs);
  margin-bottom: 6px;
  background: var(--surface);
  font-size: 13px;
}
.phone-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-width: 16px;
  accent-color: var(--accent);
}
.phone-check .phone-status {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-tertiary);
}
.phone-check .phone-status.available { color: #1a8d3a; }
.phone-check .phone-status.busy { color: var(--yellow); }
