/*
 * Copyright © 2026 Chaeseong Lim.
 * This software and its underlying algorithms may not be copied, modified, distributed, reverse engineered, or used to create derivative works without explicit written permission.
 */

:root {
  color-scheme: light;
  font-family:
    "Pretendard", Arial, sans-serif;
  --bg: #eef5ff;
  --ink: #0f172a;
  --muted: #5b6b86;
  --line: #c8d8ee;
  --panel: #ffffff;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --leaf: #2563eb;
  --spine: #b45309;
  --server: #475569;
}

@font-face {
  font-family: "Pretendard";
  src: url("../fonts/Pretendard-1.3.9/web/static/woff2-subset/Pretendard-Regular.subset.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Pretendard";
  src: url("../fonts/Pretendard-1.3.9/web/static/woff2-subset/Pretendard-Medium.subset.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Pretendard";
  src: url("../fonts/Pretendard-1.3.9/web/static/woff2-subset/Pretendard-SemiBold.subset.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Pretendard";
  src: url("../fonts/Pretendard-1.3.9/web/static/woff2-subset/Pretendard-Bold.subset.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Pretendard";
  src: url("../fonts/Pretendard-1.3.9/web/static/woff2-subset/Pretendard-ExtraBold.subset.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Pretendard";
  src: url("../fonts/Pretendard-1.3.9/web/static/woff2-subset/Pretendard-Black.subset.woff2") format("woff2");
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
}

.app {
  position: relative;
  width: 100%;
  max-width: 1320px;
  margin: 0;
  height: 100vh;
  padding: 20px 20px 74px;
  overflow: hidden;
}

.app-footer {
  position: absolute;
  right: 20px;
  bottom: 20px;
  left: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin: 0;
  color: #000;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
}

.app-footer-version {
  flex: 0 0 auto;
}

.app-footer-right {
  min-width: 0;
  text-align: right;
}

.app-footer-notice,
.app-footer-contact {
  margin: 0;
}

.app-footer-notice {
  white-space: nowrap;
}

.app-footer-contact {
  margin-top: 2px;
}

.app-footer-notice-text::before {
  content: "\203B";
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", "Segoe UI Symbol", sans-serif;
  margin-right: 0.35em;
}

.workspace {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  height: 100%;
  min-height: 0;
}

.sidebar {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
  height: 100%;
  min-height: 0;
}

.sidebar-scroll {
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
}

.panel,
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.09);
}

.inputs {
  display: grid;
  gap: 12px;
  padding: 20px;
}

.panel-header {
  position: relative;
  min-height: 106px;
  padding: 20px;
  text-align: center;
}
.panel-header h1 {
  margin: 6px 0 4px;
  font-size: 25px;
  line-height: 1.25;
}

.title-lockup {
  display: inline-grid;
  justify-items: stretch;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.1;
  white-space: nowrap;
}

.title-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
}

.title-credit {
  color: #000;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  text-align: right;
}

.section-title {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--accent-dark);
  font-size: 16px;
  font-weight: 900;
}

.inputs > .section-title:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.section-title-with-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.title-check {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.title-check input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.title-check span {
  font-weight: 600;
}

.subsection-title {
  margin-top: 2px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

input {
  width: 100%;
  border: 1px solid #c8d0cb;
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
  font: inherit;
  background: #fff;
}

select {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 34px 0 12px;
  color: var(--ink);
  font: inherit;
  font-weight: 900;
  background: #fff;
}

input:focus {
  outline: 3px solid rgba(37, 99, 235, 0.16);
  border-color: var(--accent);
}

select:focus {
  outline: 3px solid rgba(37, 99, 235, 0.16);
  border-color: var(--accent);
}

.inline-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.inline-field span {
  color: var(--muted);
  font-weight: 800;
}

.field-note {
  display: block;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.55;
}

.node-twin-notice {
  margin-top: -6px;
  pointer-events: none;
}

.check-row {
  grid-template-columns: 18px 1fr;
  gap: 10px;
  align-items: center;
}

.check-row span {
  font-weight: 500;
}

.check-row input {
  width: 18px;
  height: 18px;
}

.sub-check-row {
  margin-top: -4px;
}

.check-row.is-disabled {
  color: var(--muted);
  opacity: 0.58;
}

label.is-disabled,
label:has(input:disabled) {
  opacity: 0.58;
}

label.is-disabled input,
label:has(input:disabled) input {
  cursor: not-allowed;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segmented label {
  display: block;
  position: relative;
}

.segmented input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.segmented span {
  display: grid;
  min-height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f9faf8;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  pointer-events: none;
}

.segmented input:checked + span {
  border-color: var(--accent);
  background: #dbeafe;
  color: var(--accent-dark);
}

.hidden {
  display: none;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

.form-actions-separator {
  height: 0;
  margin-top: 8px;
  border-top: 1px solid var(--line);
}

.inputs button[type="submit"] {
  margin-top: 8px;
}

.save-report {
  width: 100%;
  background: #0f766e;
}

.save-report:hover {
  background: #115e59;
}

.reset-inputs {
  display: block;
  width: 100%;
  background: #64748b;
}

.reset-inputs:hover {
  background: #475569;
}

.input-transfer-menu .export-menu-list {
  left: 0;
  right: auto;
  width: 100%;
}

.hidden-file-input {
  display: none;
}

#resetInputs {
  background: #dc2626;
}

#resetInputs:hover {
  background: #b91c1c;
}

.results {
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: contain;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
}

.results-scroll {
  display: grid;
  gap: 16px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
}

.summary-shell {
  position: relative;
}

.language-control {
  display: inline-flex;
  align-items: center;
}

.language-control select {
  min-height: 26px;
  padding: 3px 24px 3px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  min-height: 116px;
  padding: 18px 16px 18px 24px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 32px;
}

.detail,
.diagram-panel {
  padding: 18px;
}

h2 {
  margin: 0 0 12px;
  font-size: 20px;
}

.detail-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.detail-title h2 {
  margin: 0;
}

.status-badge {
  display: inline-grid;
  min-height: 22px;
  place-items: center;
  border: 1px solid #fecaca;
  border-radius: 999px;
  background: #fff1f2;
  color: #be123c;
  font-size: 14px;
  font-weight: 900;
  padding: 0 9px;
  white-space: nowrap;
}

.status-badge.hidden {
  display: none;
}

dl {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) 1fr;
  gap: 7px 16px;
  margin: 0;
}

dt {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

dl > dt:not(.detail-group):not(.detail-separator) {
  padding-left: 14px;
}

dd {
  margin: 0;
  padding-left: 4px;
  font-size: 14px;
  font-weight: 750;
}

dd.is-warning {
  color: #dc2626;
}

.detail-separator {
  grid-column: 1 / -1;
  height: 1px;
  margin: 2px 0;
  border-top: 1px solid var(--line);
}

.detail-group {
  grid-column: 1 / -1;
  margin: 8px 0 1px;
  padding: 7px 9px;
  border-radius: 6px;
  background: #eef5ff;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 900;
}

.detail-group:first-child {
  margin-top: 0;
}

.message {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.message.is-warning {
  color: #b45309;
  font-weight: 700;
}

.diagram-title {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  margin-bottom: 12px;
}

.diagram-heading {
  display: flex;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.diagram-heading h2 {
  margin: 0;
  white-space: nowrap;
}

.icon-button {
  display: inline-grid;
  width: 18px;
  min-height: 18px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  padding: 0;
  transform: translateY(-1px);
}

.icon-button:hover {
  background: #dbeafe;
}

.diagram-actions {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: nowrap;
  justify-content: flex-end;
  min-width: 0;
  overflow: visible;
}

@media (min-width: 1600px) {
  .workspace {
    grid-template-columns: 380px minmax(0, 1fr);
  }

  .summary-grid {
    gap: 14px;
  }
}

.diagram-actions span {
  flex: 0 1 auto;
  min-width: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zoom-controls,
.view-controls,
.export-controls {
  display: inline-grid;
  align-items: center;
  flex: 0 0 auto;
}

.view-controls {
  grid-template-columns: repeat(3, 62px);
  gap: 5px;
}

.zoom-controls {
  grid-template-columns: 36px 64px 36px 36px 36px;
  gap: 5px;
}

.zoom-controls button,
.view-controls button,
.export-controls button {
  min-height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
}

.export-controls {
  display: flex;
  gap: 5px;
}

.export-controls .export-menu,
.export-controls #exportDiagram,
.export-controls #openPortMapWindow {
  width: 72px;
}

.export-controls #exportDiagram,
.export-controls #openPortMapWindow {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.zoom-controls button:hover,
.view-controls button:hover,
.export-controls button:hover {
  background: #dbeafe;
}

.export-controls #exportDiagram:hover,
.export-controls #openPortMapWindow:hover {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
}

.export-menu {
  position: relative;
  min-width: 0;
}

.export-menu-list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  display: none;
  min-width: 100%;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.16);
}

.export-menu.is-open .export-menu-list {
  display: grid;
  gap: 4px;
}

.report-export .export-menu-list {
  left: 0;
  right: auto;
  width: 100%;
}

.export-menu-list button {
  width: 100%;
  min-height: 28px;
  justify-content: start;
  padding: 0 10px;
  border: 0;
  background: #fff;
  color: var(--accent-dark);
  text-align: left;
  font-size: 12px;
  font-weight: 900;
}

.export-menu-list button:hover {
  background: #dbeafe;
}

.zoom-controls button {
  font-size: 16px;
}

#zoomReset {
  font-size: 12px;
}

.view-controls button.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.diagram {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overscroll-behavior: contain;
  height: 560px;
  height: clamp(460px, calc(100vh - 540px), 540px);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.diagram.is-dragging {
  cursor: grabbing;
}

svg {
  display: block;
  width: 100%;
  height: 100%;
  shape-rendering: geometricPrecision;
  text-rendering: geometricPrecision;
}

.link {
  stroke: #5f8f73;
  stroke-width: 1.35;
  vector-effect: non-scaling-stroke;
  transition: opacity 0.14s ease, stroke-width 0.14s ease;
}

.uplink {
  stroke: #8d6b54;
  stroke-width: 1.45;
  vector-effect: non-scaling-stroke;
  transition: opacity 0.14s ease, stroke-width 0.14s ease;
}

.node rect,
.node circle {
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}

.node text {
  fill: #fff;
  font-size: 14px;
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: middle;
}

.node .node-label-bg {
  fill: #fff;
  stroke: #111827;
  stroke-width: 0.75;
  vector-effect: non-scaling-stroke;
}

.node .node-label {
  fill: #0f172a;
  font-size: 10.5px;
  font-weight: 450;
}

.diagram [data-device] {
  cursor: pointer;
}

.diagram .is-dimmed {
  opacity: 0.2;
}

.diagram [data-device].is-selected {
  opacity: 1;
}

.diagram [data-device].is-selected .node-label-bg {
  stroke: #2563eb;
  stroke-width: 1.6;
}

.diagram [data-source][data-target].is-highlighted {
  opacity: 1;
  stroke-width: 2;
}

.ellipsis-node rect {
  fill: #eef2f7;
  stroke: #94a3b8;
  stroke-dasharray: 4 4;
}

.ellipsis-node text {
  fill: #334155;
  font-size: 19px;
}

.ellipsis-node .ellipsis-label {
  fill: #0f172a;
  font-size: 10px;
  font-weight: 450;
}

.spine .switch-body {
  fill: var(--spine);
  stroke: #92400e;
}

.leaf .switch-body {
  fill: var(--leaf);
  stroke: #1e40af;
}

.switch-face {
  fill: rgba(255, 255, 255, 0.14);
  stroke: rgba(255, 255, 255, 0.22);
}

.switch-port {
  fill: #e5e7eb;
  stroke: #111827;
  stroke-width: 0.6;
}

.switch-led {
  fill: #86efac;
  stroke: #166534;
  stroke-width: 0.7;
}

.spine text,
.leaf text {
  fill: var(--ink);
  font-size: 10.5px;
  font-weight: 450;
}

.server rect {
  fill: var(--server);
  stroke: #334155;
}

.server .server-body {
  fill: var(--server);
  stroke: #334155;
}

.server .server-face {
  fill: #64748b;
  stroke: #334155;
}

.server .nic-port {
  fill: #bbf7d0;
  stroke: #1f2937;
  stroke-width: 0.8;
}

.server .server-led {
  fill: #86efac;
  stroke: #166534;
  stroke-width: 0.7;
}

.server .server-name {
  font-size: 10.5px;
  font-weight: 450;
  fill: var(--ink);
}

.row-label {
  fill: var(--muted);
  font-size: 14px;
  font-weight: 900;
  text-anchor: start;
  dominant-baseline: middle;
}

.label-gutter {
  fill: #fff;
  stroke: none;
}

.hint text {
  fill: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

@media (max-width: 980px) {
  .app {
    height: auto;
    min-height: 100vh;
    padding: 14px 14px 88px;
    overflow: visible;
  }

  .app-footer {
    right: 14px;
    bottom: 20px;
    left: 14px;
    gap: 12px;
  }

  .app-footer-notice {
    white-space: normal;
  }

  .workspace,
  .sidebar,
  .summary-grid {
    grid-template-columns: 1fr;
    height: auto;
  }

  .sidebar {
    margin-top: 0;
  }

  .summary-grid {
    position: static;
    padding-bottom: 0;
  }

  .sidebar-scroll,
  .inputs,
  .results {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .sidebar-scroll {
    display: contents;
  }

  .results-scroll {
    display: contents;
  }

  .results-scroll {
    overflow: visible;
    padding-right: 0;
  }

  .diagram {
    height: 520px;
  }

  dl {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  dd {
    margin-bottom: 8px;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 8mm;
  }

  * {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  body {
    min-width: 0;
    background: #fff;
    overflow: visible;
  }

  .app {
    width: 100%;
    max-width: none;
    height: auto;
    padding: 0;
    overflow: visible;
  }

  .workspace {
    display: block;
    height: auto;
  }

  .sidebar {
    display: block;
    height: auto;
  }

  .sidebar-scroll {
    display: block;
    overflow: visible;
    padding-right: 0;
  }

  .panel {
    break-inside: avoid;
    box-shadow: none;
    border-color: #c8d8ee;
    padding: 10px;
  }

  .inputs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: none;
    gap: 6px 10px;
    margin-bottom: 8px;
    max-height: none;
    overflow: visible;
  }

  .results {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .inputs h1,
  .inputs button[type="submit"],
  .report-export,
  .input-transfer-menu,
  .reset-inputs,
  .diagram-actions,
  .icon-button {
    display: none;
  }

  .outputs {
    display: block;
  }

  .summary-grid {
    position: static;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 8px;
    padding-bottom: 0;
  }

  .detail {
    margin-bottom: 8px;
  }

  .detail dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 10px;
  }

  .diagram-panel {
    break-before: auto;
  }

  .diagram-title {
    margin-bottom: 8px;
  }

  .diagram {
    height: 118mm;
    border-color: #c8d8ee;
    cursor: default;
  }

  .diagram svg {
    width: 100%;
    height: 100%;
  }
}
