/* Parapet Studio — the app */
:root, [data-theme="light"] {
  --app-bg: #eceef2;
  --grid-dot: #c9cdd6;
  --panel: rgba(255, 255, 255, .88);
  --panel-solid: #ffffff;
  --text: #1d1d1f;
  --text-2: #48484d;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, .08);
  --line-2: rgba(0, 0, 0, .14);
  --hover: rgba(0, 0, 0, .045);
  --field: #f1f2f5;
  --node-bg: #ffffff;
  --node-border: #e0e3e9;
  --edge: #98a1b1;
  --card: #f7f8fa;
  --shadow-panel: 0 0 0 1px rgba(0, 0, 0, .06), 0 12px 40px -14px rgba(16, 24, 40, .25);
  --shadow-node: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px -4px rgba(16, 24, 40, .1);
  --logo-tile: #ffffff;
  --logo-ring: rgba(0, 0, 0, .08);
  color-scheme: light;
}
[data-theme="dark"] {
  --app-bg: #0b0c0f;
  --grid-dot: #2a2d34;
  --panel: rgba(28, 29, 34, .88);
  --panel-solid: #1c1d22;
  --text: #f5f5f7;
  --text-2: #d1d1d6;
  --muted: #9a9ba2;
  --line: rgba(255, 255, 255, .08);
  --line-2: rgba(255, 255, 255, .16);
  --hover: rgba(255, 255, 255, .06);
  --field: #2a2b31;
  --node-bg: #1c1e23;
  --node-border: #30333b;
  --edge: #5f6677;
  --card: #232429;
  --shadow-panel: 0 0 0 1px rgba(255, 255, 255, .07), 0 16px 40px -10px rgba(0, 0, 0, .6);
  --shadow-node: 0 2px 8px rgba(0, 0, 0, .4);
  --logo-tile: #f2f2f4;
  --accent: #3b82ff;
  --accent-hover: #5a96ff;
  --accent-soft: rgba(59, 130, 255, .18);
  --logo-ring: rgba(255, 255, 255, .0);
  color-scheme: dark;
}

html, body { height: 100%; overflow: hidden; }
.btn-ghost { color: var(--text); border-color: var(--line-2); }
.btn-ghost:hover { border-color: var(--text-2); background: var(--hover); }
body { background: var(--app-bg); color: var(--text); font-size: 14px; }
.app { position: fixed; inset: 0; display: flex; flex-direction: column; }
[data-theme="dark"] .check input:not(:checked) { background: #2a2b31; border-color: #4a4d55; }
[data-theme="dark"] .check input:checked ~ span { text-decoration-color: rgba(255,255,255,.3); }
[data-theme="dark"] .ring .ring-track { stroke: rgba(255,255,255,.1); }
[data-theme="dark"] .switch span { background: #3a3b41; }

/* ---------- top bar ---------- */
.topbar { height: 56px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 12px; background: var(--panel); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid var(--line); z-index: 30; position: relative; }
.tb-left, .tb-center, .tb-right { display: flex; align-items: center; gap: 4px; }
.tb-left { flex: 1 1 0; min-width: 0; }
.tb-right { flex: 1 1 0; justify-content: flex-end; }
.tb-brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none !important; padding: 4px 6px; border-radius: 10px; flex: none; }
.tb-brand:hover { background: var(--hover); }
.tb-brand-name { font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: -0.02em; white-space: nowrap; }
.tb-brand-name span { color: var(--muted); font-weight: 600; }
.tb-sep { width: 1px; height: 22px; background: var(--line-2); margin: 0 6px; flex: none; }
.tb-name { min-width: 60px; width: 220px; max-width: 30vw; height: 32px; border: 1px solid transparent; background: transparent; border-radius: 8px; padding: 0 8px; font-size: 14px; font-weight: 600; color: var(--text); text-overflow: ellipsis; }
.tb-name:hover { background: var(--hover); }
.tb-name:focus { outline: none; background: var(--field); border-color: var(--accent); }
.tb-saved { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); white-space: nowrap; transition: opacity .3s; }
.tb-saved .ico { width: 13px; height: 13px; color: var(--ok); }
.tb-btn { height: 34px; min-width: 34px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; background: transparent; color: var(--text-2); border-radius: 9px; padding: 0 8px; font-size: 13.5px; font-weight: 500; transition: background .15s, color .15s; }
.tb-btn:hover { background: var(--hover); color: var(--text); }
.tb-btn:disabled { opacity: .35; cursor: default; background: transparent; }
.tb-btn .ico { width: 18px; height: 18px; }
.tb-text { padding: 0 11px; }
.tb-only-mobile { display: none !important; }
.tb-report { gap: 8px; padding-left: 5px; margin-left: 6px; }
.tb-grade { width: 24px; height: 24px; border-radius: 50%; background: rgba(255,255,255,.25); display: grid; place-items: center; font-weight: 800; font-size: 12.5px; }

