/* ====== Reset & Base ====== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #2a2d39 0%, #3d4152 100%);
    color: #e8eaed;
    height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    padding-bottom: 80px;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: auto;
}

/* Скрываем скроллбары */
body::-webkit-scrollbar {
    display: none;
}
body {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* ====== App Container ====== */
.app {
    width: 100%;
    max-width: 520px;
    max-height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* ====== Screens ====== */
.screen {
    display: none;
    animation: fadeIn 0.3s ease;
}
.screen.active {
    display: block;
}

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

/* ====== Home Screen ====== */
.app-title {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 40px;
    color: #e8eaed;
    letter-spacing: -0.02em;
}

.home-main-section {
    display: flex;
    gap: 16px;
    margin-bottom: 32px;
}

.home-code-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-self: stretch;
}

.code-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border: 2px solid #3d4354;
    border-radius: 16px;
    background: #252936;
    transition: all 0.2s;
    padding: 0;
    min-height: 0;
    height: 100%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.code-input-wrapper:hover {
    border-color: #5b6478;
    background: #2d3142;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.code-input-wrapper:focus-within {
    border-color: #5b6478;
    background: #2d3142;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.home-code-section .code-slots-container {
    cursor: text;
}

.home-code-section .code-input-hidden {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 1px;
    height: 1px;
}

/* Контейнер слотов */
.code-slots-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 0;
}

.code-slots {
    display: flex;
    align-items: center;
    justify-content: center;
}

.code-slot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 3.2rem;
    font-size: 2.5rem;
    font-family: 'Courier New', monospace;
    color: #e8eaed;
    text-align: center;
    position: relative;
}

/* Отображение введённой цифры */
.code-slot::before {
    content: attr(data-digit);
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    font-family: 'Courier New', monospace;
    color: #e8eaed;
    opacity: 0;
    transition: opacity 0.1s ease;
    pointer-events: none;
}

.code-slot[data-digit]::before {
    opacity: 1;
}

.code-input-wrapper.blink-success .code-slot[data-digit]::before {
    color: #4ade80;
    transition: color 0.3s ease;
}

.code-input-wrapper.blink-success .slot-placeholder {
    color: #4ade80;
    transition: color 0.3s ease;
}

.code-input-wrapper.blink-success .code-hint {
    color: #4ade80;
    transition: color 0.3s ease;
}

/* Плейсхолдер внутри слота */
.slot-placeholder {
    display: inline-block;
    font-size: 2.5rem;
    font-family: 'Courier New', monospace;
    color: #8a8f9e;
    transition: opacity 0.15s ease;
    line-height: 1;
}

.slot-placeholder.hidden {
    opacity: 0;
    width: 0;
    height: 0;
    overflow: hidden;
    position: absolute;
}

/* Курсор для активного слота */
.code-slot.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 3px;
    background: #5b6478;
    border-radius: 2px;
    animation: blinkCode 1s ease infinite;
}

.code-separator {
    display: inline-block;
    width: 0.5em;
    font-size: 2.5rem;
    font-family: 'Courier New', monospace;
    color: transparent;
    user-select: none;
}

.home-code-section .code-input {
    width: 100%;
    text-align: center;
    font-size: 3.2rem;
    border: none;
    background: transparent;
    color: #e8eaed;
    font-family: 'Courier New', monospace;
    outline: none;
    letter-spacing: 0.25em;
    text-indent: 0.125em;
    padding: 24px 0 0;
    transition: opacity 0.15s ease;
    box-sizing: border-box;
}

@keyframes blinkCode {
    0%, 100% { opacity: 1; }
    25% { opacity: 0; }
    50% { opacity: 1; }
    75% { opacity: 0; }
}

.code-input-wrapper.blink {
    animation: blinkCode 0.6s ease 1;
}

