:root {
  --roi-brand: #1c4e80;
  --roi-brand-2: #22a699;
  --roi-text: #0f172a;
  --roi-muted: #475569;
  --roi-bg: #ffffff;
  --roi-surface: #f8fafc;
  --roi-border: #e2e8f0;
  --roi-focus: #93c5fd;
  --roi-bad: #b91c1c;
  --roi-good: #065f46;
  --roi-tooltip-maxw: 300px;
}

/* ------------------------------
   Base calculator styles
------------------------------ */

.roi * {
  box-sizing: border-box;
}

.roi {
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--roi-text);
}

.roi .card {
  background: var(--roi-bg);
  border: 1px solid var(--roi-border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 4px 12px rgba(2, 8, 20, 0.04);
}

.roi h2,
.roi h3 {
  margin: 0 0 0.6rem;
  font-weight: 700;
  color: var(--roi-brand);
}

.roi h2 {
  font-size: clamp(1.1rem, 2vw, 1.35rem);
}

.roi h3 {
  font-size: clamp(1rem, 1.8vw, 1.2rem);
  color: var(--roi-muted);
}

.roi .grid {
  display: grid;
  gap: 14px;
}

.roi .grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.roi .grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 920px) {
  .roi .grid.cols-3 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .roi .grid.cols-2 {
    grid-template-columns: 1fr;
  }
}

@media only screen and (min-width: 980px) {
  .roi-lead-panel {
    width: 60%;
    margin: 0 auto;
  }
}

.roi .field {
  display: grid;
  gap: 6px;
}

.roi label {
  font-size: 0.9rem;
  color: var(--roi-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.roi input[type="number"],
.roi input[type="text"],
.roi input[type="email"],
.roi select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--roi-border);
  border-radius: 10px;
  background: #fff;
  outline: none;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.roi textarea {
  width: 100%;
}

.roi input:focus,
.roi select:focus {
  border-color: var(--roi-focus);
  box-shadow: 0 0 0 3px rgba(147, 197, 253, 0.45);
}

.roi .unit {
  color: var(--roi-muted);
  font-size: 0.85rem;
  margin-left: 2px;
}

.roi .section {
  display: grid;
  gap: 14px;
  margin-bottom: 1.2em;
}

.roi .section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.roi #job-info {
  background-color: #d9e8ee;
}

.roi #current-info {
  background-color: #efefef;
}

.roi #new-info {
  background: linear-gradient(90deg, rgba(156, 209, 230, 1) 0%, rgba(190, 237, 223, 1) 100%);
}

.roi #results-info {
  background-color: #d9e8ee;
}

.roi .results {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 720px) {
  .roi .results {
    grid-template-columns: 1fr;
  }
}

.roi .result {
  background: var(--roi-surface);
  border: 1px dashed var(--roi-border);
  border-radius: 12px;
  padding: 12px;
}

.roi .result .label {
  color: var(--roi-muted);
  font-size: 0.85rem;
}

.roi .result .value {
  font-weight: 700;
  font-size: 1.3rem;
}

.roi .overall {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.roi .pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(34, 166, 153, 0.08);
  color: var(--roi-brand-2);
  font-weight: 600;
  font-size: 0.8rem;
}

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

.roi button {
  appearance: none;
  border: 1px solid var(--roi-border);
  background: var(--roi-bg);
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}

.roi button.primary {
  background: var(--roi-brand);
  color: white;
  border-color: var(--roi-brand);
}

.roi button:hover {
  filter: brightness(0.98);
}

/* ------------------------------
   Tooltip UI
------------------------------ */

.roi .tip {
  position: relative;
  cursor: help;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #1e2835;
  color: #fff;
  font-size: 12px;
}

.roi .tip:hover .tip-body {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.roi .tip-body {
  position: absolute;
  z-index: 10;
  top: calc(100% + 8px);
  left: 50%;
  transform: translate(-50%, 6px);
  width: min(var(--roi-tooltip-maxw), 92vw);
  opacity: 0;
  pointer-events: none;
  transition: 0.15s ease;
  background: #0b1220;
  color: #e5e7eb;
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 10px 30px rgba(2, 8, 20, 0.5);
  text-wrap: pretty;
}

.roi .tip-body::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: #0b1220;
}

/* ------------------------------
   Split layout
------------------------------ */

.roi .split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 980px) {
  .roi .split {
    grid-template-columns: 1fr;
  }
}

