:root {
    --bg: #121212;
    --bg-elevated: #1e1e1e;
    --border: #2c2c2c;
    --text: #e8e8e8;
    --text-muted: #999;
    --accent: #c41e1e;
    --accent-hover: #e02b2b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Manrope', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
}

header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

header[hidden] {
    display: none;
}

header h1 {
    font-size: 1.4rem;
    margin: 0;
}

.logout {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    cursor: pointer;
}
.logout:hover { color: var(--accent); }
.logout:disabled { opacity: 0.6; cursor: default; }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    padding: 1.5rem;
    max-width: 900px;
    margin: 0 auto;
}

.grid[hidden] {
    display: none;
}

.tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
    position: relative;
    overflow: hidden;
    background: linear-gradient(160deg, #16233a, #0f1622);
    border: 1px solid rgba(59, 130, 246, 0.35);
    border-radius: 16px;
    padding: 2rem 1.5rem;
    text-decoration: none;
    color: var(--text);
    font: inherit;
    cursor: pointer;
    box-shadow: 0 0 0 rgba(59, 130, 246, 0);
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.tile::before {
    content: '';
    position: absolute;
    inset: -60%;
    background: radial-gradient(circle at 30% 25%, rgba(59, 130, 246, 0.28), transparent 60%);
    animation: tile-drift 7s ease-in-out infinite;
    pointer-events: none;
}

@keyframes tile-drift {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50%      { transform: translate(8%, -6%) scale(1.08); }
}

.tile:hover {
    border-color: #3b82f6;
    transform: translateY(-4px);
    box-shadow: 0 10px 32px rgba(59, 130, 246, 0.28);
}

.tile-icon {
    position: relative;
    font-size: 2.3rem;
    margin-bottom: 0.75rem;
    filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.55));
}
.tile-name {
    position: relative;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.3rem;
}
.tile-desc {
    position: relative;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Login */
.login-box {
    max-width: 340px;
    margin: 15vh auto;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
}

.login-box h1 { margin-top: 0; font-size: 1.3rem; }

.login-box input[type="text"] {
    width: 100%;
    padding: 0.75rem;
    font-size: 1.4rem;
    text-align: center;
    letter-spacing: 0.3rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    margin-bottom: 1rem;
}

.login-box button {
    width: 100%;
    padding: 0.75rem;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
}
.login-box button:hover { background: var(--accent-hover); }

.link-btn {
    background: none !important;
    color: var(--text-muted) !important;
    font-weight: 400 !important;
    font-size: 0.85rem !important;
    margin-top: 0.5rem;
}

.resend { margin-top: 0; }

.error {
    color: var(--accent-hover);
    font-size: 0.9rem;
}

@media (max-width: 480px) {
    .grid { grid-template-columns: 1fr; padding: 1rem; }
    header { padding: 1rem; }
}

/* ==========================================================
   LOGIN SCREEN - стил, пренесен от toner-app (particle sphere
   анимация + сегментирани OTP полета)
   ========================================================== */

.login-body {
    background: #0e1420;
    background-image:
        radial-gradient(circle at 15% 0%, rgba(34,195,230,0.07), transparent 40%),
        radial-gradient(circle at 85% 10%, rgba(255,92,138,0.06), transparent 40%);
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    -webkit-font-smoothing: antialiased;
}

.login-main {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-main[hidden] {
    display: none;
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 0 12px;
    text-align: center;
    animation: fadeUp 0.35s ease;
}

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

.login-card h2 {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    font-size: 24px;
    color: #fff;
    margin: 0 0 4px;
}

.login-card .eyebrow {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #22c3e6;
    margin: 0 0 6px;
}

.login-card .muted {
    color: #8892a8;
    font-size: 14px;
    margin: 0 0 18px;
}

.atol-anim {
    position: relative;
    width: 100%;
    max-width: 220px;
    margin: 0 auto 12px;
    line-height: 0;
}
.atol-anim__img {
    width: 100%;
    height: auto;
    display: block;
    animation: atol-breathe 6s ease-in-out infinite;
}
@keyframes atol-breathe {
    0%, 100% { filter: drop-shadow(0 0 0 rgba(79,157,255,0)); }
    50%      { filter: drop-shadow(0 0 16px rgba(79,157,255,.45)); }
}

.atol-anim__orbit {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
.atol-anim__dot {
    offset-distance: 0%;
    animation: atol-fly 5.5s linear infinite;
}
@keyframes atol-fly {
    from { offset-distance: 0%; }
    to   { offset-distance: 100%; }
}

.atol-anim__shine {
    position: absolute;
    inset: 0;
    -webkit-mask-image: url(atol-logo-transparent.png);
    mask-image: url(atol-logo-transparent.png);
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    background: linear-gradient(75deg,
        transparent 40%, rgba(255,255,255,.85) 50%, transparent 60%);
    background-size: 300% 100%;
    background-position: 130% 0;
    mix-blend-mode: screen;
    animation: atol-shine 5.5s ease-in-out infinite;
}
@keyframes atol-shine {
    0%   { background-position: 160% 0; }
    45%  { background-position: -60% 0; }
    100% { background-position: -60% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .atol-anim__img, .atol-anim__dot, .atol-anim__shine { animation: none !important; }
}

.login-card label {
    display: block;
    font-size: 12px;
    color: #8892a8;
    margin: 16px 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

#requestStep .primary-btn { margin-top: 32px; }

.otp-digits {
    display: flex;
    gap: 8px;
}

.otp-digit {
    width: 100%;
    aspect-ratio: 1 / 1;
    text-align: center;
    font-size: 22px;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 600;
    border: 1px solid #3d4a68;
    border-radius: 8px;
    background: #161d2e;
    color: #e7ebf3;
    padding: 0;
}

.otp-digit:focus {
    outline: none;
    border-color: #22c3e6;
    box-shadow: 0 0 0 3px rgba(34,195,230,0.18);
}

.otp-digit.filled { border-color: #22c3e6; }

.otp-digits.shake { animation: shake 0.4s ease; }
.otp-digits.shake .otp-digit { border-color: #ff6b6b; }

@keyframes shake {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(4px); }
    30%, 50%, 70% { transform: translateX(-8px); }
    40%, 60% { transform: translateX(8px); }
}

.login-card .primary-btn {
    background: #22c3e6;
    color: #06141f;
    border: none;
    border-radius: 8px;
    padding: 12px 18px;
    width: 100%;
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.02em;
    cursor: pointer;
    margin-top: 16px;
    transition: filter 0.15s ease, transform 0.1s ease;
}
.login-card .primary-btn:hover { filter: brightness(1.1); }
.login-card .primary-btn:active { transform: scale(0.98); }

.login-card .status-line {
    font-size: 13px;
    min-height: 18px;
    margin: 10px 0 0;
    color: var(--text-muted);
}
.login-card .status-line.error { color: #ff6b6b; }
.login-card .status-line.ok { color: #35d68e; }

.login-card .resend-line {
    margin: 18px 0 0;
    font-size: 13px;
    color: #8892a8;
}

.login-card .resend-link {
    background: none;
    border: none;
    padding: 0;
    color: #22c3e6;
    text-decoration: none;
    font-weight: 600;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
}
.login-card .resend-link:hover { text-decoration: underline; }

@media (max-width: 480px) {
    .login-card { padding: 0 8px; }
    .otp-digit { font-size: 18px; }
}

/* ---------- Успешна проверка: чекмарк overlay точно върху цифрите ---------- */
.view-title-link {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    font-size: 26px;
    color: #fff;
    cursor: pointer;
    line-height: 1;
}
.view-title-link:hover { color: var(--ink-c, #22c3e6); }
.view-title-icon {
    font-size: 1em;
    line-height: 1;
}
.view-title-short { display: none; }

@media (max-width: 420px) {
    .view-title-full { display: none; }
    .view-title-short { display: inline; }
}

.otp-digits-wrap {
    position: relative;
}

.otp-digit.success {
    border-color: #3b82f6;
    color: #3b82f6;
    box-shadow: 0 0 10px rgba(59,130,246,0.35);
}

#otpHeading,
#otpLabel,
.resend-form {
    transition: opacity 0.25s ease;
}

.otp-check-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
}

.otp-check-overlay[hidden] {
    display: none;
}

.success-check {
    width: 64px;
    height: 64px;
}

.success-check-box {
    fill: none;
    stroke: #35d68e;
    stroke-width: 3;
    filter: drop-shadow(0 0 6px rgba(53,214,142,0.5));
}

.success-check-mark {
    fill: none;
    stroke: #35d68e;
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 0 6px rgba(53,214,142,0.6));
}

.login-card .status-line.success-text {
    color: #35d68e;
    font-weight: 600;
    font-size: 15px;
    margin-top: 24px;
}

/* Safety net - [hidden] винаги печели, независимо от display правилата по-горе */
[hidden] {
    display: none !important;
}
