body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  background: #f5f7f9;
}

.header {
  background: #002b45;
  color: white;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  height: 36px;
}

.header-spacer {
  flex: 1 1 auto;
}

/* Small dark mode toggle button (header, top-right) */
.dark-toggle {
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.10);
  color: #ffffff;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1.4;
  white-space: nowrap;
}

.dark-toggle:hover {
  background: rgba(255,255,255,0.18);
}

.dark-toggle.is-on {
  background: rgba(255,255,255,0.22);
  border-color: rgba(255,255,255,0.55);
}

.container {
  max-width: 1100px;
  margin: 24px auto;
}

.card {
  background: #ffffff;
  border-radius: 6px;
  margin-bottom: 16px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

summary {
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 12px;
}

/* Inputs/selects/textarea defaults */
input {
  width: 100%;
  max-width: 350px;
  padding: 8px;
  margin-bottom: 8px;
  box-sizing: border-box;
  font-family: monospace;
}

select {
  width: 100%;
  max-width: 170px;
  padding: 8px;
  margin-bottom: 8px;
  box-sizing: border-box;
  font-family: monospace;
}

textarea {
  width: 100%;
  padding: 8px;
  margin-bottom: 8px;
  box-sizing: border-box;
  font-family: monospace;
}

small {
  color: #666;
}

/* Reduce size of form field labels */
label {
  font-size: 13px;
  line-height: 1.3;
  color: #333;
}

/* Common formatting for section description text */
.section-desc{
  margin: 6px 0 12px;
  font-size: 13px;
  line-height: 1.35;
  color: #555;
}

/* Form grid */
.form-grid {
  display: grid;
  grid-template-columns:
    max-content minmax(260px, 1fr)
    max-content minmax(180px, 320px);
  gap: 8px 12px;
  align-items: center;
  max-width: 1000px;
}

.form-grid select {
  width: auto;
  max-width: 170px;
  box-sizing: border-box;
}

.form-grid input {
  width: auto;
  max-width: 350px;
  box-sizing: border-box;
}

/* Utility: field spans to the end of the row */
.form-grid .span-to-end {
  grid-column: 2 / -1;
}

/* HA table column sizing */
.ha-table {
  width: 80%;
  table-layout: fixed;
}

.ha-table th:nth-child(1),
.ha-table td:nth-child(1) {
  width: 15%;
}

.ha-table th:nth-child(2),
.ha-table td:nth-child(2) {
  width: 25%;
}

.ha-table th:nth-child(3),
.ha-table td:nth-child(3) {
  width: 50%;
}

/* HA table header styling */
#ha_section th {
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: #333;
  padding-bottom: 6px;
}

#ha_section td {
  text-align: left;
  font-size: 13px;
  color: #333;
  padding-bottom: 6px;
}

/* Ports table typography */
.ports-table .ports-label {
  font-size: 13px;
  line-height: 1.25;
}

.ports-table .ports-port {
  font-size: 13px;
}

/* Base button style for all ports buttons */
.ports-btn{
  font-size: 12px;
  padding: 2px 10px;
  border: 1px solid #cfd4d9;
  background: #f8f9fb;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1.4;
}

.ports-btn:hover{
  background: #eef2f6;
}

/* Protocol group header */
.ports-group-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.ports-group-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

/* Subtle alternating row background for ports */
.ports-table tr:nth-child(even) {
  background-color: #f6f8fa;
}

/* Subtle card background for each protocol group */
.ports-group {
  background-color: #f8f9fb;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid #e4e7eb;
}

/* Output box */
.output-box {
  margin-top: 12px;
  border: 1px solid #ccc;
}

.output-box header {
  background: #f0f2f5;
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  font-weight: 600;
}

.output-box button {
  background: #0077b6;
  color: white;
  border: none;
  padding: 4px 10px;
  cursor: pointer;
  border-radius: 6px;
}

/* Download buttons explicitly grey */
.output-box button.btn-secondary {
  background: #4a5568;
}

pre {
  padding: 12px;
  white-space: pre-wrap;
  font-family: monospace;
}

/* HA PSK block */
.ha-psk-block{
  margin: 10px 0 14px;
  max-width: 1000px;
}

