:root {
  --bg: #0a0a0f;
  --surface: #12121a;
  --surface-2: #1a1a26;
  --border: #2a2a3d;
  --text: #f0f0f5;
  --text-muted: #8888a0;
  --accent: #00d4aa;
  --accent-dim: #00d4aa22;
  --accent-glow: #00d4aa44;
  --error: #ff5c6a;
  --error-bg: #ff5c6a18;
  --success: #00d4aa;
  --radius: 14px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  line-height: 1.5;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.25;
  mask-image: radial-gradient(ellipse at center, black 20%, transparent 70%);
  pointer-events: none;
}

.container {
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 1;
}

.header {
  text-align: center;
  margin-bottom: 32px;
}

.logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-glow);
  border-radius: 16px;
  color: var(--accent);
  margin-bottom: 16px;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 6px;
}

.steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 24px;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: color 0.3s;
}

.step.active {
  color: var(--accent);
}

.step.done {
  color: var(--text);
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  transition: all 0.3s;
}

.step.active .step-num {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

.step.done .step-num {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--bg);
}

.step-line {
  width: 40px;
  height: 2px;
  background: var(--border);
  margin: 0 4px 16px;
  transition: background 0.3s;
}

.step-line.done {
  background: var(--accent);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  animation: fadeUp 0.35s ease;
}

.card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.hint {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 24px;
}

.hint strong {
  color: var(--text);
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
  margin-top: 16px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

label:first-of-type {
  margin-top: 0;
}

input[type="text"],
select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
  padding: 14px 16px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

select {
  cursor: pointer;
  appearance: none;
  background-color: var(--surface-2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238888a0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

select option {
  background: var(--surface-2);
  color: var(--text);
}

.script-preview {
  margin-top: 12px;
  margin-bottom: 4px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.script-preview-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.script-preview p {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}

.script-toolbar {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.script-toolbar select {
  flex: 1;
  min-width: 0;
  max-width: 100%;
}

.script-upload {
  margin-top: 16px;
  margin-bottom: 8px;
  padding: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.script-upload-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.script-upload-header label {
  margin: 0;
}

.btn-link-small {
  font-size: 0.8125rem;
}

#script-name,
#script-text {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.9375rem;
  padding: 12px 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#script-name {
  margin-bottom: 10px;
}

#script-text {
  min-height: 120px;
  resize: vertical;
  line-height: 1.55;
}

#script-name:focus,
#script-text:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.script-editor-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0 16px;
}

.editor-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.dropzone {
  padding: 20px 16px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.06);
}

.dropzone.uploading {
  opacity: 0.7;
  pointer-events: none;
}

.dropzone-title {
  margin: 0 0 6px;
  font-size: 0.9375rem;
  color: var(--text);
}

.dropzone-sub {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.dropzone-sub + .dropzone-sub {
  margin-top: 4px;
}

.btn-small {
  width: auto;
  padding: 10px 14px;
  font-size: 0.875rem;
  white-space: nowrap;
}

.script-toolbar .btn-small {
  flex-shrink: 0;
}

.live-console {
  margin-bottom: 24px;
  background: #0a0a0f;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.live-console-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.console-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: #101018;
  border-bottom: 1px solid var(--border);
}

.console-status-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.console-status-text {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  text-align: right;
}

.console-status-text.status-calling,
.console-status-text.status-ringing {
  color: #ffd166;
}

.console-status-text.status-answered {
  color: #86efac;
}

.console-status-text.status-no-answer,
.console-status-text.status-rejected {
  color: #ff8fa3;
}

.console-status-text.status-await {
  color: #c4b5fd;
}

.console-status-text.status-gathering {
  color: #7dd3fc;
}

.code-sent-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(134, 239, 172, 0.08);
  border-bottom: 1px solid rgba(134, 239, 172, 0.25);
}

.code-sent-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.code-sent-label {
  font-size: 0.9375rem;
  font-weight: 700;
  color: #86efac;
}

.code-sent-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.code-review-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(125, 211, 252, 0.08);
  border-bottom: 1px solid rgba(125, 211, 252, 0.25);
}

.code-review-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #7dd3fc;
}

