:root {
    /* Темна тема (Основна для Emergency UI) */
    --bg-color-safe: #07150d;
    --text-color-safe: #2ecc71;
    --text-sub-safe: #e0e0e0;

    --bg-color-danger: #3a0000;
    --text-color-danger: #ffffff;
    --text-sub-danger: #ffcccc;

    --bg-color-offline: #2d2d2d;
    --text-color-offline: #ffcc00;
    --text-sub-offline: #cccccc;

    --bg-color-loading: #121212;
    --text-color-loading: #ffffff;
    --text-sub-loading: #aaaaaa;
    
    --btn-bg: rgba(255, 255, 255, 0.1);
    --btn-text: #ffffff;
    --btn-hover: rgba(255, 255, 255, 0.2);

    --progress-bg: rgba(255, 255, 255, 0.1);
    --progress-fill: #ffffff;
}

[data-theme="light"] {
    --bg-color-safe: #f0fdf4;
    --text-color-safe: #166534;
    --text-sub-safe: #374151;

    --bg-color-danger: #fef2f2;
    --text-color-danger: #991b1b;
    --text-sub-danger: #7f1d1d;

    --bg-color-offline: #fef3c7;
    --text-color-offline: #92400e;
    --text-sub-offline: #4b5563;

    --bg-color-loading: #f9fafb;
    --text-color-loading: #111827;
    --text-sub-loading: #6b7280;

    --btn-bg: rgba(0, 0, 0, 0.05);
    --btn-text: #111827;
    --btn-hover: rgba(0, 0, 0, 0.1);

    --progress-bg: rgba(0, 0, 0, 0.1);
    --progress-fill: #111827;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow: hidden;
}

/* --- СТАНИ СИСТЕМИ --- */
body.loading {
    background-color: var(--bg-color-loading);
    color: var(--text-color-loading);
}
body.loading p { color: var(--text-sub-loading); }

body.safe {
    background-color: var(--bg-color-safe);
    color: var(--text-color-safe);
}
body.safe p { color: var(--text-sub-safe); }

body.danger {
    background-color: var(--bg-color-danger);
    color: var(--text-color-danger);
    animation: pulse-bg 1.5s infinite;
}
body.danger p { color: var(--text-sub-danger); }
body.danger .progress-bar { background-color: var(--text-color-danger); }

body.offline {
    background-color: var(--bg-color-offline);
    color: var(--text-color-offline);
}
body.offline p { color: var(--text-sub-offline); }
body.offline .progress-bar { background-color: var(--text-color-offline); }


/* Анімації */
@keyframes pulse-bg {
    0% { background-color: var(--bg-color-danger); }
    50% { background-color: #5a0000; }
    100% { background-color: var(--bg-color-danger); }
}

[data-theme="light"] body.danger {
    animation: pulse-bg-light 1.5s infinite;
}
@keyframes pulse-bg-light {
    0% { background-color: var(--bg-color-danger); }
    50% { background-color: #fca5a5; }
    100% { background-color: var(--bg-color-danger); }
}

/* --- OVERLAY ДЛЯ ІНІЦІАЛІЗАЦІЇ --- */
.overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.95);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.overlay.hidden { display: none; }
.overlay-content {
    text-align: center;
    padding: 2rem;
    max-width: 90%;
}
.overlay-content h2 {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    margin-bottom: 1rem;
}
.btn-primary {
    background: #2563eb;
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 20px;
    transition: background 0.2s;
}
.btn-primary:hover { background: #1d4ed8; }

/* --- ОСНОВНА ВЕРСТКА --- */
.controls {
    display: flex;
    justify-content: flex-end;
    padding: 1rem;
    gap: 10px;
    z-index: 10;
}

.icon-btn {
    background-color: var(--btn-bg);
    color: var(--btn-text);
    border: none;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}
.icon-btn:hover { background-color: var(--btn-hover); }

.main-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 1rem;
    z-index: 10;
}

.status-icon {
    font-size: clamp(4rem, 15vw, 8rem);
    margin-bottom: 0.5rem;
    line-height: 1;
}

h1 {
    font-size: clamp(2.5rem, 8vw, 6rem);
    margin: 0 0 0.5rem 0;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 800;
}

body.danger h1 {
    animation: shake 0.5s infinite;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
}

#sub-text {
    font-size: clamp(1.2rem, 4vw, 2rem);
    font-weight: 600;
    margin-bottom: 2rem;
    max-width: 80%;
}

.system-info {
    font-size: clamp(0.9rem, 3vw, 1.2rem);
    background: rgba(0, 0, 0, 0.15);
    padding: 15px 30px;
    border-radius: 12px;
}
[data-theme="light"] .system-info {
    background: rgba(255, 255, 255, 0.6);
}
.system-info p { margin: 5px 0; }

.progress-container {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 8px;
    background-color: var(--progress-bg);
    z-index: 20;
}
.progress-bar {
    height: 100%; width: 100%;
    background-color: var(--progress-fill);
    transition: width 0.1s linear;
}

/* --- MOCK BUTTONS --- */
.test-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    color: white;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    width: max-content;
    max-width: 90%;
}
.test-controls p { margin: 0 10px 0 0; align-self: center; font-size: 0.9rem; }
.test-controls button {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    color: white;
}
.btn-danger { background-color: #dc2626; }
.btn-safe { background-color: #16a34a; }
.btn-offline { background-color: #d97706; }