/* ABMK Финансы (EN3): светлая и тёмная тема по системе, без внешних шрифтов и ресурсов (CSP: только свои файлы) */
:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #5d6b78;
  --line: #dde3e8;
  --accent: #1f5f8b;
  --accent-text: #ffffff;
  --accent-soft: #e5f0f8;
  --ok: #1e7b4f;
  --warn: #9a6200;
  --bad: #b3261e;
  --bad-soft: #fbe9e7;
  --warn-soft: #fff4dc;
  --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12171c;
    --panel: #1b2229;
    --text: #e6ebef;
    --muted: #9aa8b4;
    --line: #2d3741;
    --accent: #5aa7dc;
    --accent-text: #0d1a24;
    --accent-soft: #1d3446;
    --ok: #4cc38a;
    --warn: #e0a84a;
    --bad: #f2867c;
    --bad-soft: #3a1f1d;
    --warn-soft: #3a2f17;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.boot, .noscript { padding: 40px 16px; text-align: center; color: var(--muted); }

/* ---------- кнопки и поля ---------- */
button {
  border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 7px 14px; cursor: pointer;
}
button:hover { border-color: var(--accent); }
button:disabled { opacity: .55; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger { color: var(--bad); }
button.danger.armed { background: var(--bad); border-color: var(--bad); color: #fff; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; }
input[type=text], input[type=email], select, textarea {
  border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 7px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 15px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.msg { margin-top: 12px; padding: 9px 12px; border-radius: 6px; font-size: 14px; }
.msg.err { background: var(--bad-soft); color: var(--bad); }
.msg.warn { background: var(--warn-soft); color: var(--warn); }
.msg.ok { background: var(--accent-soft); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }

/* ---------- вход ---------- */
.login { max-width: 380px; margin: 9vh auto 40px; padding: 0 16px; }
.login .card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.login h1 { font-size: 21px; margin: 0 0 4px; }
.login .code { letter-spacing: .3em; font-size: 22px; text-align: center; font-variant-numeric: tabular-nums; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.brand img { width: 26px; height: 26px; }

/* ---------- каркас ---------- */
.top {
  display: flex; align-items: center; gap: 14px; padding: 10px 16px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.grow { flex: 1; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.live::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.live.on::before { background: var(--ok); }
.live.db::before { background: var(--warn); }
.who { font-size: 13px; text-align: right; line-height: 1.25; }
.who b { font-size: 14px; }
.layout { display: grid; grid-template-columns: 210px 1fr; min-height: calc(100vh - 53px); }
nav.side { border-right: 1px solid var(--line); padding: 12px 8px; background: var(--panel); }
nav.side a {
  display: block; padding: 8px 12px; border-radius: 6px; color: var(--text); text-decoration: none; margin-bottom: 2px;
}
nav.side a:hover { background: var(--bg); }
nav.side a.cur { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
nav.side a .lvl { float: right; font-size: 11px; color: var(--muted); margin-top: 3px; }
main { padding: 20px 24px 60px; max-width: 1180px; width: 100%; min-width: 0; }
main h2 { font-size: 20px; margin: 0 0 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
main h3 { font-size: 16px; margin: 28px 0 10px; }
main h2 button { font-size: 14px; font-weight: 500; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel + .panel { margin-top: 14px; }
.panel > :first-child { margin-top: 0; }
.panel > :last-child { margin-bottom: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 14px; }

/* ---------- таблицы ---------- */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.off td { color: var(--muted); }
tr.flash td { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }
td.nowrap, th.nowrap { white-space: nowrap; }
.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }
.badge.ok { color: var(--ok); }
.badge.off { color: var(--muted); }
.diff { font-size: 13px; }
.diff div { margin: 1px 0; }
.diff .was { text-decoration: line-through; color: var(--muted); }
.perm-w { color: var(--ok); font-weight: 600; }
.perm-r { color: var(--accent); }
.perm-n { color: var(--muted); }
details summary { cursor: pointer; color: var(--accent); margin: 24px 0 10px; }
.empty { padding: 18px; color: var(--muted); text-align: center; }
.edit { background: var(--bg); }
.edit td { padding: 14px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar select { width: auto; }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  nav.side { border-right: 0; border-bottom: 1px solid var(--line); display: flex; overflow-x: auto; gap: 4px; padding: 8px; }
  nav.side a { white-space: nowrap; margin: 0; }
  nav.side a .lvl { display: none; }
  main { padding: 16px 16px 50px; }
  .top { flex-wrap: wrap; gap: 8px 12px; }
  .who { text-align: left; }
}
