* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Roboto", Arial, sans-serif;
  color: #111827;
  background: #f8fafc;
}

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

a {
  color: #1d4ed8;
}

.app-navbar {
  min-height: 72px;
  padding: 0;
  background: #0f172a;
  border-bottom: 1px solid #1e293b;
}

.top-panel {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: none;
  min-height: 72px;
  margin: 0;
  padding: .75rem 1.5rem;
  background: #0f172a;
  border: 0;
  border-radius: 0;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .18);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  color: #f8fafc;
  white-space: nowrap;
}

.brand-icon {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: #fff;
  font-size: 1.12rem;
  background: #2563eb;
  border: 1px solid rgba(191, 219, 254, .35);
  border-radius: 10px;
  box-shadow: inset 0 -8px 18px rgba(15, 23, 42, .24);
}

.brand-icon i {
  line-height: 1;
}

.btn-nav {
  color: #e2e8f0;
  border-color: #334155;
  background: #1e293b;
}

.btn-nav:hover {
  color: #fff;
  border-color: #60a5fa;
  background: #1d4ed8;
}

.nav-actions {
  margin-left: auto;
  justify-content: flex-end;
}

.home-screen {
  min-height: calc(100vh - 64px);
  background:
    radial-gradient(circle at 15% 20%, rgba(37, 99, 235, .12), transparent 28%),
    linear-gradient(135deg, #eef2ff, #ecfeff 58%, #f8fafc);
}

.home-hero {
  padding-top: clamp(3rem, 8vh, 5.5rem);
  padding-bottom: clamp(2rem, 6vh, 4rem);
}

.hero-kicker {
  width: fit-content;
  margin-bottom: 1rem;
  padding: .35rem .65rem;
  color: #1d4ed8;
  font-size: .82rem;
  font-weight: 700;
  background: #dbeafe;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
}

.home-hero h1 {
  margin: 0 0 1rem;
  color: #0f172a;
}

.home-hero .lead {
  max-width: 680px;
  color: #475569;
  line-height: 1.55;
}

.hero-actions {
  margin-top: 1.5rem;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
  margin-top: 1.35rem;
  color: #334155;
  font-size: .94rem;
}

.hero-stats span {
  padding: .45rem .65rem;
  background: rgba(255, 255, 255, .76);
  border: 1px solid #dbeafe;
  border-radius: 8px;
}

.preview-board {
  position: relative;
  height: 330px;
  overflow: hidden;
  background:
    linear-gradient(to right, rgba(148, 163, 184, .25) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(148, 163, 184, .25) 1px, transparent 1px),
    #fff;
  background-size: 24px 24px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .14);
}

.preview-board:after {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px dashed #bfdbfe;
  border-radius: 8px;
  pointer-events: none;
}

.preview-board svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.preview-board line {
  stroke: #2563eb;
  stroke-width: 5;
  stroke-linecap: round;
}

.preview-node {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 104px;
  height: 72px;
  color: #0f172a;
  font-weight: 700;
  background: #fff;
  border: 2px solid #334155;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, .12);
}

.preview-node.pc {
  left: 38px;
  top: 50px;
}

.preview-node.switch {
  left: 150px;
  top: 132px;
  background: #ecfeff;
  border-color: #0891b2;
}

.preview-node.router {
  right: 30px;
  top: 56px;
  background: #fef3c7;
  border-color: #b45309;
}

.auth-panel {
  max-width: 620px;
  padding-top: 3rem;
}

.form-card {
  padding: 1.25rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.select2-container {
  width: 100% !important;
  font-family: "Roboto", Arial, sans-serif;
}

.select2-container--default .select2-selection--single {
  height: 42px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
  color: #111827;
  line-height: 40px;
  padding-left: .7rem;
  padding-right: 2rem;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 40px;
  right: .35rem;
}

.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
  border-color: #60a5fa;
  box-shadow: 0 0 0 .18rem rgba(37, 99, 235, .12);
}

.select2-dropdown {
  overflow: hidden;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(15, 23, 42, .14);
}

.select2-results__option {
  padding: .55rem .7rem;
  font-family: "Roboto", Arial, sans-serif;
}

.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
  background: #2563eb;
}

