:root {
  --ink: #15213f; --muted: #5d6782; --line: #e3e8f2; --bg: #f3f5fa; --card: #fff;
  --brand: #16244f; --brand2: #2b45a8; --accent: #3b5bdb;
  --green: #0f8a5f; --green-bg: #e3f5ec; --yellow: #a86b00; --yellow-bg: #fff4d6; --red: #c2331f; --red-bg: #fde7e4;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.boot { padding: 60px; text-align: center; color: var(--muted); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt { margin-top: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* -------- кнопки и поля */
.btn { border: 1px solid #cfd6e6; background: #fff; border-radius: 10px; padding: 9px 14px; font-weight: 600;
  cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f0f3fa; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #3150c4; }
.btn.danger { color: var(--red); }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 4px 0; }
.btn:disabled { opacity: .55; cursor: default; }
input[type=text], input[type=password], input[type=email], input[type=date], input[type=number], select, textarea {
  width: 100%; border: 1px solid #cfd6e6; border-radius: 10px; padding: 9px 11px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #3b5bdb22; }
label.f { display: block; margin-bottom: 10px; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.check { display: flex; gap: 8px; align-items: center; }

/* -------- вход */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(135deg, #16244f, #2b45a8); }
.login { width: 100%; max-width: 400px; background: #fff; border-radius: 18px; padding: 28px 24px;
  box-shadow: 0 20px 60px #0004; }
.login h1 { margin: 0 0 4px; font-size: 21px; }
.login .sub { color: var(--muted); margin-bottom: 18px; }
.login .btn.primary { width: 100%; padding: 11px; margin-top: 6px; }
.err { color: var(--red); background: var(--red-bg); border-radius: 10px; padding: 9px 12px; margin: 10px 0; }
.ok { color: var(--green); background: var(--green-bg); border-radius: 10px; padding: 9px 12px; margin: 10px 0; }
.foot { color: #ffffffb3; text-align: center; margin-top: 14px; font-size: 12px; }
.sig { color: #ffffffa6; text-align: center; margin-top: 26px; font-size: 12.5px; line-height: 1.6; min-height: 40px; }
.sig b { color: #ffffffe6; font-weight: 600; }

/* -------- шапка */
header.top { background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 20; }
.top-in { max-width: 1200px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 14px; }
.logo { font-weight: 800; font-size: 16px; letter-spacing: .2px; }
.logo small { display: block; font-weight: 500; font-size: 11.5px; color: #c9d2f2; }
nav.menu { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; min-width: 0; }
nav.menu::-webkit-scrollbar { display: none; }
nav.menu a { color: #dbe2fb; text-decoration: none; padding: 7px 11px; border-radius: 9px; white-space: nowrap; font-size: 14px; }
nav.menu a.on, nav.menu a:hover { background: #ffffff1f; color: #fff; }
.user { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #dbe2fb; flex-shrink: 0; }
.user .who { color: #dbe2fb; text-decoration: none; padding: 7px 10px; border-radius: 9px; white-space: nowrap; font-size: 14px; }
.user .who:hover, .user .who.on { background: #ffffff1f; color: #fff; }
.user .btn { background: transparent; color: #fff; border-color: #ffffff40; }

/* -------- строка состояния */
.status { border-bottom: 1px solid var(--line); background: #fff; cursor: pointer; }
.status-in { max-width: 1200px; margin: 0 auto; padding: 7px 16px; display: flex; gap: 10px; align-items: center;
  font-size: 13px; flex-wrap: wrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.dot.green { background: var(--green); } .dot.yellow { background: #e0a100; } .dot.red { background: var(--red); }
.status .s-long { color: var(--muted); }
.status.yellow { background: var(--yellow-bg); } .status.red { background: var(--red-bg); }

main { max-width: 1200px; margin: 0 auto; padding: 18px 16px 60px; }
h2.page { font-size: 21px; margin: 4px 0 14px; }
h3 { font-size: 15px; margin: 0 0 10px; }

/* -------- карточки */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.wide { grid-column: 1 / -1; }
.kpi-label { color: var(--muted); font-size: 13px; }
.kpi { font-size: 27px; font-weight: 800; letter-spacing: -.3px; margin: 2px 0; }
.kpi .unit { font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 4px; }
.delta { font-size: 12.5px; font-weight: 600; }
.delta.up { color: var(--green); } .delta.down { color: var(--red); }
.lines { margin-top: 10px; }
.line { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px dashed var(--line); font-size: 14px; }
.line:first-child { border-top: 0; }
.line .v { font-weight: 700; white-space: nowrap; }
.bar { height: 10px; border-radius: 6px; overflow: hidden; display: flex; background: #eef1f8; margin: 10px 0 6px; }
.bar i { display: block; height: 100%; }
.c-green { background: #2fb37d; } .c-orange { background: #f08a2c; } .c-dark { background: #9b1c1c; } .c-grey { background: #a9b0c0; } .c-yellow { background: #f2b52d; } .c-red { background: #e2553f; } .c-violet { background: #7a5af5; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; }
.tabs { display: inline-flex; background: #e9edf6; padding: 3px; border-radius: 10px; gap: 2px; margin-bottom: 14px; }
.tabs button { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; font-weight: 600; cursor: pointer; color: var(--muted); }
.tabs button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px #0001; }
.note { font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.warnbox { background: var(--yellow-bg); color: #6b4800; border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

/* -------- таблицы */
.tbl-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); background: #f7f9fd; padding: 9px 10px;
  border-bottom: 1px solid var(--line); white-space: nowrap; cursor: default; user-select: none; }
.tbl th.sort { cursor: pointer; } .tbl th.sort:hover { color: var(--ink); }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.wrap { min-width: 200px; max-width: 420px; white-space: pre-wrap; word-break: break-word; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 600; background: #eef1f8; }
.pill.ok { background: var(--green-bg); color: var(--green); } .pill.error { background: var(--red-bg); color: var(--red); }
.pill.warn { background: var(--yellow-bg); color: var(--yellow); }

/* -------- фильтры журналов */
.filters { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.fgrid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.fgrid label span { font-size: 12px; color: var(--muted); display: block; margin-bottom: 3px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { border: 1px solid #cfd6e6; background: #fff; border-radius: 20px; padding: 5px 11px; font-size: 13px; cursor: pointer; }
.chip:hover { background: #f0f3fa; }
.chip.saved { border-color: #b9c6f3; background: #f2f5ff; }
.chip .x { margin-left: 6px; color: var(--muted); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; font-size: 13px; }

/* -------- окно */
.modal-bg { position: fixed; inset: 0; background: #0f1a3a80; display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 480px; max-height: 92vh; overflow: auto; padding: 20px; }
.modal h3 { font-size: 17px; margin-bottom: 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--brand); color: #fff;
  padding: 10px 16px; border-radius: 10px; z-index: 60; box-shadow: 0 8px 30px #0003; max-width: 92vw; }
.toast.bad { background: var(--red); }

footer.ver { text-align: center; color: var(--muted); font-size: 12.5px; padding: 12px 0 30px; }
footer.ver b { color: var(--ink); font-weight: 600; }

@media (max-width: 720px) {
  .top-in { flex-wrap: wrap; gap: 8px; }
  nav.menu { order: 3; flex-basis: 100%; }
  .user .who { font-size: 13px; padding: 6px 8px; }
  .s-long { display: none; }
  .kpi { font-size: 24px; }
  main { padding: 14px 12px 50px; }
  .grid { grid-template-columns: 1fr; }
}

.modebar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.errbox { background: var(--red-bg); color: var(--red); border-radius: 10px; padding: 10px 14px; margin-top: 10px; font-size: 14px; }
tr.warnrow td { background: var(--yellow-bg); }
tr.errrow td { background: var(--red-bg); }
tr.strong td { font-weight: 700; }
label.f.inline { display: flex; align-items: center; gap: 8px; margin: 0; }

.bar.tall { height: 16px; }
.tabs.small { margin-bottom: 0; } .tabs.small button { padding: 5px 10px; font-size: 12.5px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 7px; vertical-align: middle; }
.tbl th.right { text-align: right; }
.tbl.aging td, .tbl.aging th { white-space: nowrap; }
.show-sm { display: none; }
@media (max-width: 560px) { .tbl.aging td, .tbl.aging th { padding: 8px 5px; font-size: 12.5px; }
  .hide-sm { display: none; } .show-sm { display: inline; } }
