:root {
  --bg: #07101f;
  --panel: #0b1628;
  --panel-2: #101d31;
  --panel-3: #13233a;
  --line: #20324a;
  --line-soft: #17273c;
  --text: #e9f1fc;
  --muted: #7689a4;
  --cyan: #4bd3ff;
  --blue: #4e8cff;
  --green: #35d497;
  --amber: #ffb44d;
  --danger: #ff647c;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; overflow: hidden; }
button, input { font: inherit; }
button { color: inherit; }

.app-shell { min-width: 1080px; min-height: 100vh; height: 100vh; background: radial-gradient(circle at 47% -20%, #173760 0, transparent 35%), var(--bg); overflow: hidden; }
.topbar { height: 76px; display: grid; grid-template-columns: 260px 1fr auto; align-items: center; border-bottom: 1px solid var(--line); background: rgba(8, 17, 31, .96); padding: 0 20px 0 18px; position: relative; z-index: 20; box-shadow: 0 12px 35px rgba(0,0,0,.18); }
.brand-group { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: #06101c; font-size: 11px; font-weight: 900; background: linear-gradient(145deg, #67e3ff, #4284ff); box-shadow: 0 0 0 1px rgba(113,218,255,.45), 0 8px 20px rgba(52,142,255,.22); transform: rotate(-5deg); }
.brand-mark span { transform: rotate(5deg); }
.brand-name { font-size: 13px; letter-spacing: .12em; font-weight: 600; white-space: nowrap; }
.brand-name b { color: var(--cyan); }
.brand-subtitle { color: var(--muted); font-size: 10px; margin-top: 3px; }
.project-title { justify-self: center; display: flex; align-items: center; gap: 10px; min-width: 255px; }
.project-title strong { font-size: 13px; font-weight: 650; display: block; }
.project-title small { display: block; font-size: 10px; color: var(--muted); margin-top: 4px; }
.project-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px rgba(53,212,151,.7); }
.top-actions { display: flex; align-items: center; gap: 9px; }
.ghost-btn, .run-btn { border: 1px solid var(--line); height: 36px; border-radius: 9px; padding: 0 14px; background: #101d30; cursor: pointer; font-size: 12px; transition: .2s ease; }
.ghost-btn:hover { background: #17263b; border-color: #38506e; }
.run-btn { border-color: #3a84ff; background: linear-gradient(180deg, #448eff, #2472ed); font-weight: 700; box-shadow: 0 8px 24px rgba(34,112,239,.25); }
.run-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.run-btn:disabled { opacity: .65; cursor: wait; }
.avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; color: #062023; font-size: 11px; font-weight: 800; background: linear-gradient(145deg, #9fffe7, #40c4d5); border: 2px solid #193149; }

.studio { height: calc(100vh - 76px); display: grid; grid-template-columns: 230px minmax(620px, 1fr) 286px; }
.device-sidebar, .inspector { background: rgba(10, 21, 38, .95); min-height: 0; overflow: auto; scrollbar-width: thin; scrollbar-color: #263b57 transparent; }
.device-sidebar { border-right: 1px solid var(--line); padding: 17px 14px; }
.side-heading { height: 24px; display: flex; align-items: center; justify-content: space-between; color: #8294ad; font-size: 9px; font-weight: 800; letter-spacing: .14em; }
.side-heading button { border: 0; background: transparent; color: #607793; cursor: pointer; font-size: 18px; }
.side-heading.compact { margin-bottom: 3px; }
.search-box { height: 35px; border: 1px solid var(--line); background: #0d1a2c; border-radius: 8px; display: flex; align-items: center; gap: 8px; padding: 0 10px; margin: 9px 0 13px; }
.search-box span { color: #637995; font-size: 18px; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 11px; }
.search-box input::placeholder { color: #536984; }
.palette-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.palette-card { height: 81px; border: 1px solid #1d3048; background: linear-gradient(160deg, #111f34, #0c1829); border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; cursor: grab; color: #9eb0c8; font-size: 10px; transition: .18s ease; }
.palette-card:hover { transform: translateY(-2px); border-color: #496787; background: #14263d; box-shadow: 0 10px 22px rgba(0,0,0,.2); color: #dfeaff; }
.palette-card:active { cursor: grabbing; }
.palette-icon { width: 32px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-size: 21px; font-weight: 700; background: #102945; color: #62adff; }
.palette-card.purple .palette-icon, .selected-icon.purple { background: #26234a; color: #aa94ff; }
.palette-card.cyan .palette-icon, .selected-icon.cyan { background: #12394b; color: #58dbff; }
.palette-card.orange .palette-icon, .selected-icon.orange { background: #402b22; color: #ffae61; }
.palette-card.green .palette-icon, .selected-icon.green { background: #153b35; color: #55e4aa; }
.palette-card.violet .palette-icon, .selected-icon.violet { background: #2b234b; color: #ba99ff; }
.palette-card.pink .palette-icon, .selected-icon.pink { background: #42263c; color: #ff91c6; }
.sidebar-tip { margin-top: 12px; padding: 11px; display: flex; gap: 9px; border: 1px solid #1d3a55; background: linear-gradient(145deg, rgba(40,114,166,.13), rgba(18,40,64,.18)); border-radius: 10px; }
.sidebar-tip > span { color: var(--cyan); }
.sidebar-tip strong { font-size: 10px; display: block; }
.sidebar-tip p { color: #6f849f; font-size: 9px; line-height: 1.55; margin: 3px 0 0; }
.saved-projects { margin-top: 18px; }
.project-item { width: 100%; display: flex; align-items: center; text-align: left; gap: 9px; border: 0; border-radius: 8px; background: transparent; padding: 8px; margin: 2px 0; cursor: pointer; }
.project-item:hover, .project-item.active { background: #12243a; }
.project-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 7px; background: #193759; color: #67b1ff; }
.project-item strong { display: block; font-size: 10px; }
.project-item small { display: block; color: #607590; font-size: 8px; margin-top: 3px; }

.workspace-wrap { min-width: 0; display: flex; flex-direction: column; overflow: hidden; background: #081321; }
.metric-row { height: 70px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.metric { display: flex; align-items: center; gap: 11px; background: #0c192b; padding: 0 17px; min-width: 0; }
.metric-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; }
.metric-icon.green { color: var(--green); background: rgba(53,212,151,.12); }
.metric-icon.blue { color: #62a0ff; background: rgba(78,140,255,.12); }
.metric-icon.amber { color: var(--amber); background: rgba(255,180,77,.12); }
.metric small { display: block; color: #617690; font-size: 8px; font-weight: 800; letter-spacing: .1em; white-space: nowrap; }
.metric strong { display: block; font-size: 17px; margin-top: 4px; white-space: nowrap; }
.metric strong em { color: #60738d; font-size: 11px; font-style: normal; }
.metric-trend { margin-left: auto; color: var(--green); font-size: 9px; border-radius: 9px; background: rgba(53,212,151,.09); padding: 4px 6px; }
.metric-trend.safe { color: #65dcb0; }
.spark { margin-left: auto; color: #58a0ff; letter-spacing: -2px; font-size: 15px; }
.canvas-toolbar { min-height: 52px; display: flex; justify-content: space-between; align-items: center; padding: 0 13px; border-bottom: 1px solid var(--line); background: #0c1829; }
.tool-group { display: flex; align-items: center; gap: 5px; }
.tool-btn, .zoom-label { height: 30px; min-width: 30px; padding: 0 8px; border-radius: 7px; border: 1px solid transparent; background: transparent; color: #7f93ae; font-size: 12px; cursor: pointer; }
.tool-btn:hover, .zoom-label:hover { background: #17273d; color: #dce9f9; }
.tool-btn.active { background: #173963; color: #66b6ff; border-color: #24568c; }
.tool-btn.active-link { background: #3b3261; color: #c1aeff; border-color: #66559b; }
.tool-btn.text { border-color: var(--line); padding: 0 11px; }
.connect-control { min-width: 92px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-color: #2a405c; background: #111f32; }
.connect-control span, .arrange-btn span { font-size: 9px; font-weight: 700; }
.arrange-btn { display: inline-flex; align-items: center; gap: 6px; }
.zoom-label { font-size: 10px; min-width: 42px; }
.tool-separator { width: 1px; height: 19px; background: var(--line); margin: 0 3px; }
.protocol-btn { height: 30px; border-radius: 7px; padding: 0 10px; background: #111f32; border: 1px solid var(--line); color: #93a7c1; font-size: 9px; font-weight: 700; cursor: pointer; }
.protocol-btn span { margin-right: 5px; }
.protocol-btn.https span { color: var(--green); }
.protocol-btn.icmp span { color: var(--amber); }
.protocol-btn:hover { background: #17283e; color: #e5effb; }
.protocol-btn:disabled { opacity: .5; cursor: wait; }
.canvas-frame { flex: 1; min-height: 0; padding: 12px; background: #07111e; }
.workspace { width: 100%; height: 100%; min-height: 465px; position: relative; overflow: hidden; border: 1px solid #1b3048; border-radius: 11px; background-color: #091627; background-image: linear-gradient(rgba(47,78,111,.15) 1px, transparent 1px), linear-gradient(90deg, rgba(47,78,111,.15) 1px, transparent 1px), radial-gradient(circle at 45% 46%, rgba(33,89,137,.13), transparent 38%); background-size: 20px 20px, 20px 20px, 100% 100%; box-shadow: inset 0 0 60px rgba(0,0,0,.2); }
.workspace.connecting { cursor: crosshair; box-shadow: inset 0 0 0 1px rgba(151,126,255,.35), inset 0 0 60px rgba(0,0,0,.2); }
.canvas-scale { width: 100%; height: 100%; position: absolute; top: 0; left: 0; transform-origin: left top; transition: transform .18s ease; }
.network-lines { position: absolute; inset: 0; overflow: visible; pointer-events: none; }
.link-shadow { stroke: rgba(0,0,0,.5); stroke-width: 8; }
.link-line { stroke: #2a638c; stroke-width: 2; stroke-dasharray: 5 4; filter: url(#glow); }
.link-preview { stroke: #b59aff; stroke-width: 2.5; stroke-dasharray: 8 6; filter: url(#glow); animation: linkFlow .65s linear infinite; }
.link-port { fill: #5fc4ff; stroke: #10263c; stroke-width: 2; }
@keyframes linkFlow { to { stroke-dashoffset: -14; } }
.connect-guide[hidden] { display: none; }
.connect-guide { position: absolute; top: 14px; left: 50%; z-index: 15; transform: translateX(-50%); min-width: 360px; display: flex; align-items: center; gap: 11px; padding: 9px 10px; border: 1px solid #6c5aa5; border-radius: 11px; background: rgba(25, 25, 52, .96); box-shadow: 0 14px 35px rgba(0,0,0,.35), 0 0 25px rgba(151,113,255,.14); }
.guide-step { width: 27px; height: 27px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: #765bd1; color: white; font-size: 11px; font-weight: 800; }
.connect-guide div { min-width: 0; flex: 1; }
.connect-guide strong { display: block; font-size: 10px; color: #eeeaff; }
.connect-guide small { display: block; margin-top: 3px; color: #9d93bd; font-size: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.connect-guide button { height: 27px; padding: 0 9px; border: 1px solid #4e456f; border-radius: 7px; background: #2a2540; color: #c7bddf; font-size: 8px; cursor: pointer; }
.device-node { position: absolute; width: 110px; height: 78px; border: 1px solid #29445f; border-radius: 11px; background: linear-gradient(160deg, rgba(20,39,61,.98), rgba(12,25,42,.98)); color: var(--text); display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: move; box-shadow: 0 12px 24px rgba(0,0,0,.3); user-select: none; touch-action: none; transition: border-color .17s ease, box-shadow .17s ease; z-index: 3; }
.device-node:hover { border-color: #547797; }
.device-node.selected { border-color: #4fa3ff; box-shadow: 0 0 0 2px rgba(62,145,255,.2), 0 14px 30px rgba(0,0,0,.42); }
.device-node.connect-start { border-color: #aa8bff; box-shadow: 0 0 0 3px rgba(166,129,255,.18), 0 0 25px rgba(151,113,255,.22); }
.node-icon { color: #63aeff; font-size: 24px; line-height: 1; margin-bottom: 5px; }
.device-node.purple .node-icon { color: #aa94ff; }.device-node.cyan .node-icon { color: #58dbff; }.device-node.orange .node-icon { color: #ffad5c; }.device-node.green .node-icon { color: #54dda8; }.device-node.violet .node-icon { color: #b59aff; }.device-node.pink .node-icon { color: #ff90c4; }
.device-node strong { font-size: 9px; max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-node small { color: #69809b; font-size: 7px; margin-top: 3px; }
.status-led { position: absolute; top: 8px; right: 8px; width: 5px; height: 5px; border-radius: 50%; background: var(--green); box-shadow: 0 0 7px rgba(53,212,151,.8); }
.port { position: absolute; top: 35px; width: 6px; height: 10px; background: #152a41; border: 1px solid #3e6285; border-radius: 2px; }
.port.left { left: -4px; }.port.right { right: -4px; }
.packet { width: 14px; height: 14px; border-radius: 50%; position: absolute; z-index: 9; opacity: 0; pointer-events: none; transition: left .68s cubic-bezier(.35,.04,.21,1), top .68s cubic-bezier(.35,.04,.21,1), background .2s; }
.packet span { position: absolute; inset: 4px; border-radius: 50%; background: white; }
.packet.ok { background: #38dca0; box-shadow: 0 0 10px #36d89d, 0 0 28px rgba(54,216,157,.7); }
.packet.deny { background: var(--danger); box-shadow: 0 0 10px var(--danger), 0 0 28px rgba(255,74,105,.7); animation: shake .18s 3; }
.packet.visible { opacity: 1; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(4px); } }
.canvas-label { position: absolute; bottom: 12px; left: 14px; color: #657a95; font-size: 8px; font-weight: 800; letter-spacing: .08em; }
.canvas-label b { color: #425873; margin-left: 7px; font-weight: 500; }
.live-dot { display: inline-block; width: 5px; height: 5px; background: var(--green); border-radius: 50%; margin-right: 6px; box-shadow: 0 0 7px var(--green); }
.mini-map { position: absolute; right: 12px; bottom: 12px; width: 116px; height: 72px; border: 1px solid #263c56; background: rgba(10,24,41,.88); border-radius: 7px; padding: 7px; }
.mini-inner { width: 100%; height: 42px; position: relative; background: linear-gradient(#1b2e44 1px,transparent 1px),linear-gradient(90deg,#1b2e44 1px,transparent 1px); background-size: 8px 8px; border: 1px solid #1c3047; overflow: hidden; }
.mini-inner i { width: 5px; height: 4px; background: #4b9fff; position: absolute; border-radius: 1px; }
.mini-map > span { display: block; color: #50647d; font-size: 6px; margin-top: 5px; letter-spacing: .15em; }
.status-bar { height: 34px; padding: 0 14px; border-top: 1px solid var(--line); background: #0b1728; display: flex; align-items: center; justify-content: space-between; }
.simulation-status { min-width: 0; display: flex; gap: 7px; align-items: center; }
.simulation-status span { color: var(--green); font-size: 9px; }.simulation-status span.pulse { animation: pulse 1s infinite; }
.simulation-status strong { font-size: 9px; font-weight: 600; color: #91a6c0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-meta { display: flex; gap: 16px; color: #516780; font-size: 8px; }
@keyframes pulse { 50% { opacity: .25; } }

.inspector { border-left: 1px solid var(--line); }
.inspector-tabs { height: 48px; display: grid; grid-template-columns: 1fr 1fr; padding: 0 15px; border-bottom: 1px solid var(--line); }
.inspector-tabs button { border: 0; border-bottom: 2px solid transparent; background: transparent; color: #627791; font-size: 10px; cursor: pointer; }
.inspector-tabs button.active { color: #dbe8f7; border-color: #4a9aff; }
.inspector-content { padding: 14px; }
.selected-card { display: flex; align-items: center; gap: 9px; border: 1px solid #21364e; background: linear-gradient(145deg,#112139,#0d1a2d); border-radius: 10px; padding: 10px; }
.selected-icon { width: 38px; height: 38px; border-radius: 8px; display: grid; place-items: center; font-size: 22px; color: #66aeff; background: #163353; }
.selected-card > div:nth-child(2) { min-width: 0; flex: 1; }
.selected-card small { color: #60748d; display: block; font-size: 7px; font-weight: 800; letter-spacing: .09em; }
.selected-card strong { font-size: 11px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 4px; }
.selected-card span { display: block; color: #7890ab; font-size: 8px; margin-top: 4px; }
.selected-card span i { display: inline-block; width: 5px; height: 5px; background: var(--green); border-radius: 50%; margin-right: 4px; }
.selected-card > button { align-self: flex-start; border: 0; background: transparent; color: #5a6e87; cursor: pointer; font-size: 11px; }
.property-section { border-bottom: 1px solid #1a2b41; padding: 16px 1px; }
.property-section h3, .activity-head h3 { margin: 0 0 12px; color: #6c8099; font-size: 8px; letter-spacing: .15em; }
.property-section label { display: block; color: #7b90a9; font-size: 8px; margin-top: 10px; }
.property-section input, .read-field { width: 100%; height: 33px; border-radius: 7px; border: 1px solid #233951; outline: 0; background: #0d192a; color: #c8d7e9; font-size: 9px; padding: 0 10px; margin-top: 5px; }
.property-section input:focus { border-color: #3978b9; box-shadow: 0 0 0 2px rgba(61,136,210,.12); }
.read-field { display: flex; align-items: center; justify-content: space-between; }
.read-field.status { justify-content: flex-start; gap: 6px; }.read-field.status span { margin-left: auto; }
.read-field.status i { width: 5px; height: 5px; border-radius: 50%; background: var(--green); }
.field-row { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; }
.policy-section { padding-bottom: 12px; }
.policy-row { min-height: 32px; display: flex; align-items: center; justify-content: space-between; color: #8da0b7; font-size: 9px; }
.policy-row span i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 7px; }.https-dot { background: var(--green); }.icmp-dot { background: var(--amber); }
.toggle { width: 29px; height: 16px; border: 0; border-radius: 10px; background: #2a3a4d; padding: 2px; cursor: pointer; transition: .2s; }
.toggle i { display: block; width: 12px; height: 12px; background: #798aa0; border-radius: 50%; transition: .2s; }
.toggle.on { background: #176c58; }.toggle.on i { transform: translateX(13px); background: #54e3b2; }
.delete-btn { width: 100%; height: 31px; margin-top: 11px; border: 1px solid rgba(255,100,124,.22); color: #e77989; background: rgba(255,100,124,.06); border-radius: 7px; font-size: 9px; cursor: pointer; }
.delete-btn:hover { background: rgba(255,100,124,.12); }
.activity-panel { margin-top: 17px; }
.activity-head { display: flex; justify-content: space-between; align-items: center; }.activity-head h3 { margin: 0; }.activity-head span { color: #51657e; font-size: 7px; }
.log-row { display: flex; gap: 8px; padding: 8px 1px; border-bottom: 1px solid #14263b; }
.log-row > i { width: 6px; height: 6px; flex: 0 0 auto; margin-top: 3px; border-radius: 50%; background: #548fff; }.log-row > i.ok { background: var(--green); }.log-row > i.deny { background: var(--danger); }
.log-row div { min-width: 0; }.log-row span { color: #8296af; display: block; font-size: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }.log-row small { display: block; color: #475c74; font-size: 7px; margin-top: 3px; }
.empty-inspector { padding: 90px 35px; text-align: center; color: #536981; }.empty-inspector > span { width: 48px; height: 48px; display: grid; place-items: center; margin: auto; border-radius: 12px; background: #12243a; font-size: 20px; }.empty-inspector strong { display: block; color: #8ea2b9; font-size: 11px; margin-top: 13px; }.empty-inspector p { font-size: 9px; line-height: 1.55; }

@media (max-height: 760px) {
  .topbar { height: 66px; }
  .studio { height: calc(100vh - 66px); }
  .palette-card { height: 67px; }
  .sidebar-tip, .saved-projects { margin-top: 10px; }
  .property-section { padding: 11px 1px; }
  .activity-panel { margin-top: 11px; }
  .metric-row { height: 62px; }
}

@media (max-width: 1180px) {
  .studio { grid-template-columns: 210px minmax(580px, 1fr) 270px; }
  .device-sidebar { padding-left: 10px; padding-right: 10px; }
  .arrange-btn span { display: none; }
}
