:root {
  --app-bg: #f5f7fa;
  --panel: #ffffff;
  --ink: #1d2734;
  --ink-soft: #4f5e70;
  --muted: #7b8796;
  --line: #e2e7ed;
  --line-strong: #d3dae3;
  --navy: #111b2d;
  --navy-2: #1b2942;
  --blue: #326be6;
  --blue-dark: #2455bf;
  --blue-soft: #edf3ff;
  --green: #148a5b;
  --green-soft: #eaf8f2;
  --red: #c34150;
  --red-soft: #fff0f2;
  --amber: #b76c1d;
  --shadow: 0 20px 60px rgb(18 31 49 / 16%);
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--app-bg); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--app-bg);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select { font: inherit; }

button { color: inherit; }

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgb(50 107 230 / 22%);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

.app-shell {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 25px 15px 20px;
  color: #dce4f0;
  background: var(--navy);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 0 10px 32px;
  color: #fff;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.brand-mark {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 7px;
  background: var(--blue);
  font-weight: 800;
}

.brand-name {
  font-size: 18px;
  font-weight: 750;
  letter-spacing: -0.7px;
}

.brand-name span { color: #78a0ff; }

nav { display: grid; gap: 6px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 11px 12px;
  color: #9eabc0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  font-weight: 600;
  text-align: left;
}

.nav-item svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.nav-item:hover,
.nav-item.active { color: #fff; background: var(--navy-2); }

.local-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: auto;
  padding: 16px 10px 0;
  border-top: 1px solid #28364f;
}

.local-dot {
  width: 8px;
  height: 8px;
  margin-top: 4px;
  border-radius: 50%;
  background: #42c58a;
  box-shadow: 0 0 0 4px rgb(66 197 138 / 10%);
}
.local-note.unavailable .local-dot { background: #e36b78; box-shadow: 0 0 0 4px rgb(227 107 120 / 12%); }

.local-note strong,
.local-note small { display: block; }
.local-note strong { font-size: 12px; }
.local-note small { max-width: 140px; margin-top: 4px; color: #7f8ca1; font-size: 11px; line-height: 1.4; }

#app { min-width: 0; }

.topbar {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 38px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: 13px;
}

.breadcrumb button {
  padding: 0;
  color: var(--muted);
  border: 0;
  background: none;
  cursor: pointer;
}

.breadcrumb button:hover { color: var(--blue); }
.breadcrumb .chevron { color: #aab2bd; font-size: 18px; }
.breadcrumb strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.save-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
  color: var(--green);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.save-state::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.save-state.saving { color: var(--amber); }
.save-state.failed { color: var(--red); }

.top-actions,
.page-actions,
.button-row,
.inline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: #435165;
  cursor: pointer;
  font-weight: 650;
  font-size: 12px;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.button:hover:not(:disabled) { border-color: #9db5e8; background: #f9fbff; }
.button:active:not(:disabled) { transform: translateY(1px); }
.button:disabled { cursor: not-allowed; opacity: 0.45; }
.button.primary { color: #fff; border-color: var(--blue); background: var(--blue); }
.button.primary:hover:not(:disabled) { border-color: var(--blue-dark); background: var(--blue-dark); }
.button.danger { color: var(--red); border-color: #edc6cc; background: #fff; }
.button.danger:hover:not(:disabled) { background: var(--red-soft); border-color: #df9da7; }
.button.quiet { border-color: transparent; background: transparent; }
.button.small { min-height: 31px; padding: 6px 10px; }
.button.icon-only { width: 34px; padding: 7px; }

.dashboard {
  padding: 42px 44px 60px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 34px;
}

.page-heading h1,
.editor-heading h1 {
  margin: 0;
  font-size: clamp(25px, 3vw, 32px);
  letter-spacing: -1.1px;
}

.page-heading p,
.editor-heading p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.page-actions .button { white-space: nowrap; }

.dashboard-summary {
  display: flex;
  gap: 34px;
  padding: 0 0 24px;
  border-bottom: 1px solid var(--line);
}

.summary-item span,
.stat label,
.field label,
.eyebrow,
.table-head {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.summary-item strong {
  display: block;
  margin-top: 7px;
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
}

.plans-section { margin-top: 27px; }

.section-toolbar {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.section-toolbar h2 { margin: 0; font-size: 16px; letter-spacing: -0.3px; }
.selected-count { margin-left: 7px; color: var(--muted); font-size: 12px; font-weight: 500; }

.search-wrap { position: relative; }
.search-wrap svg { position: absolute; top: 10px; left: 11px; width: 15px; fill: none; stroke: #8b96a4; }
.search-wrap input { width: 220px; padding: 9px 11px 9px 34px; }

.input,
.field input,
.field textarea,
.field select,
.search-wrap input {
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
}

.plans-table {
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.plan-row {
  display: grid;
  grid-template-columns: 42px minmax(210px, 1.4fr) minmax(150px, 0.8fr) minmax(130px, 0.8fr) minmax(120px, 0.7fr) 158px;
  min-height: 72px;
  align-items: center;
  gap: 12px;
  padding: 0 16px 0 12px;
  border-bottom: 1px solid var(--line);
  transition: background 140ms ease;
}

.plan-row:last-child { border-bottom: 0; }
.plan-row:not(.table-head):hover { background: #fafcff; }
.plan-row.is-selected { background: var(--blue-soft); }
.plan-row.table-head { min-height: 41px; background: #f8fafc; }

.check {
  display: grid;
  place-items: center;
}

.check input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--blue);
  cursor: pointer;
}

.plan-title {
  display: block;
  min-width: 0;
  padding: 8px 0;
  color: inherit;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.plan-title strong,
.plan-title small { display: block; }
.plan-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.plan-title small { margin-top: 5px; color: var(--muted); font-family: var(--mono); font-size: 11px; }
.plan-title:hover strong { color: var(--blue); }
.row-export { width: 100%; min-height: 34px; padding: 6px 8px; color: var(--ink-soft); border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; font-size: 11px; cursor: pointer; }
.row-value { color: var(--ink-soft); font-size: 12px; }
.row-value.mono { font-family: var(--mono); }

.usage-mini { display: flex; align-items: center; gap: 8px; }
.usage-track { width: 64px; height: 5px; overflow: hidden; border-radius: 5px; background: #e6eaf0; }
.usage-track span { display: block; height: 100%; border-radius: inherit; background: var(--blue); }

.empty-plans {
  padding: 80px 20px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
  text-align: center;
}

.empty-plans .empty-glyph,
.inspector-empty .empty-glyph {
  display: grid;
  width: 44px;
  height: 44px;
  margin: 0 auto 15px;
  place-items: center;
  color: var(--blue);
  border-radius: 13px;
  background: var(--blue-soft);
  font-family: var(--mono);
  font-size: 19px;
}

.empty-plans h2 { margin: 0; font-size: 17px; }
.empty-plans p { margin: 7px 0 18px; color: var(--muted); }

.editor { min-width: 0; }

.editor-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 38px 22px;
  background: var(--panel);
}

.editor-heading h1 { font-size: 25px; }

.title-edit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.title-edit .edit-pencil { color: #98a2af; font-size: 14px; }

.statbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 0.75fr)) minmax(200px, 1.5fr);
  min-height: 94px;
  padding: 18px 38px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.stat {
  min-width: 0;
  padding: 3px 22px 3px 0;
  margin-right: 22px;
  border-right: 1px solid var(--line);
}

.stat strong {
  display: block;
  overflow: hidden;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat strong.good { color: var(--green); }
.stat em { color: var(--muted); font-family: var(--sans); font-size: 11px; font-style: normal; }
.capacity-stat { min-width: 0; padding-top: 3px; }
.capacity-copy { display: flex; justify-content: space-between; gap: 15px; }
.capacity-copy small { color: var(--muted); font-size: 11px; }
.meter { height: 7px; overflow: hidden; margin-top: 15px; border-radius: 8px; background: #e7ebf0; }
.meter span { display: block; height: 100%; border-radius: inherit; background: var(--blue); transition: width 260ms ease; }

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 38px 14px;
}

.toolbar-help { color: var(--muted); font-size: 11px; }

.workspace {
  display: grid;
  grid-template-columns: minmax(460px, 1fr) 270px 286px;
  align-items: start;
  gap: 12px;
  padding: 0 38px 38px;
}

.canvas-panel,
.inspector,
.yaml-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.yaml-panel,
.inspector {
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
}

.yaml-panel {
  display: flex;
  min-height: 600px;
  flex-direction: column;
  overflow: hidden;
}

.yaml-head {
  display: flex;
  min-height: 76px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 17px 16px 14px;
  border-bottom: 1px solid var(--line);
}

.yaml-head h2 { margin: 0; font-size: 15px; }
.yaml-head p { margin: 6px 0 0; color: var(--muted); font-size: 10px; line-height: 1.4; }

.yaml-state {
  flex: 0 0 auto;
  padding: 4px 6px;
  color: var(--green);
  border-radius: 5px;
  background: var(--green-soft);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.yaml-editor {
  width: 100%;
  min-height: 440px;
  flex: 1;
  padding: 16px 14px;
  color: #dce7f8;
  border: 0;
  border-radius: 0;
  outline: 0;
  background: #172236;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.58;
  resize: none;
  tab-size: 2;
  white-space: pre;
}

.yaml-editor:focus { box-shadow: inset 0 0 0 2px rgb(86 132 235 / 60%); }
.yaml-error { min-height: 31px; padding: 8px 14px 5px; color: var(--red); font-size: 10px; line-height: 1.35; }
.yaml-actions { display: flex; justify-content: flex-end; gap: 7px; padding: 9px 12px 12px; border-top: 1px solid var(--line); }
.yaml-actions .import-yaml-action { margin-right: auto; }

.canvas-panel { min-height: 600px; overflow: visible; }
.canvas-head { display: flex; min-height: 76px; align-items: center; justify-content: space-between; gap: 20px; padding: 17px 22px; border-bottom: 1px solid var(--line); }
.canvas-head h2 { margin: 0; font-size: 15px; }
.canvas-head p { margin: 6px 0 0; color: var(--muted); font-size: 11px; }
.canvas-controls { display: grid; justify-items: end; gap: 9px; }
.legend { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; white-space: nowrap; }
.legend i { width: 8px; height: 8px; border-radius: 2px; background: #5b87eb; }
.legend i.reserved { margin-left: 7px; background: #d9dfe6; }

.zoom-controls {
  display: inline-grid;
  grid-template-columns: 26px 44px 26px;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
}

.zoom-controls button { height: 25px; padding: 0; color: var(--ink-soft); border: 0; background: transparent; cursor: pointer; }
.zoom-controls button:hover:not(:disabled) { color: var(--blue); background: var(--blue-soft); }
.zoom-controls button:disabled { cursor: not-allowed; opacity: 0.35; }
.zoom-controls strong { color: var(--muted); border-inline: 1px solid var(--line); font-family: var(--mono); font-size: 9px; font-weight: 600; line-height: 25px; text-align: center; }

.address-canvas {
  position: relative;
  min-height: 520px;
  padding: 25px 22px 26px 66px;
  background-image: linear-gradient(to bottom, rgb(226 231 237 / 36%) 1px, transparent 1px);
  background-size: 100% 65px;
}

.range-rail {
  position: absolute;
  top: 26px;
  bottom: 28px;
  left: 31px;
  width: 18px;
  border-left: 2px solid #c8d0da;
}

.range-rail::before,
.range-rail::after {
  position: absolute;
  left: -2px;
  width: 9px;
  height: 2px;
  background: #c8d0da;
  content: "";
}

.range-rail::before { top: 0; }
.range-rail::after { bottom: 0; }

.rail-label {
  position: absolute;
  left: -15px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  transform: rotate(-90deg);
  transform-origin: center;
  white-space: nowrap;
}

.rail-label.start { top: 32px; }
.rail-label.end { bottom: 30px; }

.canvas-meta { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; color: var(--muted); font-size: 10px; }
.canvas-meta strong { color: var(--ink-soft); font-family: var(--mono); font-size: 11px; }

.subnet-track {
  position: relative;
  min-height: 0;
  overflow: visible;
  border: 1px solid #e0e5ec;
  border-radius: 7px;
  background: #f8fafc;
}

.track-line {
  position: absolute;
  z-index: 0;
  right: 0;
  left: 0;
  height: 1px;
  border-top: 1px solid #e6eaf0;
  pointer-events: none;
}

.track-line small {
  position: absolute;
  top: 4px;
  right: 7px;
  color: #a2abb6;
  font-family: var(--mono);
  font-size: 8px;
}

.free-range {
  position: absolute;
  z-index: 1;
  right: 3px;
  left: 3px;
  overflow: hidden;
  color: #a0a9b5;
  border: 1px dashed rgb(201 209 219 / 70%);
  border-radius: 5px;
  background: rgb(246 248 251 / 56%);
  pointer-events: none;
}

.free-range span { display: block; padding: 5px 8px; font-family: var(--mono); font-size: 8px; }
.free-range.micro { border-top-style: solid; border-right: 0; border-bottom: 0; border-left: 0; border-radius: 0; }
.free-range.micro span { display: none; }

.subnet-block {
  position: absolute;
  z-index: 3;
  right: 5px;
  left: 5px;
  display: grid;
  grid-template-columns: 16px minmax(120px, 1fr) auto;
  min-height: 0;
  align-items: center;
  gap: 7px;
  overflow: hidden;
  padding: 4px 10px 4px 5px;
  color: #fff;
  border-radius: 6px;
  cursor: grab;
  touch-action: none;
  transition: top 130ms ease, height 130ms ease, box-shadow 130ms ease, opacity 130ms ease;
  will-change: top, height;
}

.subnet-block:hover { z-index: 5; box-shadow: 0 7px 20px rgb(32 52 84 / 20%); }
.subnet-block.selected { z-index: 6; outline: 3px solid rgb(50 107 230 / 28%); outline-offset: 2px; }
.subnet-block.manipulating { z-index: 9; cursor: grabbing; opacity: 0.92; transition: box-shadow 130ms ease; box-shadow: 0 12px 30px rgb(26 43 70 / 28%); }
.subnet-block.invalid-placement { outline: 3px solid rgb(212 55 74 / 65%); background: #c34150 !important; }
.subnet-block.merge-target,
.merge-target { z-index: 8; outline: 4px solid rgb(20 138 91 / 45%); outline-offset: 2px; }
.subnet-block.reserved { color: #536172; border: 1px dashed #aeb9c6; background: #e7ebf0 !important; }
.subnet-block.compact { grid-template-columns: 14px minmax(150px, 1fr); padding-block: 1px; }
.subnet-block.compact .block-size { display: none; }
.subnet-block.micro { min-height: 0; overflow: visible; padding: 0; border-radius: 1px; }
.subnet-block.micro::before {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: -3px;
  width: 34px;
  height: 18px;
  content: "";
  transform: translateY(-50%);
}
.subnet-block.micro::after {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 5px;
  width: 7px;
  height: 7px;
  border: 1px solid rgb(255 255 255 / 82%);
  border-radius: 50%;
  background: var(--block-color);
  box-shadow: 0 1px 4px rgb(26 43 70 / 28%);
  content: "";
  transform: translateY(-50%);
}
.subnet-block.micro.reserved::after { border-color: #8793a2; background: #e7ebf0; }
.subnet-block.micro:hover { box-shadow: 0 0 0 3px rgb(50 107 230 / 15%); }
.subnet-block.micro .drag-grip,
.subnet-block.micro .block-fields,
.subnet-block.micro .block-size,
.subnet-block.micro .resize-handle { display: none; }

.drag-grip { color: rgb(255 255 255 / 66%); font-size: 13px; cursor: grab; }
.reserved .drag-grip { color: #8d98a6; }
.block-fields { display: grid; min-width: 0; grid-template-columns: minmax(84px, 0.75fr) minmax(112px, 1fr); gap: 6px; }
.block-name,
.block-cidr {
  width: 100%;
  min-width: 0;
  padding: 3px 5px;
  overflow: hidden;
  color: inherit;
  border: 1px solid transparent;
  border-radius: 4px;
  outline: 0;
  background: transparent;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.block-name { font-weight: 700; }
.block-cidr { font-family: var(--mono); font-size: 10px; opacity: 0.9; }
.block-name:hover,
.block-name:focus,
.block-cidr:hover,
.block-cidr:focus { border-color: rgb(255 255 255 / 48%); background: rgb(255 255 255 / 15%); }
.reserved .block-name:hover,
.reserved .block-name:focus,
.reserved .block-cidr:hover,
.reserved .block-cidr:focus { border-color: #adb8c5; background: rgb(255 255 255 / 60%); }
.block-size { font-size: 9px; opacity: 0.82; white-space: nowrap; }

.resize-handle {
  position: absolute;
  z-index: 11;
  right: 7px;
  left: 7px;
  height: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: ns-resize;
}
.resize-handle.top { top: -3px; }
.resize-handle.bottom { bottom: -3px; }
.resize-handle::after { position: absolute; left: 50%; width: 24px; height: 2px; border-radius: 2px; background: rgb(255 255 255 / 70%); content: ""; transform: translateX(-50%); }
.resize-handle.top::after { top: 3px; }
.resize-handle.bottom::after { bottom: 3px; }
.reserved .resize-handle::after { background: #97a3b1; }

.subnet-block.micro.selected { z-index: 12; }
.subnet-block.micro.selected .block-fields,
.subnet-block.micro:focus-within .block-fields {
  position: absolute;
  z-index: 14;
  top: 50%;
  right: 18px;
  left: 38px;
  display: grid;
  min-height: 34px;
  align-items: center;
  padding: 5px 7px;
  border: 1px solid rgb(255 255 255 / 34%);
  border-radius: 6px;
  background: var(--block-color);
  box-shadow: 0 8px 24px rgb(26 43 70 / 28%);
  transform: translateY(-50%);
}
.subnet-block.micro.reserved.selected .block-fields,
.subnet-block.micro.reserved:focus-within .block-fields { border-color: #aeb9c6; background: #e7ebf0; }
.subnet-block.micro.selected .resize-handle,
.subnet-block.micro:focus-within .resize-handle { display: block; }
.subnet-block.micro.selected .resize-handle.top,
.subnet-block.micro:focus-within .resize-handle.top { top: -12px; }
.subnet-block.micro.selected .resize-handle.bottom,
.subnet-block.micro:focus-within .resize-handle.bottom { bottom: -12px; }

.micro-picker {
  position: absolute;
  z-index: 30;
  left: 38px;
  width: min(286px, calc(100% - 56px));
  overflow: hidden;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 34px rgb(26 43 70 / 25%);
}
.micro-picker-head {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  padding: 6px 7px 6px 11px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.micro-picker-head button { width: 25px; height: 25px; padding: 0; color: var(--muted); border: 0; border-radius: 4px; background: transparent; cursor: pointer; }
.micro-picker-head button:hover { color: var(--ink); background: var(--blue-soft); }
.micro-picker-list { max-height: 230px; overflow: auto; padding: 4px; }
.micro-picker-list button {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 8px;
  color: var(--ink);
  border: 0;
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.micro-picker-list button:hover,
.micro-picker-list button:focus-visible { outline: 0; background: var(--blue-soft); }
.micro-picker-list strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.micro-picker-list small { color: var(--muted); font-family: var(--mono); font-size: 9px; }

body.is-manipulating { cursor: grabbing; user-select: none; }

.inspector { min-height: 600px; overflow: auto; padding: 21px; }
.inspector-empty { padding: 155px 16px 30px; color: var(--muted); text-align: center; }
.inspector-empty h2 { margin: 0; color: var(--ink); font-size: 16px; }
.inspector-empty p { margin: 8px 0 0; font-size: 12px; line-height: 1.5; }
.inspector-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.inspector-head h2 { margin: 6px 0 0; font-size: 16px; }
.color-dot { width: 13px; height: 13px; border-radius: 3px; }
.field { margin-top: 16px; }
.field input,
.field textarea,
.field select { width: 100%; margin-top: 6px; padding: 9px 10px; font-family: var(--mono); font-size: 12px; }
.field textarea { min-height: 112px; resize: vertical; line-height: 1.5; }
.field-hint { display: block; margin-top: 6px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.field-error { display: block; min-height: 15px; margin-top: 5px; color: var(--red); font-size: 10px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; margin-top: 18px; }
.detail-grid div { padding: 9px 0; border-bottom: 1px solid var(--line); }
.detail-grid span { display: block; color: var(--muted); font-size: 9px; letter-spacing: 0.06em; text-transform: uppercase; }
.detail-grid strong { display: block; overflow: hidden; margin-top: 5px; font-family: var(--mono); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.inspector-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 20px; }
.inspector-actions .wide { grid-column: 1 / -1; }
.compact-fields { gap: 10px; }
.compact-fields .field { min-width: 0; }

.modal-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  overflow: auto;
  place-items: center;
  padding: 24px;
  background: rgb(10 18 31 / 58%);
  backdrop-filter: blur(3px);
  animation: backdrop-in 150ms ease both;
}

.modal {
  position: relative;
  width: min(650px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 32px;
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
  animation: modal-in 180ms ease both;
}

.modal.wide { width: min(760px, 100%); }
.modal.small { width: min(450px, 100%); }
.modal h2 { margin: 7px 0 8px; font-size: 25px; letter-spacing: -0.7px; }
.modal > p { margin: 0; color: var(--muted); line-height: 1.55; }
.modal-close { position: absolute; top: 14px; right: 15px; display: grid; width: 34px; height: 34px; place-items: center; color: #7e8996; border: 0; border-radius: 7px; background: transparent; cursor: pointer; font-size: 22px; }
.modal-close:hover { background: #f1f3f6; color: var(--ink); }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }

.start-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 24px 0 20px; }
.start-option { min-height: 140px; padding: 17px; color: var(--ink-soft); border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; cursor: pointer; text-align: left; }
.start-option:hover { border-color: #adc0e8; }
.start-option.active { color: var(--blue-dark); border-color: var(--blue); background: var(--blue-soft); box-shadow: inset 0 0 0 1px var(--blue); }
.start-option .option-icon { display: grid; width: 34px; height: 34px; margin-bottom: 15px; place-items: center; border-radius: 8px; background: #f0f3f7; font-family: var(--mono); font-size: 16px; }
.start-option.active .option-icon { background: #dce7ff; }
.start-option strong,
.start-option small { display: block; }
.start-option small { margin-top: 7px; color: var(--muted); font-size: 11px; line-height: 1.45; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form-grid .full { grid-column: 1 / -1; }

.import-modal { display: flex; overflow: hidden; flex-direction: column; padding: 0; }
.import-modal-scroll { min-height: 0; overflow: auto; padding: 32px 32px 0; }
.import-modal-scroll > p { margin: 0; color: var(--muted); line-height: 1.55; }
.import-modal .modal-close { z-index: 3; }
.import-modal .modal-footer { flex: 0 0 auto; margin: 0; padding: 18px 32px 24px; background: #fff; }
.import-modal code { font-family: var(--mono); font-size: 0.92em; }
.import-warning { margin-top: 14px !important; padding: 10px 12px; color: #72521b !important; border: 1px solid #ead4a7; border-radius: 7px; background: #fff9ec; font-size: 11px; }
.import-drop-zone {
  display: flex;
  width: 100%;
  min-height: 112px;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin-top: 22px;
  padding: 20px;
  color: var(--ink-soft);
  border: 1px dashed #aebbd0;
  border-radius: 9px;
  background: #f8fafc;
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}
.import-drop-zone:hover,
.import-drop-zone:focus-visible,
.import-drop-zone.dragover { border-color: var(--blue); background: var(--blue-soft); box-shadow: inset 0 0 0 1px var(--blue); }
.import-drop-zone:focus-visible { outline: 2px solid rgb(50 107 230 / 28%); outline-offset: 2px; }
.import-drop-icon { display: grid; width: 42px; height: 42px; flex: 0 0 auto; place-items: center; color: var(--blue); border-radius: 10px; background: #e6edff; font-size: 22px; font-weight: 750; }
.import-drop-copy,
.import-drop-copy > strong,
.import-drop-copy > span,
.import-drop-copy > small { display: block; }
.import-drop-copy > strong { font-size: 13px; }
.import-drop-copy > span { margin-top: 5px; color: var(--muted); font-size: 11px; }
.import-drop-copy > small { margin-top: 8px; color: #8b96a4; font-family: var(--mono); font-size: 9px; }
.import-drop-zone .import-browse-copy { display: inline; color: var(--blue); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.import-divider { display: flex; align-items: center; gap: 10px; margin: 17px 0 12px; color: #9aa4b1; font-size: 9px; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; }
.import-divider::before,
.import-divider::after { height: 1px; flex: 1; background: var(--line); content: ""; }
.import-paste-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; }
.import-yaml-text {
  width: 100%;
  min-height: 220px;
  padding: 15px;
  color: #dce7f8;
  border: 1px solid #26344c;
  border-radius: 8px;
  outline: 0;
  background: #172236;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.55;
  resize: vertical;
  tab-size: 2;
  white-space: pre;
}
.import-yaml-text:focus { border-color: #648bed; box-shadow: 0 0 0 3px rgb(50 107 230 / 18%); }
.import-yaml-text[aria-invalid="true"] { border-color: #d76574; box-shadow: 0 0 0 3px rgb(212 55 74 / 12%); }
.import-feedback { display: flex; min-height: 44px; align-items: flex-start; gap: 10px; padding: 11px 1px 3px; color: var(--muted); }
.import-feedback-dot { width: 8px; height: 8px; flex: 0 0 auto; margin-top: 4px; border-radius: 50%; background: #a7b0bd; }
.import-feedback strong,
.import-feedback small { display: block; }
.import-feedback strong { color: var(--ink-soft); font-size: 11px; }
.import-feedback small { margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.import-feedback.checking .import-feedback-dot { background: var(--amber); }
.import-feedback.ready .import-feedback-dot { background: var(--green); box-shadow: 0 0 0 4px rgb(20 138 91 / 10%); }
.import-feedback.ready strong { color: var(--green); }
.import-feedback.error .import-feedback-dot { background: var(--red); box-shadow: 0 0 0 4px rgb(212 55 74 / 9%); }
.import-feedback.error strong,
.import-feedback.error small { color: var(--red); }
.import-preview { display: grid; grid-template-columns: 1.35fr 1fr 0.8fr 1fr; margin-top: 10px; border-block: 1px solid var(--line); }
.import-preview div { min-width: 0; padding: 12px 12px 12px 0; }
.import-preview div + div { padding-left: 12px; border-left: 1px solid var(--line); }
.import-preview span,
.import-preview strong,
.import-preview small { display: block; }
.import-preview span { color: var(--muted); font-size: 8px; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; }
.import-preview strong { overflow: hidden; margin-top: 6px; font-family: var(--mono); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.import-preview small { margin-top: 4px; color: var(--muted); font-size: 9px; }

.export-types { display: flex; flex-wrap: wrap; gap: 7px; margin: 21px 0 14px; }
.export-type { padding: 7px 10px; color: #596576; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; cursor: pointer; font-size: 11px; font-weight: 650; }
.export-type:hover { border-color: #a8bce7; }
.export-type.active { color: var(--blue-dark); border-color: #9db8f2; background: var(--blue-soft); }
.code-preview { height: 210px; overflow: auto; margin: 0; padding: 15px; color: #dbe7ff; border-radius: 7px; background: #172236; font-family: var(--mono); font-size: 10px; line-height: 1.55; white-space: pre; }

.toast {
  position: fixed;
  z-index: 30;
  bottom: 24px;
  left: 50%;
  max-width: calc(100vw - 36px);
  padding: 11px 15px;
  color: #fff;
  border-radius: 7px;
  background: #172236;
  box-shadow: 0 10px 30px rgb(17 27 45 / 24%);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
  font-size: 12px;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes page-in { from { opacity: 0; transform: translateY(5px); } }
@keyframes backdrop-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(9px) scale(0.985); } }

@media (max-width: 1340px) {
  .app-shell { grid-template-columns: 72px minmax(0, 1fr); }
  .sidebar { padding-inline: 10px; }
  .brand { justify-content: center; padding-inline: 0; }
  .brand-name,
  .nav-item span,
  .local-note div { display: none; }
  .nav-item { justify-content: center; }
  .local-note { justify-content: center; padding-inline: 0; }
  .workspace { grid-template-columns: minmax(400px, 1fr) 230px 260px; }
}

@media (max-width: 1080px) {
  .statbar { overflow-x: auto; grid-template-columns: repeat(4, minmax(145px, 1fr)); }
  .capacity-stat { display: none; }
  .workspace { grid-template-columns: minmax(440px, 1fr) 270px; }
  .canvas-panel { grid-row: 1 / span 2; }
  .yaml-panel,
  .inspector { position: static; max-height: none; grid-column: 2; }
  .inspector { min-height: auto; }
  .inspector-empty { padding: 38px 16px; }
}

@media (max-width: 1060px) {
  .dashboard { padding: 30px 22px 45px; }
  .plan-row { grid-template-columns: 38px minmax(180px, 1fr) 120px 100px; }
  .plan-row > :nth-child(3),
  .plan-row > :nth-child(4) { display: none; }
}

@media (max-width: 900px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .canvas-panel,
  .yaml-panel,
  .inspector { grid-column: auto; grid-row: auto; }
  .yaml-panel { min-height: 520px; }
}

@media (max-width: 800px) {
  .topbar,
  .editor-heading,
  .editor-toolbar,
  .workspace { padding-left: 22px; padding-right: 22px; }
  .top-actions .button:not(.primary) { display: none; }
}

@media (max-width: 620px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: 59px; flex-direction: row; align-items: center; padding: 0 14px; }
  .brand { width: auto; padding: 0; }
  .brand-name { display: inline; }
  .sidebar nav { margin-left: auto; }
  .nav-item { width: auto; }
  .nav-item span { display: inline; }
  .local-note { display: none; }
  .topbar { min-height: 60px; padding-inline: 16px; }
  .dashboard { padding-inline: 16px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .page-heading .button { width: 100%; }
  .page-actions { width: 100%; }
  .page-actions .button { width: auto; flex: 1; }
  .dashboard-summary { gap: 22px; overflow-x: auto; }
  .section-toolbar { align-items: flex-start; flex-direction: column; }
  .search-wrap,
  .search-wrap input { width: 100%; }
  .plan-row { grid-template-columns: 34px minmax(150px, 1fr) 72px; padding-inline: 8px; }
  .plan-row > :nth-child(3),
  .plan-row > :nth-child(4),
  .plan-row > :nth-child(5) { display: none; }
  .editor-heading,
  .editor-toolbar,
  .workspace { padding-left: 14px; padding-right: 14px; }
  .editor-heading { align-items: flex-start; flex-direction: column; }
  .editor-toolbar { align-items: flex-start; flex-direction: column; }
  .address-canvas { padding-left: 52px; padding-right: 12px; }
  .range-rail { left: 24px; }
  .canvas-head { align-items: flex-start; flex-direction: column; }
  .canvas-controls { width: 100%; align-items: center; grid-auto-flow: column; justify-content: space-between; }
  .block-name { width: 47%; }
  .block-size { display: none; }
  .modal { padding: 27px 19px 22px; }
  .import-modal { padding: 0; }
  .import-modal-scroll { padding: 27px 19px 0; }
  .import-modal .modal-footer { padding: 14px 19px 18px; box-shadow: 0 -8px 18px rgb(17 27 45 / 7%); }
  .import-drop-zone { min-height: 92px; padding: 15px; }
  .import-yaml-text { min-height: 160px; }
  .import-preview { grid-template-columns: 1fr 1fr; }
  .import-preview div:nth-child(3) { border-left: 0; }
  .import-preview div:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .import-modal .modal-footer .button { flex: 1; }
  .start-options,
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 1ms !important; transition-duration: 1ms !important; }
}

@media print {
  .sidebar,
  .topbar,
  .editor-toolbar,
  .yaml-panel,
  .inspector,
  .toast { display: none !important; }
  .app-shell { display: block; }
  .workspace { display: block; padding: 0; }
  .canvas-panel { border: 0; }
  .editor-heading,
  .statbar { padding-inline: 0; }
  body { background: #fff; }
}