@keyframes blinkSuccess {
    0%, 100% { opacity: 1; border-color: #4ade80; box-shadow: 0 0 20px rgba(74, 222, 128, 0.2); }
    50% { opacity: 0.6; border-color: #22c55e; box-shadow: 0 0 12px rgba(34, 197, 94, 0.15); }
}

.code-input-wrapper.blink-success {
    animation: blinkSuccess 0.4s ease 3;
    border-color: #4ade80;
}

.error-text {
    color: #8a8f9e;
    text-align: center;
    font-size: 1.1rem;
    position: absolute;
    bottom: 8px;
    left: 0;
    right: 0;
}

.code-hint {
    text-align: center;
    color: #8a8f9e;
    font-size: 1.1rem;
    position: absolute;
    bottom: 8px;
    left: 0;
    right: 0;
    margin: 0;
    transition: opacity 0.2s;
}

.mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mode-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
    min-width: 120px;
    border: 2px solid #3d4354;
    border-radius: 16px;
    background: #252936;
    color: #e8eaed;
    cursor: pointer;
    transition: all 0.25s ease;
    font-size: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.mode-btn:hover {
    border-color: #5b6478;
    background: #2d3142;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.mode-btn.active-send,
.mode-btn.active-receive {
    border-color: #5b6478;
    background: #3d4354;
}

.mode-icon {
    width: 40px;
    height: 40px;
    margin-bottom: 8px;
}

#btn-send-mode .mode-icon {
    color: #7a8fbf;
}

#btn-send-mode:hover .mode-icon {
    color: #5ba0f5;
}

#btn-receive-mode .mode-icon {
    color: #7abf8f;
}

#btn-receive-mode:hover .mode-icon {
    color: #5be08f;
}

.mode-label {
    font-weight: 500;
    font-size: 0.95rem;
    color: #8a8f9e;
}

.mode-btn:hover .mode-label {
    color: #e8eaed;
}

.code-input-wrapper:hover .code-hint,
.code-input-wrapper:focus-within .code-hint {
    color: #e8eaed;
}

/* ====== Common Elements ====== */
h2 {
    text-align: center;
    margin-bottom: 24px;
    color: #e8eaed;
    font-weight: 600;
}

.btn-back {
    background: none;
    border: none;
    color: #8a8f9e;
    font-size: 1rem;
    cursor: pointer;
    padding: 8px 0;
    margin-bottom: 16px;
    transition: color 0.2s;
}
.btn-back:hover {
    color: #e8eaed;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    background: #5b6478;
    color: #e8eaed;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-primary:hover {
    background: #6b7488;
    transform: translateY(-1px);
}
.btn-primary:disabled {
    background: #3d4354;
    cursor: not-allowed;
    opacity: 0.5;
}

.btn-icon {
    width: 20px;
    height: 20px;
}

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

/* ====== Home Code Section ====== */
/* Moved to Home Screen section */

/* ====== Selected Files ====== */
.selected-files {
    margin-top: 12px;
    padding: 12px;
    background: #252936;
    border-radius: 12px;
    max-height: 250px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #5b6478 #252936;
}
.selected-files .file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    border-bottom: 1px solid #3d4354;
    color: #e8eaed;
    font-size: 0.9rem;
}
.selected-files .file-item:last-child {
    border-bottom: none;
}
.selected-files .file-remove {
    background: none;
    border: none;
    color: #8a8f9e;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0 4px;
    transition: color 0.2s;
}
.selected-files .file-remove:hover {
    color: #e8eaed;
}

/* ====== File List (receiver) ====== */
.file-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 350px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #5b6478 #252936;
    padding-right: 4px;
}
.file-list .file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: #252936;
    border-radius: 12px;
    color: #e8eaed;
    border: 1px solid #3d4354;
}
.file-list .file-item .file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-list .file-item .file-size {
    color: #8a8f9e;
    margin-left: auto;
    font-size: 0.85rem;
}

.file-list .file-item .btn-download-single {
    background: none;
    border: none;
    color: #8a8f9e;
    cursor: pointer;
    padding: 4px 8px;
    margin-left: 8px;
    transition: all 0.15s;
}
.file-list .file-item .btn-download-single:hover {
    color: #e8eaed;
    transform: scale(1.1);
}

/* ====== Upload Area ====== */
.upload-area {
    border: 2px dashed #3d4354;
    border-radius: 16px;
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s;
    background: #252936;
}
.upload-area:hover,
.upload-area.dragover {
    border-color: #5b6478;
    background: #2d3142;
}

.upload-icon {
    width: 64px;
    height: 64px;
    display: block;
    margin: 0 auto 16px;
    color: #8a8f9e;
}

.upload-area:hover .upload-icon {
    color: #e8eaed;
}

.upload-area p {
    color: #8a8f9e;
}

.upload-hint {
    text-align: center;
    color: #8a8f9e;
    font-size: 0.85rem;
    margin-top: 12px;
}