.ha-psk-keyline{
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.ha-psk-keyline input{
  flex: 1 1 520px;
  max-width: 520px;
}

.ha-psk-block select{
  width: auto;
  margin-bottom: 10px;
}

.ha-psk-help{
  display: block;
  margin-top: 6px;
  color: #555;
  font-size: 13px;
}

/* Rounded corners for controls */
input,
select,
textarea {
  border-radius: 6px;
  border: 1px solid #cfd4d9;
  padding: 6px 8px;
  box-sizing: border-box;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #0077b6;
}

/* Output header row (title + format selector) */
.output-header-row{
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.output-title{
  margin: 0;
}

.output-format{
  display: flex;
  align-items: center;
  gap: 8px;
}

.output-format select{
  max-width: 220px;
  width: auto;
  margin-bottom: 0;
}

.out-actions{
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Informational tip / callout box */
.tip-box {
  margin-top: 14px;
  padding: 12px 14px;
  background: #f0f7fb;
  border-left: 4px solid #0077b6;
  border-radius: 4px;
  max-width: 900px;
}

.tip-box .tip-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
  color: #003a5d;
}

.tip-box p {
  margin: 6px 0;
  font-size: 13px;
  line-height: 1.35;
  color: #333;
}

/* Fade transitions for callouts that show/hide */
.callout {
  overflow: hidden;
  opacity: 1;
  transform: translateY(0);
  max-height: 800px;
  transition: opacity 220ms ease, transform 220ms ease, max-height 220ms ease;
}

.callout-hidden {
  opacity: 0;
  transform: translateY(-6px);
  max-height: 0;
  margin-top: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  border-left-width: 0 !important;
}

/* Tiny fade for full sections (ports) */
.fade-section {
  opacity: 1;
  transform: translateY(0);
  max-height: 2000px;
  overflow: hidden;
  transition: opacity 220ms ease, transform 220ms ease, max-height 260ms ease;
}

.fade-hidden {
  opacity: 0;
  transform: translateY(-6px);
  max-height: 0;
  pointer-events: none;
}

.scaling-sliders-and-summary{
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

.scaling-sliders-and-summary .scaling-sliders{
  min-width: 0;
}



.scaling-sliders{
  /* narrower block to reduce page width and keep controls compact */
  //max-width: 650px;
  margin-top: 6px;
}

.scaling-row{
  display: grid;
  grid-template-columns: 220px 1fr;
  column-gap: 14px;
  align-items: center;

  /* reduce vertical space between rows */
  padding: 6px 0;
}

/* .scaling-left{ */
  /* display: flex; */
  /* min-width: 0; */
  /* align-items: flex-start; /* was center */ */
  /* gap: 6px; */
/* } */

.scaling-left{
  justify-content: flex-start;   /* defensive: never space-between */
  align-items: flex-start;       /* keep ? aligned to the first line */
  gap: 6px;
}

.scaling-label{
  white-space: normal;
  line-height: 1.15;
  font-size: 13px;
  font-weight: 600;
  color: #222;
  min-width: 0;
}

.scaling-left .scaling-label{
  display: inline;               /* key: stop acting like a full-width block */
  line-height: 1.15;
}

.scaling-help{
  align-self: flex-start;	
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #e7edf3;
  color: #4b5563;
  font-size: 12px;
  font-weight: 700;
  cursor: help;
  user-select: none;
  margin-top: 1px;         /* align with first line of label */
}

/* .scaling-left .scaling-help{ */
  /* flex: 0 0 auto; */
  /* align-self: flex-start; */
  /* margin-top: 1px;               /* tiny nudge to align to first text line */ */
/* } */

.scaling-right{
  width: 100%;
  max-width: 560px;
  min-width: 0;
}

.scaling-trackline{
  display: flex;
  align-items: center;
  gap: 10px;

  /* tighter */
  margin: 0;
}

/* badge sits beside the slider track, fixed width so ticks can align */
.scaling-badge{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  height: 22px;
  padding: 0 8px;
  border-radius: 4px;
  background: #00b37d;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  box-sizing: border-box;
}

/* the actual range input track area */
.scaling-range{
  flex: 1 1 auto;
  width: 100%;
  max-width: 100%;
  margin: 0;

  /* keep track and ticks aligned end-to-end */
  box-sizing: border-box;

  /* reduce height footprint a bit */
  height: 18px;
}

/* tick labels align to the slider track (NOT the whole row) */
.scaling-ticks{
  display: flex;
  justify-content: space-between;

  /* key alignment: match left offset of slider track (badge + gap)
     and add equal left/right padding to compensate thumb radius */
  margin-left: calc(64px + 10px);
  padding: 0 10px;

  /* tighter vertical space */
  margin-top: 2px;

  font-size: 12px;
  color: #6b7280;
  line-height: 1.15;
}

.scaling-ticks span{
  white-space: nowrap;
}

/* ------------------------------------------------------------
   Max spool usage row – align with scaling grid
   ------------------------------------------------------------ */

.spool-input-wrap{
  display: grid;
  grid-template-columns: 200px 1fr;
  column-gap: 14px;
  align-items: center;

  max-width: 650px;
  margin-top: 8px;
}

.spool-input-label{
  min-width: 0; /* allow wrapping instead of forcing width */	
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 13px;
  color: #222;
}

/* existing help-icon class used by spool control */
.help-icon{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #e7edf3;
  color: #4b5563;
  font-size: 10px;
  font-weight: 700;
  cursor: help;
  user-select: none;
}

.spool-input-control{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 200px;
}

.spool-input-control input[type="number"]{
  width: 110px;
  max-width: 110px;
  text-align: right;
  margin-bottom: 0;
}

.spool-unit{
  font-weight: 600;
  font-size: 14px;
  color: #333;
}

/* Track-aligned stop markers (dots on the slider rail) */
.scaling-track-wrap{
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 500px;
}

.scaling-track-wrap .scaling-range{
  position: relative;
  z-index: 2; /* keep thumb interactive above dots */
}

.scaling-stop-dots{
  position: absolute;
  z-index: 1;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  justify-content: space-between;
  padding: 0 10px;  /* compensates for thumb radius so endpoints align */
  pointer-events: none;
}

.scaling-stop-dots span{
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #9ca3af;
}

/* Hide scaling_params textarea but keep it available to JS */
.scaling-hidden-textarea {
  display: none;
}

body.dark .scaling-stop-dots span{
  background: #6b7280;
}

/* ------------------------------------------------------------
   Dark mode tweaks for new scaling/spool UI
   ------------------------------------------------------------ */

body.dark .scaling-help,
body.dark .help-icon{
  background: #2a3a52;
  color: #e6edf3;
}

body.dark .scaling-label,
body.dark .spool-input-label{
  color: #e6edf3;
}

body.dark .scaling-ticks{
  color: #a9b7c8;
}

body.dark .spool-unit{
  color: #cfd8e3;
}

/* =========================
   Dark mode (append only)
   ========================= */

body.dark {
  background: #0b1220;
  color: #e6edf3;
}

body.dark .card {
  background: #0f1b2d;
}

body.dark summary,
body.dark label {
  color: #e6edf3;
}

body.dark .section-desc,
body.dark small {
  color: #b7c3d0;
}

body.dark input,
body.dark select,
body.dark textarea {
  background: #0b1627;
  color: #e6edf3;
  border-color: #2a3a52;
}

body.dark .ports-group {
  background: #0b1627;
  border-color: #2a3a52;
}

body.dark .ports-table tr:nth-child(even) {
  background: rgba(255,255,255,0.03);
}

body.dark .ports-btn {
  background: #0b1627;
  color: #e6edf3;
  border-color: #2a3a52;
}

body.dark .ports-btn-primary {
  background: rgba(121,184,255,0.18);
  border-color: #79b8ff;
}

body.dark .tip-box {
  background: rgba(121,184,255,0.10);
  border-left-color: #79b8ff;
}

.ports-groups,
body.dark .ports-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  gap: 14px;
}


@media (max-width: 860px){
  .scaling-sliders-and-summary{
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .ports-groups,
  body.dark .ports-groups {
    grid-template-columns: 1fr;
  }
}

/* Dark mode: output boxes */
body.dark .output-box {
  border-color: #2a3a52;
}

body.dark .output-box header {
  background: #0b1627;   /* darker header bar */
  color: #e6edf3;        /* readable title text */
  border-bottom: 1px solid #2a3a52;
}

body.dark .output-box header button {
  background: #0f1b2d;
  color: #e6edf3;
  border: 1px solid #2a3a52;
}

body.dark .output-box header button:hover {
  background: #13233a;
}

body.dark pre {
  background: #0b1627;   /* match header tone */
  color: #e6edf3;
}

/* Dark mode: link contrast */
body.dark a {
  color: #79b8ff;              /* accessible, calm blue */
  text-decoration-color: rgba(121, 184, 255, 0.6);
}

body.dark a:hover,
body.dark a:focus {
  color: #a6d1ff;
  text-decoration-color: rgba(166, 209, 255, 0.85);
}

/* Dark mode: callout / tip readability */
body.dark .callout,
body.dark .tip-box {
  color: #e6edf3; /* main readable text */
}

body.dark .callout p,
body.dark .tip-box p {
  color: #d2dbea;
}

body.dark .callout code,
body.dark .tip-box code {
  background: rgba(255, 255, 255, 0.08);
  color: #e6edf3;
}

body.dark .callout .tip-title {
  color: #ffffff;
}

/* Dark mode: scaling value badges use Solace blue */
body.dark .scaling-badge {
  background-color: rgba(121, 184, 255, 0.18); /* same blue family as links */
  color: #e6f1ff;                              /* high-contrast text */
  border-color: rgba(121, 184, 255, 0.45);
}

body.dark .scaling-resource-summary .sum-row span {
  color: #c9d1d9; /* soft light gray, readable but not dominant */
}

.scaling-track-wrap{
  --std-cutoff: 100%;
  --std-cutoff-px: 0px; /* set by JS */
}

/* Stronger Enterprise headroom band */
.scaling-track-wrap::before {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  top: calc(50% - 6px);   /* raise above main track */
  height: 12px;           /* thicker */
  border-radius: 999px;
  z-index: 0;
  pointer-events: none;

  background: linear-gradient(
    to right,
    rgba(180, 180, 180, 0.35) 0%,
    rgba(180, 180, 180, 0.35) var(--std-cutoff),
    rgba(0, 122, 204, 0.55) var(--std-cutoff),
    rgba(0, 122, 204, 0.55) 100%
  );
}

/* Dark mode tuning */
body.dark .scaling-track-wrap::before {
  background: linear-gradient(
    to right,
    rgba(120, 130, 140, 0.25) 0%,
    rgba(120, 130, 140, 0.25) var(--std-cutoff),
    rgba(121, 184, 255, 0.55) var(--std-cutoff),
    rgba(121, 184, 255, 0.55) 100%
  );
  box-shadow: 0 0 6px rgba(121, 184, 255, 0.35);
}


.scaling-track-wrap {
  --enterprise-label-left: 0px;
}

/* Label pill */
.scaling-track-wrap .enterprise-label{
  position: absolute;
  top: -12px; /* keep inside row to avoid overlap */
  left: var(--enterprise-label-left);
  transform: translateX(14px); /* push to the RIGHT of the cutoff */
  
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  border-radius: 10px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;

  background: rgba(0, 122, 204, 0.50);
  color: #0a4f8a;
  border: 1px solid rgba(0, 122, 204, 0.75);
}


.scaling-track-wrap .enterprise-label::after{
  content: "";
  position: absolute;
  left: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-right: 6px solid rgba(0, 122, 204, 0.55);
}
body.dark .scaling-track-wrap .enterprise-label::after{
  border-right-color: rgba(121, 184, 255, 0.65);
}

/* Dark mode tuning */
body.dark .scaling-track-wrap .enterprise-label {
  background: rgba(121, 184, 255, 0.50);
  color: #e6f1ff;
  border-color: rgba(121, 184, 255, 0.85);
}
body.dark .scaling-track-wrap .enterprise-label::after {
  border-top-color: rgba(121, 184, 255, 0.65);
}

/* Only show label if:
   - the slider has an enterprise zone (has-enterprise-label)
   - AND user has attempted to exceed a standard limit at least once (show-enterprise-labels) */
.scaling-track-wrap.has-enterprise-label .enterprise-label {
  opacity: 0;
}
body.show-enterprise-labels .scaling-track-wrap.has-enterprise-label .enterprise-label {
  opacity: 1;
}

/* Ensure label sits above track + slider */
.scaling-track-wrap .enterprise-label {
  z-index: 5;
}

.scaling-track-wrap::before { z-index: 0; }
.scaling-track-wrap::after  { z-index: 1; } /* cutoff marker if you have it */
.scaling-track-wrap .scaling-range { z-index: 3; }

.scaling-track-wrap { position: relative; }

/* Scaling resource summary panel */
.scaling-resource-summary{
  margin-top:16px;
  padding:12px;
  border:1px solid rgba(0,0,0,0.1);
  border-radius:8px;
  max-width: 300px;
  width: 100%;
  justify-self: center;

}
.scaling-resource-summary .resource-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px 16px;
}
.scaling-resource-summary span{
  color:#666;
  font-size:13px;
}
.scaling-resource-summary strong{
  font-weight:700;
}
body.dark .scaling-resource-summary{
  border-color:rgba(255,255,255,0.2);
}

.scaling-sliders-and-summary{
  align-items: start;
}

.scaling-sliders-and-summary .scaling-sliders{
  max-width: none;   /* override the 650px cap inside the grid */
}

.scaling-sliders-and-summary .scaling-resource-summary{
  margin-top: 0;     /* prevent the panel being pushed downward */
}


.scaling-right{
  max-width: none;  /* remove 560px cap */
}

.scaling-track-wrap{
  max-width: none;  /* remove 500px cap */
}

.scaling-resource-summary__grid{
  display: grid;
  gap: 10px;
}

.scaling-resource-summary .sum-row{
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: baseline;
  margin-bottom: -4px;
}

.scaling-resource-summary .sum-row strong{
  font-size: 14px; 
  line-height: 1.2;
  font-weight: 500;
  margin-bottom: -4px;
}

.scaling-resource-summary .sum-row small{
  font-size: 14px; 
  line-height: 1.2;
  font-weight: 500;
  margin-bottom: -4px;
}

.scaling-resource-summary .sum-row span{
  font-size: 14px;
  line-height: 1.2;
  margin-bottom: -4px;
}

.scaling-resource-summary__title{
  margin-bottom: 8px;
}