/* SecureNet VLAN Lab */
:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --border: #dde2ea;
  --border-strong: #c5ccd8;
  --text: #172033;
  --muted: #5b6577;
  --faint: #8a93a3;
  --accent: #1f5eff;
  --accent-soft: #e6edff;
  --ok: #138a4b;
  --ok-soft: #e3f5ea;
  --bad: #c62839;
  --bad-soft: #fde8ea;
  --warn: #b26a00;
  --warn-soft: #fff1d9;
  --link: #8b97a8;
  --term-bg: #0f1420;
  --term-text: #d8e1ee;
  --term-dim: #7f8ba0;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .05);
  --radius: 12px;

  --v1: #4f46e5;
  --v2: #0d9488;
  --v3: #c27803;
  --v4: #db2759;
  --v5: #15803d;
  --dmz: #ea580c;
  --inet: #64748b;
  --zone-alpha: .07;

  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "DejaVu Sans Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --surface: #151b24; --surface-2: #1b2230; --border: #2a3342; --border-strong: #3a4558;
    --text: #e6ebf2; --muted: #a3adbd; --faint: #758096; --accent: #6b9bff; --accent-soft: #1b2a4a;
    --ok: #3ccf7f; --ok-soft: #12301f; --bad: #ff6b7a; --bad-soft: #3a161c; --warn: #f2b14c; --warn-soft: #3a2a10;
    --link: #5d6a7e; --term-bg: #0a0e15; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.25);
    --v1: #8b84ff; --v2: #2dd4bf; --v3: #f5b942; --v4: #ff6b93; --v5: #4ade80; --dmz: #fb923c; --inet: #94a3b8; --zone-alpha: .12;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117; --surface: #151b24; --surface-2: #1b2230; --border: #2a3342; --border-strong: #3a4558;
  --text: #e6ebf2; --muted: #a3adbd; --faint: #758096; --accent: #6b9bff; --accent-soft: #1b2a4a;
  --ok: #3ccf7f; --ok-soft: #12301f; --bad: #ff6b7a; --bad-soft: #3a161c; --warn: #f2b14c; --warn-soft: #3a2a10;
  --link: #5d6a7e; --term-bg: #0a0e15; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.25);
  --v1: #8b84ff; --v2: #2dd4bf; --v3: #f5b942; --v4: #ff6b93; --v5: #4ade80; --dmz: #fb923c; --inet: #94a3b8; --zone-alpha: .12;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
