:root {
    --bg: #f3f5f8;
    --card: #ffffff;
    --line: #dde2e8;
    --line2: #eef1f4;
    --text: #1d2733;
    --muted: #6b7684;
    --primary: #1f6fb2;
    --primary-d: #185a91;
    --ok: #2e7d32;
    --ok-bg: #e7f4e8;
    --err: #c62828;
    --err-bg: #fdecec;
    --warn: #a35d00;
    --warn-bg: #fff4e0;
    --prod: #b3261e;
    --radius: 8px;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    background: var(--bg); color: var(--text);
    font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--primary); }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
[hidden] { display: none !important; }

/* ── шапка ───────────────────────────────────────────────── */
.lk-top { background: #16324f; color: #fff; }
.lk-top-in { max-width: 1320px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.lk-brand { display: flex; align-items: center; gap: 10px; }
.lk-brand b { display: block; font-size: 16px; letter-spacing: .3px; }
.lk-brand small { display: block; opacity: .75; font-size: 12px; }
.lk-logo { width: 34px; height: 34px; border-radius: 8px; background: #2f8ad8; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex: 0 0 34px; }
.lk-top-right { display: flex; align-items: center; gap: 14px; }
.lk-top-link { color: #cfe3f7; text-decoration: none; }
.lk-top-link:hover { color: #fff; }
.lk-svc { padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.lk-svc-test { background: rgba(255,255,255,.14); color: #e6f0fa; }
.lk-svc-prod { background: var(--prod); color: #fff; }

.lk-wrap { max-width: 1320px; margin: 0 auto; padding: 16px; }
.lk-foot { color: var(--muted); font-size: 12px; text-align: center; padding: 18px 0 8px; }
.lk-foot code { font-size: 11px; }

/* ── карточки ────────────────────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; margin: 0 0 14px; }
.card h3 { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.card-h h3 { margin: 0; }
.step .num { display: inline-flex; width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff; align-items: center; justify-content: center; font-size: 13px; flex: 0 0 26px; }
.step.done .num { background: var(--ok); }
.step.disabled { opacity: .5; pointer-events: none; }

.lk-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.lk-grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 16px; }
@media (max-width: 900px) { .lk-grid4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .lk-grid2, .lk-grid4 { grid-template-columns: 1fr; } }

.lbl { display: block; font-weight: 600; margin-bottom: 4px; font-size: 13px; }
.hint { color: var(--muted); font-size: 12px; font-weight: normal; }
.muted { color: var(--muted); font-size: 12px; }
.opt { display: block; padding: 3px 0; cursor: pointer; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nowrap { white-space: nowrap; }

input[type=text], input[type=password], input[type=number], input[type=date], input[type=search] {
    width: 100%; padding: 7px 10px; border: 1px solid #c9d1da; border-radius: 6px; font: inherit; background: #fff; color: var(--text);
}
.inline input[type=text], .inline input[type=password] { flex: 1 1 260px; width: auto; }
input:focus { outline: 2px solid rgba(31,111,178,.25); border-color: var(--primary); }
input.mono { font-family: var(--mono); font-size: 13px; }

/* ── кнопки ──────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 7px 14px; border-radius: 6px; border: 1px solid #c9d1da; background: #fff; color: var(--text);
    font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: #f4f6f9; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-success:hover { background: #256a29; }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn-danger:hover { background: #a82020; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--primary); }
.btn-ghost:hover { background: #eef4fa; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
a.danger { color: var(--err); }

/* ── статусы, бейджи ─────────────────────────────────────── */
.status { margin-top: 10px; font-size: 13.5px; min-height: 18px; }
.status:empty { display: none; }
.st-ok { color: var(--ok); } .st-err { color: var(--err); } .st-warn { color: var(--warn); } .st-info { color: var(--muted); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11.5px; background: #eceff3; color: #44505e; white-space: nowrap; }
.b-ok { background: var(--ok-bg); color: var(--ok); }
.b-err { background: var(--err-bg); color: var(--err); }
.b-warn { background: var(--warn-bg); color: var(--warn); }
.b-prod { background: var(--prod); color: #fff; }
.lk-note { padding: 9px 12px; border-radius: 6px; margin: 0 0 14px; font-size: 13px; }
.lk-note-warn { background: var(--warn-bg); color: #6b3d00; border: 1px solid #f3d9a8; }

/* ── вкладки ─────────────────────────────────────────────── */
.lk-tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin: 20px 0 14px; overflow-x: auto; }
.lk-tab {
    background: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -2px; padding: 10px 16px;
    font: inherit; font-size: 15px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.lk-tab .hint { font-weight: normal; margin-left: 4px; }
.lk-tab:hover { color: var(--text); }
.lk-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── диагностика ─────────────────────────────────────────── */
.diag { margin-top: 12px; }
.diag:empty { display: none; }
.art { border: 1px solid #e2e6eb; border-radius: 6px; margin: 6px 0; overflow: hidden; }
.art-h { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: #f6f7f9; cursor: pointer; user-select: none; flex-wrap: wrap; }
.art-h b { font-size: 13px; font-weight: 600; }
.art-h .caret { color: var(--muted); transition: transform .15s; display: inline-block; }
.art.open .caret { transform: rotate(90deg); }
.art-links { margin-left: auto; display: flex; gap: 12px; }
.art-links .dl { font-size: 12px; }
.art-b { display: none; }
.art.open .art-b { display: block; }
.art pre { margin: 0; padding: 10px 12px; max-height: 360px; overflow: auto; font: 11.5px/1.5 var(--mono); background: #1e2329; color: #e3e6ea; white-space: pre-wrap; word-break: break-word; }

/* ── таблицы ─────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th { text-align: left; background: #f3f5f8; color: #4a5562; font-weight: 600; padding: 7px 8px; border-bottom: 1px solid var(--line); position: sticky; top: 0; white-space: nowrap; }
.tbl td { padding: 6px 8px; border-bottom: 1px solid var(--line2); vertical-align: top; }
.tbl tbody tr:hover td { background: #f8fafc; }
.tbl tr.cur td { background: #eef5fc; }
.tbl td.clip { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl-scroll { max-height: 72vh; overflow: auto; border: 1px solid var(--line2); border-radius: 6px; }
.tbl-scroll .tbl th { z-index: 1; }
#rg_table td.clip { max-width: 240px; }
.tbl .muted { font-size: 11.5px; }
.lk-pager { display: flex; align-items: center; justify-content: center; gap: 12px; padding-top: 12px; color: var(--muted); font-size: 13px; }
.lk-pager:empty { display: none; }

/* ── реестр ──────────────────────────────────────────────── */
.lk-filters { margin: 14px 0 4px; border: 1px solid var(--line2); border-radius: 6px; padding: 0 12px; background: #fafbfc; }
.lk-filters summary { cursor: pointer; padding: 9px 0; font-weight: 600; }
.lk-filters[open] { padding-bottom: 12px; }
.lk-actions { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line2); }
.lk-progress { margin-top: 12px; }
.lk-progress .bar { height: 6px; background: #e6eaef; border-radius: 3px; overflow: hidden; }
.lk-progress .bar i { display: block; height: 100%; width: 0; background: var(--primary); transition: width .3s; }
.lk-progress .bar.indet i { width: 35% !important; animation: lk-indet 1.2s infinite ease-in-out; }
@keyframes lk-indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(290%); } }

/* ── модалки ─────────────────────────────────────────────── */
.modal-bg { position: fixed; inset: 0; z-index: 1000; background: rgba(15, 25, 35, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: #fff; border-radius: 10px; width: 760px; max-width: 100%; max-height: 92vh; overflow: auto; padding: 18px 20px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal-wide { width: 1200px; }
.modal h3 { margin: 0 0 12px; font-size: 16px; }
.modal-foot { text-align: right; margin-top: 14px; display: flex; gap: 8px; justify-content: flex-end; }
.cert-list { max-height: 60vh; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.cert { display: flex; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line2); cursor: pointer; }
.cert:last-child { border-bottom: 0; }
.cert.off { opacity: .5; cursor: default; }
.cert small { color: var(--muted); }

/* ── вход ────────────────────────────────────────────────── */
.lk-login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #16324f; padding: 16px; }
.lk-login { background: #fff; border-radius: 12px; padding: 26px 28px; width: 360px; max-width: 100%; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.3); }
.lk-login .lk-brand { margin-bottom: 8px; color: var(--text); }
.lk-login .lk-brand small { color: var(--muted); opacity: 1; }
.lk-login label { font-weight: 600; font-size: 13px; }
.lk-login-err { color: var(--err); font-size: 13px; }
.lk-login .btn { margin-top: 6px; padding: 9px; }

#rg_history.busy a[data-open], #rg_history.busy a[data-del] { pointer-events: none; opacity: .4; }