/* ====== Options ====== */
.options {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 10px 14px;
    border-radius: 10px;
    background: #252936;
    transition: background 0.2s;
    border: 1px solid #3d4354;
}
.checkbox-label:hover {
    background: #2d3142;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #5b6478;
}

/* ====== QR Code ====== */
.qr-container {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.qr-container > div {
    background: #fff;
    padding: 12px;
    border-radius: 12px;
}

/* ====== Session Code ====== */
.session-code {
    text-align: center;
    margin: 16px 0;
}

.code-label {
    color: #8a8f9e;
    font-size: 0.9rem;
}

.code-value {
    display: block;
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: 8px;
    color: #e8eaed;
    font-family: 'Courier New', monospace;
    margin-top: 4px;
}

/* ====== File Info ====== */
.file-info {
    text-align: center;
    padding: 12px;
    background: #252936;
    border-radius: 12px;
    margin: 12px 0;
    color: #8a8f9e;
    font-size: 0.9rem;
    border: 1px solid #3d4354;
}

/* ====== Status Messages ====== */
.status-message {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    padding: 16px;
    border-radius: 12px;
    background: #252936;
    margin: 12px 0;
    color: #8a8f9e;
    border: 1px solid #3d4354;
}

.status-message.success {
    background: #2d3142;
    color: #e8eaed;
    border-color: #5b6478;
}

.status-icon {
    width: 24px;
    height: 24px;
}

#screen-home .error-text {
    color: #8a8f9e;
    text-align: center;
    font-size: 1.1rem;
    position: absolute;
    bottom: 8px;
    left: 0;
    right: 0;
}

/* ====== Password Input ====== */
.password-input-area {
    text-align: center;
    margin-top: 20px;
    padding: 20px;
    background: #252936;
    border-radius: 12px;
    border: 1px solid #3d4354;
}

.password-input-area p {
    margin-bottom: 12px;
    color: #8a8f9e;
}

.password-input {
    width: 160px;
    text-align: center;
    font-size: 1.6rem;
    padding: 10px;
    border: 2px solid #3d4354;
    border-radius: 10px;
    background: #2d3142;
    color: #e8eaed;
    font-family: 'Courier New', monospace;
    letter-spacing: 8px;
    outline: none;
    transition: border-color 0.2s;
}
.password-input:focus {
    border-color: #5b6478;
}

/* ====== Code Input Row ====== */
.code-input-row {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
    margin: 16px 0;
}

.code-input {
    width: 200px;
    text-align: center;
    font-size: 1.6rem;
    padding: 10px;
    border: 2px solid #3d4354;
    border-radius: 10px;
    background: #2d3142;
    color: #e8eaed;
    font-family: 'Courier New', monospace;
    letter-spacing: 6px;
    outline: none;
    transition: border-color 0.2s;
}
.code-input:focus {
    border-color: #5b6478;
}

.hint-text {
    text-align: center;
    color: #8a8f9e;
    font-size: 0.85rem;
    margin: 8px 0;
}

/* ====== Spinner ====== */
.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #3d4354;
    border-top-color: #5b6478;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 24px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ====== Responsive ====== */