.page-pad {
  padding-top: 2rem;
  padding-bottom: 2rem;
}

.dashboard-actions {
  display: grid;
  gap: .65rem;
  width: min(620px, 100%);
}

.create-diagram-form {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(180px, .8fr) auto;
  gap: .55rem;
  align-items: start;
  max-width: 620px;
}

.import-diagram-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .55rem;
  width: min(520px, 100%);
  padding: .65rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.create-diagram-form .select2-container--default .select2-selection--single {
  height: 42px;
}

.create-diagram-form .select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 40px;
}

.create-diagram-form .select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 40px;
}

.custom-canvas-size {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .45rem;
  grid-column: 1 / -1;
}

.editor-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100vh - 64px);
  min-height: 640px;
}

.tool-panel {
  padding: 1rem;
  overflow: auto;
  background: #fff;
  border-right: 1px solid #e5e7eb;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(5, 42px);
  gap: .45rem;
  align-items: center;
}

.tool-icon-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  cursor: pointer;
}

.tool-icon-btn:hover,
.tool-icon-btn:focus {
  color: #fff;
  background: #2563eb;
  border-color: #2563eb;
  outline: 0;
}

.tool-icon-btn svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.connection-panel {
  padding: .75rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.connection-title {
  margin-bottom: .55rem;
  color: #334155;
  font-size: .82rem;
  font-weight: 700;
}

.connection-panel .select2-container {
  margin-bottom: .55rem;
}

.connection-panel .select2-container--default .select2-selection--single {
  height: 34px;
  border-radius: 8px;
}

.connection-panel .select2-container--default .select2-selection--single .select2-selection__rendered {
  font-size: .86rem;
  line-height: 32px;
  padding-left: .6rem;
}

.connection-panel .select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 32px;
}

.connection-fields {
  margin-top: .1rem;
}

.compact-input {
  min-height: 34px;
  padding: .35rem .5rem;
  font-size: .86rem;
  border-radius: 8px;
}

.form-control-color.compact-input {
  height: 34px;
}

.canvas-wrap {
  position: relative;
  overflow: auto;
  background: #e2e8f0;
}

.canvas-wrap.is-panning {
  cursor: grabbing;
  user-select: none;
}

.canvas-stage {
  position: relative;
  min-width: 100%;
  min-height: 100%;
}

.diagram-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 1600px;
  height: 1600px;
  transform-origin: top left;
  background-size: 24px 24px;
  background-image:
    linear-gradient(to right, #cbd5e1 1px, transparent 1px),
    linear-gradient(to bottom, #cbd5e1 1px, transparent 1px);
}

.zoom-controls {
  position: sticky;
  top: .75rem;
  left: calc(100% - 9.75rem);
  z-index: 7;
  display: flex;
  gap: .4rem;
  width: max-content;
  padding: .3rem;
  margin: .75rem .75rem -3.2rem auto;
  background: rgba(15, 23, 42, .86);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, .2);
}

.public-zoom-controls {
  left: calc(100% - 7rem);
}

.zoom-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: #0f172a;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  cursor: pointer;
}

.zoom-btn:hover,
.zoom-btn:focus {
  color: #fff;
  background: #2563eb;
  border-color: #2563eb;
  outline: 0;
}

.zoom-btn i {
  font-size: 1.1rem;
  line-height: 1;
}

.group-layer,
.link-layer,
.node-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.group-layer {
  z-index: 0;
  pointer-events: none;
}

.link-layer {
  z-index: 1;
  overflow: visible;
  pointer-events: none;
}

.node-layer {
  z-index: 2;
  pointer-events: none;
}

.diagram-node {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .28rem;
  min-width: 64px;
  min-height: 54px;
  padding: .45rem;
  color: #0f172a;
  text-align: center;
  background: #fff;
  border: 2px solid #334155;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, .08);
  cursor: move;
  pointer-events: auto;
  user-select: none;
}

.diagram-node.selected {
  outline: 3px solid #38bdf8;
}

.diagram-node.multi-selected {
  outline-color: #2563eb;
  box-shadow: 0 0 0 5px rgba(37, 99, 235, .14), 0 8px 20px rgba(15, 23, 42, .08);
}

