@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600&family=Fraunces:opsz,wght@9..144,600&display=swap");

:root {
  color-scheme: light;
  --bg: #0f1b24;
  --panel: rgba(18, 28, 38, 0.9);
  --panel-border: rgba(255, 255, 255, 0.08);
  --ink: #e8f0f5;
  --muted: rgba(232, 240, 245, 0.6);
  --accent: #ffc857;
  --accent-2: #49c6e5;
  --danger: #f26a5a;
  --success: #60d394;
  --shadow: 0 20px 50px rgba(10, 15, 20, 0.4);
  --page-bg: #05080b;
  --canvas-bg: #05080b;
  --grid-line: rgba(255, 255, 255, 0.04);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Avenir Next", "Helvetica Neue", sans-serif;
  background: var(--page-bg);
  color: var(--ink);
  min-height: 100vh;
  overflow: hidden;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--panel-border);
  background: linear-gradient(120deg, rgba(20, 33, 45, 0.95), rgba(12, 19, 27, 0.95));
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  object-fit: contain;
  border-radius: 8px;
  display: block;
}

.brand-mark {
  width: 38px;
  height: 38px;
}

.brand-title {
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: 20px;
  letter-spacing: 0.6px;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--muted);
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.cursor-readout {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  font-size: 12px;
  color: var(--muted);
}

.cursor-readout.bottom {
  position: absolute;
  left: 12px;
  bottom: 56px;
  z-index: 2;
}
.hidden {
  display: none !important;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, rgba(14, 22, 31, 0.95), rgba(5, 8, 12, 0.98));
  color: var(--ink);
}

.loading-card {
  padding: 20px 26px;
  border-radius: 14px;
  background: rgba(18, 28, 38, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  text-align: center;
  min-width: 240px;
}

.loading-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}

.loading-subtitle {
  font-size: 12px;
  color: var(--muted);
}

.btn {
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s ease;
}

.btn:hover {
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.btn.active {
  background: rgba(255, 200, 87, 0.2);
  border-color: rgba(255, 200, 87, 0.5);
  color: #ffe5b4;
}

.btn.ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.toggle-switch-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
}

.toggle-switch-btn .toggle-label {
  flex: 1;
}

.toggle-switch {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.25);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.toggle-switch::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.toggle-switch-btn.is-on .toggle-switch {
  background: rgba(96, 211, 148, 0.55);
  border-color: rgba(96, 211, 148, 0.8);
}

.toggle-switch-btn.is-on .toggle-switch::after {
  transform: translateX(16px);
}

.btn.ghost.danger {
  color: var(--danger);
  border-color: rgba(242, 106, 90, 0.5);
}

.file-btn input {
  display: none;
}

.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  padding: 16px;
  min-height: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  overflow: auto;
  position: relative;
}

/* Panel collapse/expand buttons */
.panel-collapse-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: all 0.2s ease;
  z-index: 10;
}

.panel-collapse-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--ink);
}

.panel-expand-btn {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(15, 23, 32, 0.9);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: all 0.2s ease;
  z-index: 10;
}

.panel-expand-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--ink);
}

/* Panel collapsed state */
.panel.collapsed {
  display: none;
}

.workspace.panel-collapsed {
  grid-template-columns: 1fr;
}

.panel-block {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.panel-title {
  font-weight: 600;
  margin-bottom: 12px;
  letter-spacing: 0.4px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 13px;
}

.field-inline {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
  font-size: 13px;
}

.field-inline > input {
  margin: 0;
}

.field-inline > div {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-inline .toggle {
  display: flex;
  flex-direction: row;
  gap: 8px;
  align-items: center;
  padding-top: 22px;
}

.field-inline .toggle label {
  margin: 0;
}

.field-inline .toggle input {
  margin: 0;
}

.toggle-switch-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 22px;
  cursor: pointer;
  user-select: none;
}

.toggle-switch-field input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-switch-field input:checked + .toggle-switch {
  background: rgba(96, 211, 148, 0.55);
  border-color: rgba(96, 211, 148, 0.8);
}

.toggle-switch-field input:checked + .toggle-switch::after {
  transform: translateX(16px);
}

.field input {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--ink);
}

.field textarea {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--ink);
  resize: vertical;
  min-height: 140px;
}

.field-inline input {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--ink);
}

.field-inline input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.panel-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.capacity-summary {
  display: grid;
  gap: 6px;
  margin-top: 6px;
}

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

.capacity-table {
  border-radius: 12px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  display: grid;
  gap: 6px;
}

.capacity-table-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--ink);
}

.capacity-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}

.capacity-row.total .capacity-label {
  color: var(--ink);
  font-weight: 600;
}