@media (max-width: 480px) {
    html, body {
        overflow: hidden !important;
    }

    .app-title {
        font-size: 1.1rem;
        margin-bottom: 24px;
    }

    .home-main-section {
        flex-direction: column;
        gap: 16px;
        margin-bottom: 20px;
    }

    .code-input-wrapper {
        padding: 16px;
    }

    .code-slot {
        width: 2.5rem;
        height: 3.2rem;
        font-size: 2.5rem;
    }

    .code-slot.active::after {
        width: 50%;
        height: 2px;
    }

    .code-slot::before {
        font-size: 2.5rem;
    }

    .code-separator {
        font-size: 2.5rem;
    }

    .slot-placeholder {
        font-size: 2.5rem;
    }

    .error-text {
        font-size: 0.9rem;
        bottom: 6px;
    }

    .code-hint {
        font-size: 0.9rem;
        bottom: 6px;
    }

    .mode-buttons {
        flex-direction: row;
        width: 100%;
        gap: 8px;
    }
    
    .mode-btn {
        flex: 1;
        padding: 20px 12px;
        min-width: 0;
    }
    
    .mode-icon {
        width: 32px;
        height: 32px;
        margin-bottom: 6px;
    }
    
    .mode-label {
        font-size: 0.85rem;
    }
    .code-input-row {
        flex-direction: column;
    }
    .upload-area {
        padding: 24px 16px;
    }
    .upload-icon {
        width: 48px;
        height: 48px;
        margin-bottom: 12px;
    }
    .upload-area p {
        font-size: 0.85rem;
    }
    .options .checkbox-label {
        padding: 8px 10px;
        font-size: 0.85rem;
    }
    .code-value {
        font-size: 1.6rem;
    }
    .qr-container {
        margin: 12px 0;
    }
    .qr-container > div {
        padding: 8px;
    }
    .qr-container canvas, .qr-container img {
        width: 150px !important;
        height: 150px !important;
    }
    .session-code .code-label {
        font-size: 0.75rem;
    }
    .session-code .code-value {
        font-size: 1.8rem;
    }
    .status-message {
        padding: 10px;
        font-size: 0.85rem;
    }
    .file-info {
        padding: 8px;
        font-size: 0.8rem;
    }
    .password-input {
        width: 140px;
        font-size: 1.3rem;
    }
    .selected-files {
        max-height: 150px;
    }
    .file-list {
        max-height: 200px;
    }
    .file-list .file-item {
        padding: 8px 10px;
        font-size: 0.85rem;
    }
    .btn-primary {
        padding: 10px 18px;
        font-size: 0.9rem;
    }
    .btn-icon {
        width: 18px;
        height: 18px;
    }
    .btn-back {
        padding: 6px 0;
        font-size: 0.85rem;
        margin-bottom: 8px;
    }
    h2 {
        font-size: 1.1rem;
        margin-bottom: 16px;
    }
    .spinner {
        width: 36px;
        height: 36px;
        margin: 16px auto;
    }
}

/* ====== Upload Overlay ====== */
.upload-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(26, 29, 41, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}
.upload-overlay-content {
    text-align: center;
    color: #e8eaed;
}
.upload-overlay .upload-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #3d4354;
    border-top-color: #5b6478;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}
.upload-overlay .upload-progress-bar {
    width: 240px;
    height: 6px;
    background: #3d4354;
    border-radius: 3px;
    margin: 12px auto 0;
    overflow: hidden;
}
.upload-overlay .upload-progress-fill {
    height: 100%;
    width: 0%;
    background: #5b6478;
    border-radius: 3px;
    transition: width 0.2s ease;
}
.upload-overlay .upload-percent {
    margin-top: 8px;
    font-size: 0.9rem;
    color: #8a8f9e;
}

/* ====== Transfer Stats ====== */
.transfer-stats {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    padding: 16px;
    background: transparent;
    color: #8a8f9e;
    font-size: 0.9rem;
    font-weight: normal;
    line-height: 1.4;
    border-top: none;
    pointer-events: none;
    z-index: 100;
    transform: translateY(0);
}
.transfer-stats * {
    font-size: 0.9rem !important;
    font-weight: normal;
}
.transfer-stats #stats-files {
    color: #e8eaed;
}
.transfer-stats #stats-size {
    color: #e8eaed;
}

/* ====== Auth Screens ====== */
.home-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.user-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    width: 100%;
    max-width: 400px;
}

.user-email {
    flex: 1;
    font-size: 0.85rem;
    color: #a0a4b0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-logout {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #a0a4b0;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #e8eaed;
}

.auth-step {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-label {
    font-size: 0.9rem;
    color: #a0a4b0;
    margin-bottom: -8px;
}

.auth-input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #e8eaed;
    font-size: 1rem;
    outline: none;
    transition: all 0.2s ease;
}

.auth-input:focus {
    border-color: #5b6478;
    background: rgba(255, 255, 255, 0.12);
}

.auth-input::placeholder {
    color: #6b6f7e;
}

.auth-btn {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
}

.auth-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.auth-hint {
    text-align: center;
    font-size: 0.85rem;
    color: #6b6f7e;
    margin-top: -8px;
}

.auth-code-hint {
    text-align: center;
    font-size: 0.9rem;
    color: #a0a4b0;
    margin-bottom: 20px;
}

.auth-code-hint strong {
    color: #e8eaed;
}

.auth-resend {
    text-align: center;
    margin-top: 16px;
    font-size: 0.85rem;
}

.auth-resend a {
    color: #5b8def;
    text-decoration: none;
    transition: color 0.2s ease;
}

