:root {
  --bg: #f6f7f9;
  --panel: #fff;
  --line: #d9dde3;
  --ink: #1d2430;
  --muted: #6b7480;
  --accent: #1b5fb0;
  --red-bg: #fde7e7; --red-ink: #a01b1b; --red-line: #e8b4b4;
  --yellow-bg: #fdf3d8; --yellow-ink: #8a6100; --yellow-line: #e6d097;
  --green-bg: #e3f5e6; --green-ink: #1c6b30; --green-line: #a8d9b4;
}

* { box-sizing: border-box; }
/* сами задаём display элементам, которые прячем атрибутом hidden (.overlay и др.),
   поэтому правило браузера [hidden]{display:none} нужно вернуть себе */
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
}
h1 { font-size: 18px; margin: 0; }
.muted { color: var(--muted); }
.mono { font-family: Consolas, "SF Mono", monospace; font-size: 12px; }
.nowrap { white-space: nowrap; }
a.link { color: var(--accent); text-decoration: none; margin-left: 12px; }
a.link:hover { text-decoration: underline; }

button {
  font: inherit; padding: 5px 12px; border-radius: 5px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
}
button:hover:not(:disabled) { border-color: #b6bec9; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.ghost { background: transparent; }
button.danger { color: var(--red-ink); border-color: var(--red-line); }

/* ------------------------------------------------------------------ вход */
.login-wrap { display: flex; justify-content: center; padding-top: 12vh; }
.login {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 28px 32px; width: 340px; display: flex; flex-direction: column; gap: 12px;
}
.login label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.login input {
  font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 5px; color: var(--ink);
}
.login-error {
  background: var(--red-bg); color: var(--red-ink); border: 1px solid var(--red-line);
  border-radius: 5px; padding: 7px 10px;
}

/* ------------------------------------------------------------- шапка */
.top {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20; flex-wrap: wrap;
}
.top-left, .top-right { display: flex; align-items: center; gap: 12px; }
.stamp { text-align: right; font-size: 12px; color: var(--muted); }
.agent { display: block; }
.agent.online { color: var(--green-ink); }
.agent.offline { color: var(--muted); }
.who { font-size: 12px; color: var(--muted); }

.joblog {
  margin: 8px 16px 0; background: #1d2430; color: #d8e0ea; border-radius: 6px; padding: 8px 12px;
}
.joblog-head { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; }
.joblog pre { margin: 0; max-height: 160px; overflow: auto; font-size: 12px; white-space: pre-wrap; }

.filters-note { padding: 8px 16px 0; font-size: 12px; }

/* ------------------------------------------------------------- таблица */
table { border-collapse: collapse; width: calc(100% - 32px); margin: 8px 16px 40px; background: var(--panel); }
th, td { border: 1px solid var(--line); padding: 5px 8px; text-align: left; vertical-align: top; }
thead th {
  position: sticky; top: 52px; background: #eef1f5; z-index: 10; white-space: nowrap;
  font-size: 12px; text-transform: uppercase; letter-spacing: .02em;
}
.th-sort { cursor: pointer; }
.th-filter { cursor: pointer; color: var(--muted); margin-left: 6px; }
.th-filter:hover { color: var(--accent); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #eef4fc; }
.col-n { width: 44px; color: var(--muted); }
.col-name { max-width: 520px; }
.col-dup { width: 60px; text-align: center; }
td.overdue { background: var(--red-bg); color: var(--red-ink); font-weight: 600; }

.plate {
  display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px;
  white-space: nowrap; border: 1px solid transparent;
}
.plate.red { background: var(--red-bg); color: var(--red-ink); border-color: var(--red-line); }
.plate.yellow { background: var(--yellow-bg); color: var(--yellow-ink); border-color: var(--yellow-line); }
.plate.green { background: var(--green-bg); color: var(--green-ink); border-color: var(--green-line); }
.plate-wide {
  display: block; padding: 7px 10px; border-radius: 5px; margin: 8px 0; border: 1px solid transparent;
}
.plate-wide.red { background: var(--red-bg); color: var(--red-ink); border-color: var(--red-line); }
.plate-wide.yellow { background: var(--yellow-bg); color: var(--yellow-ink); border-color: var(--yellow-line); }
.plate-wide.green { background: var(--green-bg); color: var(--green-ink); border-color: var(--green-line); }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #e4e8ed; }
.dot-red { background: #c0392b; } .dot-yellow { background: #d3a017; } .dot-green { background: #2e8b46; }

/* -------------------------------------------------------- панель фильтра */
.filterpanel {
  position: absolute; z-index: 40; width: 300px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.14);
  padding: 8px;
}
.filterpanel input[type=text] {
  width: 100%; font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 4px;
}
.filterlist { max-height: 260px; overflow: auto; margin: 6px 0; }
.filterlist label {
  display: block; padding: 2px 3px; font-size: 13px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; cursor: pointer;
}
.filterlist label:hover { background: #eef4fc; }
.filteractions { display: flex; gap: 6px; justify-content: flex-end; }

/* ------------------------------------------------------------ окно отчёта */
.overlay {
  position: fixed; inset: 0; background: rgba(20,26,35,.45); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow: auto;
}
.modal {
  background: var(--panel); border-radius: 8px; width: min(860px, 100%);
  box-shadow: 0 18px 48px rgba(0,0,0,.28);
}
.modal-head {
  display: flex; justify-content: space-between; gap: 16px; align-items: flex-start;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.modal-number { font-weight: 600; }
.modal-name { color: var(--muted); font-size: 13px; margin-top: 2px; }
.modal-close { border: none; background: none; font-size: 22px; line-height: 1; color: var(--muted); }

.sec { border-bottom: 1px solid var(--line); }
.sec-head {
  width: 100%; text-align: left; border: none; background: none; padding: 10px 18px;
  display: flex; align-items: center; gap: 8px; font-weight: 600;
}
.sec-head:hover { background: #f2f5f9; }
.sec-head .chev { color: var(--muted); width: 12px; }
.sec-head .badge { margin-left: auto; font-weight: 400; font-size: 12px; padding: 1px 8px; border-radius: 10px; }
.badge.grey { background: #edf0f4; color: var(--muted); }
.badge.red { background: var(--red-bg); color: var(--red-ink); }
.badge.yellow { background: var(--yellow-bg); color: var(--yellow-ink); }
.badge.green { background: var(--green-bg); color: var(--green-ink); }
.sec-body { padding: 4px 18px 16px; }

.verdict-line { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 13px; }
.legal-title { display: flex; align-items: center; gap: 10px; }
.legal-text { font-weight: 600; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 14px; }
.question { font-weight: 600; margin: 10px 0 8px; }
.decide { display: flex; gap: 10px; }
.decide .yes { border-color: var(--green-line); color: var(--green-ink); background: var(--green-bg); }
.decide .no { border-color: var(--red-line); color: var(--red-ink); background: var(--red-bg); }
.decide .armed { outline: 2px solid var(--accent); outline-offset: 1px; }
.decided { margin: 10px 0 0; font-size: 13px; }
.revoke { display: flex; gap: 8px; margin-top: 12px; }
.revoke input {
  flex: 1; font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 4px;
}
.history { margin-top: 12px; font-size: 12px; color: var(--muted); }
.history ul { margin: 6px 0 0; padding-left: 18px; }

/* ------------------------------------------------------------------ тост */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #1d2430; color: #fff; padding: 8px 16px; border-radius: 6px; z-index: 80;
}

table.audit { font-size: 13px; }
table.audit thead th { top: 52px; }
