:root {
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #1e293b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 10% -10%, #dbeafe 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 0%, #e9d5ff 0%, transparent 60%),
    #f8fafc;
}

.container {
  max-width: 1020px;
  margin: 28px auto;
  padding: 0 16px 36px;
}

.hero {
  background: linear-gradient(135deg, #0f172a, #1e3a8a);
  color: #fff;
  border-radius: 18px;
  padding: 22px 20px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.25);
}


.tvik-logo {
  display: inline-block;
  margin-bottom: 8px;
  font-family: 'Montserrat Alternates', Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ffffff;
  text-decoration: none;
}

.tvik-logo:hover {
  color: #bfdbfe;
}

.kicker {
  margin: 0;
  color: #bfdbfe;
  font-size: 13px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

h1 {
  margin: 8px 0;
  line-height: 1.2;
}

.lead {
  margin: 0;
  color: #dbeafe;
}

.card {
  background: #fff;
  border-radius: 14px;
  padding: 12px;
  margin-top: 12px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

.form-card h2 {
  margin: 0 0 10px;
  font-size: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

label {
  display: grid;
  gap: 5px;
}

label span {
  font-size: 14px;
  color: #334155;
}

input,
select,
button {
  font-size: 15px;
}

input,
select {
  width: 100%;
  max-width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
}

input:focus,
select:focus {
  outline: 2px solid #93c5fd;
  border-color: #60a5fa;
}

small {
  color: #64748b;
}

.dynamic-hint {
  color: #2563eb;
  font-weight: 600;
}

.sml-note {
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
  color: #334155;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

button {
  border: none;
  border-radius: 10px;
  background: linear-gradient(180deg, #2563eb, #1d4ed8);
  color: #fff;
  padding: 10px 15px;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.05);
}

button.secondary {
  background: #e2e8f0;
  color: #0f172a;
}


.dashboard-top {
  border: 1px solid #dbeafe;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.results-panel {
  padding: 8px;
}

.results-panel h2 {
  margin: 0 0 6px;
  font-size: 16px;
}

.results-panel .pipe-meta {
  margin: 8px 0 0;
}

.results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 6px;
}

.result-item {
  border: 1px solid #dbeafe;
  background: linear-gradient(180deg, #f8fbff, #eef6ff);
  border-radius: 10px;
  padding: 7px 8px;
  display: grid;
  gap: 2px;
}

.result-item span {
  color: #334155;
}

.result-item strong {
  font-size: 17px;
  color: #0f172a;
}

.result-item em {
  color: #475569;
  font-style: normal;
}

.messages {
  min-height: 40px;
}

.warning {
  color: #92400e;
  margin: 0;
}

.error {
  color: #b91c1c;
  margin: 6px 0 0;
}

.details-card summary {
  cursor: pointer;
  font-weight: 600;
}

.details-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.details-grid > div {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px 10px;
  background: #f8fafc;
}

.pipe-card h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.info-list {
  margin: 0 0 10px;
  padding-left: 20px;
  display: grid;
  gap: 6px;
  color: #334155;
}

.pipe-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 10px;
  color: #1e3a8a;
  font-size: 14px;
}

.pipe-meta strong {
  color: #0f172a;
}

.pipe-scene {
  position: relative;
  padding: 20px 18px 64px 72px;
  border-radius: 14px;
  border: 1px solid #dbeafe;
  background: linear-gradient(180deg, #eff6ff, #dbeafe);
  overflow: hidden;
}

.pipe-shell {
  --pipe-tilt: 1deg;
  --water-level: 50%;
  --flow-duration: 4s;
  --pipe-height: 90px;
  --rim-height: 114px;
  --dot-duration: 4s;
  --pipe-offset-y: 0px;
  position: relative;
  height: var(--pipe-height);
  border-radius: 999px;
  border: 3px solid #334155;
  background: linear-gradient(180deg, #f8fafc, #e2e8f0);
  overflow: hidden;
  transform: translateY(var(--pipe-offset-y)) rotate(var(--pipe-tilt));
  transform-origin: left center;
}

.pipe-dimension {
  position: absolute;
  color: #1e3a8a;
  font-size: 13px;
  font-weight: 700;
  pointer-events: none;
}

.pipe-dimension::before,
.pipe-dimension::after {
  content: '';
  position: absolute;
  background: #1e3a8a;
}

.pipe-dimension__label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid #93c5fd;
  background: rgba(239, 246, 255, 0.96);
  box-shadow: 0 4px 12px rgba(30, 58, 138, 0.14);
}

.pipe-dimension--vertical {
  width: 24px;
}

.pipe-dimension--vertical::before {
  left: 11px;
  top: 0;
  bottom: 0;
  width: 2px;
}

.pipe-dimension--vertical::after {
  left: 7px;
  top: 0;
  width: 10px;
  height: 2px;
  box-shadow: 0 100% 0 #1e3a8a;
}

.pipe-dimension--vertical .pipe-dimension__label {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
}

.pipe-dimension--horizontal {
  height: 26px;
}

.pipe-dimension--horizontal::before {
  left: 0;
  right: 0;
  top: 13px;
  height: 2px;
}

.pipe-dimension--horizontal::after {
  top: 8px;
  left: 0;
  width: 2px;
  height: 12px;
  box-shadow: 100% 0 0 #1e3a8a;
}

.pipe-dimension--horizontal .pipe-dimension__label {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
}

.water {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--water-level);
  overflow: hidden;
  background: linear-gradient(180deg, #60a5fa, #2563eb);
}

.water::after {
  content: '';
  position: absolute;
  left: -100%;
  top: -2px;
  width: 300%;
  height: 10px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 10' preserveAspectRatio='none'%3E%3Cpath d='M0 6 C10 2 20 2 30 6 C40 10 50 10 60 6 C70 2 80 2 90 6 C100 10 110 10 120 6' fill='none' stroke='rgba(255,255,255,0.78)' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E")
      0 0 / 120px 10px repeat-x;
  opacity: 0.8;
  animation: water-surface-wave var(--wave-duration, var(--flow-duration)) linear infinite;
  pointer-events: none;
}

.water::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(18px 12px at 54px 48%, rgba(255, 255, 255, 0.24) 0 70%, transparent 71%),
    radial-gradient(14px 10px at 184px 60%, rgba(255, 255, 255, 0.22) 0 70%, transparent 71%),
    radial-gradient(16px 11px at 230px 40%, rgba(255, 255, 255, 0.2) 0 70%, transparent 71%);
  background-size: var(--particle-pattern-px, 240px) 100%;
  background-repeat: repeat-x;
  animation: bubbles-run var(--particle-duration, var(--flow-duration)) linear infinite;
  pointer-events: none;
}

@keyframes bubbles-run {
  from {
    background-position-x: 0;
  }

  to {
    background-position-x: var(--particle-pattern-px, 240px);
  }
}

@keyframes water-surface-wave {
  from {
    background-position-x: 0;
  }

  to {
    background-position-x: 120px;
  }
}

.sp30-inline h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.sp30-caption {
  margin: 0;
  color: #334155;
  font-size: 14px;
}

.sp30-status {
  margin: 8px 0 6px;
  font-weight: 600;
  color: #1e293b;
}

.sp30-status.ok {
  color: #166534;
}

.sp30-status.warn {
  color: #92400e;
}

.sp30-status.danger {
  color: #b91c1c;
}

.sp30-inline {
  margin-top: 8px;
  border-top: 1px dashed #cbd5e1;
  padding-top: 8px;
}

.sp30-checks {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 6px;
}

.sp30-check-card {
  --delay: 0ms;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 6px 8px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  animation: sp30-card-in 0.35s ease forwards;
  animation-delay: var(--delay);
}

.sp30-check-card.ok {
  border-color: #86efac;
  background: linear-gradient(180deg, #f0fdf4, #dcfce7);
}

.sp30-check-card.warn {
  border-color: #fcd34d;
  background: linear-gradient(180deg, #fffbeb, #fef3c7);
}

.sp30-check-title {
  margin: 0;
  font-size: 14px;
}

.sp30-check-value {
  margin: 4px 0 0;
  font-weight: 700;
  color: #0f172a;
}

.sp30-check-hint {
  margin: 4px 0 0;
  color: #334155;
  font-size: 13px;
  line-height: 1.35;
}

@keyframes sp30-card-in {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}


.form-grid label {
  background: #f8fafc;
  border: 1px solid #dbe3ef;
  border-radius: 12px;
  padding: 8px;
}

input,
select {
  min-height: 38px;
}

.segments-card h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.segments-toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  align-items: end;
}

.segments-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.export-row {
  margin-top: 10px;
}

.import-label {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 10px 15px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
}

.import-label input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.segments-table-wrap {
  margin-top: 12px;
  overflow-x: auto;
}

#networkSummary {
  margin: 0;
}

.segments-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

.segments-table th,
.segments-table td {
  border: 1px solid #dbe3ef;
  padding: 7px 8px;
  font-size: 13px;
  text-align: left;
}

.segments-table th {
  background: #eff6ff;
  color: #1e3a8a;
}


.tree-cell {
  --depth: 0;
  position: relative;
  display: inline-flex;
  align-items: center;
  padding-left: calc(var(--depth) * 16px + 2px);
  font-weight: 600;
}

.tree-cell::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #60a5fa;
  margin-right: 8px;
  flex: 0 0 auto;
}

.segments-table tbody tr {
  cursor: pointer;
}

.segments-table tbody tr:hover {
  background: #f8fafc;
}

.segments-table tbody tr.active-row {
  background: #dbeafe;
}

.empty-row {
  text-align: center;
  color: #64748b;
  font-style: italic;
}



.calculator-categories {
  display: grid;
  gap: 14px;
}

.calculator-category {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
}

.calculator-category-title {
  margin: 0 0 8px;
  color: #0f172a;
  font-size: 17px;
}

.calculator-empty {
  margin: 0;
  color: #64748b;
}

.calculator-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.calculator-list a {
  display: block;
  border: 1px solid #dbe3ef;
  border-radius: 12px;
  padding: 12px;
  text-decoration: none;
  color: inherit;
  background: #f8fafc;
}

.calculator-list a:hover {
  border-color: #2563eb;
  background: #eff6ff;
}

.status-ok {
  color: #166534;
  font-weight: 700;
}

.status-bad {
  color: #b91c1c;
  font-weight: 700;
}

.explainer {
  margin-top: 14px;
  color: #475569;
  padding-left: 20px;
}

.hint-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
  margin-left: 6px;
  cursor: help;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
}

.checkbox-label input[type='checkbox'] {
  width: 16px;
  height: 16px;
}

.schema-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.rotate-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #334155;
  font-weight: 600;
}