.auth-resend a:hover {
    color: #7ba3f7;
    text-decoration: underline;
}

/* ====== Код-инпут внутри экрана профиля ====== */
#screen-profile .auth-step {
    width: 100%;
    max-width: none;
}

#screen-profile .code-input {
    width: 100%;
    padding: 16px 20px;
    font-size: 2rem;
    font-weight: 600;
    text-align: center;
    letter-spacing: 0.5em;
    font-family: 'Courier New', monospace;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    color: #fff;
    transition: all 0.2s ease;
}

#screen-profile .code-input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.08);
}

#screen-profile .code-input::placeholder {
    color: rgba(255, 255, 255, 0.2);
    letter-spacing: 0.5em;
}

#screen-profile .auth-code-hint {
    font-size: 0.85rem;
    color: #a0a4b0;
    margin-bottom: 16px;
}

#screen-profile .auth-timer-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    gap: 12px;
}

#screen-profile .auth-timer {
    font-size: 1.1rem;
    font-weight: 600;
    color: #8a8f9e;
    font-variant-numeric: tabular-nums;
    min-width: 32px;
}

#screen-profile .btn-resend {
    flex: 1;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #a0a4b0;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

#screen-profile .btn-resend:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.25);
    color: #fff;
}

#screen-profile .btn-resend:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Hidden utility class */
.hidden {
    display: none !important;
}

/* ====== Site Header ====== */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: transparent;
}

.site-header-left {
    flex: 1;
}

.site-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-profile {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #e8eaed;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-profile:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-1px);
}

.profile-icon {
    width: 18px;
    height: 18px;
}

.profile-label {
    line-height: 1;
}

/* ====== Экран профиля ====== */
.app:has(#screen-profile.active) {
    max-width: 1200px;
}

#screen-profile .auth-step {
    max-width: 500px;
    margin: 0 auto;
}

.modal-title {
    text-align: center;
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 24px;
    color: #e8eaed;
    letter-spacing: -0.02em;
}

/* ====== Profile Info (logged in) ====== */
.profile-info {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 14px;
    margin-bottom: 20px;
}

.profile-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.profile-avatar svg {
    width: 32px;
    height: 32px;
    color: #a0a4b0;
}

.profile-details {
    flex: 1;
    min-width: 0;
}

.profile-label-text {
    font-size: 0.8rem;
    color: #6b6f7e;
    margin-bottom: 4px;
}

.profile-email {
    font-size: 1rem;
    color: #e8eaed;
    word-break: break-all;
}

.btn-logout-full {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    color: #a0a4b0;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-logout-full:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #e8eaed;
    border-color: rgba(255, 255, 255, 0.25);
}

/* ====== Adjust body padding for header ====== */
body {
    padding-top: 70px;
}

/* ====== Responsive for header ====== */
@media (max-width: 480px) {
    .site-header {
        padding: 10px 16px;
    }

    .btn-profile {
        padding: 6px 12px;
        font-size: 0.85rem;
    }

    .profile-icon {
        width: 16px;
        height: 16px;
    }

    .profile-label {
        font-size: 0.85rem;
    }

    .modal-title {
        font-size: 1.1rem;
        margin-bottom: 20px;
    }

    .profile-info {
        padding: 16px;
        gap: 12px;
    }

    .profile-avatar {
        width: 48px;
        height: 48px;
    }

    .profile-avatar svg {
        width: 28px;
        height: 28px;
    }

    body {
        padding-top: 64px;
    }
}

/* ====== Subscription Plans ====== */
.profile-plan {
    margin: 20px 0;
    padding: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
}

.profile-plan-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.profile-plan-name {
    font-size: 1rem;
    font-weight: 600;
    color: #4a9eff;
}

.profile-plan-expires {
    font-size: 0.85rem;
    color: #a0a4b0;
    margin-bottom: 12px;
}

.profile-plan-expires.warning {
    color: #ffa94d;
}

.profile-plan-expires.expired {
    color: #ff6b6b;
}

.profile-usage {
    margin-top: 12px;
}

.profile-usage-text {
    font-size: 0.9rem;
    color: #a0a4b0;
    margin-bottom: 8px;
}

