/* =========================================================
   GLOBAL / BASE
   ========================================================= */
body {
  margin: 0;
  padding: 0;
  font-family: Poppins, sans-serif;
  background-color: #f9f9f9;
  min-height: 100vh;
  display: block;
}

.center { text-align: center; }
.text-center { text-align: center; }


/* Headings */
.heading {
  font-size: 2rem;
  font-weight: 600;
  color: #346EB6;
  margin-top: 0;
  margin-bottom: 1.5rem;
  text-align: center;
}

/* Brand logo image */
.login-logo {
  display: block;
  margin: 40px auto 20px auto;
  max-width: 300px;
  height: auto;
}

/* =========================================================
   CONTAINERS & LAYOUT SHELLS
   ========================================================= */
.container {
  width: 90%;
  max-width: 1000px;
  margin: 0 auto 40px auto;
  padding: 2rem;
  background-color: #F3F5F8;
  border-radius: 12px;
  box-shadow: 0 0 10px #346EB6;
  box-sizing: border-box;
  overflow-x: auto;
}

.container-wrapper {
  display: flex;
  margin: 0 4% 0 4%;
  gap: 2rem;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap; /* stack on smaller screens */
}

/* Shared: ensure dash grid fills the available row inside the flex wrapper (Dashboard + Manage Account) */
.container-wrapper > .dash-grid {
  width: 100%;
  flex: 1 1 auto;
  min-width: 0;
}

/* Calculator pages: match dashboard width without affecting dashboard layout */
.calculator-wrapper {
  width: 85%;
  max-width: 1000px;
  margin: 0 auto;
}
.calculator-wrapper .container {
  width: 100%;
  max-width: none;
}

.tools-box        { flex: 0 0 300px; }  /* fixed width */
.submissions-box  { flex: 1; min-width: 300px; max-width: none; }

/* Logo card (dash-user): flat, no border/shadow at all breakpoints */
.container.dash-user {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0; /* use 1rem if you prefer spacing inside */
}

/* =========================================================
   OUTCOME / MESSAGES
   ========================================================= */
.container.outcome.is-pass {
  background-color: #28a745;
  border: 1px solid #28a745;
  color: #fff;
}
.container.outcome.is-fail {
  background-color: #A71D22;
  border: 1px solid #A71D22;
  color: #fff;
}

/* Let the colored container carry the look */
.container.outcome .result-message.visible {
  background: transparent;
  box-shadow: none;
  padding: 0;
  margin: 0;
}
.container.outcome .result-message {
  font-size: 1rem;
  line-height: 1.4;
}
.container.outcome .result-message p {
  margin: 0;
  font-size: inherit;
  line-height: inherit;
}
.container.outcome .result-message.success,
.container.outcome .result-message.error {
  color: #fff;
}

/* Generic result message block */
.result-message { display: none; }
.result-message.visible {
  display: block;
  margin-top: 20px;
  padding: 1rem;
  border-radius: 12px;
  background-color: #f0f4f8;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.1);
}
.success { color: green;  font-size: 0.9rem; margin-top: 10px; }
.error   { color: #A71D22; font-size: 0.9rem; margin-top: 10px; }

/* =========================================================
   PDF HELPER PANEL
   ========================================================= */
.pdf-helper-panel {
  display: none;
  margin-top: 0.75rem;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
  max-width: 760px;
  padding: 0.75rem;
  border: 1px solid rgba(211, 47, 47, 0.35);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(18, 32, 56, 0.08);
  box-sizing: border-box;
}
.pdf-helper-panel.is-visible { display: block; }
.pdf-helper-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem 1rem;
  text-align: left;
}
.pdf-helper-field label {
  font-weight: 600;
  color: #122038;
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.95rem;
}
.pdf-helper-field input,
.pdf-helper-field textarea {
  width: 100%;
  padding: 0.55rem 0.6rem;
  border: 1px solid #c9ced6;
  border-radius: 6px;
  font-size: 0.95rem;
  box-sizing: border-box;
}
.pdf-helper-field textarea { resize: vertical; min-height: 70px; }
.pdf-helper-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.1rem;
  flex-wrap: wrap;
}

/* =========================================================
   FORMS & BUTTONS
   ========================================================= */
