:root {
    --bg: #f8f9fa;
    --card: #fff;
    --border: #e0e0e0;
    --text: #212529;
    --primary: #4361ee;
    --secondary: #6c757d;
    --danger: #e63946;
    --success: #06d6a0;
    --radius: 8px;
    --shadow: 0 2px 6px rgba(0, 0, 0, .06);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    padding: 6px;
    line-height: 1.5;
}

/* Карточки */
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 12px;
}

/* Заголовок */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

h1 {
    font-size: 1.4rem;
    font-weight: 500;
    margin: 0;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sync-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
}

.sync-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.sync-dot.offline {
    background-color: #dc3545;
}

.sync-dot.online {
    background-color: #28a745;
}

.sync-dot.syncing {
    background-color: #ffc107;
    animation: pulse 1.5s infinite;
}

.sync-dot.error {
    background-color: #dc3545;
    animation: pulse 1s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.sync-status {
    font-size: 14px;
    color: var(--secondary);
}

/* Модальное окно */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.modal-content h3 {
    margin-bottom: 15px;
    color: var(--primary);
}

/* Поиск */
.search-container {
    position: sticky;
    top: 0;
    z-index: 99;
    background: var(--card);
}

.search-bar {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.search-bar input {
    flex: 1;
    padding: 10px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.search-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--secondary);
}

/* Форма */
#form-container {
    margin-top: 10px;
}

#form-container h3 {
    margin-bottom: 10px;
    color: var(--primary);
}

input,
textarea {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
}

textarea {
    min-height: 120px;
    resize: vertical;
    font-family: monospace;
    white-space: pre-wrap;
}

.form-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

/* Список записей */
.item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    margin: 8px 0;
    background: var(--card);
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.site-display {
    font-weight: bold;
    font-size: 14px;
    color: var(--primary);
    word-break: break-word;
}

.item-actions {
    display: flex;
    gap: 6px;
}

.notes-display {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 16px;
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 6px;
    max-height: 200px;
    overflow-y: auto;
}

.updated {
    font-size: 11px;
    color: var(--secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Кнопки */
button {
    cursor: pointer;
    border: none;
    border-radius: var(--radius);
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: #3651d4;
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #05b889;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #d62839;
}

.btn-edit {
    background: #ffd166;
    color: #333;
    padding: 6px 10px;
    font-size: 12px;
}

.btn-edit:hover {
    background: #ffc145;
}

.btn-sync {
    background: var(--primary);
    color: white;
    padding: 8px;
    font-size: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-sync:hover {
    background: #3651d4;
    transform: scale(1.1);
}

.btn-sync-small {
    background: var(--secondary);
    color: white;
    padding: 5px 8px;
    font-size: 12px;
    border-radius: 4px;
}

.btn-sync-small:hover {
    background: #5a6268;
}

.sync-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 15px 0;
}

.sync-controls button {
    width: 100%;
}

/* Утилиты */
.hidden {
    display: none !important;
}

.empty {
    color: var(--secondary);
    margin: -8px;
}

.error {
    color: var(--danger);
    font-size: 12px;
    margin-top: 5px;
    padding: 5px;
    border-radius: 4px;
    background: rgba(220, 53, 69, 0.1);
}

.warning {
    color: #856404;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
    font-size: 13px;
}

.hint {
    color: var(--secondary);
    font-size: 12px;
    margin-bottom: 15px;
}

.sync-result {
    padding: 10px;
    border-radius: 4px;
    margin: 10px 0;
    font-size: 13px;
}

.sync-result.success {
    background: rgba(40, 167, 69, 0.1);
    color: #155724;
    border: 1px solid #c3e6cb;
}

.sync-result.error {
    background: rgba(220, 53, 69, 0.1);
    color: #721c24;
    border: 1px solid #f5c6cb;
}

#encryption-password-input,
#new-encryption-password,
#confirm-encryption-password {
    width: auto;
}

#encryption-login-btn,
#setup-encryption-btn {
    width: auto;
    padding: 10px 20px;
}

#new-item-btn {
    height: 37px;
}

/* Стили для действий в форме */
.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
}