code, pre, kbd { font-family: var(--mono); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; min-width: 0; }
.brand svg { width: 34px; height: 34px; flex: none; color: var(--accent); }
.brand h1 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.brand p { margin: 0; font-size: 12.5px; color: var(--muted); }
.tabs { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: transparent; padding: 7px 14px; border-radius: 7px; font-weight: 600; font-size: 13px; color: var(--muted); white-space: nowrap; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.icon-btn { border: 1px solid var(--border); background: var(--surface); width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; }
.icon-btn svg { width: 18px; height: 18px; }

main { padding: 20px 24px 40px; max-width: 1680px; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 16px 10px; }
.card-head h2 { font-size: 15px; font-weight: 700; }
.card-head .hint { color: var(--muted); font-size: 12.5px; }
.spacer { flex: 1; }
.btn { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 8px; padding: 6px 12px; font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
.btn.small { padding: 3px 9px; font-size: 12px; }

/* ---------- simulator layout ---------- */
.sim-grid {
  display: grid; gap: 16px;
  grid-template-columns: minmax(0, 1.7fr) minmax(360px, 1fr);
  grid-template-areas: "topo console" "topo events";
  grid-template-rows: auto 1fr;
}
.topo-card { grid-area: topo; display: flex; flex-direction: column; align-self: start; }
.console-card { grid-area: console; display: flex; flex-direction: column; min-height: 440px; }
.events-card { grid-area: events; display: flex; flex-direction: column; min-height: 260px; }
@media (max-width: 1100px) {
  .sim-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "topo" "console" "events"; }
}

.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 18px; height: 0; border-top: 2px solid var(--link); display: inline-block; }
.legend i.cross { border-top-style: dashed; }
.legend i.trunk { border-top: 4px solid var(--link); }
.legend b.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.topo-wrap { position: relative; padding: 0 10px; }
#topo { width: 100%; height: auto; display: block; user-select: none; }
.zone rect { stroke-width: 1.2; }
.zone text.zl { font-size: 15px; font-weight: 700; }
.zone text.zs { font-size: 12.5px; fill: var(--muted); }
.link { stroke: var(--link); stroke-width: 2; fill: none; }
.link.cross { stroke-dasharray: 6 5; }
.link.trunk { stroke-width: 5; stroke-linecap: round; }
.link.lit { stroke: var(--accent); }
.link-label { font-size: 12px; fill: var(--muted); font-family: var(--mono); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.dev { cursor: pointer; }
.dev .hit { fill: transparent; }
.dev:hover .hit, .dev:focus-visible .hit { fill: var(--accent-soft); }
.dev.sel .hit { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; }
.dev:focus { outline: none; }
.dev text.dn { font-size: 14px; font-weight: 700; fill: var(--text); }
.dev text.di { font-size: 12px; fill: var(--muted); font-family: var(--mono); }
.dev text.dm { font-size: 11.5px; fill: var(--faint); }
.badge-off rect { fill: var(--bad); }
.badge-off text { fill: #fff; font-size: 9.5px; font-weight: 700; }
.pkt { filter: drop-shadow(0 0 4px rgba(31, 94, 255, .55)); }
.drop-x line { stroke: var(--bad); stroke-width: 4; stroke-linecap: round; }
.drop-x circle { fill: var(--bad-soft); stroke: var(--bad); stroke-width: 2; }

.tooltip { position: absolute; pointer-events: none; background: var(--text); color: var(--surface); padding: 6px 9px; border-radius: 7px; font-size: 12px; line-height: 1.4; white-space: nowrap; transform: translate(-50%, calc(-100% - 12px)); z-index: 5; }
.tooltip b { font-weight: 700; }

.controls { border-top: 1px solid var(--border); padding: 12px 16px 14px; display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; }
.controls h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-right: 4px; width: 100%; }
.toggle { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px 4px 5px; background: var(--surface-2); font-size: 12.5px; font-weight: 600; }
.toggle input { appearance: none; width: 30px; height: 18px; border-radius: 999px; background: var(--border-strong); position: relative; margin: 0; cursor: pointer; transition: background .15s; }
.toggle input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.toggle input:checked { background: var(--ok); }
.toggle input:checked::after { transform: translateX(12px); }
.toggle.danger input:checked { background: var(--bad); }
.toggle.off-state { border-color: var(--bad); background: var(--bad-soft); }

/* ---------- console ---------- */
.dev-head { display: flex; gap: 12px; align-items: center; padding: 14px 16px 10px; }
.dev-head .ico { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); flex: none; }
.dev-head .ico svg { width: 34px; height: 34px; }
.dev-head h2 { font-size: 16px; }
.dev-head p { margin: 0; color: var(--muted); font-size: 12.5px; }
.zone-pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; color: #fff; margin-left: 6px; vertical-align: 1px; }
.subtabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--border); }
.subtabs button { border: 0; background: none; padding: 8px 10px; font-size: 13px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subtabs button[aria-selected="true"] { color: var(--accent); border-color: var(--accent); }
.console-body { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 12px; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--border); background: var(--surface-2); padding: 3px 9px; border-radius: 999px; font-family: var(--mono); font-size: 11.5px; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.terminal { flex: 1; min-height: 240px; max-height: 460px; overflow: auto; background: var(--term-bg); color: var(--term-text); border-radius: 9px; padding: 10px 12px; font: 12.5px/1.45 var(--mono); white-space: pre-wrap; word-break: break-word; }
.terminal .cmd { color: #fff; }
.terminal .dim { color: var(--term-dim); }
.terminal .good { color: #59d98e; }
.terminal .bad { color: #ff8b97; }
.term-input { display: flex; align-items: center; gap: 6px; background: var(--term-bg); border-radius: 9px; padding: 8px 12px; font: 12.5px var(--mono); color: var(--term-text); }
.term-input span { color: #8fb4ff; white-space: nowrap; }
.term-input input { flex: 1; background: transparent; border: 0; outline: none; color: #fff; font: inherit; min-width: 0; }

.browser { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; flex: 1; min-height: 260px; }
.browser-bar { display: flex; gap: 6px; padding: 8px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.browser-bar input { flex: 1; border: 1px solid var(--border); border-radius: 7px; padding: 5px 10px; background: var(--surface); font-family: var(--mono); font-size: 12.5px; min-width: 0; }
.browser-view { flex: 1; padding: 22px; background: #fff; color: #1d2433; }
.browser-view h3 { font-size: 20px; margin-bottom: 8px; }
.browser-view .err { color: #b42318; }
.browser-view .page-title { font-size: 11px; color: #6b7280; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 14px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); }
.note { font-size: 12.5px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }

/* ---------- events ---------- */
.result-banner { margin: 0 16px 8px; padding: 9px 12px; border-radius: 9px; font-weight: 600; font-size: 13px; display: flex; gap: 10px; align-items: flex-start; }
.result-banner.ok { background: var(--ok-soft); color: var(--ok); }
.result-banner.bad { background: var(--bad-soft); color: var(--bad); }
.result-banner.warn { background: var(--warn-soft); color: var(--warn); }
.result-banner small { display: block; font-weight: 500; color: var(--text); opacity: .85; margin-top: 2px; }
.events { list-style: none; margin: 0; padding: 0 16px 14px; overflow: auto; flex: 1; max-height: 420px; counter-reset: ev; }
.events li { counter-increment: ev; display: grid; grid-template-columns: 22px 92px 1fr; gap: 8px; align-items: baseline; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 12.5px; }
.events li::before { content: counter(ev); color: var(--faint); font-family: var(--mono); font-size: 11px; text-align: right; }
.events .who { font-weight: 700; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.events li.drop .what { color: var(--bad); font-weight: 600; }
.events li.ok .what { color: var(--ok); }
.events li.acl .what::before, .events li.nat .what::before, .events li.arp .what::before { font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 4px; margin-right: 6px; }
.events li.acl .what::before { content: "POLICY"; background: var(--accent-soft); color: var(--accent); }
.events li.nat .what::before { content: "NAT"; background: var(--warn-soft); color: var(--warn); }
.events li.arp .what::before { content: "ARP"; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.empty { color: var(--muted); padding: 10px 16px 18px; font-size: 13px; }

/* ---------- matrix ---------- */
.intro { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-end; margin-bottom: 16px; }
.intro h2 { font-size: 20px; letter-spacing: -.01em; }
.intro p { margin: 4px 0 0; color: var(--muted); max-width: 760px; }
.matrix-wrap { overflow-x: auto; padding: 4px 16px 16px; }
table.matrix { border-collapse: separate; border-spacing: 4px; width: 100%; min-width: 860px; }
table.matrix th { font-size: 12px; font-weight: 700; text-align: left; vertical-align: bottom; padding: 4px 6px; }
table.matrix th small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; }
table.matrix th.row { white-space: nowrap; border-left: 4px solid var(--zc, var(--border)); padding-left: 10px; }
table.matrix thead th { border-bottom: 3px solid var(--zc, transparent); }
.cell { width: 100%; border: 1px solid transparent; border-radius: 8px; padding: 7px 6px; font-size: 12px; font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: 1px; min-height: 52px; justify-content: center; }
.cell.ok { background: var(--ok-soft); color: var(--ok); }
.cell.bad { background: var(--bad-soft); color: var(--bad); }
.cell.na { background: var(--surface-2); color: var(--faint); cursor: default; }
.cell.sel { border-color: currentColor; }
.cell .by { font-size: 10.5px; font-weight: 600; opacity: .9; }
.cell .was { font-size: 10px; font-weight: 600; color: var(--muted); }
.cell .mark { font-size: 15px; line-height: 1; }
.detail { margin: 0 16px 16px; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--surface-2); display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.detail p { margin: 0; flex: 1 1 420px; }
.detail code { font-size: 12px; background: var(--surface); border: 1px solid var(--border); padding: 1px 5px; border-radius: 5px; }

/* ---------- scenarios ---------- */
.scen-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); }
.scen { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.scen .tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.scen h3 { font-size: 16px; }
.scen p { margin: 0; color: var(--muted); font-size: 13px; }
.scen .controls-used { font-size: 12px; }
.scen .controls-used b { color: var(--text); }
table.steps { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.steps th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 6px 6px; border-bottom: 1px solid var(--border); }
table.steps td { padding: 7px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.steps td code { font-size: 12px; }
table.steps .res { font-weight: 700; white-space: nowrap; }
table.steps .res.ok { color: var(--ok); }
table.steps .res.bad { color: var(--bad); }
table.steps .why { display: block; color: var(--muted); font-size: 11.5px; font-weight: 500; white-space: normal; margin-top: 2px; }
.verdict { font-size: 13px; padding: 9px 12px; border-radius: 9px; background: var(--accent-soft); color: var(--text); }

/* ---------- build kit ---------- */
.kit { display: grid; gap: 16px; grid-template-columns: 240px minmax(0, 1fr); align-items: start; }
.kit nav { position: sticky; top: 78px; display: flex; flex-direction: column; gap: 2px; padding: 10px; }
.kit nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 7px; font-size: 13px; font-weight: 600; }
.kit nav a:hover { background: var(--surface-2); color: var(--text); }
.kit section.card { padding: 18px 20px; margin-bottom: 16px; scroll-margin-top: 80px; }
.kit h3 { font-size: 16px; margin-bottom: 4px; }
.kit h3 .num { color: var(--accent); margin-right: 6px; }
.kit p, .kit li { color: var(--text); }
.kit .lead { color: var(--muted); margin: 0 0 12px; }
.table-scroll { overflow-x: auto; }
table.plain { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.plain th, table.plain td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.plain th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
table.plain td.mono { font-family: var(--mono); }
.cfg-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); }
.cfg { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.cfg header { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cfg header b { font-size: 14px; }
.cfg header small { color: var(--muted); }
.cfg pre { margin: 0; padding: 10px 12px; max-height: 340px; overflow: auto; font-size: 11.5px; line-height: 1.45; background: var(--term-bg); color: var(--term-text); }
.cfg pre .c { color: var(--term-dim); }
.check { list-style: none; padding: 0; margin: 0; }
.check li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.check input { margin-top: 3px; }
.check code { font-size: 12px; }
.check .exp { color: var(--muted); font-size: 12px; }
@media (max-width: 900px) { .kit { grid-template-columns: minmax(0, 1fr); } .kit nav { position: static; flex-direction: row; flex-wrap: wrap; } }

footer { text-align: center; color: var(--faint); font-size: 12px; padding: 0 16px 28px; }

@media (max-width: 640px) {
  .topbar { padding: 10px 16px; position: static; gap: 10px; }
  .topbar .icon-btn { order: 2; }
  .tabs { order: 3; flex-basis: 100%; }
  .topo-wrap { overflow-x: auto; padding: 0 0 6px; }
  #topo { min-width: 760px; }
  main { padding: 14px 16px 30px; }
  .brand p { display: none; }
  .events li { grid-template-columns: 18px 70px 1fr; }
}
@media print {
  .topbar, .kit nav, .btn, footer { display: none !important; }
  .tab-panel { display: none !important; }
  #tab-build { display: block !important; }
  .kit { display: block; }
  .card { box-shadow: none; break-inside: avoid; }
  .cfg pre { max-height: none; background: #fff; color: #000; border-top: 1px solid #ccc; }
}