.input {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  margin-bottom: 1rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  box-sizing: border-box;
}

.button {
  display: block;
  width: 100%;
  background-color: #346EB6;
  color: #fff;
  font-size: 1.125rem;
  font-weight: 500;
  padding: 0.75rem;
  border: none;
  border-radius: 8px;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.3s ease;
  box-sizing: border-box;
}
.button:hover { background-color: #28589B; }

.button.green { background-color: #28a745; color: #fff; }
.button.red   { background-color: #A71D22; color: #fff; }
.button.border{
  background-color: #fff;
  color: #000;
  border: 1px solid #000;
}

/* White variant inside colored outcome containers */
.container.outcome .button { background: #fff; color: #1b1b1b; }
.container.outcome .button:hover { background: #f2f2f2; }

/* =========================================================
   CONTACT WIDGET
   ========================================================= */
.contact-widget {
  --contact-fab-offset: 20px;
  --contact-fab-padding: 0.45rem 1rem;
  --contact-sheet-padding: 1rem;
  --contact-sheet-gap: 64px;
  font-family: inherit;
}
.contact-fab {
  position: fixed;
  right: var(--contact-fab-offset);
  bottom: var(--contact-fab-offset);
  z-index: 10000;
  background: #f9f9f9;
  border: 2px solid #1b1b1b;
  border-radius: 999px;
  padding: var(--contact-fab-padding);
  font-size: 0.95rem;
  font-weight: 600;
  color: #1b1b1b;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}
.contact-fab:hover { background: #fff; }
.contact-fab:focus-visible { outline: 2px solid #346EB6; outline-offset: 3px; }

.contact-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.25);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 180ms ease;
  z-index: 9998;
}

.contact-sheet {
  position: fixed;
  right: var(--contact-fab-offset);
  bottom: calc(var(--contact-fab-offset) + var(--contact-sheet-gap));
  width: 320px;
  max-width: calc(100vw - (var(--contact-fab-offset) * 2));
  background: #fff;
  border: 1px solid #1b1b1b;
  border-radius: 16px;
  padding: var(--contact-sheet-padding);
  box-sizing: border-box;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  pointer-events: none;
  transition: transform 200ms ease, opacity 200ms ease;
  z-index: 9999;
}

.contact-widget.is-open .contact-backdrop {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.contact-widget.is-open .contact-sheet {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.contact-sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.contact-sheet__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: #346EB6;
}
.contact-sheet__close {
  border: 0;
  background: transparent;
  font-size: 1rem;
  font-weight: 700;
  color: #1b1b1b;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 8px;
}
.contact-sheet__close:hover { background: #f2f2f2; }
.contact-sheet__body {
  color: #1f2937;
  font-size: 0.95rem;
  line-height: 1.4;
}
.contact-sheet__details {
  margin-top: 0.75rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.contact-sheet__details a {
  color: #111827;
  text-decoration: none;
}
.contact-sheet__details a:hover { text-decoration: underline; }
.contact-sheet__or { font-weight: 500; color: #6b7280; }

@media (max-width: 768px) {
  .contact-sheet {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
    padding: calc(var(--contact-sheet-padding) + 0.5rem) var(--contact-sheet-padding);
    padding-bottom: calc(var(--contact-sheet-padding) + env(safe-area-inset-bottom, 0px));
    max-height: 70vh;
    overflow-y: auto;
  }
  .contact-widget.is-open .contact-sheet { transform: translateY(0); }
}

/* Stage 1B-2 dynamic row controls */
.row-input {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: .4rem 0;
}
.row-input input.input { flex: 1; }
.remove-btn {
  border: 0;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #eef;
  color: inherit;
}
.remove-btn:hover { background: #ffdede; color: #b00; }
.remove-btn:focus-visible { outline: 2px solid #4c8bf5; outline-offset: 2px; }

/* Stage 2C harmonics grid: keep inputs aligned when labels wrap */
.harmonics-grid .row { align-items: start; }
.harmonics-grid .row label {
  display: grid;
  grid-template-rows: minmax(2.6em, auto) auto;
  gap: .35rem;
}
.harmonics-grid .row .input { margin-bottom: 0; }
/* Stage 2C harmonics header row (single, non-bold) */
#stage-2c-group .harmonics-header {
  display: grid;
  grid-template-columns: 110px 150px 1fr 1fr 1fr 1fr;
  gap: .5rem;
  margin: .35rem 0;
  font-weight: 400;
  color: #1f2937;
}
#stage-2c-group .harmonics-header-cell { font-weight: 400; }
#stage-2c-group .stage2c-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;
}
/* Stage 2C LV manufacturer toggle row */
#stage-2c-group .stage2c-lv-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  margin: .25rem 0 .5rem;
}
#stage-2c-group .stage2c-lv-select { min-width: 120px; }
/* Stage 2C: force toggle label text to normal weight */
#stage-2c-group .stage2c-toggle-row .stage2c-toggle-label {
  font-weight: 400 !important;
}
/* Stage 2C: reset toggle rows to normal weight; keep Yes/No bold */
#stage-2c-group .stage2c-toggle-row {
  font-weight: 400 !important;
}
#stage-2c-group .stage2c-toggle-row .stage2c-toggle-label {
  font-weight: 400 !important;
}
#stage-2c-group .stage2c-toggle-row .stage2c-toggle-label {
  margin-left: .25rem;
  margin-right: .25rem;
}
#stage-2c-group .stage2c-toggle-row .unit-unittext {
  font-weight: 700 !important;
}
#stage-2c-group .stage2c-toggle-row,
#stage-2c-group .stage2c-toggle-row .stage2c-toggle-label {
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}
/* Stage 2C toggle labels: force normal weight */
#stage-2c-group .stage2c-zeroTrip-row .help-label,
#stage-2c-group .stage2c-lv-row .help-label { font-weight: 400; }
/* Stage 2C: remove default fieldset border */
#stage-2c-group fieldset { border: 0; }
/* Stage 2C template block */
#stage-2c-group .stage2c-template { margin: .5rem 0; }
#stage-2c-group .stage2c-template-title {
  margin: .25rem 0;
  font-weight: 600;
  font-size: 1rem;
  color: #1f3b66;
}
#stage-2c-group .stage2c-template-note {
  margin: .25rem 0;
  font-size: 1rem;
  color: #1f2937;
}
#stage-2c-group .stage2c-template-actions {
  display: grid;
  gap: .5rem;
  align-items: center;
}
/* Stage 2C desktop: tighten R/X input spacing only */
@media (min-width: 901px) {
  #stage-2c-group .rx-grid .help-field { margin-bottom: 0; }
  #stage-2c-group .stage2c-template-actions { grid-template-columns: 1fr 1fr; }
  #stage-2c-group .stage2c-template-actions .button { width: 100%; }
}
@media (max-width: 900px) {
  .harmonics-grid .row label { grid-template-rows: minmax(3.2em, auto) auto; }
}

