:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;
    --success: #16a34a;
    --success-dark: #15803d;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --green-light: #dcfce7;
    --yellow-light: #fef9c3;
    --red-light: #fee2e2;
    --teal-dark: #0f766e;
    --teal-light: #ccfbf1;
    --sky-dark: #0369a1;
    --sky-light: #e0f2fe;
    --amber-dark: #b45309;
    --amber-light: #fef3c7;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow-md: 0 4px 14px rgba(15, 23, 42, .09);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, .13);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.navbar {
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -0.01em;
    text-decoration: none;
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    gap: 9px;
}

.nav-brand svg { width: 22px; height: 22px; }

.nav-links a {
    text-decoration: none;
    color: var(--text-muted);
    margin-left: 24px;
    font-weight: 500;
    font-size: 14px;
    padding: 6px 2px;
    border-bottom: 2px solid transparent;
    transition: color .15s;
}

.nav-links a:hover { color: var(--primary); }

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}

.step {
    background: var(--card-bg);
    border-radius: 14px;
    padding: 32px;
    margin-bottom: 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.step h2 {
    margin-bottom: 20px;
    font-size: 22px;
    letter-spacing: -0.02em;
}

.hidden { display: none !important; }

.hint {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 16px;
}

.dropzone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 48px;
    text-align: center;
    transition: border-color .2s, background .2s;
    cursor: pointer;
}

.dropzone.dragover {
    border-color: var(--primary);
    background: #eff6ff;
}

.dropzone p {
    color: var(--text-muted);
    margin-bottom: 12px;
}

.btn {
    padding: 8px 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    transition: transform .15s, box-shadow .15s, border-color .15s, color .15s, background .15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    text-decoration: none;
}

.btn:hover { border-color: var(--primary); color: var(--primary); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); box-shadow: var(--shadow-sm); }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); color: white; box-shadow: 0 4px 14px rgba(37, 99, 235, .35); }
.btn-success { background: var(--success); color: white; border-color: var(--success); }
.btn-success:hover { background: var(--success-dark); color: white; box-shadow: 0 4px 14px rgba(22, 163, 74, .3); }
.btn-sm { padding: 4px 12px; font-size: 13px; border-radius: 7px; }
.btn-danger { color: #dc2626; border-color: #fecaca; }
.btn-danger:hover { background: var(--red-light); color: #b91c1c; box-shadow: var(--shadow-md); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn:focus-visible,
.input:focus-visible,
a:focus-visible,
select:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    background: var(--card-bg);
    color: var(--text);
}

.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .13); }

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text-muted);
    cursor: pointer;
}

.file-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