.viewcube-panel {
  border: 1px solid #dbeafe;
  border-radius: 12px;
  padding: 10px;
  background: #f8fbff;
  margin-bottom: 10px;
}

.viewcube-title {
  margin: 0 0 8px;
  font-weight: 700;
  color: #1e3a8a;
}

.viewcube-cardinals {
  position: relative;
  width: 104px;
  height: 84px;
  margin-bottom: 8px;
  color: #1e40af;
  font-weight: 700;
}

.viewcube-cardinals span {
  position: absolute;
  font-size: 12px;
}

.viewcube-cardinals .north {
  top: 0;
  left: 48px;
}

.viewcube-cardinals .east {
  top: 34px;
  right: 0;
}

.viewcube-cardinals .south {
  bottom: 0;
  left: 48px;
}

.viewcube-cardinals .west {
  top: 34px;
  left: 0;
}

.viewcube-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  gap: 6px;
}

.viewcube-grid button {
  background: #fff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  color: #1e3a8a;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 8px;
}

.viewcube-grid button:hover {
  background: #eff6ff;
}

.schema-canvas-wrap {
  border: 1px solid #dbeafe;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  min-height: 460px;
}

#schemaSvg {
  width: 100%;
  height: 460px;
  display: block;
  touch-action: none;
  cursor: grab;
}

