:root {
  --paper: #f1f3ef; --surface: #ffffff; --ink: #1c2733; --muted: #5d6b79; --line: #d6dbd3; --line-strong: #b9c1b6;
  --accent: #2447d6; --accent-ink: #ffffff; --accent-soft: #e4e9fb;
  --ok: #1e7b4f; --ok-soft: #dff1e7; --warn: #9a6200; --warn-soft: #fbedcf; --bad: #b3261e; --bad-soft: #f9e0dd;
  --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", "Noto Sans Arabic", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1b2c; --surface: #15263b; --ink: #e5ebf3; --muted: #93a3b5; --line: #26384f; --line-strong: #3a4f6b;
    --accent: #7f9bff; --accent-ink: #0c1730; --accent-soft: #1b2c52;
    --ok: #5fd39a; --ok-soft: #133a2b; --warn: #f0b955; --warn-soft: #3d2f10; --bad: #ff8f86; --bad-soft: #4a1f1c;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--sans); }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: var(--mono); font-size: 0.92em; }
.muted { color: var(--muted); }
.hide { display: none !important; }

/* shell */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; padding: 22px 14px 18px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 20px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -0.01em; padding: 0 8px; }
.brand svg { flex: none; color: var(--accent); }
.brand small { font-weight: 500; color: var(--muted); font-size: 12px; }
.botstate { display: flex; align-items: center; gap: 9px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 14px; }
.botstate b { display: block; font-weight: 600; line-height: 1.2; }
.botstate span.sub { display: block; font-size: 12.5px; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.dot.warn { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .dot.warn { animation: none; } * { scroll-behavior: auto !important; } }
.rail nav { display: flex; flex-direction: column; gap: 2px; }
.rail nav a { display: block; padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--ink); font-weight: 500; }
.rail nav a:hover { background: var(--accent-soft); }
.rail nav a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
.rail .foot { margin-top: auto; }
.view { padding: 30px clamp(16px, 4vw, 44px) 80px; max-width: 980px; width: 100%; }