.code-review-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.5s ease infinite;
}

.live-console-body {
  max-height: 180px;
  overflow-y: auto;
  padding: 12px 14px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.8rem;
}

.console-line {
  display: flex;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid #1a1a26;
  line-height: 1.4;
}

.console-line:last-child {
  border-bottom: none;
}

.console-time {
  color: #55556a;
  flex-shrink: 0;
}

.console-line.info .console-msg { color: #8ec8ff; }
.console-line.calling .console-msg { color: #ffd166; }
.console-line.ringing .console-msg { color: #ffd166; }
.console-line.answered .console-msg { color: var(--accent); }
.console-line.speaking .console-msg { color: #c4b5fd; }
.console-line.spoken .console-msg { color: #86efac; }
.console-line.hangup .console-msg { color: #ff8fa3; }
.console-line.voicemail .console-msg { color: #fb923c; font-weight: 600; }
.console-line.error .console-msg { color: var(--error); }

.code-lock-display {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: #0d0d14;
}

.code-lock-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

.code-lock-slots {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.code-lock-slot {
  width: 38px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid #2a2a3a;
  background: #12121a;
  color: #55556a;
  font-size: 1.1rem;
  font-weight: 700;
  font-family: Consolas, "Courier New", monospace;
  transition: all 0.2s ease;
}

.code-lock-slot.empty {
  color: #3a3a4a;
}

.code-lock-slot.locked {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.25);
}

.code-lock-slot.web-input.locked {
  border-color: #86efac;
  background: rgba(134, 239, 172, 0.08);
}

.console-line.sms .console-msg { color: #7dd3fc; }
.console-line.gathering .console-msg { color: #fbbf24; }
.console-line.code_entered .console-msg { color: #86efac; font-weight: 600; }
.console-line.code_digit .console-msg { color: #86efac; }
.console-line.verified .console-msg { color: #86efac; }
.console-line.code_sent_prompt .console-msg { color: #86efac; font-weight: 700; }
.console-line.code_sent .console-msg { color: #7dd3fc; font-weight: 600; }
.console-line.code_complete .console-msg { color: #7dd3fc; }
.console-line.code_approved .console-msg { color: #86efac; font-weight: 600; }

.input-row {
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 20px;
  transition: border-color 0.2s;
}

.input-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.prefix {
  padding: 0 14px;
  color: var(--text-muted);
  font-size: 0.95rem;
  border-right: 1px solid var(--border);
  background: var(--bg);
  align-self: stretch;
  display: flex;
  align-items: center;
}

.input-row input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 1rem;
  padding: 14px 16px;
  font-family: inherit;
}

.code-inputs {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 24px;
}

.code-inputs input {
  width: 48px;
  height: 56px;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.code-inputs input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.1);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  width: auto;
  flex: 1;
}

.btn-ghost:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.btn-row {
  display: flex;
  gap: 12px;
}

.btn-row .btn-primary {
  flex: 2;
}

.btn-link {
  display: block;
  width: 100%;
  margin-top: 16px;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.875rem;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
}

.btn-link:hover {
  text-decoration: underline;
}

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.calling-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-glow);
  border-radius: 10px;
  margin-bottom: 24px;
  font-size: 0.875rem;
  color: var(--accent);
}

.calling-status.hidden {
  display: none;
}

.pulse-ring {
  width: 12px;
  height: 12px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 1.5s ease infinite;
  flex-shrink: 0;
}

.success-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-glow);
  border-radius: 50%;
  color: var(--accent);
}

#panel-success {
  text-align: center;
}

#panel-success .hint {
  margin-bottom: 28px;
}

.alert {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.875rem;
  animation: fadeUp 0.3s ease;
}

.alert.error {
  background: var(--error-bg);
  border: 1px solid var(--error);
  color: var(--error);
}

.alert.success {
  background: var(--accent-dim);
  border: 1px solid var(--accent-glow);
  color: var(--accent);
}

.hidden {
  display: none !important;
}

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

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

@media (max-width: 400px) {
  .code-inputs input {
    width: 40px;
    height: 48px;
    font-size: 1.2rem;
  }

  .code-inputs {
    gap: 6px;
  }
}
