:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --primary-border: #c7d2fe;
    --secondary: #64748b;
    --success: #10b981;
    --success-light: #ecfdf5;
    --success-border: #a7f3d0;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --danger-border: #fecaca;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --warning-border: #fde68a;
    --info: #0284c7;
    --info-light: #f0f9ff;
    --info-border: #bae6fd;
    --bg-page: #f1f5f9;
    --card-bg: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-radius-lg: 16px;
    --border-radius-md: 10px;
    --border-radius-sm: 6px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-page);
    background-image: 
        radial-gradient(at 0% 0%, rgba(79, 70, 229, 0.08) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(14, 165, 233, 0.08) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2rem 1rem;
}

.app-container {
    width: 100%;
    max-width: 580px;
    margin: 0 auto;
}

/* Header & Brand */
.app-header {
    text-align: center;
    margin-bottom: 2rem;
}

.brand-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: 9999px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
}

.brand-badge .dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
    animation: pulse 2s infinite;
}

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

.app-title {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.app-subtitle {
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

/* Main Card */
.auth-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    transition: all 0.25s ease;
}

.card-header-bar {
    padding: 1.25rem 1.75rem;
    border-bottom: 1px solid var(--border-color);
    background: #fafafa;
}

.card-body {
    padding: 2rem 2.25rem;
}

@media (max-width: 640px) {
    .card-body {
        padding: 1.5rem 1.25rem;
    }
    .app-title {
        font-size: 1.5rem;
    }
}

/* Stepper Component */
.stepper-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
    position: relative;
    z-index: 2;
}

.step-indicator {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    font-weight: 700;
    background: #f1f5f9;
    color: var(--secondary);
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
}

.step-item.active .step-indicator {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
}

.step-item.completed .step-indicator {
    background: var(--success);
    color: #ffffff;
    border-color: var(--success);
}

.step-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: center;
}

.step-item.active .step-label {
    color: var(--primary);
}

.step-item.completed .step-label {
    color: var(--success);
}

.stepper-connector {
    position: absolute;
    top: 16px;
    left: 16%;
    right: 16%;
    height: 2px;
    background: var(--border-color);
    z-index: 1;
}

.stepper-connector-progress {
    height: 100%;
    background: var(--success);
    transition: width 0.3s ease;
}

/* Form Controls */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon-prefix {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    pointer-events: none;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.65rem;
    font-size: 0.9375rem;
    color: var(--text-primary);
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input.no-prefix {
    padding-left: 1rem;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.input-action-btn {
    position: absolute;
    right: 12px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    padding: 4px;
    border-radius: 4px;
}

.input-action-btn:hover {
    color: var(--text-primary);
}

.validation-message {
    font-size: 0.8125rem;
    color: var(--danger);
    margin-top: 0.375rem;
    display: block;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    line-height: 1.25;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.btn-success {
    background: var(--success);
    color: #ffffff;
}

.btn-success:hover:not(:disabled) {
    background: #059669;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.btn-outline {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.btn-outline:hover:not(:disabled) {
    background: #f8fafc;
    border-color: var(--secondary);
    color: var(--text-primary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: none;
}

.btn-ghost:hover:not(:disabled) {
    background: #f1f5f9;
    color: var(--text-primary);
}

.btn-full {
    width: 100%;
}

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

/* Spinner */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

.spinner-primary {
    border-color: var(--primary-light);
    border-top-color: var(--primary);
}

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

/* Alerts */
.alert {
    padding: 0.875rem 1.125rem;
    border-radius: var(--border-radius-md);
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    line-height: 1.4;
}

.alert-icon {
    flex-shrink: 0;
    margin-top: 1px;
}

.alert-content {
    flex: 1;
}

.alert-success {
    background: var(--success-light);
    border: 1px solid var(--success-border);
    color: #065f46;
}

.alert-danger {
    background: var(--danger-light);
    border: 1px solid var(--danger-border);
    color: #991b1b;
}

.alert-info {
    background: var(--info-light);
    border: 1px solid var(--info-border);
    color: #075985;
}

.alert-warning {
    background: var(--warning-light);
    border: 1px solid var(--warning-border);
    color: #92400e;
}

/* QR Code Section */
.qr-container {
    text-align: center;
    padding: 1.25rem 0;
}

.qr-card {
    display: inline-block;
    padding: 1rem;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 1.25rem;
}

.qr-image {
    width: 220px;
    height: 220px;
    display: block;
    margin: 0 auto;
    object-fit: contain;
}

.account-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.manual-key-box {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
}

.manual-key-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.375rem;
}

.manual-key-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.manual-key-code {
    flex: 1;
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--primary);
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 0.5rem 0.75rem;
    overflow-x: auto;
}

/* OTP Input */
.otp-input-wrapper {
    margin: 1.5rem 0;
    text-align: center;
}

.otp-input {
    width: 100%;
    max-width: 340px;
    margin: 0 auto;
    padding: 0.85rem 1rem;
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 1.875rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.35em;
    color: var(--primary);
    background: #f8fafc;
    border: 2px solid var(--primary-border);
    border-radius: var(--border-radius-md);
    transition: all 0.2s ease;
}

.otp-input:focus {
    outline: none;
    background: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
}

.otp-input::placeholder {
    color: #cbd5e1;
    letter-spacing: 0.35em;
}

/* Success Card */
.success-hero {
    text-align: center;
    padding: 1.5rem 0;
}

.success-icon-badge {
    width: 72px;
    height: 72px;
    background: var(--success-light);
    border: 2px solid var(--success-border);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--success);
    margin-bottom: 1.25rem;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
}

.success-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.success-message {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    margin-bottom: 1.5rem;
}

.details-table {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 1rem 1.25rem;
    margin-bottom: 1.75rem;
    text-align: left;
}

.details-row {
    display: flex;
    justify-content: space-between;
    padding: 0.375rem 0;
    font-size: 0.875rem;
}

.details-row:not(:last-child) {
    border-bottom: 1px solid #f1f5f9;
}

.details-label {
    color: var(--text-muted);
}

.details-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* Test Presets */
.test-presets {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px dashed var(--border-color);
}

.test-presets-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.preset-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.preset-pill {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    padding: 5px 12px;
    border-radius: 9999px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.preset-pill:hover {
    background: var(--primary-light);
    border-color: var(--primary-border);
    color: var(--primary);
}

/* Footer & API Pill */
.app-footer {
    text-align: center;
    margin-top: 2rem;
}

.api-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: 9999px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    box-shadow: var(--shadow-sm);
}

.api-pill code {
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 0.75rem;
    color: var(--primary);
    background: var(--primary-light);
    padding: 2px 6px;
    border-radius: 4px;
}

.api-test-btn {
    background: transparent;
    border: none;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.75rem;
    cursor: pointer;
    text-decoration: underline;
    margin-left: 4px;
}

.api-test-btn:hover {
    color: var(--primary-hover);
}

/* Instructions List */
.instruction-steps {
    list-style: none;
    margin: 1.25rem 0;
    padding: 0;
    text-align: left;
}

.instruction-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.step-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}
