:root {
  --bg: #f5f6f8; --panel: #ffffff; --text: #1c2330; --muted: #6b7587; --line: #e2e6ee;
  --accent: #2459d8; --accent-text: #ffffff; --danger: #c62f3b; --ok-bg: #e5f6ea; --ok-fg: #17652f;
  --err-bg: #fdeaec; --err-fg: #9b1c28; --side: #121a2b; --side-text: #c9d3e6; --side-active: #22325a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1420; --panel: #171e2e; --text: #e6ebf5; --muted: #8e9ab0; --line: #283148;
    --accent: #5b8cff; --accent-text: #0b1020; --danger: #ff6b76; --ok-bg: #12301d; --ok-fg: #7ee09b;
    --err-bg: #381820; --err-fg: #ff9aa3; --side: #0a0f1a; --side-text: #aab6cf; --side-active: #1b2a4d;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font: 13px ui-monospace, SFMono-Regular, Consolas, monospace; background: color-mix(in srgb, var(--line) 55%, transparent); padding: 1px 5px; border-radius: 4px; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 17px; margin: 28px 0 10px; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 15px; margin: 22px 0 8px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); padding: 18px 12px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 18px; color: #fff; padding: 0 8px; }
.brand span { font-weight: 400; color: var(--side-text); font-size: 13px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { color: var(--side-text); padding: 8px 10px; border-radius: 8px; }
.side nav a:hover { background: color-mix(in srgb, var(--side-active) 60%, transparent); text-decoration: none; }
.side nav a.active { background: var(--side-active); color: #fff; }
.who { margin-top: auto; display: flex; justify-content: space-between; align-items: center; padding: 8px; font-size: 13px; }
main { padding: 24px 32px 60px; max-width: 1200px; width: 100%; }
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }

.help-btn { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 12px; font-weight: 600; text-decoration: none !important; flex: none; }
.help-btn:hover { color: var(--accent); border-color: var(--accent); }

table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: color-mix(in srgb, var(--line) 35%, transparent); }
tr:last-child td { border-bottom: 0; }
.details { max-width: 420px; display: inline-block; overflow-wrap: anywhere; white-space: normal; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--line); color: var(--text); }
a.chip { text-decoration: none; }
.st-draft { background: #e9ecf3; color: #43506a; } .st-certified { background: #e0ecff; color: #1a46a8; }
.st-active { background: var(--ok-bg); color: var(--ok-fg); } .st-degraded { background: #fff1d6; color: #8a5a00; }
.st-disabled, .st-blocked, .st-revoked { background: var(--err-bg); color: var(--err-fg); }
.env-prod { background: #fff1d6; color: #8a5a00; } .env-test { background: #e0ecff; color: #1a46a8; }
.cap { font-weight: 500; background: color-mix(in srgb, var(--accent) 12%, var(--panel)); color: var(--accent); }
@media (prefers-color-scheme: dark) {
  .st-draft { background: #252c3d; color: #b6c1d8; } .st-certified { background: #1c2b52; color: #9db9ff; }
  .st-degraded, .env-prod { background: #3a2c0c; color: #ffd37a; } .env-test { background: #1c2b52; color: #9db9ff; }
}

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.card, .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
.num { font-size: 30px; font-weight: 700; }
.props { display: grid; grid-template-columns: 170px 1fr; gap: 8px 16px; margin: 0 0 14px; }
.props dt { color: var(--muted); } .props dd { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
form.inline { display: inline; margin: 0; }

.btn { font: inherit; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.btn.small { padding: 3px 10px; font-size: 13px; }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }

input, select { font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); width: 100%; }
input[type=checkbox] { width: auto; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-size: 14px; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 16px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 16px; align-items: end; margin-top: 8px; }
.form-actions { display: flex; align-items: end; }
fieldset.caps { grid-column: 1 / -1; border: 1px solid var(--line); border-radius: 8px; display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 8px 12px; margin: 0; }
fieldset.caps legend { color: var(--muted); font-size: 13px; padding: 0 6px; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 14px; }
.filters label { min-width: 200px; }

.rowcard { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; }
.rowcard-title { margin-bottom: 10px; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.rowcard-body { display: grid; grid-template-columns: 150px 150px auto 1fr auto; gap: 12px 16px; align-items: end; }
@media (max-width: 1000px) { .rowcard-body { grid-template-columns: 1fr 1fr; } }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.flash.ok { background: var(--ok-bg); color: var(--ok-fg); } .flash.err { background: var(--err-bg); color: var(--err-fg); }
.newkey { background: var(--ok-bg); color: var(--ok-fg); border: 1px dashed var(--ok-fg); border-radius: 10px; padding: 14px 16px; margin: 16px 0;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.newkey code { font-size: 14px; word-break: break-all; background: transparent; }

.help-layout { display: grid; grid-template-columns: 240px 1fr; gap: 24px; }
.help-toc { display: flex; flex-direction: column; gap: 2px; }
.help-toc a { padding: 6px 10px; border-radius: 8px; color: var(--text); }
.help-toc a.active, .help-toc a:hover { background: color-mix(in srgb, var(--accent) 12%, var(--panel)); text-decoration: none; }
.prose { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 22px 18px; }
.prose h1 { font-size: 20px; margin: 16px 0 8px; } .prose h2 { font-size: 15px; margin: 18px 0 6px; display: block; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.prose p, .prose li { max-width: 70ch; }
.help-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100vw); background: var(--panel); border-left: 1px solid var(--line);
  box-shadow: -8px 0 24px rgba(0,0,0,.18); display: flex; flex-direction: column; z-index: 10; }
.help-panel[hidden] { display: none; }
.help-head { display: flex; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.help-body { overflow: auto; flex: 1; border: 0; border-radius: 0; }
.help-more { padding: 12px 18px; border-top: 1px solid var(--line); }

body.plain { display: grid; place-items: center; min-height: 100vh; }
.login { width: min(380px, 92vw); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; }
.login h1 span { font-weight: 400; color: var(--muted); font-size: 15px; }
.login form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }

@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; } .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side nav { flex-direction: row; flex-wrap: wrap; } main { padding: 16px; } .help-layout { grid-template-columns: 1fr; }
  .props { grid-template-columns: 1fr; } table { display: block; overflow-x: auto; }
}

.ver { font-size: 11px; color: var(--side-text); opacity: .7; padding: 0 8px; word-break: break-all; }