.profile-usage-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.profile-usage-fill {
    height: 100%;
    background: linear-gradient(90deg, #4a9eff, #6bb6ff);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.profile-usage-fill.warning {
    background: linear-gradient(90deg, #ffa94d, #ffb366);
}

.profile-usage-fill.full {
    background: linear-gradient(90deg, #ff6b6b, #ff8787);
}

.plans-section {
    margin: 20px 0;
    padding: 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
}

.plans-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.plans-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #e8eaed;
    margin-bottom: 16px;
}

.plans-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
    table-layout: fixed;
}

.plans-table th:first-child,
.plans-table td:first-child {
    width: 70px;
    text-align: center;
}

.plans-table th:nth-child(2),
.plans-table td:nth-child(2) {
    width: 50px;
    text-align: center;
}

.plans-table th:nth-child(3),
.plans-table td:nth-child(3) {
    width: 50px;
    text-align: center;
}

.plans-table th:nth-child(4),
.plans-table td:nth-child(4) {
    width: 55px;
    text-align: center;
}

.plans-table th:nth-child(5),
.plans-table td:nth-child(5) {
    width: 55px;
    text-align: center;
}

.plans-table th:last-child,
.plans-table td:last-child {
    width: 55px;
    text-align: center;
}

.plans-table th {
    text-align: left;
    padding: 8px 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #a0a4b0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.plans-table td {
    padding: 10px 4px;
    font-size: 0.85rem;
    color: #e8eaed;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.plans-table tr:last-child td {
    border-bottom: none;
}

.plan-name {
    font-weight: 600;
    font-size: 0.8rem;
}

.plan-name.current {
    color: #4a9eff;
}

.plan-prices {
    font-size: 0.85rem;
    color: #a0a4b0;
}

.btn-select-plan {
    padding: 4px 8px;
    border: 1px solid rgba(74, 158, 255, 0.3);
    border-radius: 6px;
    background: rgba(74, 158, 255, 0.1);
    color: #4a9eff;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-select-plan:hover {
    background: rgba(74, 158, 255, 0.2);
    border-color: rgba(74, 158, 255, 0.5);
}

.btn-select-plan:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.plans-note {
    font-size: 0.85rem;
    color: #a0a4b0;
    text-align: center;
    margin: 0;
}

.plans-note a {
    color: #4a9eff;
    text-decoration: none;
}

.plans-note a:hover {
    text-decoration: underline;
}

/* Overlay для модалок */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Modal для выбора периода */
.plan-duration-modal {
    background: #1e2028;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 24px;
    min-width: 300px;
    max-width: 90%;
    width: 340px;
}

.plan-duration-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #e8eaed;
    margin-bottom: 16px;
}

.plan-duration-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.plan-duration-option {
    padding: 12px 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: all 0.2s ease;
}

.plan-duration-option:hover {
    background: rgba(74, 158, 255, 0.1);
    border-color: rgba(74, 158, 255, 0.3);
}

.plan-duration-option-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #e8eaed;
    margin-bottom: 4px;
}

.plan-duration-option-price {
    font-size: 0.85rem;
    color: #a0a4b0;
}

.plan-duration-option-discount {
    color: #4a9eff;
    margin-left: 8px;
}

@media (max-width: 768px) {
    .plans-section {
        padding: 12px;
    }

    .plans-title {
        font-size: 0.95rem;
        margin-bottom: 12px;
    }

    .plans-table {
        font-size: 0.8rem;
    }

    .plans-table th {
        padding: 6px 3px;
        font-size: 0.7rem;
    }

    .plans-table td {
        padding: 8px 3px;
        font-size: 0.8rem;
    }

    .plans-table th:first-child,
    .plans-table td:first-child {
        width: 60px;
    }

    .plans-table th:nth-child(2),
    .plans-table td:nth-child(2) {
        width: 42px;
    }

    .plans-table th:nth-child(3),
    .plans-table td:nth-child(3) {
        width: 42px;
    }

    .plans-table th:nth-child(4),
    .plans-table td:nth-child(4) {
        width: 48px;
    }

    .plans-table th:nth-child(5),
    .plans-table td:nth-child(5) {
        width: 48px;
    }

    .plans-table th:last-child,
    .plans-table td:last-child {
        width: 48px;
    }

    .plan-name {
        font-size: 0.75rem;
    }

    .plan-prices {
        font-size: 0.7rem;
    }

    .btn-select-plan {
        padding: 3px 6px;
        font-size: 0.7rem;
    }

    .plans-note {
        font-size: 0.8rem;
    }
}
