* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }

body { background: #f0f2f5; color: #1a1a1a; min-height: 100vh; }

.screen { padding: 20px; max-width: 700px; margin: 0 auto; }

.hidden { display: none !important; }

.muted { color: #888; font-size: 14px; }

.card { background: white; border-radius: 12px; padding: 20px; margin-bottom: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }

.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

h1 { font-size: 22px; margin-bottom: 8px; }
h2 { font-size: 18px; margin-bottom: 8px; }

.subtitle { color: #666; margin-bottom: 20px; font-size: 14px; }

input, select {
    width: 100%; padding: 12px 14px; margin-bottom: 12px;
    border: 1px solid #ddd; border-radius: 8px;
    font-size: 16px; background: white;
}

input:focus, select:focus { outline: none; border-color: #2563eb; }

label { display: block; font-size: 13px; color: #555; margin-bottom: 6px; margin-top: 8px; }

button {
    width: 100%; padding: 12px;
    background: #2563eb; color: white; border: none;
    border-radius: 8px; font-size: 16px; font-weight: 600;
    cursor: pointer; margin-bottom: 8px;
}

button:hover { background: #1d4ed8; }
button.secondary { background: #e5e7eb; color: #1a1a1a; }
button.secondary:hover { background: #d1d5db; }
button.small { width: auto; padding: 8px 14px; font-size: 14px; margin: 0; background: #ef4444; }
button.small:hover { background: #dc2626; }
button.small-btn { width: auto; padding: 6px 12px; font-size: 13px; margin: 0; background: #2563eb; }
button.small-btn:hover { background: #1d4ed8; }
button.small-btn.danger { background: #ef4444; }
button.small-btn.danger:hover { background: #dc2626; }

header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }

.header-right { display: flex; align-items: center; gap: 12px; }
.user-info { font-size: 14px; color: #555; }

.message { margin-top: 12px; font-size: 14px; min-height: 20px; }
.message.error { color: #dc2626; }
.message.success { color: #16a34a; }

/* Вкладки */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: white;
    border-radius: 10px;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    flex-wrap: wrap;
}

.tab {
    flex: 1;
    padding: 10px 8px;
    margin: 0;
    width: auto;
    background: transparent;
    color: #555;
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}

.tab:hover { background: #f0f2f5; color: #1a1a1a; }
.tab.active { background: #2563eb; color: white; }

.badge {
    display: inline-block;
    background: #ef4444;
    color: white;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 4px;
    font-weight: 600;
}

/* Список */
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
    gap: 12px;
}

.list-item:last-child { border-bottom: none; }

.list-item-main { flex: 1; min-width: 0; }

.list-item-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    word-break: break-word;
}

.list-item-sub {
    font-size: 12px;
    color: #666;
    line-height: 1.5;
}

.list-item-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}

/* Модальное окно */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-subtitle {
    color: #555;
    font-size: 14px;
    margin-bottom: 16px;
    padding: 8px 12px;
    background: #f0f2f5;
    border-radius: 8px;
}

.close-btn {
    width: auto;
    background: transparent;
    color: #666;
    font-size: 20px;
    padding: 4px 8px;
    margin: 0;
    border: none;
}

.close-btn:hover { background: #f0f2f5; color: #1a1a1a; }

/* Адаптив для мобильных */
@media (max-width: 480px) {
    .screen { padding: 12px; }
    .card { padding: 16px; }
    .tabs { font-size: 12px; }
    .tab { padding: 8px 4px; font-size: 12px; }
}
/* Фильтры */
.filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.filters select,
.filters input {
    margin: 0;
    font-size: 14px;
    padding: 10px 12px;
}

.filters #filter-search {
    grid-column: 1 / -1;
}

#keys-counter {
    margin-bottom: 12px;
    font-size: 13px;
}

/* Пагинация */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.page-btn {
    width: auto;
    padding: 6px 12px;
    margin: 0;
    font-size: 13px;
    background: #f0f2f5;
    color: #1a1a1a;
    font-weight: 500;
}

.page-btn:hover { background: #e0e2e5; }
.page-btn.active { background: #2563eb; color: white; }
.page-btn.active:hover { background: #1d4ed8; }

.page-dots {
    padding: 6px 4px;
    color: #888;
    font-size: 13px;
}

/* Адаптив для мобильных */
@media (max-width: 480px) {
    .filters { grid-template-columns: 1fr; }
    .filters #filter-search { grid-column: auto; }
    .page-btn { padding: 6px 8px; font-size: 12px; }
}
/* События (лента) */
.event-item {
    padding: 12px 0;
    border-bottom: 1px solid #eee;
    transition: background 0.2s;
}

.event-item:last-child { border-bottom: none; }

.event-item.unseen {
    background: #eff6ff;
    padding-left: 10px;
    padding-right: 10px;
    margin: 0 -10px;
    border-radius: 8px;
    border-bottom-color: transparent;
}

.event-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    gap: 8px;
}

.event-status {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

.event-status.pending { background: #fef3c7; color: #92400e; }
.event-status.accepted { background: #d1fae5; color: #065f46; }
.event-status.cancelled { background: #fee2e2; color: #991b1b; }

.event-date {
    font-size: 12px;
    color: #888;
}

.event-key {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.event-route {
    font-size: 13px;
    color: #555;
    margin-bottom: 4px;
}

.event-comment {
    font-size: 12px;
    color: #777;
    font-style: italic;
    padding: 4px 8px;
    background: #f9fafb;
    border-radius: 6px;
    margin-top: 4px;
    display: inline-block;
}
/* История ключа */
.history-item {
    padding: 12px;
    border-left: 3px solid #2563eb;
    background: #f9fafb;
    border-radius: 8px;
    margin-bottom: 10px;
}

.history-item:last-child { margin-bottom: 0; }

.history-date {
    font-size: 12px;
    color: #888;
    margin-bottom: 4px;
}

.history-route {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    word-break: break-word;
}

.history-status {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

.history-status.pending { background: #fef3c7; color: #92400e; }
.history-status.accepted { background: #d1fae5; color: #065f46; }
.history-status.cancelled { background: #fee2e2; color: #991b1b; }

.history-comment {
    font-size: 12px;
    color: #777;
    font-style: italic;
    margin-top: 6px;
    padding: 4px 8px;
    background: white;
    border-radius: 6px;
    display: inline-block;
}

/* Кнопка "secondary" для малых кнопок */
button.small-btn.secondary {
    background: #e5e7eb;
    color: #1a1a1a;
}

button.small-btn.secondary:hover {
    background: #d1d5db;
}