:root {
  --bg: #f5f6f8; --card: #fff; --text: #1d2330; --muted: #677084; --line: #dfe3ea;
  --accent: #2f5496; --accent-2: #eaf0fb; --ok: #1f7a3a; --ok-bg: #e7f5ec;
  --err: #b3261e; --err-bg: #fdecea; --warn: #8a5a00; --warn-bg: #fff4dc;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--accent); }
header { background: var(--accent); color: #fff; }
header .wrap { display: flex; align-items: center; gap: 24px; min-height: 52px; flex-wrap: wrap; }
header .brand { font-weight: 700; font-size: 16px; }
header nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
header nav a { color: #fff; text-decoration: none; padding: 6px 12px; border-radius: 6px; opacity: .85; }
header nav a.active, header nav a:hover { background: rgba(255,255,255,.18); opacity: 1; }
header form button { background: transparent; border: 1px solid rgba(255,255,255,.5); color: #fff; }
.wrap { max-width: 1400px; margin: 0 auto; padding: 0 16px; }
main { padding: 20px 0 48px; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 24px 0 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
button, .btn { display: inline-block; font: inherit; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn.light, button.light { background: var(--card); color: var(--accent); }
button.danger { background: var(--card); color: var(--err); border-color: var(--err); }
button.mini, .btn.mini { padding: 2px 8px; font-size: 12px; }
input[type=text], input[type=password], input[type=date], input[type=datetime-local], input[type=search], select, textarea {
  font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: 7px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f0f2f6; font-weight: 600; position: sticky; top: 0; }
tr:hover td { background: #fafbfd; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.pw { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--accent-2); padding: 1px 6px; border-radius: 4px; user-select: all; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 10px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--err-bg); color: var(--err); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #eef0f4; color: var(--muted); white-space: nowrap; }
.badge.create, .badge.sent, .badge.active { background: var(--ok-bg); color: var(--ok); }
.badge.takeover, .badge.pending, .badge.sending { background: var(--warn-bg); color: var(--warn); }
.badge.update { background: var(--accent-2); color: var(--accent); }
.badge.error, .badge.failed { background: var(--err-bg); color: var(--err); }
ul.errs { margin: 0; padding-left: 18px; color: var(--err); }
ul.warns { margin: 0; padding-left: 18px; color: var(--warn); }
.body-preview { white-space: pre-wrap; max-height: 5.5em; overflow: hidden; }
.body-full { white-space: pre-wrap; font-size: 15px; }
.stats { display: flex; gap: 12px; flex-wrap: wrap; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; min-width: 120px; }
.stat b { display: block; font-size: 20px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.filters label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.pager { display: flex; gap: 6px; margin: 12px 0; flex-wrap: wrap; }
.login { max-width: 360px; margin: 10vh auto; }
.login label { display: block; margin: 10px 0 4px; }
.login input { width: 100%; }
pre.headers { white-space: pre-wrap; font-size: 12px; background: #f7f8fa; padding: 10px; border-radius: 8px; overflow-x: auto; }
dl.meta { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
dl.meta dt { color: var(--muted); }
dl.meta dd { margin: 0; }
/* раздел 4 — генерация заданий */
.attach { margin-top: 8px; padding: 6px 10px; background: var(--accent-2); border-radius: 6px; display: inline-block; }
.attach a { text-decoration: none; font-weight: 600; }
.doc-fields { margin-top: 10px; padding: 8px 10px; border: 1px dashed var(--line); border-radius: 8px; }
.project-text { max-height: 420px; overflow-y: auto; background: #f7f8fa; padding: 10px; border-radius: 8px; margin-top: 8px; }
textarea.project-edit { width: 100%; font: 13px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; resize: vertical; }
.gen-form .field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.gen-form textarea { width: 100%; resize: vertical; }
.gen-params .field { margin-bottom: 8px; font-size: 12px; color: var(--muted); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px; }
.check { display: flex; gap: 8px; align-items: flex-start; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.check:has(input:checked) { border-color: var(--accent); background: var(--accent-2); }
.prewrap { white-space: pre-wrap; }
.btn.disabled, button:disabled { opacity: .45; cursor: not-allowed; }
.actions { margin: 14px 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 8px 0 14px; }
.tabs a { padding: 7px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.thread { margin-bottom: 28px; }
.msg { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px;
  padding: 10px 14px; margin: 0 48px 10px 0; }
.msg.exec { border-left-color: #8a5a00; margin: 0 0 10px 48px; }
.msg.has-err, tr.row-err td { background: var(--err-bg); }
.msg-head { font-size: 13px; }
.msg-subj { font-weight: 600; margin: 4px 0 6px; }
.msg .body-full { font-size: 14px; }
details.quote summary, details.edit summary { cursor: pointer; color: var(--muted); font-size: 12px; margin-top: 6px; }
details.quote .body-full { color: var(--muted); border-left: 2px solid var(--line); padding-left: 8px; margin-top: 4px; }
details.edit label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); margin-top: 8px; }
details.edit textarea { width: 100%; font: 13px/1.45 ui-monospace, Menlo, Consolas, monospace; }
details.edit label.del { flex-direction: row; align-items: center; color: var(--err); }
.savebar { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; border-top: 1px solid var(--line);
  display: flex; gap: 12px; align-items: center; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 1s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 700px) { .msg, .msg.exec { margin-left: 0; margin-right: 0; } }
@media (max-width: 700px) { header .wrap { gap: 8px; padding: 8px 16px; } th, td { padding: 6px; } }