/* menus */
.menu-wrap { position: relative; }
.menu { position: absolute; top: calc(100% + 6px); left: 0; min-width: 250px; background: var(--panel-solid); border-radius: 14px; box-shadow: var(--shadow-panel); padding: 6px; display: none; z-index: 60; }
.menu.open { display: block; animation: menuIn .18s var(--ease); }
.menu-right { left: auto; right: 0; }
.menu button { width: 100%; display: flex; align-items: center; gap: 12px; border: 0; background: none; text-align: left; padding: 9px 10px; border-radius: 9px; color: var(--text); }
.menu button:hover { background: var(--hover); }
.menu button b { display: block; font-size: 13.5px; font-weight: 600; }
.menu button small { display: block; font-size: 12px; color: var(--muted); }
.menu .ico { color: var(--muted); }
.zdot { width: 14px; height: 14px; border-radius: 5px; border: 1.5px dashed var(--zc); background: color-mix(in srgb, var(--zc) 15%, transparent); flex: none; }
@keyframes menuIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---------- workspace & canvas ---------- */
.workspace { position: relative; flex: 1; min-height: 0; }
.canvas { position: absolute; inset: 0; overflow: hidden; background-color: var(--app-bg); background-image: radial-gradient(var(--grid-dot) 1.1px, transparent 1.2px); background-size: 22px 22px; touch-action: none; cursor: default; outline: none; }
.canvas.panning { cursor: grabbing; }
.canvas.drop-hover { box-shadow: inset 0 0 0 3px rgba(11, 95, 255, .35); }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.layer { position: absolute; left: 0; top: 0; }
.edges { position: absolute; overflow: visible; pointer-events: none; }
.overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
#tempEdge { fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 6 5; }

/* zones */
.zone { position: absolute; border-radius: 22px; border: 1.5px dashed color-mix(in srgb, var(--zc) 65%, transparent); background: color-mix(in srgb, var(--zc) 6%, transparent); pointer-events: none; transition: box-shadow .2s; }
.zone.sel { border-style: solid; box-shadow: 0 0 0 3px color-mix(in srgb, var(--zc) 25%, transparent); }
.zone-head { position: absolute; left: 12px; top: 10px; display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px 0 8px; border-radius: 999px; background: color-mix(in srgb, var(--zc) 15%, var(--panel-solid)); color: color-mix(in srgb, var(--zc) 80%, var(--text)); font-size: 12px; font-weight: 600; pointer-events: auto; cursor: grab; white-space: nowrap; user-select: none; max-width: calc(100% - 24px); }
.zone-head .ico { width: 13px; height: 13px; }
.zone-head em { font-style: normal; font-weight: 500; opacity: .7; }
.zone-resize { position: absolute; right: -2px; bottom: -2px; width: 22px; height: 22px; pointer-events: auto; cursor: nwse-resize; border-radius: 0 0 20px 0; }
.zone-resize::after { content: ""; position: absolute; right: 7px; bottom: 7px; width: 9px; height: 9px; border-right: 2px solid color-mix(in srgb, var(--zc) 70%, transparent); border-bottom: 2px solid color-mix(in srgb, var(--zc) 70%, transparent); border-radius: 0 0 4px 0; }

