:root {
    --bg: #070b14;
    --page-bg: #eef2f7;
    --card: #fff;
    --text: #0f172a;
    --muted: #64748b;
    --accent: #6366f1;
    --accent-dark: #4f46e5;
    --btn-primary-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    --btn-primary-shadow: 0 8px 22px rgba(79, 70, 229, 0.38);
    --btn-primary-shadow-hover: 0 12px 28px rgba(79, 70, 229, 0.45);
    --danger: #dc2626;
    --ok: #16a34a;
    --border: #e2e8f0;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text);
    line-height: 1.6;
    background: var(--page-bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
code {
    background: #f1f5f9;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-size: 0.85em;
}
.visually-hidden {
    position: absolute;
    left: -9999px;
    height: 0;
    width: 0;
    opacity: 0;
}

/* ——— Login (dashboard style) ——— */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    background:
        radial-gradient(circle at 20% 15%, rgba(99, 102, 241, 0.18) 0%, transparent 45%),
        radial-gradient(circle at 80% 85%, rgba(56, 189, 248, 0.12) 0%, transparent 40%),
        linear-gradient(160deg, #070b14 0%, #0f172a 55%, #111827 100%);
}
.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}
.login-box {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 20px;
    padding: 28px 32px 24px;
    border: 1px solid rgba(255, 255, 255, 0.65);
    box-shadow: 0 28px 60px rgba(2, 6, 23, 0.35);
    text-align: center;
}
.login-logo { margin-bottom: 14px; }
.login-logo-img {
    width: 200px;
    max-width: 78%;
    height: auto;
    display: block;
    margin: 0 auto;
}
.login-title {
    font-size: clamp(1.05rem, 4.5vw, 1.2rem);
    line-height: 1.3;
    font-weight: 700;
    margin: 0 auto 20px;
    max-width: 17em;
    color: var(--text);
}
.login-form { text-align: left; }

.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.875rem;
    font-weight: 500;
}
.form-group input {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
}
.form-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.alert-error {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
}
.alert-ok {
    background: #f0fdf4;
    color: var(--ok);
    border: 1px solid #bbf7d0;
}

.admin-section-title {
    margin: 0 0 0.25rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
    text-align: left;
}
.admin-section-hint {
    margin: 0 0 0.85rem;
    font-size: 0.82rem;
    text-align: left;
}
.front-wrap--admin .front-box + .front-box {
    margin-top: 0;
}
.wl-textarea {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85rem;
    line-height: 1.45;
    resize: vertical;
    min-height: 7rem;
}
.wl-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.65rem 1.1rem;
    border-radius: 8px;
    border: 1px solid transparent;
    font: inherit;
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.btn-primary {
    background: var(--btn-primary-gradient);
    color: #fff;
    box-shadow: var(--btn-primary-shadow);
}
.btn-primary:hover {
    color: #fff;
    box-shadow: var(--btn-primary-shadow-hover);
    transform: translateY(-1px);
}
.btn-primary:disabled {
    opacity: 0.65;
    cursor: wait;
    transform: none;
}
.btn-ghost {
    background: #f1f5f9;
    color: #334155;
    border-color: var(--border);
}
.btn-block { width: 100%; margin-top: 0.5rem; }

/* ——— Admin / front card on dark page ——— */
body.front-page {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 3.5rem 1rem 2.5rem;
    background: #000;
}
.front-wrap {
    width: min(540px, 96vw);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.front-wrap--admin { width: min(560px, 96vw); }
.front-box {
    background: var(--card);
    border-radius: 16px;
    padding: 1.75rem 1.5rem 1.5rem;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
    border: 1px solid #e2e8f0;
    text-align: center;
}
.front-brand { margin-bottom: 1rem; }
.front-logo {
    width: 150px;
    max-width: 48%;
    height: auto;
    display: block;
    margin: 0 auto 0.7rem;
}
.front-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    color: #0f172a;
}
.front-subtitle {
    margin: 0.3rem 0 0;
    font-size: 0.85rem;
    color: var(--muted);
}