.form-left-actions {
    display: flex;
    gap: 8px;
}

.form-right-actions {
    display: flex;
    gap: 8px;
}

/* Кнопка импорта */
#import-csv-btn {
    background: #6c757d;
    color: white;
    padding: 8px 12px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 5px;
    max-height: 32px;
    min-width: 94px;
}

#import-csv-btn:hover {
    background: #5a6268;
}

/* Информация об импорте */
.import-info {
    margin-top: 15px;
    padding: 10px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.4;
    white-space: pre-line;
}

.import-info.success {
    background: rgba(40, 167, 69, 0.1);
    color: #155724;
    border: 1px solid #c3e6cb;
}

.import-info.error {
    background: rgba(220, 53, 69, 0.1);
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.import-info.info {
    background: rgba(0, 123, 255, 0.1);
    color: #004085;
    border: 1px solid #b8daff;
}

.time-indicator {
    font-size: 11px;
    color: #6c757d;
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.updated {
    font-size: 11px;
    color: var(--secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 5px;
}

/* Кнопки навигации в поиске */
.search-nav-buttons {
    display: flex;
    gap: 4px;
}

.btn-nav {
    background: var(--secondary);
    color: white;
    padding: 5px 12px;
    font-size: 14px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    line-height: 1.1;
}

.btn-nav:hover {
    background: #5a6268;
}

/* Счетчик совпадений */
.match-counter {
    font-size: 12px;
    color: var(--secondary);
    background: #f8f9fa;
    padding: 4px 8px;
    border-radius: 12px;
    margin-left: 8px;
}

/* Подсветка найденного текста */
.search-highlight {
    background-color: #ffeb3b;
    color: #000;
    padding: 2px 0;
    border-radius: 3px;
    font-weight: bold;
}

/* Выделение текущего элемента */
.item.selected {
    border: 2px solid var(--primary);
    background-color: rgba(67, 97, 238, 0.05);
    box-shadow: 0 0 0 1px var(--primary);
}

/* Анимация мигания при навигации */
@keyframes flash {

    0%,
    100% {
        background-color: rgba(67, 97, 238, 0.05);
    }

    50% {
        background-color: rgba(67, 97, 238, 0.2);
    }
}

.flash-highlight {
    animation: flash 1s ease-in-out;
}

/* Улучшенные стили для отображения заметок с подсветкой */
.notes-display mark {
    background-color: #ffeb3b;
    color: #000;
    padding: 1px 2px;
    border-radius: 2px;
    font-weight: bold;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .search-bar {
        flex-wrap: wrap;
    }

    .search-nav-buttons {
        order: 3;
        justify-content: center;
    }

    .match-counter {
        margin-left: 0;
        margin-right: 8px;
    }
}

@media (max-width: 480px) {
    .search-info {
        flex-wrap: wrap;
        gap: 8px;
    }

    .match-counter {
        order: 1;
        margin: 0;
    }

    #search-count {
        order: 2;
    }

    #sync-now-btn {
        order: 4;
    }

    #encryption-password-input,
    #encryption-login-btn {
        width: 100%;
    }
}

/* Стили для формы с учетом новых кнопок */
.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}

.search-bar input {
    flex: 1;
    margin-bottom: 0;
}

/* Улучшенные стили для заголовка */
.site-display mark {
    background-color: #ffeb3b;
    color: #000;
    padding: 1px 3px;
    border-radius: 3px;
    font-weight: bold;
}

/* Индикатор текущего выбора */
.item.selected .site-display {
    color: var(--primary);
    font-weight: bold;
}

.item.selected .notes-display {
    background-color: rgba(67, 97, 238, 0.02);
}

/* Информация о времени с иконкой */
.time-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--secondary);
}

/* Подсказки при наведении на кнопки навигации */
.btn-nav {
    position: relative;
}

.btn-nav:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 5px;
}

.btn-nav:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #333;
    margin-bottom: -5px;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 480px) {
    .form-actions {
        gap: 10px;
    }

    .form-right-actions {
        width: 100%;
    }

    .form-left-actions button,
    .form-right-actions button {
        flex: 1;
    }
}