.file-card.detected { border-left: 4px solid var(--success); }
.file-card.manual { border-left: 4px solid #f59e0b; }

.file-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.file-name { font-weight: 600; font-size: 15px; }

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.badge-green { background: var(--green-light); color: var(--success-dark); }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-yellow { background: var(--yellow-light); color: #854d0e; }
.badge-red { background: var(--red-light); color: #dc2626; }
.badge-gray { background: #e5e7eb; color: #374151; }

.upload-stats { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

.col-select-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.col-select-row select { min-width: 300px; }

.stats-panel {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 20px;
    min-width: 150px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .15s, transform .15s;
}

.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card .num { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 10px; }
.stat-card .label { font-size: 13px; color: var(--text-muted); }
.stat-card .sub { font-size: 12px; color: var(--text-muted); opacity: .85; }

.stat-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg { width: 18px; height: 18px; }

.accent-blue .stat-icon { background: var(--primary-light); color: var(--primary-dark); }
.accent-green .stat-icon { background: var(--green-light); color: var(--success-dark); }
.accent-teal .stat-icon { background: var(--teal-light); color: var(--teal-dark); }
.accent-amber .stat-icon { background: var(--amber-light); color: var(--amber-dark); }
.accent-sky .stat-icon { background: var(--sky-light); color: var(--sky-dark); }
.accent-red .stat-icon { background: var(--red-light); color: #dc2626; }

.stat-chart {
    flex: 1;
    min-width: 400px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
}

.bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 13px;
}

.bar-label { width: 200px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; background: #e2e8f0; border-radius: 4px; height: 20px; position: relative; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--primary); display: flex; align-items: center; padding-left: 6px; color: white; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; transition: width .4s ease; }

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 16px;
}

.tab {
    padding: 8px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-content { display: none; }
.tab-content.active { display: block; }

.toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.toolbar .input { min-width: 200px; }

.mapping-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-muted);
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.data-table th {
    text-align: left;
    padding: 10px 12px 8px;
    background: var(--bg);
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    font-size: 12.5px;
    letter-spacing: .03em;
    color: var(--text-muted);
    position: sticky;
    top: 56px;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(15, 23, 42, .04);
}

.data-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

.data-table tbody tr { transition: background .1s; }
.data-table tbody tr:hover { background: var(--primary-light); }

/* отступ между липкой шапкой и первой строкой */
.data-table tbody tr:first-child td { padding-top: 14px; }
.data-table tbody tr:first-child td:first-child { border-top-left-radius: 4px; }

.summary-table {
    table-layout: fixed;
}

.summary-table th,
.summary-table td {
    overflow-wrap: anywhere;
}

.method-synonym { color: var(--success-dark); }
.method-keyword { color: #854d0e; }
.method-none { color: #dc2626; font-weight: 600; }
.method-override { color: #7c3aed; }
.method-empty { color: var(--text-muted); }

.export-bar {
    margin-top: 24px;
    display: flex;
    gap: 12px;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.form-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.form-row label { width: 180px; font-weight: 500; font-size: 14px; flex-shrink: 0; }
.form-row .input { flex: 1; }

.ref-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.ref-test { display: flex; gap: 8px; align-items: center; }
.test-result { font-size: 14px; font-weight: 600; }

.cat-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

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

.cat-title { font-size: 18px; font-weight: 700; }
.cat-priority { font-size: 13px; color: var(--text-muted); }

.synonyms-list, .keywords-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 13px;
}

.tag-kw { background: #fef3c7; border-color: #fde68a; }

.tag-remove {
    cursor: pointer;
    color: #dc2626;
    font-weight: 700;
    border: none;
    background: none;
    padding: 0;
    line-height: 1;
}

.add-tag-input {
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 13px;
    outline: none;
    min-width: 120px;
}

.add-tag-input:focus { border-color: var(--primary); border-style: solid; }

.section-label { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-top: 8px; }

.category-select {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.category-select option { max-width: none; }

select.combo-native { display: none; }

.combo-btn {
    padding: 4px 26px 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    background: var(--card-bg);
    color: var(--text);
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
    position: relative;
    cursor: pointer;
}

.combo-btn::after {
    content: "▾";
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: var(--text-muted);
}

.combo-menu {
    position: fixed;
    z-index: 1000;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 6px 24px rgba(15, 23, 42, .14);
    max-width: 360px;
    min-width: 140px;
    max-height: 320px;
    overflow-y: auto;
    padding: 4px 0;
}

.combo-item {
    padding: 6px 12px;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.combo-item:hover { background: #eff6ff; }
.combo-item.selected { font-weight: 600; color: var(--primary); }

.events-table {
    table-layout: fixed;
    width: 100%;
}

.events-table th,
.events-table td {
    vertical-align: top;
}

.events-table td:nth-child(1),
.events-table td:nth-child(2) {
    overflow-wrap: break-word;
    word-break: break-word;
    white-space: normal;
    hyphens: auto;
}

.events-table td:nth-child(1),
.events-table td:nth-child(2),
.events-table td:nth-child(6) {
    overflow-wrap: break-word;
    word-break: break-word;
    white-space: normal;
    hyphens: auto;
}

.events-table td:nth-child(3),
.events-table td:nth-child(4),
.events-table td:nth-child(5),
.events-table td:nth-child(7) {
    overflow-wrap: break-word;
    word-break: break-word;
}

.cell-clamp {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.file-actions { display: flex; gap: 8px; align-items: center; }

.suggest-result { margin-top: 8px; }
.suggest-list { display: flex; flex-direction: column; gap: 6px; }
.suggest-item { display: flex; gap: 8px; align-items: center; padding: 4px 0; }
.suggest-item.best { background: var(--green-light); padding: 6px 8px; border-radius: 6px; }
.suggest-item .badge { margin-left: auto; }
.suggest-save-label { margin-left: 8px !important; font-size: 12px; white-space: nowrap; }

.data-table button.btn-success { background: var(--success); color: white; border-color: var(--success); }

#mapping-body tr.edited td { background: #fffbeb; }

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: 360px;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 32px;
    box-shadow: var(--shadow-lg);
}

.login-card .input { width: 100%; }
.login-card .btn { margin-top: 12px; }

/* ---------- Дашборд: стек-бар распределения вердиктов ---------- */

.vbar {
    display: flex;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    background: #edf2f7;
    min-width: 140px;
    max-width: 320px;
}

#ec-summary-table th:first-child,
#ec-summary-table td:first-child {
    white-space: nowrap;
    min-width: 220px;
}

#ec-summary-table td { vertical-align: middle; }

/* ---------- Адаптивные таблицы ---------- */

.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-responsive .data-table { min-width: 100%; }

.vbar i { display: block; height: 100%; min-width: 2px; }
.vbar i + i { box-shadow: inset 1px 0 0 rgba(255, 255, 255, .55); }

/* ---------- Скелетоны загрузки ---------- */

.skel {
    position: relative;
    overflow: hidden;
    background: #e8edf4;
    border-radius: 6px;
    height: 14px;
}

.skel::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .75), transparent);
    animation: shimmer 1.4s infinite;
}

@keyframes shimmer { 100% { transform: translateX(100%); } }

.skel-row td { padding: 13px 12px; }

/* ---------- Пустые состояния ---------- */

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

.empty-state svg { width: 40px; height: 40px; opacity: .45; margin-bottom: 10px; }
.empty-state .t { font-weight: 600; color: var(--text); margin-bottom: 2px; }

/* ---------- Прогресс: пульс точки ---------- */

.progress-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    margin-right: 7px;
    animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: .35; transform: scale(.72); }
}

/* ---------- Скроллбар ---------- */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ---------- Табличные числа и выделение ---------- */

::selection { background: rgba(37, 99, 235, .18); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
