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

:root {
    --bg-main: #f4f6f9;
    --bg-card: #ffffff;
    --bg-header: #2c5282;
    --text-main: #1a1a2e;
    --text-muted: #5a6478;
    --text-faint: #9aa3b5;
    --border: #e2e8f0;
    --border-input: #d4d9e3;
    --row-hover: #f4f8ff;
    --badge-bg: #e2e8f0;
    --shadow: rgba(0,0,0,0.1);
}

[data-theme="dark"] {
    --bg-main: #15171f;
    --bg-card: #1e2129;
    --bg-header: #1a2c47;
    --text-main: #e6e8ef;
    --text-muted: #aab2c5;
    --text-faint: #6b7488;
    --border: #2c2f3a;
    --border-input: #3a3e4a;
    --row-hover: #262a35;
    --badge-bg: #2c2f3a;
    --shadow: rgba(0,0,0,0.4);
}

body {
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg-main);
    color: var(--text-main);
    transition: background 0.2s, color 0.2s;
}

.header {
    background: var(--bg-header);
    color: white;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.header h1 {
    font-size: 20px;
    font-weight: 600;
}

.title-block {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.version-tag {
    font-size: 11px;
    color: rgba(255,255,255,0.6);
    margin-top: 2px;
}

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

.signature {
    font-size: 12px;
    color: rgba(255,255,255,0.7);
}

.theme-toggle {
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 6px;
    width: 34px;
    height: 34px;
    font-size: 16px;
    cursor: pointer;
    color: white;
    transition: background 0.15s;
}

.theme-toggle:hover {
    background: rgba(255,255,255,0.3);
}

.back-link {
    color: white;
    text-decoration: none;
    font-size: 14px;
}

.back-link:hover {
    text-decoration: underline;
}

.container {
    display: flex;
    gap: 20px;
    padding: 20px;
    max-width: 1600px;
    margin: 0 auto;
}

.detail-container {
    flex-direction: column;
}

/* Фильтры */
.filters-panel {
    width: 280px;
    flex-shrink: 0;
    background: var(--bg-card);
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 1px 3px var(--shadow);
    align-self: flex-start;
}

.filter-group {
    margin-bottom: 14px;
}

.filter-row {
    display: flex;
    gap: 8px;
}

.filter-row .filter-group {
    flex: 1;
}

.filter-group label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 500;
}

.filter-group input,
.filter-group select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border-input);
    border-radius: 6px;
    font-size: 13px;
    background: var(--bg-card);
    color: var(--text-main);
}

.filter-hint {
    font-size: 11px;
    color: var(--text-faint);
    margin-bottom: 14px;
}

.filter-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}

.btn:hover {
    opacity: 0.85;
}

.btn-primary {
    background: #2c5282;
    color: white;
}

.btn-secondary {
    background: var(--badge-bg);
    color: var(--text-main);
}

/* Результаты */
.results-panel {
    flex: 1;
    background: var(--bg-card);
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 1px 3px var(--shadow);
    overflow-x: auto;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.error-msg {
    color: #e53e3e;
    font-weight: 600;
}

.apps-table, .steps-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.apps-table th, .steps-table th {
    text-align: left;
    padding: 10px 12px;
    background: var(--bg-main);
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.apps-table td, .steps-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.apps-table tbody tr {
    cursor: pointer;
    transition: background 0.1s;
}

.apps-table tbody tr:hover {
    background: var(--row-hover);
}

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    background: var(--badge-bg);
    font-size: 12px;
    font-weight: 600;
}

/* Пагинация */
.pagination {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 16px;
    flex-wrap: wrap;
}

.pagination button {
    min-width: 32px;
    height: 32px;
    border: 1px solid var(--border-input);
    background: var(--bg-card);
    color: var(--text-main);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

.pagination button.active {
    background: #2c5282;
    color: white;
    border-color: #2c5282;
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: default;
}

.pagination .ellipsis {
    display: flex;
    align-items: center;
    color: var(--text-faint);
    padding: 0 4px;
}

/* Детальная карточка */
.detail-card {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px var(--shadow);
}

.detail-card h2 {
    font-size: 15px;
    margin-bottom: 14px;
    color: #4a8fd6;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.detail-field label {
    display: block;
    font-size: 11px;
    color: var(--text-faint);
    margin-bottom: 2px;
}

.detail-field .value {
    font-size: 14px;
    font-weight: 500;
}

@media (max-width: 900px) {
    .container {
        flex-direction: column;
    }
    .filters-panel {
        width: 100%;
    }
}

/* Страница входа */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
}

.login-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 36px 40px;
    width: 360px;
    box-shadow: 0 4px 16px var(--shadow);
    text-align: center;
}

.login-card h1 {
    font-size: 18px;
    color: var(--text-main);
    margin-bottom: 4px;
    line-height: 1.4;
}

.login-subtitle {
    font-size: 12px;
    color: var(--text-faint);
    margin-bottom: 24px;
}

.login-form {
    text-align: left;
}

.login-btn {
    width: 100%;
    margin-top: 8px;
}

.login-error {
    color: #e53e3e;
    font-size: 13px;
    margin-bottom: 12px;
    text-align: left;
}

.login-footer {
    margin-top: 24px;
    font-size: 11px;
    color: var(--text-faint);
}

.user-info {
    font-size: 12px;
    color: rgba(255,255,255,0.8);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.4;
}

.logout-link {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    font-size: 11px;
}

.logout-link:hover {
    text-decoration: underline;
}

.admin-form .filter-group {
    flex: 1;
}

.admin-form .filter-row {
    margin-bottom: 14px;
}

.btn-small {
    padding: 5px 12px;
    font-size: 12px;
}

.admin-actions {
    display: flex;
    gap: 6px;
}

.edit-row td {
    background: var(--bg-main);
    padding: 16px;
}

.edit-form .filter-group input:disabled {
    opacity: 0.6;
}