/* Stage 2C mobile layout: keep text in viewport, scroll only the grid */
@media (max-width: 768px) {
  #stage-2c-group fieldset {
  border: 0 !important;
  padding: 0;
  margin: 0;
  min-inline-size: 0;
}

  #stage-2c-group .harmonics-grid {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  #stage-2c-group .harmonics-grid .row {
    min-width: 1020px;
    grid-template-columns:
      110px
      minmax(100px, 1fr)
      minmax(100px, 1fr)
      minmax(100px, 1fr)
      minmax(100px, 1fr)
      minmax(190px, 1fr) !important;
  }
  #stage-2c-group .harmonics-header { min-width: 1020px; }
  #stage-2c-group .rx-grid {
    grid-template-columns: 1fr !important;
  }
  #stage-2c-group [style*="flex-wrap:nowrap"] {
    flex-wrap: wrap !important;
  }
  #stage-2c-group [style*="flex-wrap:nowrap"] > * {
    flex: 1 1 100% !important;
    min-width: 0;
  }
}

/* =========================================================
   MENU (INCLUDE)
   ========================================================= */
.main-menu {
  background-color: #F3F5F8;
  padding: 1rem 0;
  text-align: center;
}
.menu-items a {
  margin: 0 1rem;
  text-decoration: none;
  color: #346EB6;
  font-weight: 500;
  font-size: 1.1rem;
}
.menu-items a:hover { text-decoration: underline; }
/* Active menu item: brand red + larger by 0.5rem */
/* Active menu item: brand red + +0.5rem */
nav.main-menu .menu-items a.active,
nav.main-menu .menu-items a.active:link,
nav.main-menu .menu-items a.active:visited{
  color: #A71D22;
}