/* edges */
.e-line { fill: none; stroke: var(--edge); stroke-width: 1.8; transition: stroke .15s; }
.e-line.unenc { stroke-dasharray: 6 5; }
.e-line.sel { stroke: var(--accent); stroke-width: 2.4; }
.e-hit { fill: none; stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: pointer; }
.e-hit:hover + .e-line { stroke: color-mix(in srgb, var(--accent) 70%, var(--edge)); }
.edge-label { position: absolute; transform: translate(-50%, -50%); display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 9px; border-radius: 999px; background: var(--panel-solid); border: 1px solid var(--node-border); font-size: 11px; font-weight: 500; color: var(--text-2); white-space: nowrap; cursor: pointer; user-select: none; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.edge-label .ico { width: 11px; height: 11px; }
.edge-label .lk { color: var(--ok); }
.edge-label .ulk { color: var(--high); }
.edge-label.sel { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.edge-label.pulse, .node.pulse, .zone.pulse { animation: pulse 1.4s var(--ease) 2; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(11,95,255,.0); } 40% { box-shadow: 0 0 0 10px rgba(11,95,255,.25); } }

/* nodes */
.node { position: absolute; width: 176px; height: 64px; border-radius: 16px; background: var(--node-bg); border: 1px solid var(--node-border); box-shadow: var(--shadow-node); display: flex; align-items: center; gap: 10px; padding: 0 12px 0 11px; cursor: grab; user-select: none; transition: box-shadow .15s, border-color .15s; }
.node:hover { border-color: var(--line-2); }
.node.sel { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-node); }
.node.dragging { cursor: grabbing; box-shadow: 0 16px 30px -10px rgba(16,24,40,.35); z-index: 5; }
.node.oos { opacity: .55; border-style: dashed; }
.node.connect-target { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.n-ico { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex: none; background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); }
.n-ico .ico { width: 22px; height: 22px; }
.n-logo, .li-logo, .d-logo { background: var(--logo-tile) !important; box-shadow: inset 0 0 0 1px var(--logo-ring); }
.n-logo .logo { width: 26px; height: 26px; }
.li-logo .logo { width: 20px; height: 20px; }
.d-logo .logo { width: 28px; height: 28px; }
.n-txt { min-width: 0; flex: 1; }
.n-label { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.01em; }
.n-sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.n-badge { position: absolute; right: -9px; top: -9px; min-width: 23px; height: 23px; padding: 0 6px; border-radius: 999px; color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; border: 2.5px solid var(--app-bg); }
.n-badge .ico { width: 12px; height: 12px; }
.port { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2.5px solid var(--node-bg); box-shadow: 0 0 0 1px var(--accent); opacity: 0; transform: scale(.6); transition: opacity .15s, transform .15s; cursor: crosshair; z-index: 2; }
.port::before { content: ""; position: absolute; inset: -9px; border-radius: 50%; }
.port[data-side="t"] { left: calc(50% - 7px); top: -7px; }
.port[data-side="b"] { left: calc(50% - 7px); bottom: -7px; }
.port[data-side="l"] { left: -7px; top: calc(50% - 7px); }
.port[data-side="r"] { right: -7px; top: calc(50% - 7px); }
.node:hover .port, .node.sel .port, .canvas.connecting .port { opacity: 1; transform: scale(1); }
.port:hover { transform: scale(1.25) !important; }

/* empty state */
.empty[hidden] { display: none !important; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; padding: 20px; }
.empty-card { pointer-events: auto; text-align: center; max-width: 440px; background: var(--panel); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border-radius: 28px; padding: 34px 30px 26px; box-shadow: var(--shadow-panel); }
.empty-ico { display: grid; place-items: center; margin-bottom: 16px; }
.empty-ico .logo-mark { width: 56px; height: 56px; filter: drop-shadow(0 10px 20px rgba(91,75,255,.3)); }
.empty-card h2 { font-family: var(--font-display); font-size: 24px; letter-spacing: -0.025em; margin: 0 0 8px; }
.empty-card p { color: var(--muted); line-height: 1.5; margin: 0 0 20px; }
.empty-actions { display: flex; flex-direction: column; gap: 8px; }
.empty-actions button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel-solid); color: var(--text); text-align: left; transition: border-color .15s, transform .15s; }
.empty-actions button:hover { border-color: var(--accent); transform: translateY(-1px); }
.empty-actions b { display: block; font-size: 14px; }
.empty-actions small { display: block; color: var(--muted); font-size: 12px; }
.empty-actions .ea-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.empty-steps { display: flex; justify-content: center; gap: 14px; margin-top: 20px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.empty-steps b { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--field); color: var(--text); font-size: 11px; margin-right: 4px; }