.node-icon {
  display: grid;
  place-items: center;
  width: min(42px, 42%);
  min-width: 30px;
  max-width: 56px;
  aspect-ratio: 1;
  color: currentColor;
  pointer-events: none;
}

.node-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.node-label {
  display: block;
  max-width: 100%;
  overflow: hidden;
  color: #1f2937;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-ip {
  display: block;
  max-width: 100%;
  overflow: hidden;
  color: #475569;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.diagram-node:not(.group) {
  overflow: hidden;
}

.diagram-node.computer {
  background: #fff;
  border-color: #334155;
}

.diagram-node.switch {
  color: #0e7490;
  background: #ecfeff;
  border-color: #0891b2;
}

.diagram-node.router {
  color: #92400e;
  background: #fef3c7;
  border-color: #b45309;
}

.diagram-node.label {
  color: #9a3412;
  background: #fff7ed;
  border-style: dashed;
  border-color: #fb923c;
}

.diagram-node.group {
  align-items: flex-start;
  justify-content: flex-start;
  color: #475569;
  background: rgba(248, 250, 252, .18);
  border-style: dashed;
  border-color: rgba(100, 116, 139, .6);
  box-shadow: none;
  opacity: .72;
}

.diagram-node.group .node-icon {
  width: 34px;
}

.diagram-node .resize-handle {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 14px;
  height: 14px;
  background: #2563eb;
  border-radius: 3px;
  cursor: nwse-resize;
}

.diagram-link {
  cursor: pointer;
  pointer-events: stroke;
}

.diagram-link-hit {
  cursor: pointer;
  pointer-events: stroke;
}

.diagram-link.selected {
  filter: drop-shadow(0 0 4px #38bdf8);
}

.link-label {
  font-size: 13px;
  fill: #111827;
  stroke: #fff;
  stroke-width: 4px;
  paint-order: stroke;
  cursor: pointer;
  pointer-events: auto;
}

.selection-actions {
  position: absolute;
  z-index: 6;
  display: flex;
  gap: .35rem;
  padding: .25rem;
  background: rgba(15, 23, 42, .86);
  border-radius: 8px;
}

.selection-action-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: #0f172a;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  cursor: pointer;
}

.selection-action-btn:hover,
.selection-action-btn:focus {
  color: #fff;
  background: #2563eb;
  border-color: #2563eb;
  outline: 0;
}

.selection-action-danger {
  color: #b91c1c;
}

.selection-action-danger:hover,
.selection-action-danger:focus {
  color: #fff;
  background: #dc2626;
  border-color: #dc2626;
}

.selection-action-btn i {
  display: block;
  font-size: 1rem;
  line-height: 1;
}

.node-connections {
  padding-top: .8rem;
  border-top: 1px solid #e5e7eb;
}

.node-connections-list {
  display: grid;
  gap: .45rem;
}

.node-connection-row {
  display: grid;
  grid-template-columns: 1fr 34px 34px;
  gap: .35rem;
  align-items: center;
  padding: .4rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.node-connection-text {
  overflow: hidden;
  color: #334155;
  font-size: .86rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-connections-empty {
  padding: .55rem .65rem;
  color: #64748b;
  font-size: .86rem;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, .45);
}

.modal-card {
  width: min(460px, calc(100vw - 2rem));
  padding: 1.25rem;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .24);
}

.public-header {
  padding: 1rem 1.5rem;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
}

.public-header h1 {
  margin: 0;
  font-size: 1.5rem;
}

.public-wrap {
  height: calc(100vh - 120px);
}

.readonly .diagram-node {
  cursor: default;
}

.readonly .resize-handle {
  display: none;
}

@media (max-width: 850px) {
  .top-panel {
    gap: .75rem;
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .hero-actions {
    flex-wrap: wrap;
  }

  .create-diagram-form {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .import-diagram-form {
    grid-template-columns: 1fr;
  }

  .editor-shell {
    grid-template-columns: 1fr;
    height: auto;
  }

  .tool-panel {
    border-right: 0;
    border-bottom: 1px solid #e5e7eb;
  }

  .canvas-wrap {
    height: 70vh;
  }
}