.roi .mono {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* ------------------------------
   Unit / currency selector
------------------------------ */

.roi .roi-title-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.roi .roi-title-actions h2 {
  margin-bottom: 0;
}

.roi .section-title .roi-options {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  background: transparent;
}

.roi .section-title .roi-options label {
  margin: 0;
  font-weight: 600;
  color: var(--roi-muted);
  white-space: nowrap;
}

.roi .section-title .roi-options select {
  width: auto;
  min-width: 140px;
  max-width: 180px;
  padding: 7px 10px;
}

@media (max-width: 720px) {
  .roi .section-title {
    align-items: flex-start;
    gap: 10px;
  }

  .roi .roi-title-actions {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .roi .section-title .roi-options {
    align-items: flex-start;
    flex-direction: column;
  }

  .roi .section-title .roi-options select {
    width: 100%;
    max-width: 220px;
  }
}

/* ------------------------------
   Branded print/PDF header
------------------------------ */

.roi .roi-print-header {
  display: none;
}

/* ------------------------------
   Print / Save as PDF
------------------------------ */

@media print {
  @page {
    margin: 6mm;
  }

  html,
  body {
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
  }

  /* Hide everything by default */
  body * {
    visibility: hidden !important;
  }

  /* Re-show only the calculator */
  .roi,
  .roi * {
    visibility: visible !important;
  }

  /* Move calculator to top of printed page */
/* Make common WordPress/theme/page-builder ancestors stop reserving print space */
html,
body,
#page,
.site,
.site-content,
.wp-site-blocks,
.entry-content,
.entry-content > *,
main,
article,
.bs-section,
.bs-section > .container,
.bs-row,
.bs-column,
.wp-block-e25m-section,
.wp-block-e25m-row,
.wp-block-e25m-column {
  margin-top: 0 !important;
  padding-top: 0 !important;
  transform: none !important;
  position: static !important;
}

/* Move calculator to the top of the printed page.
   Use absolute positioning because visibility:hidden elements elsewhere on
   production can still reserve vertical space in print layout. */
.roi {
  position: absolute !important;
  left: 0 !important;
  top: 0 !important;
  display: block !important;
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  background: #fff !important;
  color: #000 !important;
  box-shadow: none !important;
  font-size: 10pt !important;
  line-height: 1.25 !important;
}

  /* Branded print header */
  .roi .roi-print-header {
    display: flex !important;
    align-items: center !important;
    gap: 18px !important;
    margin: 0 0 10px 0 !important;
    padding: 0 0 8px 0 !important;
    border-bottom: 1px solid #d1d5db !important;
    color: #0f172a !important;
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  .roi .roi-print-header img {
    display: block !important;
    width: 130px !important;
    max-width: 130px !important;
    height: auto !important;
  }

  .roi .roi-print-header h1 {
    margin: 0 0 4px 0 !important;
    color: #1c4e80 !important;
    font-size: 18pt !important;
    line-height: 1.1 !important;
  }

  .roi .roi-print-header p {
    margin: 0 !important;
    color: #475569 !important;
    font-size: 9pt !important;
  }

  /* Hide interactive calculator elements */
  .roi button,
  .roi .controls,
  .roi .roi-lead-modal,
  .roi .roi-options,
  .roi .tip {
    display: none !important;
  }

  /* General print card layout */
  .roi .section {
    gap: 8px !important;
    margin: 0 0 8px 0 !important;
    page-break-before: auto !important;
    break-before: auto !important;
  }

  .roi .card {
    background: #fff !important;
    border: 1px solid #d1d5db !important;
    border-radius: 8px !important;
    box-shadow: none !important;
    padding: 10px !important;
    margin: 0 0 8px 0 !important;
  }

  /* Allow first card to start directly below print header */
  .roi #job-info {
    margin-top: 0 !important;
    page-break-before: auto !important;
    break-before: auto !important;
    page-break-inside: auto !important;
    break-inside: auto !important;
  }

  .roi .section-title {
    margin-top: 0 !important;
    margin-bottom: 4px !important;
    align-items: center !important;
  }

  .roi h2 {
    font-size: 14pt !important;
    margin: 0 0 4px 0 !important;
    color: #1c4e80 !important;
  }

  .roi h3 {
    font-size: 11pt !important;
    margin: 6px 0 4px 0 !important;
    color: #334155 !important;
  }

  .roi .pill {
    border: 1px solid #d1d5db !important;
    background: #fff !important;
    color: #334155 !important;
    padding: 4px 8px !important;
    font-size: 8pt !important;
  }

  .roi .grid {
    gap: 7px !important;
  }

  .roi .grid.cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  .roi .grid.cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .roi .split {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  .roi .field {
    gap: 3px !important;
  }

  .roi label {
    font-size: 8pt !important;
    color: #334155 !important;
    gap: 3px !important;
  }

  .roi input[type="number"],
  .roi input[type="text"],
  .roi input[type="email"],
  .roi select,
  .roi textarea {
    border: 1px solid #d1d5db !important;
    border-radius: 4px !important;
    background: #fff !important;
    box-shadow: none !important;
    padding: 4px 6px !important;
    font-size: 9pt !important;
    color: #000 !important;
  }

  .roi .unit {
    font-size: 7.5pt !important;
    color: #475569 !important;
  }

  .roi .results {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
  }

  .roi .result {
    background: #fff !important;
    border: 1px solid #d1d5db !important;
    border-radius: 6px !important;
    padding: 7px !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .roi .result .label {
    font-size: 8pt !important;
    color: #334155 !important;
  }

  .roi .result .value {
    font-size: 11pt !important;
    color: #000 !important;
  }

  .roi .overall {
    background: #fff !important;
    border-color: #d1d5db !important;
  }
}