/* ---------- floating panels ---------- */
.panel { position: absolute; top: 12px; bottom: 12px; background: var(--panel); -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px); border-radius: 20px; box-shadow: var(--shadow-panel); display: flex; flex-direction: column; overflow: hidden; z-index: 20; }
.panel-left { left: 12px; width: 276px; }
.panel-right { right: 12px; width: 384px; }
.icon-btn { width: 30px; height: 30px; border: 0; background: transparent; border-radius: 8px; display: inline-grid; place-items: center; color: var(--text-2); flex: none; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn .ico { width: 17px; height: 17px; }
.icon-btn.on { color: var(--accent); background: var(--accent-soft); }

/* library */
.lib-head { padding: 14px 14px 8px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--line); }
.lib-title { display: flex; align-items: center; justify-content: space-between; font-family: var(--font-display); font-weight: 700; font-size: 16px; letter-spacing: -0.02em; }
.panel-left.collapsed { display: none; }
.lib-fab { position: absolute; left: 12px; top: 12px; z-index: 20; display: none; align-items: center; gap: 8px; height: 40px; padding: 0 14px 0 11px; border: 0; border-radius: 13px; background: var(--panel); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); box-shadow: var(--shadow-panel); color: var(--text); font-size: 13.5px; font-weight: 600; }
.lib-fab .ico { width: 17px; height: 17px; color: var(--accent); }
.lib-fab:hover { background: var(--panel-solid); }
.panel-left.collapsed ~ .lib-fab { display: inline-flex; }
.search { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px; background: var(--field); border-radius: 10px; color: var(--muted); }
.search .ico { width: 15px; height: 15px; }
.search input { border: 0; background: transparent; outline: none; flex: 1; min-width: 0; height: 100%; font-size: 13.5px; color: var(--text); }
.seg { display: flex; background: var(--field); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { flex: 1; border: 0; background: transparent; height: 28px; border-radius: 8px; font-size: 12.5px; font-weight: 500; color: var(--text-2); white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 5px; transition: background .15s, color .15s; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--panel-solid); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }
.seg button span:empty { display: none; }
.seg button span { font-size: 11px; font-weight: 600; background: var(--hover); padding: 1px 6px; border-radius: 99px; }
.prov-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.prov-chips::-webkit-scrollbar { display: none; }
.prov-chips button { flex: none; height: 26px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; font-size: 12px; font-weight: 500; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.prov-chips button i { width: 7px; height: 7px; border-radius: 50%; }
.prov-chips button.on { background: var(--text); border-color: var(--text); color: var(--panel-solid); }
.lib-list { flex: 1; overflow-y: auto; padding: 6px 8px 10px; }
.lib-group { margin-bottom: 2px; }
.lib-gh { width: 100%; display: flex; align-items: center; gap: 9px; border: 0; background: none; padding: 9px 8px; border-radius: 10px; color: var(--text); text-align: left; }
.lib-gh:hover { background: var(--hover); }
.lib-gh .gdot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.lib-gh b { font-size: 13px; font-weight: 600; flex: 1; }
.lib-gh small { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.lib-gh .chev { width: 14px; height: 14px; color: var(--muted); transition: transform .2s var(--ease); }
.lib-group.collapsed .chev { transform: rotate(-90deg); }
.lib-group.collapsed .lib-items { display: none; }
.lib-items { padding: 2px 0 8px; }
.lib-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; cursor: grab; user-select: none; }
.lib-item:hover { background: var(--hover); }
.lib-item:active { cursor: grabbing; }
.li-ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: none; background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); }
.li-ico .ico { width: 17px; height: 17px; }
.li-txt { min-width: 0; flex: 1; }
.li-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-desc { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-prov { font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 6px; background: var(--hover); color: var(--muted); flex: none; }
.li-add { width: 24px; height: 24px; border-radius: 7px; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; opacity: 0; flex: none; }
.lib-item:hover .li-add { opacity: 1; }
.li-add:hover { background: var(--accent); color: #fff; }
.li-add .ico { width: 14px; height: 14px; }
.lib-empty { padding: 30px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.lib-foot { padding: 10px 12px; border-top: 1px solid var(--line); }
.lib-foot .btn { width: 100%; gap: 6px; }
.lib-foot .ico { width: 15px; height: 15px; }

/* right panel */
.sum { display: flex; align-items: center; gap: 14px; padding: 16px 16px 12px; }
.sum-txt { flex: 1; min-width: 0; }
.sum-score { font-family: var(--font-display); font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.sum-score span { font-size: 14px; font-weight: 600; }
.sum-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; line-height: 1.35; }
.sev-filter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 0 16px 12px; }
.sev-filter button { border: 1px solid transparent; background: var(--field); border-radius: 11px; padding: 7px 4px 6px; text-align: center; color: var(--text); transition: all .15s; }
.sev-filter button b { display: block; font-size: 17px; font-weight: 700; line-height: 1.1; color: color-mix(in srgb, var(--sc-b, var(--muted)) 62%, var(--text)); }
.sev-filter button span { font-size: 10.5px; color: var(--muted); font-weight: 500; }
.sev-filter button:hover { border-color: var(--line-2); }
.sev-filter button.on { border-color: var(--sc); background: color-mix(in srgb, var(--sc) 12%, transparent); }
.tabs { margin: 0 16px 10px; }
.panel-body { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 16px 20px; }

/* threats list */
.tl-tools { display: flex; gap: 6px; margin-bottom: 10px; }
.tl-tools .search { flex: 1; height: 32px; min-width: 0; }
.select { height: 32px; border-radius: 10px; border: 0; background: var(--field); padding: 0 26px 0 10px; font-size: 12.5px; font-weight: 500; color: var(--text); appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238e8e93' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; cursor: pointer; }
.tl-status { margin-bottom: 10px; }
.ctx-chip { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; background: var(--accent-soft); color: var(--accent); border-radius: 12px; font-size: 12.5px; font-weight: 600; margin-bottom: 10px; }
.ctx-chip span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-chip button { border: 0; background: transparent; color: inherit; height: 24px; padding: 0 8px; border-radius: 7px; font-size: 12px; font-weight: 600; }
.ctx-chip button:hover { background: rgba(11,95,255,.12); }
.tl-group { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 14px 2px 8px; display: flex; align-items: center; gap: 8px; }
.tl-group:first-child { margin-top: 2px; }
.tl-group .ico { width: 14px; height: 14px; }
.tl-empty { text-align: center; padding: 34px 10px; color: var(--muted); }
.tl-empty .big { width: 52px; height: 52px; border-radius: 16px; background: rgba(31,157,97,.12); color: var(--ok); display: grid; place-items: center; margin: 0 auto 12px; }
.tl-empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.tc { background: var(--panel-solid); border-radius: 14px; box-shadow: 0 0 0 1px var(--line); margin-bottom: 8px; overflow: hidden; transition: box-shadow .15s; }
.tc:hover { box-shadow: 0 0 0 1px var(--line-2); }
.tc.open { box-shadow: 0 0 0 1px var(--line-2), 0 8px 24px -12px rgba(16,24,40,.25); }
.tc.done .tc-title { color: var(--muted); }
.tc-head { width: 100%; display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 11px 12px 11px 0; text-align: left; color: var(--text); }
.tc-bar { width: 4px; align-self: stretch; border-radius: 0 3px 3px 0; flex: none; }
.tc-main { flex: 1; min-width: 0; }
.tc-title { font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
.tc-target { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); margin-top: 3px; min-width: 0; }
.tc-target span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-target .ico { width: 12px; height: 12px; flex: none; }
.tc-score { min-width: 28px; height: 22px; padding: 0 7px; border-radius: 999px; color: #fff; font-size: 11.5px; font-weight: 700; display: grid; place-items: center; flex: none; }
.tc-done-ico { width: 22px; height: 22px; border-radius: 50%; background: rgba(31,157,97,.14); color: var(--ok); display: grid; place-items: center; flex: none; }
.tc-done-ico .ico { width: 13px; height: 13px; }
.tc-chev { width: 14px; height: 14px; color: var(--muted); flex: none; transition: transform .2s var(--ease); }
.tc.open .tc-chev { transform: rotate(90deg); }
.tc-body { padding: 2px 14px 14px 14px; display: flex; flex-direction: column; gap: 12px; }
.tc-plain { font-size: 14px; line-height: 1.5; color: var(--text); margin: 0; }
.banner { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; font-size: 12.5px; line-height: 1.4; }
.banner .ico { width: 16px; height: 16px; flex: none; }
.banner-ok { background: rgba(31,157,97,.1); color: #13794a; }
[data-theme="dark"] .banner-ok { color: #4fd18f; }
.banner-fix { background: var(--accent-soft); color: var(--accent); justify-content: space-between; }
.banner-fix .btn { height: 28px; font-size: 12.5px; padding: 0 12px; }
.risk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.rk { background: var(--card); border-radius: 10px; padding: 8px 10px; }
.rk small { display: block; font-size: 10.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.rk b { display: block; font-size: 13px; font-weight: 600; margin-top: 2px; }
.rk em { font-style: normal; font-size: 11.5px; color: var(--muted); font-weight: 500; }
.rk-wide { grid-column: span 2; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.meter { flex: 1; height: 6px; border-radius: 99px; background: var(--line-2); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 99px; }
.sub-h { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; display: flex; justify-content: space-between; align-items: center; }
.sub-h em { font-style: normal; text-transform: none; letter-spacing: 0; font-weight: 500; }
.status-seg { display: grid; grid-template-columns: repeat(5, 1fr); background: var(--field); border-radius: 10px; padding: 3px; gap: 2px; }
.status-seg button { border: 0; background: transparent; height: 28px; border-radius: 8px; font-size: 11.5px; font-weight: 500; color: var(--text-2); padding: 0 2px; }
.status-seg button.on { background: var(--panel-solid); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.status-seg button.on[data-s="mitigated"] { color: var(--ok); }
.status-seg button.on[data-s="progress"] { color: var(--accent); }
.status-seg button.on[data-s="accepted"] { color: var(--med); }
.status-seg button:disabled { opacity: .5; cursor: default; }
.controls { display: flex; flex-direction: column; gap: 10px; font-size: 13.5px; }
.native { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--card); font-size: 12.5px; color: var(--text-2); }
.native .ico { width: 14px; height: 14px; color: var(--accent); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 500; padding: 4px 8px; border-radius: 8px; background: var(--card); color: var(--text-2); text-decoration: none !important; border: 1px solid var(--line); }
.tag b { font-family: var(--mono); font-size: 11px; color: var(--accent); font-weight: 600; }
a.tag:hover { border-color: var(--accent); }
.tech { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin: 0; }
.note { width: 100%; min-height: 56px; resize: vertical; border: 1px solid var(--line); background: var(--field); border-radius: 10px; padding: 8px 10px; font-size: 13px; color: var(--text); }
.note:focus { outline: none; border-color: var(--accent); }
.tc-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.mini-btn { height: 28px; border: 1px solid var(--line-2); background: transparent; border-radius: 8px; padding: 0 10px; font-size: 12px; font-weight: 500; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.mini-btn:hover { border-color: var(--text-2); color: var(--text); }
.mini-btn .ico { width: 13px; height: 13px; }
.mini-btn.danger:hover { border-color: var(--crit); color: var(--crit); }

/* details */
.d-head { display: flex; align-items: center; gap: 12px; margin: 4px 0 16px; }
.d-ico { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; flex: none; background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); }
.d-ico .ico { width: 24px; height: 24px; }
.d-head b { display: block; font-size: 16px; font-weight: 700; letter-spacing: -0.02em; }
.d-head small { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.field { margin-bottom: 16px; }
.field > label, .field-l { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.input, .textarea { width: 100%; height: 36px; border: 1px solid var(--line); background: var(--field); border-radius: 10px; padding: 0 11px; font-size: 13.5px; color: var(--text); }
.textarea { height: auto; min-height: 70px; padding: 9px 11px; resize: vertical; line-height: 1.45; }
.input:focus, .textarea:focus { outline: none; border-color: var(--accent); background: var(--panel-solid); }
select.input { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238e8e93' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 28px; }
.help { font-size: 12px; color: var(--muted); margin: 6px 0 0; line-height: 1.45; }
.sens-seg { display: grid; grid-template-columns: repeat(4, 1fr); }
.sens-seg button { font-size: 11.5px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.toggle-row:last-of-type { border-bottom: 1px solid var(--line); }
.toggle-row b { display: block; font-size: 13.5px; font-weight: 600; }
.toggle-row small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.35; }
.info-card { display: flex; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--card); font-size: 12.5px; line-height: 1.45; color: var(--text-2); margin-bottom: 16px; }
.info-card .ico { width: 16px; height: 16px; flex: none; margin-top: 1px; color: var(--muted); }
.info-card b { color: var(--text); }
.d-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 16px; }
.d-stat { background: var(--card); border-radius: 12px; padding: 10px; text-align: center; }
.d-stat b { display: block; font-size: 18px; font-weight: 700; }
.d-stat small { font-size: 11px; color: var(--muted); }
.d-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 18px; }
.d-section { font-size: 12px; font-weight: 700; color: var(--text); margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; }
.inline-row { display: flex; gap: 6px; }
.inline-row .input { flex: 1; min-width: 0; }
.ct-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--card); margin-bottom: 6px; font-size: 13px; }
.ct-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prot-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.prot-row .ico { width: 18px; height: 18px; color: var(--accent); flex: none; }
.prot-row div { flex: 1; }
.prot-row b { display: block; font-size: 13px; }
.prot-row small { display: block; font-size: 12px; color: var(--muted); }

/* insights */
.ins { display: flex; gap: 12px; padding: 13px; border-radius: 14px; background: var(--panel-solid); box-shadow: 0 0 0 1px var(--line); margin-bottom: 8px; }
.ins-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.ins-ico .ico { width: 17px; height: 17px; }
.ins-warn .ins-ico { background: rgba(242,113,28,.12); color: var(--high); }
.ins-tip .ins-ico { background: var(--accent-soft); color: var(--accent); }
.ins-good .ins-ico { background: rgba(31,157,97,.12); color: var(--ok); }
.ins b { display: block; font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em; }
.ins p { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.ins .btn { height: 28px; font-size: 12.5px; padding: 0 12px; margin-top: 10px; }

/* dock */
.dock { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 2px; padding: 5px; background: var(--panel); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border-radius: 14px; box-shadow: var(--shadow-panel); z-index: 15; white-space: nowrap; }
.dock-zoom { border: 0; background: transparent; min-width: 52px; height: 30px; font-size: 12.5px; font-weight: 600; color: var(--text-2); border-radius: 8px; font-variant-numeric: tabular-nums; }
.dock-zoom:hover { background: var(--hover); }
.dock-sep { width: 1px; height: 18px; background: var(--line-2); margin: 0 4px; }
.dock-legend { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); padding: 0 8px 0 4px; }
.dock-legend i { width: 18px; height: 0; border-top: 2px solid var(--edge); display: inline-block; }
.dock-legend .lg-dash { border-top-style: dashed; margin-left: 8px; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 76px; transform: translate(-50%, 20px); background: rgba(29,29,31,.94); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 13px; font-weight: 500; opacity: 0; pointer-events: none; transition: opacity .3s var(--ease), transform .3s var(--ease); z-index: 100; max-width: calc(100vw - 32px); box-shadow: 0 10px 30px rgba(0,0,0,.25); display: flex; align-items: center; gap: 10px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { border: 0; background: rgba(255,255,255,.16); color: #fff; border-radius: 999px; height: 26px; padding: 0 10px; font-size: 12px; font-weight: 600; }
[data-theme="dark"] .toast { background: rgba(245,245,247,.95); color: #1d1d1f; }
[data-theme="dark"] .toast button { background: rgba(0,0,0,.08); color: #1d1d1f; }

/* ---------- modals ---------- */
.modal-root { position: fixed; inset: 0; z-index: 90; pointer-events: none; }
.modal-back { position: absolute; inset: 0; background: rgba(10,12,20,.38); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 20px; pointer-events: auto; animation: fadeIn .2s ease; overflow-y: auto; }
.modal { width: 100%; max-width: 520px; background: var(--panel-solid); border-radius: 24px; box-shadow: 0 30px 80px -20px rgba(0,0,0,.4); animation: modalIn .28s var(--ease); max-height: calc(100vh - 40px); display: flex; flex-direction: column; overflow: hidden; }
.modal-wide { max-width: 980px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 22px 6px; }
.modal-head h2 { font-family: var(--font-display); font-size: 21px; letter-spacing: -0.02em; margin: 0; }
.modal-body { padding: 10px 22px 22px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px 20px; border-top: 1px solid var(--line); }
.modal-foot .btn { height: 38px; font-size: 14px; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }

/* welcome */
.welcome { text-align: center; padding: 30px 30px 26px; }
.welcome .logo-mark { width: 64px; height: 64px; margin: 0 auto 18px; filter: drop-shadow(0 12px 24px rgba(91,75,255,.35)); }
.welcome h2 { font-family: var(--font-display); font-size: 28px; letter-spacing: -0.03em; margin: 0 0 8px; }
.welcome > p { color: var(--muted); margin: 0 auto 22px; line-height: 1.5; max-width: 380px; }
.w-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 24px; text-align: left; }
.w-step { background: var(--card); border-radius: 16px; padding: 14px; }
.w-step .ws-ico { width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin-bottom: 10px; }
.w-step b { display: block; font-size: 14px; margin-bottom: 4px; }
.w-step span { font-size: 12.5px; color: var(--muted); line-height: 1.4; display: block; }
.w-actions { display: flex; flex-direction: column; gap: 8px; }
.w-actions .btn { width: 100%; }

/* blueprints */
.bp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.bp-card { border: 1px solid var(--line); background: var(--panel-solid); border-radius: 18px; padding: 10px; text-align: left; color: var(--text); display: flex; flex-direction: column; transition: border-color .15s, transform .15s, box-shadow .15s; }
.bp-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 12px 30px -16px rgba(16,24,40,.35); }
.bp-thumb { height: 140px; border-radius: 12px; background: var(--card); display: grid; place-items: center; overflow: hidden; padding: 8px; margin-bottom: 10px; }
.bp-thumb svg { width: 100%; height: 100%; }
.bp-card b { font-size: 14.5px; letter-spacing: -0.01em; padding: 0 4px; }
.bp-card small { font-size: 12.5px; color: var(--muted); line-height: 1.4; padding: 4px 4px 2px; }
.bp-card .bp-tag { align-self: flex-start; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); margin: 0 4px 6px; }
.bp-blank .bp-thumb { border: 2px dashed var(--line-2); background: transparent; color: var(--muted); }
.bp-blank .bp-thumb .ico { width: 30px; height: 30px; }

/* help */
.help-steps { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.help-step { display: flex; gap: 12px; }
.help-step .hs-n { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; font-size: 13px; display: grid; place-items: center; flex: none; }
.help-step b { display: block; font-size: 14px; }
.help-step span { font-size: 13px; color: var(--muted); line-height: 1.45; }
.kbd-grid { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; font-size: 13px; padding-top: 14px; border-top: 1px solid var(--line); }
kbd { font-family: var(--font); font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 6px; background: var(--field); border: 1px solid var(--line-2); border-bottom-width: 2px; }

/* report */
.report { color: var(--text); }
.rp-top { display: flex; align-items: center; gap: 24px; padding: 6px 0 22px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.rp-grade { width: 104px; height: 104px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-family: var(--font-display); font-weight: 800; font-size: 50px; flex: none; }
.rp-meta h1 { font-family: var(--font-display); font-size: 30px; letter-spacing: -0.03em; margin: 0 0 4px; }
.rp-meta p { margin: 0; color: var(--muted); }
.rp-kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 20px 0; }
.rp-kpi { background: var(--card); border-radius: 14px; padding: 12px; }
.rp-kpi b { display: block; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.rp-kpi small { font-size: 11.5px; color: var(--muted); }
.rp-h { font-family: var(--font-display); font-size: 18px; letter-spacing: -0.02em; margin: 26px 0 12px; }
.rp-diagram { background: var(--card); border-radius: 16px; padding: 12px; }
.rp-diagram svg { width: 100%; height: auto; max-height: 420px; }
.rp-print { display: none; }
.rp-text { color: var(--text-2); line-height: 1.6; margin: 0; white-space: pre-wrap; }
.rp-stride { display: flex; flex-direction: column; gap: 8px; }
.rp-bar { display: grid; grid-template-columns: 170px 1fr 34px; align-items: center; gap: 10px; font-size: 13px; }
.rp-bar .meter { height: 10px; }
.rp-bar .meter i { background: var(--grad); }
.rp-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.rp-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 8px 8px; border-bottom: 1px solid var(--line-2); }
.rp-table td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; line-height: 1.4; }
.rp-table td small { color: var(--muted); display: block; }
.rp-table .sev { height: 20px; font-size: 11px; }
.rp-status { font-weight: 600; white-space: nowrap; }
.rp-status.mitigated { color: var(--ok); } .rp-status.accepted { color: var(--med); } .rp-status.progress { color: var(--accent); }
.rp-foot { margin-top: 24px; font-size: 11.5px; color: var(--muted); }
.rp-scroll { overflow-x: auto; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .panel-left { width: 248px; }
  .panel-right { width: 348px; }
  .tb-label { display: none; }
  .tb-report .tb-label { display: inline; }
  .tb-text { padding: 0 8px; }
  .dock-legend { display: none; }
}
@media (max-width: 860px) {
  .tb-only-mobile { display: inline-flex !important; }
  .tb-hide-sm, .tb-saved, .tb-brand-name, .tb-center .tb-sep { display: none !important; }
  .tb-name { width: auto; flex: 1; max-width: none; }
  .tb-right { flex: none; }
  .tb-left { flex: 1; }
  .tb-center { gap: 0; }
  .panel { top: auto; bottom: 0; left: 0 !important; right: 0 !important; width: auto !important; height: 72%; border-radius: 22px 22px 0 0; transform: translateY(105%); transition: transform .35s var(--ease); z-index: 40; }
  .panel.show { transform: none; }
  .panel-left.collapsed { display: flex; }
  .lib-fab, .lib-collapse { display: none !important; }
  .dock { bottom: 12px; }
  .bp-grid { grid-template-columns: 1fr 1fr; }
  .w-steps { grid-template-columns: 1fr; }
  .rp-kpis { grid-template-columns: repeat(3, 1fr); }
  .rp-bar { grid-template-columns: 110px 1fr 28px; }
}
@media (max-width: 520px) {
  .topbar { padding: 0 6px; gap: 2px; }
  #btnBlueprints, #btnHelp, #btnRedo, .tb-left .tb-sep { display: none !important; }
  .tb-name { min-width: 0; padding: 0 4px; font-size: 13px; }
  .tb-btn { min-width: 32px; padding: 0 6px; }
  .tb-sep { margin: 0 2px; }
  .bp-grid { grid-template-columns: 1fr; }
  .tb-report .tb-label { display: none; }
  .tb-report { padding: 0 5px; }
  .modal-back { padding: 10px; }
}

/* ---------- print (report) ---------- */
@media print {
  @page { margin: 14mm; }
  html, body { height: auto; overflow: visible; background: #fff; }
  .app, .toast { display: none !important; }
  .modal-root { position: static; }
  .modal-back { position: static; background: none; backdrop-filter: none; -webkit-backdrop-filter: none; padding: 0; display: block; overflow: visible; }
  .modal { max-width: none; box-shadow: none; border-radius: 0; max-height: none; overflow: visible; animation: none; }
  .modal-body { overflow: visible; padding: 0; }
  .no-print, .modal-head, .modal-foot { display: none !important; }
  .rp-diagram, .rp-kpi { break-inside: avoid; }
  .rp-screen { display: none !important; }
  .rp-print { display: block !important; }
  .rp-table tr { break-inside: avoid; }
  [data-theme="dark"] .report { --text: #1d1d1f; --text-2: #48484d; --muted: #6e6e73; --card: #f5f5f7; --line: rgba(0,0,0,.08); --line-2: rgba(0,0,0,.14); }
}
