:root {
    /*    --bg-gradient: radial-gradient(circle at 50% 50%, #1e1b4b 0%, #0f172a 100%);
    --accent-color: #6366f1;*/


    --bg-gradient: radial-gradient(circle at 50% 50%, #214b5f 0%, #112630 100%);
    --accent-color: #607D8B;

    /*--accent-gradient: linear-gradient(135deg, #6366f1 0%, #06b6d4 100%);*/
    --accent-gradient: linear-gradient(135deg, #56a8d1 0%, #4078a5 100%);

    --danger-color: #ef4444;
    --danger-gradient: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);

    --glass-bg: rgb(15 23 42 / 0%);
    /*rgba(15, 23, 42, 0.55);*/



    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-highlight: rgba(255, 255, 255, 0.03);

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dark: #0f172a;

    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-display: 'Outfit', sans-serif;

    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

body,
html {
    width: 100%;
    height: 100%;
    font-family: var(--font-main);
    background: var(--bg-gradient);
    color: var(--text-main);
    overflow: hidden;
}

#app {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* Эффект Glassmorphism */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Экран подключения */
#connectScreen {
    position: relative;
    width: 440px;
    padding: 40px;
    display: none;
    flex-direction: column;
    z-index: 10;
    animation: fadeInScale 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Выбор языка */
.lang-selector-container {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 20;
}

.lang-select {
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 8px;
    /*background: rgba(15, 23, 42, 0.6);*/
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    outline: none;
    cursor: pointer;
    transition: all 0.2s;
    width: auto;
}

.lang-select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.lang-select option {
    background: #0f172a;
    color: var(--text-main);
}

#connectScreen.active {
    display: flex;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.logo-container {
    text-align: center;
    margin-bottom: 30px;
}

.logo-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: var(--accent-gradient);
    border-radius: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 26px;
    color: white;
    box-shadow: 0 8px 16px rgba(99, 102, 241, 0.3);
}

h1 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 28px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 6px;
}

.subtitle {
    font-size: 14px;
    color: var(--text-muted);
}

.form-container {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-group.half {
    flex: 1;
}

.input-with-button {
    display: flex;
    gap: 8px;
}

.input-with-button input {
    flex: 1;
}

.btn-icon {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent-color);
}

label {
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

input[type="text"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    background: rgb(26 67 86);
    /*rgba(15, 23, 42, 0.4);*/
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    font-family: var(--font-main);
    font-size: 14px;
    color: var(--text-main);
    outline: none;
    transition: all 0.2s;
}

/* Переопределяем цвета автозаполнения браузера (чтобы фон не становился белым) */
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus, 
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 1000px rgb(26 67 86) inset !important;
    -webkit-text-fill-color: var(--text-main) !important;
    transition: background-color 5000s ease-in-out 0s;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    background: rgba(15, 23, 42, 0.6);
}

select option {
    background: #0f172a;
    color: var(--text-main);
}

.form-tip {
    margin-top: 6px;
    font-size: 12px;
    text-align: left;
}

.cabinet-link {
    color: #56a8d1;
    text-decoration: none;
    transition: color 0.2s;
    font-weight: 500;
}

.cabinet-link:hover {
    color: #78c0e6;
    text-decoration: underline;
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.form-checkbox input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-color);
    cursor: pointer;
}

.form-checkbox label {
    text-transform: none;
    font-size: 13px;
    color: var(--text-muted);
    letter-spacing: normal;
    cursor: pointer;
}

/* Кнопки */
.btn {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 8px;
    font-family: var(--font-main);
    font-weight: 600;
    font-size: 15px;
    color: white;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent-gradient);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.3), var(--shadow-glow);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
    width: auto;
}

/* Спиннер */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    position: absolute;
}

.hidden {
    display: none !important;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.status-msg {
    margin-top: 20px;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}

.status-msg.error {
    color: var(--danger-color);
}

/* Экран просмотра */
.viewer-container {
    width: 100%;
    height: 100%;
    display: none;
    position: relative;
    flex-direction: column;
}

.viewer-container.active {
    display: flex;
}

/* Панель управления сверху */
.control-panel {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    gap: 24px;
    min-width: 580px;
    border-radius: 50px;
    opacity: 0.1;
    transition: all 0.3s ease;
}

.control-panel:hover,
.control-panel.keep-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    box-shadow: var(--shadow-lg), 0 0 30px rgba(99, 102, 241, 0.1);
}

.panel-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.agent-id-tag {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-indicator.connected {
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
}

.stats-text {
    font-size: 12px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    display: inline-block;
    min-width: 140px;
}

.panel-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
}

.panel-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent-color);
}

.panel-btn.active {
    background: var(--accent-color);
    border-color: var(--accent-color);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
}

.panel-btn.btn-danger:hover {
    background: var(--danger-color);
    border-color: var(--danger-color);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}

.panel-select {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 20px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    outline: none;
    cursor: pointer;
    width: auto;
}

#scaleModeText {
    font-size: 11px;
    font-weight: 700;
}

.icon {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Вьюпорт Canvas */
.canvas-viewport {
    width: 100%;
    height: 100%;
    background: #090a0f;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Режим Fit: вписываем Canvas */
.canvas-viewport.fit-mode {
    overflow: hidden;
}

.canvas-viewport.fit-mode canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
}

/* Режим Scroll: прокрутка холста */
.canvas-viewport.scroll-mode {
    overflow: auto;
    justify-content: flex-start;
    align-items: flex-start;
}

.canvas-viewport.scroll-mode canvas {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
}

/* Модальное окно буфера обмена */
.clipboard-modal {
    position: absolute;
    top: 80px;
    right: 20px;
    z-index: 90;
    width: 320px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.clipboard-modal h3 {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
}

.clipboard-tip {
    font-size: 11px;
    color: var(--text-muted);
}

.clipboard-modal textarea {
    height: 120px;
    resize: none;
    font-size: 13px;
}

.clipboard-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Стилизация скроллбаров */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.3);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    border: 2px solid rgba(15, 23, 42, 0.3);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}