.capacity-label {
  max-width: 65%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.capacity-value {
  font-variant-numeric: tabular-nums;
}

.capacity-backbone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  color: var(--muted);
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.legend-swatch {
  width: 16px;
  height: 8px;
  border-radius: 999px;
  display: inline-block;
}

 

.canvas-wrap {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow);
  min-height: 0;
}

.canvas-bg {
  position: absolute;
  inset: 0;
  background: var(--canvas-bg);
}

.canvas {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.node {
  cursor: grab;
}

.node:active {
  cursor: grabbing;
}

.node-rect {
  fill: #1c2430;
  stroke: rgba(255, 255, 255, 0.35);
  stroke-width: 1.2px;
}

.node-rect.selected {
  stroke-width: 2px;
}

.node.link-drop-target .node-rect {
  stroke: #7fb2ff;
  stroke-width: 2.5px;
  filter: drop-shadow(0 0 6px rgba(127, 178, 255, 0.45));
}

.node-label {
  font-size: 12px;
  fill: #0f141a;
  pointer-events: none;
  font-weight: 700;
}

.node-label-bg {
  fill: #ffffff;
  stroke: rgba(0, 0, 0, 0.18);
  stroke-width: 1px;
}


.region {
  cursor: grab;
}

.region:active {
  cursor: grabbing;
}

.region-rect {
  stroke-width: 1.5px;
}

.region-rect.selected {
  stroke-width: 2.5px;
}

.region-header {
  font-size: 14px;
  font-weight: 600;
  fill: var(--ink);
  pointer-events: none;
}

.region-section {
  font-size: 11px;
  fill: var(--muted);
  pointer-events: none;
}

.region-resize {
  cursor: nwse-resize;
  fill: rgba(255, 255, 255, 0.6);
  stroke: rgba(0, 0, 0, 0.3);
  stroke-width: 1px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.region.selected .region-resize,
.region:hover .region-resize {
  opacity: 1;
}

.link {
  fill: none;
  stroke-linecap: butt;
}

.link.selected {
}

.link-shadow {
  pointer-events: none;
}

.link-info-group {
  pointer-events: auto;
}

.link-info-bg {
  fill: rgba(8, 12, 18, 0.9);
  opacity: 1;
}

.link-info {
  font-size: 8px;
  fill: var(--muted);
  pointer-events: none;
  paint-order: stroke;
  stroke: rgba(10, 15, 22, 0.8);
  stroke-width: 3px;
}

.link-capacity-group {
  pointer-events: none;
}

.link-capacity-bg {
  fill: rgba(8, 12, 18, 0.9);
  stroke: rgba(255, 255, 255, 0.12);
}

.link-capacity {
  font-size: 9px;
  fill: var(--ink);
  letter-spacing: 0.2px;
  paint-order: stroke;
  stroke: rgba(10, 15, 22, 0.85);
  stroke-width: 3px;
}

.distance-indicator line {
  stroke: rgba(127, 178, 255, 0.6);
  stroke-width: 1;
  stroke-dasharray: 6 4;
}

.distance-label-bg {
  fill: rgba(10, 15, 22, 0.92);
  stroke: rgba(255, 255, 255, 0.12);
}

.distance-label {
  font-size: 11px;
  fill: var(--ink);
  letter-spacing: 0.2px;
}

.via-point {
  fill: rgba(255, 255, 255, 0.85);
  stroke: #0b141c;
  stroke-width: 1px;
  cursor: default;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.link-group.show-handles .via-point,
.link-group.selected .via-point,
.via-point.show {
  opacity: 1;
}

.link-group.selected .via-point {
  cursor: move;
}

.via-point.selected {
  fill: #7fb2ff;
  stroke: #fff;
  stroke-width: 2px;
  opacity: 1;
}

.statusbar {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(15, 23, 32, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  z-index: 2;
}

.status-right {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--muted);
}

.kiosk-bar {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(15, 23, 32, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  z-index: 2;
}

.tooltip {
  position: absolute;
  z-index: 3;
  min-width: 320px;
  max-width: 760px;
  background: rgba(10, 15, 22, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 12px;
  color: var(--ink);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  overflow: visible;
}

.tooltip a {
  color: var(--accent-2);
  text-decoration: none;
  word-break: break-all;
  pointer-events: auto;
}

.tooltip a.chart-link {
  display: block;
  cursor: pointer;
}

.tooltip a.chart-link svg {
  pointer-events: auto;
  max-width: 100%;
  height: auto;
  display: block;
}

.tooltip img {
  width: 100%;
  max-height: 150px;
  object-fit: cover;
  border-radius: 8px;
  margin-top: 8px;
  display: block;
}

.mini-chart {
  display: grid;
  gap: 10px;
  margin-top: 6px;
}

.chart-legend {
  display: grid;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}

.chart-swatch.in {
  background: #60d394;
}

.chart-swatch.out {
  background: #6fb6ff;
}

.chart-stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  color: var(--muted);
}

.chart-stats-table th,
.chart-stats-table td {
  padding: 4px 6px;
  text-align: right;
}

.chart-stats-table th:first-child,
.chart-stats-table td:first-child {
  text-align: left;
}

.chart-stats-table thead th {
  font-weight: 600;
  color: var(--ink);
}

.chart-stats-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--ink);
}

.chart-stack {
  display: grid;
  gap: 16px;
}

.chart-stack-item {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 12px;
}

.chart-stack-item:first-child {
  border-top: none;
  padding-top: 0;
}

.chart-stack-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.chart-sources {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.chart-source-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
}

.chart-source-label {
  font-weight: 600;
  color: var(--ink);
}

.chart-source-metrics {
  color: var(--ink);
}

.modal {
  position: absolute;
  inset: 0;
  background: rgba(6, 10, 14, 0.25);
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  z-index: 4;
  pointer-events: none;
}

.modal.interactive {
  pointer-events: auto;
}

.modal-card {
  width: min(420px, 90vw);
  max-height: 100vh;
  background: rgba(18, 28, 38, 0.96);
  border: 1px solid var(--panel-border);
  border-radius: 18px 0 0 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  margin: 24px 0 24px 24px;
  pointer-events: auto;
}

.modal-card-wide {
  width: min(860px, 95vw);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--panel-border);
  font-weight: 600;
}

.modal-body {
  padding: 16px;
  overflow: auto;
}

.section-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 16px 0 8px;
}

