@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

:root, [data-theme="dark"] {
    --bg: #031008;
    --surface: #091a10;
    --surface2: #142a1b;
    --border: rgba(16,185,129,0.15);
    --accent: #10b981;
    --accent-soft: rgba(16,185,129,0.1);
    --accent-glow: rgba(16,185,129,0.25);
    --danger: #ff4d6d;
    --text: #ecfdf5;
    --muted: #6ee7b7;
    --radius: 16px;
    --gradient: linear-gradient(135deg, #059669 0%, #84cc16 35%, #eab308 70%, #d97706 100%);
    --shadow: 0 24px 64px rgba(0,0,0,0.5);
    --bg-grad-1: rgba(16,185,129,0.15);
    --bg-grad-2: rgba(251,191,36,0.1);
}

[data-theme="light"] {
    --bg: #f3faf5;
    --surface: #ffffff;
    --surface2: #e2f2e9;
    --border: #d1efde;
    --accent: #047857;
    --accent-soft: rgba(4,120,87,0.08);
    --accent-glow: rgba(4,120,87,0.15);
    --danger: #dc2626;
    --text: #064e3b;
    --muted: #059669;
    --shadow: 0 10px 40px rgba(0,0,0,0.06);
    --bg-grad-1: rgba(16,185,129,0.08);
    --bg-grad-2: rgba(251,191,36,0.05);
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, sans-serif;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    transition: background-color 0.3s, color 0.3s;
    background-image:
        radial-gradient(ellipse at 20% 20%, var(--bg-grad-1) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 80%, var(--bg-grad-2) 0%, transparent 60%);
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow);
    animation: fadeUp .35s ease both;
    transition: background-color 0.3s, border-color 0.3s, box-shadow 0.3s;
}

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

.icon-wrap {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    background: var(--accent-soft);
    border: 1px solid var(--accent-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    font-size: 2.2rem;
    overflow: hidden;
    padding: 10px;
}

.icon-wrap img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

h1 {
    font-size: 1.35rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.4rem;
    letter-spacing: -0.01em;
}

.subtitle {
    text-align: center;
    color: var(--muted);
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: 2rem;
}

.alert {
    background: rgba(255,77,109,0.12);
    border: 1px solid rgba(255,77,109,0.3);
    color: #ff6b84;
    border-radius: 10px;
    padding: .75rem 1rem;
    font-size: .875rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: .5rem;
}

/* ---- Form controls ---- */
.input-control, .code-input {
    width: 100%;
    background: var(--surface2);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    outline: none;
    font-family: inherit;
    transition: border-color .2s, box-shadow .2s;
}

.input-control {
    padding: .9rem 1.25rem;
    font-size: .95rem;
}

.code-input {
    text-align: center;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.5rem;
    padding: 1rem 1.25rem;
    -moz-appearance: textfield;
}

.code-input::-webkit-outer-spin-button,
.code-input::-webkit-inner-spin-button { -webkit-appearance: none; }

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

.form-group {
    margin-bottom: 1.25rem;
}

/* ---- Buttons ---- */
.btn {
    display: block;
    width: 100%;
    padding: .9rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-family: inherit;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
    text-align: center;
    text-decoration: none;
}

.btn-primary {
    background: var(--gradient);
    color: #fff;
    box-shadow: 0 4px 14px rgba(16,185,129,0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(16,185,129,0.45);
}

.btn-primary:active { transform: translateY(0); }

.btn-danger {
    background: rgba(255,77,109,0.1);
    color: var(--danger);
    border: 1px solid rgba(255,77,109,.3);
}

.btn-danger:hover { background: rgba(255,77,109,.2); }

/* ---- Utility ---- */
.separator {
    text-align: center;
    font-size: .78rem;
    color: var(--muted);
    margin: 1.25rem 0;
    position: relative;
}

.separator::before, .separator::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 38%;
    height: 1px;
    background: var(--border);
}
.separator::before { left: 0; }
.separator::after  { right: 0; }

.hint {
    font-size: .78rem;
    color: var(--muted);
    text-align: center;
    margin-top: .5rem;
    margin-bottom: 1.75rem;
}

.back, .back-link {
    display: block;
    text-align: center;
    color: var(--muted);
    text-decoration: none;
    font-size: .85rem;
    transition: color .2s;
}

.back:hover, .back-link:hover { color: var(--text); }

/* ---- Layout variants ---- */
.container {
    width: 100%;
    max-width: 520px;
}

.header {
    text-align: center;
    margin-bottom: 2rem;
}

.header .logo {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: .25rem;
}

.header p {
    color: var(--muted);
    font-size: .875rem;
}

/* ---- Flash types ---- */
.flash-success { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,.3); color: #4ade80; }
.flash-danger  { background: rgba(255,77,109,0.1);  border: 1px solid rgba(255,77,109,.3); color: #ff6b84; }
.flash-warning { background: rgba(251,191,36,0.1); border: 1px solid rgba(251,191,36,.3); color: #fbbf24; }

/* ---- Status badge ---- */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .3rem .85rem;
    border-radius: 100px;
    font-size: .8rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}
.status-active   { background: rgba(16,185,129,0.1); color: #4ade80; border: 1px solid rgba(16,185,129,.25); }
.status-inactive { background: var(--accent-soft);  color: #6ee7b7; border: 1px solid var(--accent-glow); }

/* ---- Steps ---- */
.steps { list-style: none; margin-bottom: 1.75rem; }
.steps li {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: .75rem 0;
    border-bottom: 1px solid var(--border);
    font-size: .9rem;
    line-height: 1.5;
}
.steps li:last-child { border-bottom: none; }

.step-num {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-soft);
    border: 1px solid var(--accent-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    font-weight: 700;
    color: #6ee7b7;
    margin-top: .05rem;
}

/* ---- QR Code & Setup ---- */
.qr-wrap {
    display: flex;
    justify-content: center;
    margin: 1.5rem 0;
}

.qr-frame {
    background: #fff;
    padding: 1rem;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(16,185,129,0.2);
}

.manual-code {
    text-align: center;
    margin-top: .75rem;
    margin-bottom: 1.5rem;
}

.manual-code small {
    color: var(--muted);
    font-size: .78rem;
    display: block;
    margin-bottom: .3rem;
}

.code-pill {
    display: inline-block;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .35rem .85rem;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: .15em;
    color: #6ee7b7;
    cursor: pointer;
    transition: border-color .2s;
    word-break: break-all;
    max-width: 100%;
}

.code-pill:hover { border-color: var(--accent); }

.active-info {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    font-size: .9rem;
    color: var(--muted);
    line-height: 1.6;
}

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