.status-card {
    text-align: left;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.6rem 0.85rem;
    background: #f8fafc;
    margin-bottom: 1rem;
}
.status-row {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.28rem 0;
    font-size: 0.88rem;
    border-bottom: 1px solid #eef2f7;
}
.status-row:last-child { border-bottom: none; }
.status-label { color: var(--muted); font-weight: 600; }
.status-value { color: #0f172a; font-weight: 600; word-break: break-all; }
.status-value.is-ok { color: var(--ok); }
.status-value.is-bad { color: #b91c1c; }
.status-value.is-wait { color: #b45309; }

.pair-panel, .docs { text-align: left; margin-bottom: 1rem; }
.pair-panel h2, .docs h2 {
    margin: 0 0 0.4rem;
    font-size: 0.95rem;
    color: #0f172a;
}
.pair-msg { min-height: 1.2em; margin: 0.45rem 0; }
.qr-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 0.75rem;
    border: 1px dashed var(--border);
    border-radius: 12px;
    background: #fafafa;
}
.qr-img {
    width: 240px;
    height: 240px;
    image-rendering: pixelated;
    border-radius: 8px;
    background: #fff;
}
.pair-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.55rem;
}

.code-block {
    margin: 0 0 0.65rem;
    padding: 0.75rem 0.85rem;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 8px;
    font-size: 0.74rem;
    overflow-x: auto;
    line-height: 1.45;
    white-space: pre-wrap;
}

.front-login-link-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 0.35rem 0 0;
}
.front-login-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.85rem;
    font: inherit;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: #c7d2fe;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(129, 140, 248, 0.4);
    border-radius: 6px;
    cursor: pointer;
}
.front-login-btn:hover {
    color: #fff;
    background: var(--accent);
    border-color: #818cf8;
}

.front-page-footer {
    margin-top: 0.85rem;
    text-align: center;
}
.front-page-footer-version,
.front-page-footer-credit {
    margin: 0;
    font-size: 0.62rem;
    line-height: 1.5;
    color: rgba(148, 163, 184, 0.85);
}
.front-page-footer-credit {
    margin-top: 0.2rem;
    font-size: 0.58rem;
}
.front-page-footer-credit a {
    color: inherit;
    text-decoration: none;
}
.front-page-footer-credit a:hover { text-decoration: underline; }
.front-page-footer-credit .love {
    color: #f87171;
    font-weight: 700;
}
.login-page .front-page-footer-version,
.login-page .front-page-footer-credit {
    color: rgba(148, 163, 184, 0.85);
}

/* ——— Test send form (admin) ——— */
.test-mode-tabs {
    display: flex;
    gap: 0.4rem;
    margin: 0 0 1rem;
    padding: 0.25rem;
    background: #f1f5f9;
    border-radius: 10px;
}
.test-mode-tab {
    flex: 1;
    padding: 0.5rem 0.65rem;
    border: none;
    border-radius: 8px;
    background: transparent;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.test-mode-tab:hover { color: var(--text); }
.test-mode-tab.is-active {
    background: #fff;
    color: var(--accent-dark);
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}
.test-send-form { text-align: left; }
.test-textarea {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    line-height: 1.45;
    resize: vertical;
    min-height: 5.5rem;
}
.test-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}
.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
@media (max-width: 420px) {
    .form-row-2 { grid-template-columns: 1fr; }
}
.test-otp-preview {
    margin: -0.35rem 0 0.85rem;
    padding: 0.55rem 0.7rem;
    background: #f8fafc;
    border: 1px dashed var(--border);
    border-radius: 8px;
    white-space: pre-wrap;
    line-height: 1.4;
}
.test-result {
    margin: 0 0 0.85rem;
    padding: 0.65rem 0.75rem;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 8px;
    font-size: 0.72rem;
    overflow-x: auto;
    line-height: 1.45;
    white-space: pre-wrap;
    text-align: left;
}
.test-history {
    margin-top: 1.15rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    text-align: left;
}
.test-history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.55rem;
}
.test-history-title {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 700;
    color: #0f172a;
}
.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.78rem;
}
.test-history-list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    max-height: 240px;
    overflow-y: auto;
}
.test-msg-item {
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
    font-size: 0.8rem;
    line-height: 1.4;
}
.test-msg-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.65rem;
    margin-bottom: 0.25rem;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
}
.test-msg-status {
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.test-msg-status.is-ok { color: var(--ok); }
.test-msg-status.is-bad { color: #b91c1c; }
.test-msg-body {
    color: #0f172a;
    word-break: break-word;
    white-space: pre-wrap;
}