.config-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.scale-list {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.scale-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
}

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

.scale-range input[type="range"] {
  width: 100%;
}

.scale-value {
  min-width: 44px;
  text-align: right;
  font-size: 12px;
  color: var(--muted);
}

.scale-row input[type="color"] {
  width: 42px;
  height: 32px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: transparent;
}

.scale-remove {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  color: var(--danger);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
}

.rrd-list {
  display: grid;
  gap: 6px;
  max-height: 320px;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 8px;
}

.rrd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
}

.rrd-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.rrd-item span {
  font-size: 12px;
  color: var(--ink);
  word-break: break-all;
}

.modal-section.hidden {
  display: none;
}

.via-list {
  display: grid;
  gap: 8px;
}

.via-item {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
}

.via-item input {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 6px 8px;
  color: var(--ink);
  font-size: 12px;
}

@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .panel {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .panel-block {
    flex: 1 1 240px;
  }
}

body.kiosk .workspace {
  grid-template-columns: 1fr;
}

body.kiosk .topbar {
  display: none;
}

body.kiosk .panel {
  display: none;
}

body.kiosk .statusbar {
  display: none;
}

body.kiosk .cursor-readout {
  display: none;
}

body.kiosk #gridRect {
  visibility: hidden;
}

body[data-theme="light"] {
  color-scheme: light;
  --bg: #eef2f6;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-border: rgba(20, 30, 40, 0.12);
  --ink: #1c2733;
  --muted: rgba(28, 39, 51, 0.6);
  --accent: #f39c12;
  --accent-2: #2c90d8;
  --danger: #d95850;
  --success: #2d9b6a;
  --shadow: 0 18px 40px rgba(15, 22, 32, 0.12);
  --page-bg: #f1f4f8;
  --canvas-bg: #f4f7fb;
  --grid-line: rgba(25, 35, 45, 0.12);
}

body[data-theme="light"] .node-rect {
  fill: #ffffff;
  stroke: rgba(44, 55, 70, 0.35);
}

body[data-theme="light"] .topbar {
  background: linear-gradient(120deg, rgba(250, 252, 255, 0.95), rgba(236, 242, 249, 0.95));
}

body[data-theme="light"] .statusbar,
body[data-theme="light"] .kiosk-bar {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(28, 39, 51, 0.12);
}

body[data-theme="light"] .tooltip {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(28, 39, 51, 0.14);
  box-shadow: 0 20px 45px rgba(15, 22, 32, 0.18);
}

body[data-theme="light"] .user-menu-dropdown,
body[data-theme="light"] .user-menu-submenu {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(28, 39, 51, 0.14);
}

body[data-theme="light"] .user-menu-item:hover {
  background: rgba(28, 39, 51, 0.06);
}

body[data-theme="light"] .submenu-caret {
  border: 1px solid rgba(28, 39, 51, 0.2);
  background: rgba(28, 39, 51, 0.04);
}

body[data-theme="light"] .node-label-bg,
body[data-theme="light"] .link-info-bg,
body[data-theme="light"] .link-capacity-bg {
  fill: rgba(255, 255, 255, 0.95);
  stroke: rgba(28, 39, 51, 0.18);
}

body[data-theme="light"] .link-info,
body[data-theme="light"] .link-capacity,
body[data-theme="light"] .node-label {
  fill: #1c2733;
  stroke: transparent;
  font-weight: 600;
}