/* page */
.page-h { margin-bottom: 26px; }
.page-h h1 { font-size: 27px; letter-spacing: -0.015em; font-weight: 680; }
.page-h p { color: var(--muted); margin-top: 4px; max-width: 62ch; }
.sec { border-top: 1px solid var(--line-strong); padding: 22px 0 8px; margin-bottom: 18px; }
.sec > header { margin-bottom: 8px; }
.sec > header h2 { font-size: 16.5px; font-weight: 650; }
.sec > header p { color: var(--muted); font-size: 13.5px; margin-top: 2px; max-width: 70ch; }
.row { display: grid; grid-template-columns: minmax(0, 250px) minmax(0, 1fr); gap: 8px 28px; padding: 14px 0; border-bottom: 1px solid var(--line); align-items: start; }
.row:last-of-type { border-bottom: 0; }
.row-h label, .row-h .lbl { font-weight: 600; display: block; }
.hint { color: var(--muted); font-size: 13px; margin-top: 2px; }
.row-c { min-width: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sec > footer { padding: 12px 0 6px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
@media (max-width: 720px) { .row { grid-template-columns: 1fr; } }

/* controls */
.in, .sel, textarea.in { width: 100%; max-width: 420px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); }
.in.short { max-width: 130px; }
textarea.in { max-width: 100%; min-height: 150px; font-family: var(--mono); font-size: 13.5px; line-height: 1.45; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); cursor: pointer; font-weight: 600; min-height: 38px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.small { padding: 4px 10px; min-height: 30px; font-size: 13.5px; }
.btn[disabled] { opacity: 0.55; cursor: progress; }
.sw { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.sw input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.sw span { position: absolute; inset: 0; background: var(--line-strong); border-radius: 12px; transition: background 0.15s; }
.sw span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.sw input:checked + span { background: var(--accent); }
.sw input:checked + span::after { transform: translateX(18px); }
.sw input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.sw input:disabled + span { opacity: 0.5; }

/* status bits */
.chip { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--line); color: var(--ink); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); } .chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); } .chip.info { background: var(--accent-soft); color: var(--accent); }
.banner { padding: 12px 14px; border-radius: 10px; margin-bottom: 20px; border: 1px solid var(--line-strong); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.banner.warn { background: var(--warn-soft); border-color: var(--warn); } .banner.bad { background: var(--bad-soft); border-color: var(--bad); } .banner.ok { background: var(--ok-soft); border-color: var(--ok); }
.banner p { flex: 1 1 260px; }
.empty { color: var(--muted); padding: 14px 0; }

/* overview: one stacked bar tells the story of today */
.today { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.today .big { font-size: 44px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.bar { display: block; width: 100%; height: 16px; border-radius: 8px; overflow: hidden; background: var(--line); }
.bar rect.done { fill: var(--ok); } .bar rect.wait { fill: var(--accent); } .bar rect.blocked { fill: var(--warn); } .bar rect.failed { fill: var(--bad); }
.legend { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 10px; font-size: 14px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.legend i.done { background: var(--ok); } .legend i.wait { background: var(--accent); } .legend i.blocked { background: var(--warn); } .legend i.failed { background: var(--bad); }
.health { list-style: none; margin: 0; padding: 0; }
.health li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.health li:last-child { border-bottom: 0; }
.health .name { font-weight: 600; min-width: 110px; }
.health .info { flex: 1; color: var(--muted); min-width: 0; overflow-wrap: anywhere; }

/* qr */
.qr-wrap { display: flex; gap: 26px; align-items: center; flex-wrap: wrap; padding: 6px 0 14px; }
.qr-frame { width: 236px; height: 236px; border-radius: 16px; background: #fff; padding: 10px; border: 1px solid var(--line-strong); display: grid; place-items: center; }
.qr-frame img { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.steps { margin: 0; padding-left: 20px; max-width: 42ch; }
.steps li { margin-bottom: 6px; }

/* tables */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.tbl td { padding: 10px 10px 10px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: var(--accent-soft); }
.tbl td.wrap { overflow-wrap: anywhere; min-width: 160px; }
.tbl .sel { max-width: 130px; padding: 4px 8px; }
.detail { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.rule { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: start; }
.rule .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.rule .t { overflow-wrap: anywhere; } .rule .d { color: var(--muted); font-size: 13px; margin-top: 2px; }
.rule.off .t { text-decoration: line-through; color: var(--muted); }
.rule .ctl { display: flex; gap: 10px; align-items: center; }
.matrix td, .matrix th { text-align: center; } .matrix td:first-child, .matrix th:first-child { text-align: left; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 18px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.pager { display: flex; gap: 10px; align-items: center; padding-top: 12px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.filters .in { max-width: 280px; }
.result { margin-top: 10px; padding: 12px 14px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); width: 100%; }
.result ul { margin: 6px 0 0; padding-left: 20px; }

/* plugin groups, collapsible entries */
.view:focus { outline: none; }
.type-h { margin: 34px 0 6px; }
.type-h h2 { font-size: 21px; font-weight: 680; letter-spacing: -0.01em; }
.type-h p { color: var(--muted); margin-top: 2px; }
.sec > header h2 .chip { vertical-align: 2px; margin-left: 6px; }
details.rule { display: block; padding: 10px 0; }
details.rule > summary { cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
details.rule > summary::-webkit-details-marker { display: none; }
details.rule > summary::before { content: "▸"; color: var(--muted); width: 14px; }
details.rule[open] > summary::before { content: "▾"; }
details.rule[open] { padding-bottom: 14px; }
details > summary.btn { list-style: none; margin-top: 10px; }
details > summary.btn::-webkit-details-marker { display: none; }
[data-rform] { border: 1px solid var(--line); border-radius: 10px; padding: 4px 14px 8px; margin-top: 8px; background: var(--surface); }
textarea.in[dir="rtl"] { font-family: var(--sans); }
textarea.in { min-height: 0; }
.filters .btn { flex: none; }

/* toasts */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 11px 14px; border-radius: 8px; background: var(--ink); color: var(--paper); box-shadow: 0 6px 22px rgba(0, 0, 0, 0.25); font-weight: 500; }
.toast.bad { background: var(--bad); color: #fff; } .toast.ok { background: var(--ok); color: #fff; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login form { width: min(380px, 100%); }
.login h1 { font-size: 26px; letter-spacing: -0.02em; margin: 14px 0 4px; }
.login p { color: var(--muted); margin-bottom: 20px; }
.login .in { max-width: none; margin-bottom: 12px; }
.login .btn { width: 100%; justify-content: center; }
.login .err { background: var(--bad-soft); color: var(--bad); padding: 10px 12px; border-radius: 6px; margin-bottom: 12px; font-weight: 600; }

/* mobile */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 14px 12px; gap: 12px; }
  .rail nav { flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .rail nav a { white-space: nowrap; }
  .rail .foot { margin-top: 0; }
  .view { padding-top: 22px; }
  .today .big { font-size: 36px; }
}
