:root {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --border: #e3e8ef;
    --text: #1a2231;
    --muted: #6b7684;
    --accent: #1f6feb;
    --accent-dark: #1858c4;
    --warn-bg: #fff8e6;
    --warn-border: #f5d78e;
    --error-bg: #fdeeee;
    --error-border: #f2b8b8;
    --error-text: #a11414;
    --auto-row: #fffaf0;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

h1, h2 { margin: 0; font-weight: 600; }
h1 { font-size: 20px; }
h2 { font-size: 17px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); font-size: 13px; }

/* ---------- Вход ---------- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px 28px;
}

.login-head { text-align: center; margin-bottom: 24px; }
.login-icon { font-size: 32px; margin-bottom: 8px; }
.login-head p { margin: 6px 0 0; }

/* ---------- Шапка ---------- */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.brand-icon { font-size: 18px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.page {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ---------- Карточки ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

/* ---------- Форма ---------- */
.filters { display: flex; flex-direction: column; gap: 16px; }

.filters-row {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filters-row-bottom { justify-content: space-between; align-items: center; }

.field { display: flex; flex-direction: column; gap: 5px; flex: 1 1 160px; }
.field > span { font-size: 12px; font-weight: 500; color: var(--muted); }

input[type="text"], input[type="password"], input[type="date"], input[type="search"], select {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    width: 100%;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(31, 111, 235, .12);
}

.field + .field { margin-top: 0; }
.login-card .field { margin-bottom: 14px; }

.presets { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.chip {
    padding: 4px 11px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    font-size: 12px;
    color: var(--muted);
    cursor: pointer;
    font-family: inherit;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

.checkbox { display: flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }
.checkbox input { width: 15px; height: 15px; cursor: pointer; accent-color: var(--accent); }

.hint {
    width: 15px; height: 15px;
    border-radius: 50%;
    background: var(--border);
    color: var(--muted);
    font-size: 10px;
    font-style: normal;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: help;
}

/* ---------- Кнопки ---------- */
.btn {
    padding: 8px 16px;
    border-radius: 7px;
    border: 1px solid transparent;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    display: inline-block;
    text-align: center;
    transition: background .12s, border-color .12s;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); text-decoration: none; }
.btn-primary:disabled { background: #a8c3ef; cursor: not-allowed; }

.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn-ghost:hover { border-color: var(--muted); color: var(--text); text-decoration: none; }

.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 6px; }

/* ---------- Прогресс ---------- */
.progress-card { display: flex; flex-direction: column; gap: 10px; }
.progress-head { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }

.progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0;
    background: var(--accent);
    border-radius: 3px;
    transition: width .3s ease;
}

.progress-stats { font-size: 12px; }

/* ---------- Уведомления ---------- */
.alert {
    padding: 11px 14px;
    border-radius: 8px;
    border: 1px solid;
    font-size: 13px;
}
.alert ul { margin: 6px 0 0; padding-left: 18px; }
.alert-warn { background: var(--warn-bg); border-color: var(--warn-border); color: #7a5a00; }
.alert-error { background: var(--error-bg); border-color: var(--error-border); color: #a11414; }

/* ---------- Результат ---------- */
.result-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.result-head p { margin: 4px 0 0; }
.result-actions { display: flex; gap: 10px; align-items: center; }
.search { width: 200px; }

.table-filters {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    padding: 12px;
    margin-bottom: 14px;
    background: #fafbfc;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.filter-select {
    width: auto;
    min-width: 150px;
    max-width: 220px;
    font-size: 13px;
    padding: 6px 9px;
}

.table-filters .checkbox { white-space: nowrap; }
.table-filters .muted { margin-left: auto; white-space: nowrap; }

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

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

.data-table th {
    background: #fafbfc;
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    font-size: 12px;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--accent); }
.data-table th.sort-asc::after { content: " ↑"; }
.data-table th.sort-desc::after { content: " ↓"; }

.data-table td {
    padding: 9px 12px;
    border-bottom: 1px solid #f0f3f7;
    vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafbfc; }
.data-table tbody tr.row-auto { background: var(--auto-row); }
.data-table tbody tr.row-auto:hover { background: #fff4e0; }

.tag {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 11px;
    margin-left: 6px;
    white-space: nowrap;
}
.tag-info { background: #e8f0fe; color: #1858c4; }

.legend { margin: 12px 0 0; display: flex; align-items: center; gap: 6px; font-size: 12px; }
.legend-swatch {
    display: inline-block;
    width: 12px; height: 12px;
    background: var(--auto-row);
    border: 1px solid var(--warn-border);
    border-radius: 3px;
}

.empty { text-align: center; padding: 32px; color: var(--muted); }

@media (max-width: 720px) {
    .page, .topbar-inner { padding: 14px; }
    .filters-row { flex-direction: column; align-items: stretch; }
    .filters-row-bottom { align-items: stretch; }
    .result-actions { width: 100%; }
    .search { flex: 1; width: auto; }
}