body[data-theme="light"] .modal-card {
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(28, 39, 51, 0.14);
}

body[data-theme="light"] .modal-header {
  border-bottom: 1px solid rgba(28, 39, 51, 0.12);
}

body[data-theme="light"] .field input,
body[data-theme="light"] .field textarea,
body[data-theme="light"] .field-inline input,
body[data-theme="light"] .field select,
body[data-theme="light"] .field-inline select {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(28, 39, 51, 0.18);
  color: #1c2733;
}

body[data-theme="light"] .field label,
body[data-theme="light"] .field-inline label {
  color: #1c2733;
}

body[data-theme="light"] .field input::placeholder,
body[data-theme="light"] .field textarea::placeholder {
  color: rgba(28, 39, 51, 0.5);
}

body[data-theme="light"] .field-inline input[type="checkbox"] {
  accent-color: #2c90d8;
}

body[data-theme="light"] .btn {
  background: rgba(28, 39, 51, 0.06);
  border-color: rgba(28, 39, 51, 0.14);
}

body[data-theme="light"] .btn:hover {
  border-color: rgba(28, 39, 51, 0.2);
}

body[data-theme="light"] .btn.active {
  background: rgba(44, 144, 216, 0.16);
  border-color: rgba(44, 144, 216, 0.5);
  color: #1c2733;
}

body[data-theme="light"] .btn.ghost {
  background: transparent;
  border-color: rgba(28, 39, 51, 0.18);
}

body[data-theme="light"] .toggle-switch {
  background: rgba(28, 39, 51, 0.12);
  border-color: rgba(28, 39, 51, 0.2);
}

body[data-theme="light"] .toggle-switch::after {
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(22, 30, 39, 0.2);
}

body[data-theme="light"] .toggle-switch-btn.is-on .toggle-switch {
  background: rgba(46, 160, 92, 0.35);
  border-color: rgba(46, 160, 92, 0.6);
}

body[data-theme="light"] .toggle-switch-field input:checked + .toggle-switch {
  background: rgba(46, 160, 92, 0.35);
  border-color: rgba(46, 160, 92, 0.6);
}

body[data-theme="light"] .btn.ghost.danger {
  color: var(--danger);
  border-color: rgba(217, 88, 80, 0.5);
}
.field select,
.field-inline select {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 8px 32px 8px 10px;
  color: var(--ink);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 12' xmlns='http://www.w3.org/2000/svg' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%23bfc7d6' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px 12px;
}
.canvas #grid path {
  stroke: var(--grid-line);
}

/* Vendor filter dimming */
.dimmed {
  opacity: 0.1;
}

/* Vendor summary panel */
.vendor-summary {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.vendor-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.vendor-summary-row:last-child {
  border-bottom: none;
}

.vendor-summary-name {
  color: var(--ink);
}

.vendor-summary-count {
  color: var(--muted);
  font-weight: 500;
}

/* Auth controls */
.auth-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
  padding-left: 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
}

.auth-user {
  font-size: 12px;
  color: var(--ink);
}

/* User dropdown menu */
.user-menu {
  position: relative;
}

.user-menu-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  min-width: 160px;
  background: rgba(18, 28, 38, 0.96);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: visible;
  z-index: 1000;
}

.user-menu-item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
}

.user-menu-item.has-submenu {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
}

.submenu-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  color: var(--muted);
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.05);
}

.submenu-caret svg {
  width: 12px;
  height: 12px;
  display: block;
}

.user-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.user-menu-submenu {
  position: absolute;
  top: 0;
  right: 100%;
  margin-right: 8px;
  width: 280px;
  padding: 12px;
  background: rgba(18, 28, 38, 0.96);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1001;
  color: var(--ink);
}

.user-menu-submenu .btn {
  width: 100%;
  color: var(--ink);
}

.user-menu-submenu .btn.active {
  color: var(--ink);
}

.submenu-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink);
  margin-bottom: 4px;
}

/* Login modal */
.login-card {
  width: min(360px, 90vw);
  margin: auto;
  border-radius: 18px;
}

.login-error {
  color: var(--danger);
  font-size: 12px;
  margin-bottom: 12px;
  padding: 8px;
  background: rgba(242, 106, 90, 0.15);
  border-radius: 8px;
}

.login-success {
  color: var(--success);
  font-size: 12px;
  margin-bottom: 12px;
  padding: 8px;
  background: rgba(96, 211, 148, 0.15);
  border-radius: 8px;
}

#loginForm .btn {
  width: 100%;
  margin-top: 8px;
}

/* Read-only mode indicator */
.read-only-badge {
  font-size: 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.08);
  padding: 4px 8px;
  border-radius: 6px;
  margin-left: 8px;
}

/* Disabled state for edit buttons when not logged in */
.toolbar .btn:disabled,
.panel .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