nav.main-menu .menu-items a.active{
  font-size: calc(1em + 0.5rem);
  line-height: 1.2;          /* keep row height tidy on mobile */
  display: inline-block;     /* avoids tiny layout shifts */
}

/* Optional: keep underline on hover and prevent layout jump on mobile */
.main-menu .menu-items a.active:hover{ text-decoration: underline; }
@media (max-width: 768px){
  .main-menu .menu-items a.active{ line-height: 1.2; }
}

.subnav {
  display:flex; gap:.5rem; justify-content:center; align-items:center; margin:.5rem auto 1.25rem;
  padding:0; max-width:900px; background:none; border:none;
}
.subnav a {
  display:inline-block; padding:.45rem .8rem; border-radius:8px;
  text-decoration:none; color:#1f3b66; border:1px solid transparent;
  font-weight:600;
}
.subnav a:hover { border-color:#c7d6f5; background:#fff; }
.subnav a.active { background:#346eb6; color:#fff; border-color:#346eb6; }


/* =========================================================
   DASHBOARD — GRID LAYOUT (mobile-first)
   ========================================================= */
/* Mobile: logo above tools, then submissions */
.dash-grid {
  display: grid;
  gap: 2rem;
  grid-template-columns: 1fr;
  grid-template-areas:
    "user"
    "tools"
    "subs";
  align-items: flex-start;
}

.dash-user  { grid-area: user; }
.dash-tools { grid-area: tools; }
.dash-subs  { grid-area: subs; width: 100%; max-width: none; }

/* Compact user card contents */
.dash-user {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 0;
}

/* =========================================================
   Manage Account
   ========================================================= */

/* Messages */
.msg { margin: .75rem 0; padding: .75rem; border-radius: 8px; display: block; }
.msg.success { background: #e6f7ee; color: #0b6a2b; border: 1px solid #bfe9cf; }
.msg.error   { background: #fdeaea; color: #8f1a1a; border: 1px solid #f2c0c0; }

/* Upgrade drawer */
.upgrade-panel { display: none; border: 1px solid #dbe4f7; padding: .75rem; border-radius: 8px; margin: .5rem 0 1rem; }

/* Proration preview */
.upgrade-summary { font-size: .95rem; background: #f8fbff; border: 1px dashed #cfe0ff; border-radius: 8px; padding: .5rem .75rem; margin-top: .5rem; }

/* Row layout */
.upgrade-row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.upgrade-row .input { min-width: 220px; }

/* Small helper text */
.mini { font-size: .9em; color: #6b7280; }


/* =========================================================
   G5 SELECTOR
   ========================================================= */
   
.pricing-toggle {
  margin-top: .5rem;
  font-size: .95rem;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  text-decoration: underline;
}

.pricing-panel {
  display: none;
  margin-top: .5rem;
  font-size: .95rem;
  color: #111827;
}

.flow-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  line-height: 1.4;
  margin: .35rem 0;
}

.flow-step {
  font-weight: 600;
  letter-spacing: .02em;
}

.flow-arrow {
  font-size: 1rem;
  opacity: .7;
}

.flow-total {
  font-size: .9rem;
  color: #6b7280;
  white-space: nowrap;
}

.flow-between {
  text-align: center;
  margin: .2rem 0 .5rem;
  font-size: .9rem;
  color: #A71D22;
}

.muted {
  color: #6b7280;
  font-size: .9rem;
}

/* =========================================================
   RUN CARD HEADER (Archive/Delete) — robust layout
   ========================================================= */
.run-card-head {
  display: grid;
  grid-template-columns: 1fr auto; /* meta | actions */
  align-items: flex-start;
  gap: 12px;
}
.run-card-head .card-meta   { min-width: 0; }
.run-card-head .card-actions{
  display: flex;
  gap: 10px;
  white-space: nowrap;
  align-self: flex-start;
}
.run-card-head .card-actions .button {
  width: auto;
  min-width: 110px;
  padding: .35rem .7rem;
  font-size: .9rem;
}
.run-card-head .card-actions form { margin: 0; }

/* On small screens, put the actions ABOVE the text */
@media (max-width: 768px) {
  .run-card-head { display: flex; flex-direction: column; gap: 8px; }
  .run-card-head .card-actions { order: -1; flex-wrap: wrap; justify-content: flex-start; }
}

/* =========================================================
   RESPONSIVE — MOBILE
   ========================================================= */
@media (max-width: 768px) {
  .login-logo { width: 60vw; max-width: 200px; margin-top: 20px; }
  .heading    { font-size: 1.5rem; }
  .container  { padding: 1rem; }

  /* Hide the Tools column only on this page */
  /*.page-manage-account .tools-box { display: none; }*/

  /* menu include: stack vertically if present */
  .menu-wrapper { display: flex; flex-direction: column; text-align: center; }
  .menu-items   { margin-top: 1rem; }
  .menu-items a { display: block; margin: 0.5rem 0; }
}


/* =========================================================
   RESPONSIVE — TABLET (≥768px and <1200px)
   ========================================================= */
@media (min-width: 768px) and (max-width: 1199.98px) {
  /* Grid: tools + user on row 1, submissions spans row 2 */
  .dash-grid {
    grid-template-columns: 320px 1fr;
    grid-template-areas:
      "tools user"
      "subs  subs";
  }

  /* Smaller logo & heading inside the user card on tablet */
  .dash-user .login-logo { max-width: 200px; margin: 10px auto; }
  .dash-user .heading    { font-size: 1.4rem; margin: 6px 0 8px; }

  /* Spacing tweaks requested */
  .main-menu { margin-bottom: 50px; }          /* gap below the menu */
  .container.dash-tools,
  .container.dash-user { margin-bottom: 12px; } /* tighten gap above subs */
  .container.dash-subs { margin-top: 12px; }
  .page-manage-account .submissions-box .w-50-lg { width: 100%; }
}

@media (min-width: 769px){
  .page-manage-account .submissions-box .w-50-lg { width: 100%; } /* half-width on desktop/tablet */
}

/* =========================================================
   RESPONSIVE — DESKTOP (≥1200px)
   ========================================================= */
@media (min-width: 1200px) {
  .container.submissions-box.dash-subs {
    width: 100%;
    max-width: 665px;
    margin-left: 0;
    margin-right: 0;
    display: flex;
    flex-direction: column;
  }

  /* Grid: logo spans top, tools + submissions beneath */
.dash-grid {
  grid-template-columns: 320px 665px;
  grid-template-areas:
    "user user"
    "tools subs";
  column-gap: 40px;
  justify-content: center;
}
  
  .container.submissions-box.dash-subs > * {
    width: 100%;
    max-width: 665px;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
  }

  .page-manage-account .submissions-box .w-50-lg {width: 100%; }

  /* Center the logo card above the two columns */
  .dash-user {
    max-width: 760px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
  }

}

/* -------------------------------
   SSC unit toggle
---------------------------------- */

.unit-switch-wrap{
  display:flex;
  align-items:center;
  gap:.5rem;               /* space between toggle and label */
}

.unit-switch{
  --h: 36px;               /* control height */
  --pad: 4px;
  position: relative;
  width: 60px;            /* ~half of the previous 200px */
  height: var(--h);
  border-radius: 999px;
  background: #ecf0f8;
  border: 3px solid #6b82c8;
  box-shadow: inset 0 0 0 1px rgba(107,130,200,.15);
  cursor: pointer;
  user-select: none;
}

.unit-switch .knob{
  position:absolute;
  top: var(--pad);
  left: var(--pad);
  width: calc(var(--h) - 2*var(--pad));
  height: calc(var(--h) - 2*var(--pad));
  border-radius:50%;
  background:#fff;
  box-shadow: 0 4px 10px rgba(0,0,0,.12);
  transition:left .22s ease;
}

.unit-switch[data-state="ka"] .knob,
.unit-switch[data-state="pct"] .knob,
.unit-switch[data-state="yes"] .knob{
  left: calc(100% - var(--h) + var(--pad));
}

/* Text to the right of the toggle */
.unit-unittext{
  font-weight:700;
  color:#34539e;
  letter-spacing:.2px;
}

.section-line{
  border:0;
  border-top:3px solid #ccc;
  margin:7mm 0;
}
