:root {
  --bg: #f1f5f9;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #0f766e;
  --accent-2: #14b8a6;
  --accent-soft: #ccfbf1;
  --nav: #0b1220;
  --nav-ink: #cbd5e1;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --err: #b91c1c;
  --err-soft: #fee2e2;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --code: #0b1220;
  --code-ink: #e2e8f0;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220; --panel: #111a2e; --ink: #e2e8f0; --muted: #94a3b8; --line: #23314f;
    --accent: #2dd4bf; --accent-2: #14b8a6; --accent-soft: #123a3a; --nav: #070d18; --nav-ink: #cbd5e1;
    --warn: #fbbf24; --warn-soft: #3a2c0b; --err: #f87171; --err-soft: #3b1414; --ok: #4ade80; --ok-soft: #0f2e1b;
    --code: #050a14;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font-family: "Segoe UI", "Rubik", Arial, sans-serif; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.ltr { direction: ltr; unicode-bidi: plaintext; text-align: left; }
code, .mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; }

/* top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 30px; }
.title { font-weight: 700; font-size: 18px; }
.subtitle { color: var(--muted); font-size: 12px; direction: ltr; text-align: right; }
.profile { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.profile select { min-width: 160px; width: auto; }
.save-state { font-size: 12px; color: var(--muted); min-width: 90px; }

/* layout */
.layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: calc(100vh - 62px); }
.steps { background: var(--nav); color: var(--nav-ink); padding: 16px 10px; position: sticky; top: 62px; height: calc(100vh - 62px); overflow: auto; }
.step-link { display: flex; gap: 10px; align-items: center; width: 100%; text-align: right; background: none; border: 0; color: inherit;
  padding: 10px 12px; border-radius: 10px; cursor: pointer; font: inherit; margin-bottom: 4px; }
.step-link:hover { background: rgba(255,255,255,.06); }
.step-link.active { background: rgba(45,212,191,.16); color: #fff; }
.step-num { flex: 0 0 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.08); font-size: 13px; font-weight: 700; }
.step-link.active .step-num { background: var(--accent-2); color: #042f2e; }
.step-text small { display: block; color: #7c8aa5; font-size: 11.5px; }
.step-badge { margin-inline-start: auto; font-size: 11px; padding: 1px 7px; border-radius: 99px; background: rgba(255,255,255,.1); }
.step-badge.err { background: #7f1d1d; color: #fecaca; }
.steps .nav-foot { margin-top: 18px; padding: 10px 12px; font-size: 12px; color: #7c8aa5; border-top: 1px solid rgba(255,255,255,.08); }

main { padding: 24px 28px 80px; max-width: 1200px; width: 100%; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 24px; }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 760px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card h2 { margin: 0 0 12px; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.card h3 { margin: 14px 0 8px; font-size: 15px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px 16px; }
.grid.two { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 13px; font-weight: 600; }
.field small { color: var(--muted); font-size: 12px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-2); outline-offset: 0; border-color: transparent; }
input.ltr, textarea.ltr { direction: ltr; text-align: left; }
textarea { min-height: 90px; resize: vertical; }
textarea.code { font-family: Consolas, monospace; font-size: 13px; min-height: 260px; direction: ltr; text-align: left; white-space: pre; }
.pw { position: relative; }
.pw button { position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; cursor: pointer; font-size: 15px; }

.check { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: var(--bg); }
.check input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--accent); flex: 0 0 auto; }
.check b { display: block; font-weight: 600; }
.check small { color: var(--muted); }
.check.on { border-color: var(--accent-2); background: var(--accent-soft); }
.checks { display: grid; gap: 8px; }

.btn { font: inherit; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: var(--accent-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.big { padding: 12px 20px; font-size: 16px; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.danger { color: var(--err); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

.callout { border-radius: 10px; padding: 12px 14px; margin: 10px 0; border: 1px solid var(--line); background: var(--bg); }
.callout.info { border-color: #99f6e4; background: var(--accent-soft); }
.callout.warn { border-color: #fcd34d; background: var(--warn-soft); }
.callout.err { border-color: #fca5a5; background: var(--err-soft); }
.callout.ok { border-color: #86efac; background: var(--ok-soft); }
.callout p { margin: 4px 0; }
.callout ul { margin: 4px 0; padding-inline-start: 20px; }

/* apps */
.cat-title { display: flex; align-items: center; gap: 10px; margin: 18px 0 8px; }
.cat-title h3 { margin: 0; font-size: 15px; }
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.app { display: flex; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); cursor: pointer; position: relative; transition: border-color .15s, background .15s; }
.app:hover { border-color: var(--accent-2); }
.app.on { border-color: var(--accent); background: var(--accent-soft); }
.app .ic { font-size: 26px; line-height: 1; }
.app b { display: block; }
.app small { color: var(--muted); display: block; font-size: 12.5px; }
.app .ports { font-size: 11.5px; color: var(--muted); direction: ltr; text-align: right; margin-top: 4px; }
.app .tick { position: absolute; top: 8px; inset-inline-end: 10px; width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--line); display: grid; place-items: center; font-size: 13px; color: #fff; }
.app.on .tick { background: var(--accent); border-color: var(--accent); }
.app .badge { font-size: 10.5px; padding: 0 6px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); margin-inline-start: 4px; font-weight: normal; }
.app .actions { display: flex; gap: 4px; margin-top: 6px; }

/* settings accordion */
details.acc { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); margin-bottom: 8px; }
details.acc > summary { list-style: none; cursor: pointer; padding: 12px 16px; display: flex; gap: 10px; align-items: center; }
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary::after { content: "▾"; margin-inline-start: auto; color: var(--muted); }
details.acc[open] > summary::after { content: "▴"; }
details.acc .acc-body { padding: 4px 16px 16px; border-top: 1px solid var(--line); }
.chip { font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); direction: ltr; }

/* table */
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th, table.t td { border-bottom: 1px solid var(--line); padding: 8px; text-align: right; vertical-align: top; }
table.t th { color: var(--muted); font-weight: 600; font-size: 13px; }
.yes { color: var(--ok); font-weight: 600; }
.no { color: var(--muted); }
.part { color: var(--warn); font-weight: 600; }

/* finish */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.stat { padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); }
.stat b { font-size: 24px; display: block; }
.issues li { margin: 4px 0; }
.issues .err { color: var(--err); }
.issues .warn { color: var(--warn); }
pre.code { background: var(--code); color: var(--code-ink); padding: 14px; border-radius: 10px; overflow: auto; max-height: 520px; direction: ltr; text-align: left; font-size: 12.5px; line-height: 1.45; margin: 0; }
.cmd { display: flex; gap: 8px; align-items: stretch; margin: 6px 0 12px; }
.cmd pre { flex: 1; margin: 0; background: var(--code); color: var(--code-ink); padding: 10px 12px; border-radius: 8px; direction: ltr; text-align: left; white-space: pre-wrap; word-break: break-all; font-size: 13px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.tabs .btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.nav-buttons { display: flex; justify-content: space-between; margin-top: 20px; }

/* modal + toast */
.modal { position: fixed; inset: 0; background: rgba(2,6,23,.55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-box { background: var(--panel); border-radius: 14px; width: min(860px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 18px 20px; border: 1px solid var(--line); }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 10px; z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,.25); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .steps { position: static; height: auto; display: flex; overflow-x: auto; gap: 4px; padding: 8px; }
  .step-link { flex: 0 0 auto; width: auto; margin: 0; }
  .step-text small, .steps .nav-foot { display: none; }
  main { padding: 16px; }
}