#schemaSvg.is-dragging {
  cursor: grabbing;
}

.schema-edge {
  stroke: #1d4ed8;
  stroke-width: 2.5;
  fill: none;
}

.schema-edge.selected {
  stroke: #ea580c;
  stroke-width: 3.5;
}

.schema-node {
  fill: #0ea5e9;
  stroke: #0369a1;
  stroke-width: 1.5;
}

.schema-node.main {
  fill: #0ea5e9;
  stroke: #0369a1;
}

.schema-node.riser {
  fill: #22c55e;
  stroke: #15803d;
}

.schema-node.sanitary {
  fill: #8b5cf6;
  stroke: #6d28d9;
}

.schema-node.branch {
  fill: #f59e0b;
  stroke: #b45309;
}

.schema-node.selected {
  fill: #f97316;
  stroke: #c2410c;
}

.schema-node-icon {
  font-size: 9px;
  font-weight: 700;
  fill: #ffffff;
  user-select: none;
  pointer-events: none;
}

.schema-appliance-badge {
  fill: #ffffff;
  stroke: #1d4ed8;
  stroke-width: 1;
}

.schema-appliance-label {
  font-size: 10px;
  font-weight: 700;
  fill: #1e293b;
  user-select: none;
  pointer-events: none;
}

.schema-label {
  font-size: 12px;
  fill: #0f172a;
  user-select: none;
}

