:root {
    --bg: #12141a;
    --panel: #191c24;
    --panel-2: #1f2330;
    --line: #2b3040;
    --text: #e7e9ee;
    --muted: #969cad;
    --accent: #c9a227;
    --accent-soft: rgba(201, 162, 39, 0.12);
    --ok: #4caf7d;
    --err: #e2574c;
    --run: #4a8fd4;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

/* ── Каркас ── */
header {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 28px;
    height: 60px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    font-weight: 600;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    gap: 10px;
}
.brand span { color: var(--accent); }

nav { display: flex; gap: 4px; margin-left: auto; }

nav button {
    background: none;
    border: 0;
    color: var(--muted);
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
}
nav button:hover { color: var(--text); background: var(--panel-2); }
nav button.active { color: var(--accent); background: var(--accent-soft); }

main { max-width: 1180px; margin: 0 auto; padding: 28px; }

.view { display: none; }
.view.active { display: block; }

h1 { font-size: 21px; margin: 0 0 4px; font-weight: 600; }
h2 { font-size: 16px; margin: 28px 0 12px; font-weight: 600; }
.sub { color: var(--muted); font-size: 13.5px; margin: 0 0 22px; }

/* ── Панели ── */
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 18px;
}

.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 760px) { .grid.two { grid-template-columns: 1fr; } }

/* ── Поля ── */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

input[type=text], input[type=password], input[type=number], select, textarea {
    width: 100%;
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 8px;
    padding: 9px 12px;
    font: inherit;
    font-size: 14px;
}
textarea { resize: vertical; min-height: 68px; }
input:focus, select:focus, textarea:focus { outline: 1px solid var(--accent); }

.checkline { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.checkline input { width: 16px; height: 16px; accent-color: var(--accent); }

button.btn {
    background: var(--accent);
    color: #16181d;
    border: 0;
    border-radius: 8px;
    padding: 10px 18px;
    font: inherit;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}
button.btn:hover { filter: brightness(1.08); }
button.btn:disabled { opacity: 0.45; cursor: default; }
button.btn.ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--line);
    font-weight: 500;
}
button.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
button.btn.small { padding: 6px 12px; font-size: 13px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ── Зона загрузки ── */
.drop {
    border: 1.5px dashed var(--line);
    border-radius: var(--radius);
    padding: 26px;
    text-align: center;
    color: var(--muted);
    cursor: pointer;
    transition: 0.15s;
    font-size: 14px;
}
.drop:hover, .drop.over { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.drop b { color: var(--text); font-weight: 500; }

.filelist { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 12.5px;
    color: var(--muted);
}

/* ── Список дел ── */
.case {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 8px;
    cursor: pointer;
}
.case:hover { border-color: var(--accent); }
.case .t { font-weight: 500; }
.case .m { color: var(--muted); font-size: 13px; margin-left: auto; }

/* ── Статусы ── */
.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    padding: 3px 10px;
    border-radius: 20px;
    background: var(--panel-2);
    color: var(--muted);
}
.status.done { color: var(--ok); }
.status.error { color: var(--err); }
.status.running { color: var(--run); }
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.running .dot { animation: pulse 1.1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* ── Журнал ── */
.log {
    background: #0e1015;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 14px;
    max-height: 260px;
    overflow-y: auto;
    font: 12.5px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--muted);
}
.log div { white-space: pre-wrap; }
.log .t { color: #5d6478; margin-right: 8px; }

/* ── Результат ── */
.result {
    background: #0e1015;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px 24px;
    max-height: 560px;
    overflow-y: auto;
    white-space: pre-wrap;
    font: 14px/1.75 "Georgia", "Times New Roman", serif;
}

.warn {
    background: rgba(226, 87, 76, 0.1);
    border: 1px solid rgba(226, 87, 76, 0.35);
    color: #f0a49d;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13.5px;
    margin-bottom: 14px;
}
.warn ul { margin: 6px 0 0; padding-left: 18px; }

.note {
    background: var(--accent-soft);
    border: 1px solid rgba(201, 162, 39, 0.3);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13.5px;
    color: #e5d5a4;
}

.muted { color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); text-align: center; padding: 36px; font-size: 14px; }

/* ── Таблица источников базы ── */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
    text-align: left;
    color: var(--muted);
    font-weight: 500;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    font-size: 12.5px;
}
td { padding: 9px 10px; border-bottom: 1px solid rgba(43, 48, 64, 0.5); vertical-align: top; }
tr:hover td { background: var(--panel-2); }
.mode {
    font-size: 11.5px;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--panel-2);
    color: var(--muted);
    white-space: nowrap;
}
.mode.always { color: var(--accent); background: var(--accent-soft); }
.mode.articles { color: var(--run); background: rgba(74, 143, 212, 0.12); }

/* ── Модальное окно ── */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(8, 9, 12, 0.72);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 24px;
}
.modal.open { display: flex; }
.modal .box {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 24px;
    width: 100%;
    max-width: 620px;
    max-height: 86vh;
    overflow-y: auto;
}

.toast {
    position: fixed;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 20px;
    font-size: 14px;
    z-index: 90;
    display: none;
}
.toast.show { display: block; }
.toast.err { border-color: var(--err); color: #f0a49d; }

/* ── Кто вошёл ── */
.who { display: flex; align-items: center; gap: 12px; margin-left: 18px; }
.who a:hover { color: var(--accent); }

/* ── Черновик карточки по документам ── */
.draft-field {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 8px;
    background: var(--panel-2);
}
.draft-field.applied { border-color: rgba(76, 175, 125, 0.5); }
.draft-field .h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.draft-field .name { font-size: 13px; color: var(--muted); }
.draft-field .val { font-size: 14px; margin-top: 4px; white-space: pre-wrap; }
.draft-field .src {
    font-size: 12.5px;
    color: var(--muted);
    margin-top: 6px;
    border-left: 2px solid var(--line);
    padding-left: 10px;
    font-style: italic;
}
.draft-field .act { margin-left: auto; }

/* ── Повторяющиеся строки карточки ── */
.rowline { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.rowline input, .rowline select { flex: 1; min-width: 120px; }
.rowline .w-date { flex: 0 0 130px; min-width: 130px; }

/* ── Вход ── */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-box {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 34px;
    width: 340px;
    text-align: center;
}