.schema-legend {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: #334155;
  font-size: 13px;
}

.schema-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.schema-legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
}

.schema-legend-dot.main {
  background: #0ea5e9;
}

.schema-legend-dot.riser {
  background: #22c55e;
}

.schema-legend-dot.sanitary {
  background: #8b5cf6;
}

.schema-legend-dot.branch {
  background: #f59e0b;
}


.schema-canvas-wrap {
  position: relative;
}

#schemaCanvas {
  width: 100%;
  height: 460px;
  display: block;
}

#schemaCanvas canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

#css2dLayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.schema-label-2d {
  background: rgba(255,255,255,0.9);
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 11px;
  color: #0f172a;
  font-weight: 600;
  white-space: nowrap;
}

.viewcube-overlay {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 148px;
  background: rgba(248,251,255,0.95);
  border: 1px solid #dbeafe;
  border-radius: 10px;
  padding: 6px;
  z-index: 4;
}

#viewCubeCanvas {
  width: 100%;
  height: 140px;
  display: block;
}

.viewcube-grid {
  grid-template-columns: repeat(4, minmax(24px, 1fr));
}

.viewcube-grid button {
  padding: 3px;
  font-size: 10px;
}

.checkbox-label.compact {
  margin-top: 0;
}

.pipe-params-block {
  grid-column: 1 / -1;
  background: #eef6ff;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  padding: 8px;
  display: grid;
  gap: 8px;
}

.inline-radios {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.inline-radio,
.inline-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
}

.inline-radio input,
.inline-checkbox input {
  width: auto;
  min-height: auto;
}

.catalog-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  padding: 8px;
  border: 1px dashed #bfdbfe;
  border-radius: 12px;
  background: #f8fbff;
}


.catalog-results {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  padding: 8px;
  background: #ffffff;
  border: 1px solid #dbeafe;
  border-radius: 10px;
}

.catalog-results p {
  margin: 0;
  font-size: 13px;
  color: #334155;
}

.catalog-hint {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 13px;
  color: #334155;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 8px;
}
