@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;600&display=swap');

/* Base page and canvas styles */
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Roboto Flex", "Open Sans", sans-serif;
  font-size: 13px;
  color: #333;
  background: linear-gradient(180deg, #f3f0e6 0%, #f8f7f2 100%);
}

canvas#webgl {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
}

#brand-mark {
  position: fixed;
  top: 18px;
  left: 20px;
  z-index: 300;
  pointer-events: none;
}

#brand-mark img {
  display: block;
  width: 150px;
  height: auto;
}

.startup-modal {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.startup-modal[aria-hidden="true"] {
  display: none;
}

.startup-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(110, 116, 118, 0.28);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.startup-modal__panel {
  position: relative;
  width: min(100%, 560px);
  min-height: 540px;
  border-radius: 14px;
  background: rgba(248, 248, 247, 0.95);
  box-shadow: 0 30px 80px rgba(36, 47, 60, 0.18);
  padding: 30px 34px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  font-family: "Open Sans", sans-serif;
  font-weight: 300;
}

.startup-modal__brand {
  width: 100%;
  display: flex;
  justify-content: flex-start;
  margin-bottom: 10px;
}

.startup-modal__brand img {
  width: 155px;
  height: auto;
}

.startup-modal__animation-placeholder {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 4px;
}

.startup-modal__animation-frame {
  width: min(100%, 360px);
  aspect-ratio: 1.4 / 1;
  border-radius: 14px;
  border: 1px dashed rgba(0, 74, 151, 0.28);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(238, 238, 235, 0.92)),
    radial-gradient(circle at top, rgba(0, 74, 151, 0.08), transparent 55%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #4a6077;
  overflow: hidden;
}

.startup-modal__animation-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.startup-modal__content {
  margin-top: auto;
  width: 100%;
  max-width: 400px;
}

.startup-modal__content h1 {
  margin: 32px 0 24px;
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.12;
  font-weight: 300;
  letter-spacing: -0.04em;
  color: #0f355d;
}

.startup-modal__description {
  margin: 0 0 24px;
  font-family: "Open Sans", sans-serif;
  font-size: 13px;
  line-height: 1.5;
  font-weight: 300;
  color: #4a6077;
}

.startup-modal__cta {
  min-width: 170px;
  height: 42px;
  border: none;
  border-radius: 4px;
  background: #0051a8;
  color: #fff;
  font-family: "Open Sans", sans-serif;
  font-size: 16px;
  font-weight: 300;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.startup-modal__cta:hover {
  background: #00458d;
  transform: translateY(-1px);
}

.startup-modal__cta:focus-visible {
  outline: 3px solid rgba(0, 81, 168, 0.28);
  outline-offset: 3px;
}

.startup-modal__terms {
  margin-top: 14px;
  font-family: "Open Sans", sans-serif;
  text-align: center;
  color: #6b7785;
}

.startup-modal__terms p {
  margin: 0;
  font-size: 10px;
  line-height: 1.3;
}

.startup-modal__terms p + p {
  margin-top: 1px;
}

.startup-modal__terms a {
  color: inherit;
  font-weight: 600;
  text-underline-offset: 2px;
}

.terms-modal {
  position: fixed;
  inset: 0;
  z-index: 5100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.terms-modal[aria-hidden="true"] {
  display: none;
}

.terms-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(25, 34, 45, 0.42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.terms-modal__panel {
  position: relative;
  width: min(100%, 920px);
  min-height: min(78vh, 640px);
  max-height: 78vh;
  padding: 40px 44px;
  border-radius: 18px;
  background: rgba(248, 248, 247, 0.98);
  box-shadow: 0 28px 72px rgba(24, 34, 46, 0.22);
  overflow-y: auto;
}

.terms-modal__close {
  position: sticky;
  top: 0;
  margin-left: auto;
  display: block;
  min-width: 96px;
  height: 38px;
  border: 1px solid #cbd6e2;
  border-radius: 999px;
  background: #ffffff;
  color: #123d69;
  font-family: "Open Sans", sans-serif;
  font-size: 12px;
  cursor: pointer;
}

.terms-modal__content {
  margin-top: 24px;
  color: #23486f;
  font-family: "Open Sans", sans-serif;
}

.terms-modal__content h2 {
  margin: 0 0 18px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.05;
  font-weight: 300;
  color: #0f355d;
}

.terms-modal__content p {
  margin: 0;
  max-width: 720px;
  font-size: 16px;
  line-height: 1.6;
}

.terms-modal__content p + p {
  margin-top: 14px;
}

.terms-modal__body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.terms-modal__body h3 {
  margin: 14px 0 0;
  font-size: 18px;
  line-height: 1.3;
  font-weight: 600;
  color: #0f355d;
}

.terms-modal__body p {
  max-width: none;
  font-size: 14px;
  line-height: 1.55;
  color: #23486f;
}

.terms-modal__body p + p {
  margin-top: 0;
}

/* --- LAYOUT ARCHITECTURE --- */

#controls-container {
  position: fixed;
  top: 75px;
  left: 25px;
  bottom: 22px;
  width: 348px;
  background: transparent;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
  border: 1px solid #d5dde7;
  border-radius: 12px;
  background: rgba(250, 251, 252, 0.96);
  box-shadow: 0 12px 28px rgba(22, 43, 77, 0.08);
  overflow: hidden;
}

#analysis-container {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  background: transparent; 
  z-index: 110;
  transform: translateX(360px); 
  transition: transform 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
  display: flex;
  flex-direction: row; 
  pointer-events: none; 
  border-left: 1px solid rgba(0,0,0,0.1);
}

#analysis-container.open {
  transform: translateX(0);
}

#analysis-container > * {
  pointer-events: auto;
}

/* --- SIDEBAR TABS --- */
.sidebar-tabs {
  display: flex;
  gap: 0;
  background: linear-gradient(180deg, #e9edf1 0%, #e1e6eb 100%);
  border-bottom: 1px solid #d6dde5;
  padding: 0;
}

.sidebar-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 14px 16px;
  cursor: pointer;
  font-weight: 500;
  color: #123d69;
  border-bottom: 1px solid transparent;
  transition: all 0.2s ease;
  font-size: 14px;
  background: transparent;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}

.sidebar-tab:hover {
  background: rgba(255, 255, 255, 0.25);
}

.sidebar-tab.active {
  color: #123d69;
  border-bottom-color: #f8fbff;
  background: #f8fbff;
}

.sidebar-tab svg {
  width: 18px;
  height: 18px;
  stroke: #0458b7;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.sidebar-tab.active svg {
  stroke: #0458b7;
}

.sidebar-tab span {
  white-space: nowrap;
}

/* --- ANALYSIS DRAWER COMPONENTS --- */

.analysis-sidebar {
    width: 60px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid #e9ecef;
    border-left: none; 
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-shrink: 0;
    position: relative;
    z-index: 10; 
    box-shadow: none;
}

.analysis-tab {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #6c757d;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
    position: relative;
    z-index: 11; 
}

.analysis-tab:hover {
    background: #e9ecef;
    color: #343a40;
}

.analysis-tab.active {
    background: #004a97;
    color: white;
    box-shadow: 0 4px 10px rgba(0, 74, 151, 0.3);
}

.analysis-tab svg {
    width: 20px;
    height: 20px;
}

.analysis-tab__icon-image {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

.analysis-tab.active .analysis-tab__icon-image,
.analysis-tab.has-errors .analysis-tab__icon-image {
    filter: brightness(0) invert(1);
}

.analysis-tab .co2-main {
    fill: currentColor;
    font-size: 10.8px;
    font-family: "Roboto Flex", "Open Sans", sans-serif;
    font-weight: 700;
    letter-spacing: -0.28px;
}

/* --- ERROR STATE FOR TABS (NEW) --- */
.analysis-tab.has-errors {
    background-color: #ef5350 !important; /* Light red */
    color: white !important;
    animation: pulse-red 2s infinite;
}

.analysis-tab.has-errors:hover {
    background-color: #e53935 !important;
}

.analysis-tab.has-errors.active {
    background-color: #c62828 !important; /* Darker red when selected */
    box-shadow: 0 4px 10px rgba(198, 40, 40, 0.4) !important;
    animation: none;
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(239, 83, 80, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(239, 83, 80, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 83, 80, 0); }
}

.analysis-tab::after {
    content: attr(data-title);
    position: absolute;
    right: 120%; 
    top: 50%;
    transform: translateY(-50%);
    background: #333;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 1000;
}
.analysis-tab:hover::after {
    opacity: 1;
}

.analysis-main-content {
    flex: 1; 
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: hidden;
    position: relative;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: none; 
    box-shadow: -6px 0 20px rgba(0,0,0,0.05);
    z-index: 20;
}

.analysis-header-bar {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    background: rgba(255,255,255,0.5);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.analysis-header-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.chart-panel-container {
    height: 240px;
    padding: 10px 20px 0 20px;
    flex-shrink: 0;
    position: relative;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}
.chart-panel-container > div {
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    box-sizing: border-box;
}

.carbon-chart-stack {
    display: grid;
    grid-template-rows: minmax(260px, 300px) minmax(260px, 320px) auto;
    align-content: start;
    gap: 12px;
    width: 100%;
    min-height: 0;
}

.carbon-chart-split {
    width: 100%;
    min-height: 0;
}

.carbon-chart-split--bar {
    height: 100%;
}

.carbon-chart-split--pie {
    height: 100%;
}

.carbon-chart-disclaimer {
    padding: 0 4px 10px;
    font-size: 10px;
    line-height: 1.35;
    color: #6b7785;
    text-align: center;
}

.carbon-chart-disclaimer p {
    margin: 0;
}

.carbon-chart-disclaimer p + p {
    margin-top: 2px;
}

#carbon-chart-panel {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding-right: 4px;
}

#cost-chart-panel,
#cost-chart {
    overflow: visible !important;
}

#cfs-clt-info-panel {
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

.cfs-legend-card {
    padding: 0;
    color: #0f2742;
}

.cfs-legend-eyebrow {
    font-size: 12px;
    line-height: 1.1;
    font-weight: 500;
    color: #123d69;
}

.cfs-legend-title {
    margin-top: 0;
    font-size: 16px;
    line-height: 1.1;
    font-weight: 400;
    color: #0f2742;
}

.cfs-legend-dynamic {
    display: flex;
    flex-direction: column;
    margin-top: 6px;
}

.cfs-legend-dynamic__labels {
    display: grid;
    align-items: end;
    min-height: 90px;
    margin-bottom: 6px;
}

.cfs-legend-dynamic__label {
    justify-self: center;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 10px;
    line-height: 1;
    letter-spacing: 0.02em;
    color: #0f2742;
}

.cfs-legend-dynamic__bar {
    display: grid;
    width: 100%;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(9, 38, 71, 0.1);
    background: #eef4fb;
}

.cfs-legend-dynamic__segment {
    height: 34px;
    border-right: 2px solid rgba(255, 255, 255, 0.28);
}

.cfs-legend-dynamic__segment:last-child {
    border-right: none;
}

@media (max-width: 520px) {
    .cfs-legend-dynamic__labels {
        min-height: 82px;
        margin-bottom: 8px;
    }

    .cfs-legend-dynamic__label {
        font-size: 10px;
    }

    .cfs-legend-dynamic__segment {
        height: 30px;
    }
}

#analysis-gui-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    position: relative;
    box-sizing: border-box;
}

/* --- COMPONENTS --- */

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px 20px;
  background: #f8fbff;
}

.control-section {
  margin-bottom: 16px;
  border-bottom: none;
  padding-bottom: 0;
}
.control-section:last-child {
  border-bottom: none;
}
.section-title {
  font-size: 15px;
  text-transform: none;
  letter-spacing: 0;
  color: #173a63;
  font-weight: 600;
  margin-bottom: 12px;
  display: block;
}

.control-group { 
  margin-bottom: 10px; 
  display: flex;
  align-items: center;
}
.control-label {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 400;
  color: #365577;
  margin-bottom: 0;
  width: 128px;
  flex-shrink: 0;
  margin-right: 10px;
  line-height: 1.25;
}
.info-icon {
  color: #6e89ab;
  cursor: help;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffffff 0%, #eef4fb 100%);
  box-shadow: 0 1px 2px rgba(17, 49, 84, 0.12);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  margin-left: 0;
  transition: color 0.18s ease, border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.info-icon:hover,
.info-icon:focus {
  color: #0458b7;
  border-color: #0458b7;
  box-shadow: 0 4px 10px rgba(4, 88, 183, 0.18);
  outline: none;
  transform: translateY(-1px);
}

/* Custom Inputs */
.custom-select {
  width: 170px;
  max-width: 170px;
  min-height: 28px;
  padding: 3px 28px 3px 8px;
  border: 1px solid #bdd0e5;
  border-radius: 4px;
  background-color: #fbfdff;
  background-image:
    linear-gradient(45deg, transparent 50%, #4b6e96 50%),
    linear-gradient(135deg, #4b6e96 50%, transparent 50%);
  background-position:
    calc(100% - 12px) 50%,
    calc(100% - 7px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  font-family: inherit;
  font-size: 12px;
  color: #0458b7;
  cursor: pointer;
  outline: none;
  flex: 0 0 auto;
  margin-left: auto;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}
.custom-select:focus { border-color: #0458b7; }
.custom-select::-ms-expand { display: none; }

/* Slider Styles */
.slider-container { display: flex; align-items: center; gap: 10px; padding: 0; flex: 1; }
.slider-inline-select {
  width: 100px;
  max-width: 100px;
  min-width: 100px;
  margin-left: 0;
}
.custom-range { -webkit-appearance: none; width: 100%; background: transparent; flex: 1; cursor: pointer; height: 18px; margin: 0; }
.custom-range:focus { outline: none; }
.custom-range::-webkit-slider-runnable-track { width: 100%; height: 2px; cursor: pointer; background: #c8d7ea; border-radius: 999px; }
.custom-range::-moz-range-track { width: 100%; height: 2px; cursor: pointer; background: #c8d7ea; border-radius: 999px; }
.custom-range::-webkit-slider-thumb { height: 18px; width: 3px; background: #0458b7; cursor: pointer; -webkit-appearance: none; margin-top: -8px; border-radius: 2px; box-shadow: none; }
.custom-range::-moz-range-thumb { height: 18px; width: 3px; background: #0458b7; cursor: pointer; border: none; border-radius: 2px; box-shadow: none; }
.custom-number { width: 42px; min-height: 24px; padding: 2px 4px; border: 1px solid #bdd0e5; border-radius: 4px; text-align: center; font-family: inherit; font-size: 12px; color: #0458b7; background-color: #fbfdff; transition: border-color 0.2s; -moz-appearance: textfield; }
.custom-number-wrap { position: relative; display: inline-flex; align-items: center; }
.custom-number-wrap::after { content: attr(data-unit); position: absolute; right: 5px; color: #5b7aa0; font-size: 10px; pointer-events: none; opacity: 0; }
.custom-number-wrap[data-unit]::after { opacity: 1; }
.custom-number--with-unit { text-align: left; }
.custom-number::-webkit-outer-spin-button, .custom-number::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.custom-number:focus { border-color: #0458b7; outline: none; }

/* Geometry tab density overrides */
.geometry-controls .control-section {
  margin-bottom: 10px;
}
.geometry-controls .section-title {
  font-size: 13px;
  margin-bottom: 6px;
}
.geometry-controls .control-group {
  margin-bottom: 5px;
}
.geometry-controls .control-label {
  width: 112px;
  margin-right: 6px;
  font-size: 11px;
  line-height: 1.1;
}
.geometry-controls .info-icon {
  width: 13px;
  height: 13px;
  font-size: 8px;
}
.geometry-controls .slider-container {
  gap: 6px;
  padding-left: 34px;
  box-sizing: border-box;
}
.geometry-controls .custom-range {
  height: 12px;
}
.geometry-controls .custom-range::-webkit-slider-runnable-track {
  height: 2px;
}
.geometry-controls .custom-range::-moz-range-track {
  height: 2px;
}
.geometry-controls .custom-range::-webkit-slider-thumb {
  height: 12px;
  margin-top: -5px;
}
.geometry-controls .custom-range::-moz-range-thumb {
  height: 12px;
}
.geometry-controls .custom-number {
  width: 36px;
  min-height: 22px;
  padding: 1px 3px;
  box-sizing: border-box;
  font-size: 10px;
}
.geometry-controls .custom-number--with-unit {
  padding-left: 2px;
  padding-right: 10px;
}
.geometry-controls .custom-number-wrap::after {
  right: 3px;
  font-size: 8px;
}
.geometry-controls .custom-select {
  min-height: 22px;
  padding: 1px 22px 1px 7px;
  font-size: 10px;
  background-position:
    calc(100% - 9px) 50%,
    calc(100% - 5px) 50%;
}
.geometry-controls .slider-inline-select {
  width: 60px;
  max-width: 60px;
  min-width: 60px;
}
.geometry-controls .toggle-row {
  padding: 0;
}
.geometry-controls .toggle-label {
  font-size: 11px;
  line-height: 1.1;
}
.geometry-controls .toggle-switch {
  width: 18px;
  height: 18px;
}

.toggle-row { display: flex; justify-content: space-between; align-items: center; padding: 2px 0; cursor: pointer; }
.toggle-label { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; color: #365577; font-size: 12px; line-height: 1.2; flex: 1 1 auto; min-width: 0; }
.toggle-label .info-icon { flex: 0 0 auto; margin-left: 0; }
.toggle-switch { position: relative; width: 22px; height: 22px; background-color: #fbfdff; border: 1px solid #bdd0e5; border-radius: 4px; transition: .2s; }
.toggle-switch::after { content: ''; position: absolute; opacity: 0; transition: .2s; }
input[type="checkbox"] { display: none; }
input[type="checkbox"]:checked + .toggle-switch { background-color: #fbfdff; border-color: #bdd0e5; }
input[type="checkbox"]:checked + .toggle-switch::after { opacity: 1; transform: rotate(45deg); width: 6px; height: 12px; border-radius: 0; background: transparent; border-right: 2px solid #0458b7; border-bottom: 2px solid #0458b7; top: 1px; left: 6px; }

.loads-meta {
  margin-top: 14px;
  padding-top: 8px;
  color: #7a8694;
  font-size: 9px;
  line-height: 1.2;
}

.loads-meta p {
  margin: 0;
  overflow-wrap: anywhere;
}

.loads-meta p + p {
  margin-top: 1px;
}

.loads-meta strong {
  color: #6d7885;
  font-weight: 600;
}

.loads-meta__value {
  font-size: 0.95em;
}

.loads-meta__value--codes {
  font-size: 0.88em;
  letter-spacing: -0.01em;
}

.loads-meta__link {
  margin-top: 2px;
  padding: 0;
  border: none;
  background: none;
  display: inline;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.loads-meta__link:hover,
.loads-meta__link:focus-visible {
  color: #4f5c69;
}

/* Analysis Data Groups */
.analysis-group {
  width: 100%;
  margin-bottom: 18px;
  border: none;
  border-radius: 0;
  background: transparent;
  overflow: visible;
  box-sizing: border-box;
}
.analysis-group-header {
  padding: 0 0 8px;
  background: transparent;
  border-bottom: none;
  font-weight: 500;
  color: #0f355d;
  font-size: 17px;
  display: flex;
  justify-content: space-between;
}
.analysis-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0;
  border-bottom: none;
  font-size: 12px;
}
.analysis-row:last-child { border-bottom: none; }
.analysis-label {
  color: #4a627b;
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.analysis-value {
  font-weight: 400;
  color: #3b5876;
  text-align: right;
  flex: 0 0 auto;
  white-space: nowrap;
}
.analysis-row--input {
  align-items: center;
}
.analysis-value--input {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: normal;
}
.analysis-cost-input {
  width: 56px;
  min-height: 26px;
  padding: 2px 6px;
  border: 1px solid #bdd0e5;
  border-radius: 4px;
  text-align: right;
  font-family: inherit;
  font-size: 11px;
  color: #0458b7;
  background-color: #fbfdff;
  box-sizing: border-box;
  -moz-appearance: textfield;
}
.analysis-cost-input::-webkit-outer-spin-button,
.analysis-cost-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.analysis-cost-input:focus {
  border-color: #0458b7;
  outline: none;
}
.analysis-cost-input__unit {
  color: #7a8ea3;
  font-size: 11px;
}
.analysis-row--total {
  padding-top: 4px;
}
.analysis-label--total,
.analysis-value--total {
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.analysis-subheader {
  margin: 14px 0 6px;
  padding: 0;
  font-size: 14px;
  font-weight: 500;
  color: #0f355d;
}

.analysis-note {
  margin: 8px 0 10px;
  font-size: 10px;
  line-height: 1.45;
  color: #7a8ea3;
}

.cfs-floor-breakdown {
  margin-top: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  overflow: visible;
}

.cfs-floor-breakdown__title {
  padding: 0 0 8px;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.15;
  color: #0f355d;
}

.cfs-floor-breakdown__scroll {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0;
}

.cfs-floor-breakdown__table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 8px;
  color: #3b5876;
  font-family: "Roboto Flex", "Open Sans", sans-serif;
}

.cfs-floor-breakdown__table th,
.cfs-floor-breakdown__table td {
  padding: 6px 8px;
  vertical-align: top;
  text-align: left;
}

.cfs-floor-breakdown__table thead th:first-child,
.cfs-floor-breakdown__table tbody th {
  width: 25%;
}

.cfs-floor-breakdown__table thead th:nth-child(2),
.cfs-floor-breakdown__table thead th:nth-child(3),
.cfs-floor-breakdown__table tbody td {
  width: 37.5%;
}

.cfs-floor-breakdown__table thead th {
  padding-top: 4px;
  padding-bottom: 8px;
  font-size: 10px;
  font-weight: 500;
  color: #0f355d;
}

.cfs-floor-breakdown__table tbody th {
  font-size: 11px;
  font-weight: 500;
  color: #4a627b;
  white-space: nowrap;
}

.cfs-floor-breakdown__table tbody td {
  overflow-wrap: normal;
  word-break: normal;
  white-space: nowrap;
  line-height: 1.35;
  font-weight: 400;
  color: #3b5876;
}

.cfs-floor-breakdown__table tbody tr + tr th,
.cfs-floor-breakdown__table tbody tr + tr td {
  border-top: 1px solid #eef2f5;
}

.cfs-floor-breakdown__bypass {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.cfs-floor-breakdown__note {
  margin: 0;
  padding: 10px 0 0;
  font-size: 11px;
  color: #4a627b;
}

.cfs-floor-breakdown__note span {
  font-weight: 500;
  color: #0f355d;
}

@media (max-width: 1280px) {
  .cfs-floor-breakdown__title {
    font-size: 17px;
  }

  .cfs-floor-breakdown__table {
    font-size: 9px;
  }

  .cfs-floor-breakdown__table th,
  .cfs-floor-breakdown__table td {
    padding: 5px 6px;
  }

  .cfs-floor-breakdown__table tbody th {
    font-size: 10px;
  }
}

/* Utilities */
#loading-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(255, 255, 255, 0.8); display: flex; justify-content: center; align-items: center; z-index: 2000; color: #004a97; font-weight: 600; font-size: 1.2em; backdrop-filter: blur(5px); }
#tooltip-container {
  position: fixed;
  z-index: 220;
  left: 0;
  top: 0;
  max-width: min(360px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid rgba(176, 197, 221, 0.95);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 14px 28px rgba(24, 52, 84, 0.18);
  color: #183453;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  overflow: hidden;
}

#tooltip-container.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.tooltip-card {
  width: min(340px, calc(100vw - 32px));
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(246, 250, 255, 0.98) 100%);
}

.tooltip-card--text-only {
  width: auto;
  min-width: 180px;
  max-width: 260px;
}

.tooltip-card__body {
  padding: 12px 14px;
}

.tooltip-card__title {
  margin: 0 0 4px;
  color: #123d69;
  font-size: 13px;
  line-height: 1.25;
  font-weight: 700;
}

.tooltip-card__text {
  margin: 0;
  color: #23486f;
  font-size: 12px;
  line-height: 1.45;
  font-weight: 600;
}

.tooltip-card__caption {
  margin: 8px 0 0;
  color: #5a7593;
  font-size: 11px;
  line-height: 1.4;
  font-weight: 500;
}

.tooltip-card__figure {
  padding: 0 12px 12px;
}

.tooltip-card__figure svg {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid rgba(190, 205, 224, 0.92);
  border-radius: 10px;
  background: #f5e8c8;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

/* --- ERROR LOG PANEL (Inside Drawer) --- */
.error-card {
    margin: 15px;
    padding: 15px;
    border: 1px solid #ffcdd2;
    border-radius: 6px;
    background-color: #fffafb;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.error-card-header {
    color: #d32f2f;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom: 1px solid #ffebee;
    padding-bottom: 8px;
}

.error-icon { font-size: 14px; }
.error-location { font-weight: 600; margin: 4px 0; color: #333; font-size: 13px; }
.error-message { margin: 4px 0; color: #555; line-height: 1.4; }
.error-details {
    margin-top: 8px;
    font-size: 11px;
    color: #334e68;
    background: #fff;
    padding: 10px;
    border-radius: 4px;
    line-height: 1.4;
    border: 1px solid #eee;
    white-space: normal;
    overflow-x: hidden;
    overflow-y: visible;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.error-detail-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    white-space: nowrap;
}

.error-detail-line + .error-detail-line {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #f1f4f8;
}

.error-detail-label {
    min-width: 0;
    font-weight: 600;
    color: #243b53;
}

.error-detail-value {
    flex: 0 0 auto;
    padding: 2px 8px;
    border-radius: 999px;
    background: #fdebec;
    color: #b42318;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.error-hints {
    margin-top: 10px;
    padding: 10px 12px;
    border: 1px solid #f1d5d8;
    border-radius: 4px;
    background: #fff7f8;
}

.error-hints-title {
    font-size: 11px;
    font-weight: 700;
    color: #b43b45;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.error-hints-list {
    margin: 6px 0 0 16px;
    padding: 0;
    color: #5f5760;
    font-size: 12px;
    line-height: 1.45;
}

.error-hints-list li + li {
    margin-top: 4px;
}

/* --- JSON OUTPUT PANEL (New) --- */
#validation-panel {
    padding: 14px 16px 16px;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

.validation-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: #23486f;
}

.validation-panel__hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
}

.validation-panel__icon {
    width: 43px;
    height: 43px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.validation-panel__icon img {
    width: 43px;
    height: 43px;
    object-fit: contain;
}

.validation-panel__title {
    margin: 0;
    font-size: 14px;
    line-height: 1.25;
    font-weight: 500;
    color: #163b62;
}

.validation-panel__body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.validation-panel__body p,
.validation-panel__disclaimer {
    margin: 0;
    font-size: 10px;
    line-height: 1.45;
    color: #365577;
}

.validation-panel__emphasis {
    font-weight: 700;
    color: #163b62;
}

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

.validation-form__actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 2px;
}

.validation-form__actions--hidden {
    display: none;
}

.validation-form__metadata {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.validation-form__metadata--hidden {
    display: none;
}

.validation-form__metadata-label {
    font-size: 10px;
    font-weight: 600;
    color: #163b62;
}

.validation-form__metadata-input {
    width: 100%;
    min-height: 120px;
    border: 1px solid #cfd9e6;
    border-radius: 2px;
    padding: 9px;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 10px;
    line-height: 1.45;
    color: #23486f;
    background: #fff;
    resize: vertical;
}

.validation-form__metadata-input:focus {
    outline: none;
    border-color: #004a97;
    box-shadow: 0 0 0 2px rgba(0, 74, 151, 0.12);
}

.validation-form__input {
    width: 100%;
    min-height: 28px;
    border: 1px solid #cfd9e6;
    border-radius: 2px;
    padding: 0 9px;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 10px;
    color: #23486f;
    background: #fff;
}

.validation-form__input:focus {
    outline: none;
    border-color: #004a97;
    box-shadow: 0 0 0 2px rgba(0, 74, 151, 0.12);
}

.validation-form__submit {
    min-height: 30px;
    border: none;
    border-radius: 2px;
    background: #004a97;
    color: #fff;
    font-family: inherit;
    font-size: 10px;
    font-weight: 400;
    cursor: pointer;
}

.validation-form__submit:hover {
    background: #003f80;
}

.validation-form__submit--secondary {
    background: #edf4fb;
    color: #004a97;
    border: 1px solid #cfd9e6;
}

.validation-form__submit--secondary:hover {
    background: #e0edf9;
}

.validation-form__status {
    margin: 0;
    min-height: 0;
}

.validation-panel__disclaimer {
    border-top: 1px solid #e3e8ef;
    padding-top: 10px;
    margin-top: 2px;
    font-size: 9px;
    line-height: 1.35;
    color: #6b7785;
}

#info-panel {
    padding: 10px 14px 8px;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

.info-panel {
    color: #23486f;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.info-panel__section {
    padding: 9px 0;
}

.info-panel__section + .info-panel__section {
    border-top: 1px solid #e3e8ef;
}

.info-panel__section--legend {
    padding-bottom: 4px;
}

.info-panel__section--applicability {
    padding-top: 6px;
}

.info-panel__section--download {
    padding-top: 8px;
}

.info-panel__section--controls {
    padding-top: 8px;
    padding-bottom: 0;
}

.info-panel__title {
    margin: 0 0 8px;
    font-size: 18px;
    line-height: 1.2;
    font-weight: 500;
    color: #163b62;
}

.info-panel__title--secondary {
    margin-bottom: 8px;
    font-size: 15px;
}

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

.info-panel__item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.info-panel__label {
    font-size: 14px;
    line-height: 1.3;
    color: #365577;
}

.info-panel__mouse {
    position: relative;
    width: 18px;
    height: 30px;
    border: 1px solid #c5d0dc;
    border-radius: 12px;
    background: #ffffff;
    flex: 0 0 auto;
}

.info-panel__mouse::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 50%;
    width: 1px;
    height: 10px;
    background: #c5d0dc;
    transform: translateX(-50%);
}

.info-panel__mouse span {
    position: absolute;
    inset: 0;
}

.info-panel__mouse--rotate span::before,
.info-panel__mouse--zoom span::before,
.info-panel__mouse--pan span::before {
    content: '';
    position: absolute;
    background: #8ea0b5;
}

.info-panel__mouse--rotate span::before {
    top: 4px;
    left: 2px;
    width: 6px;
    height: 10px;
    border-radius: 8px 0 0 0;
}

.info-panel__mouse--zoom span::before {
    top: 4px;
    left: 6px;
    width: 6px;
    height: 10px;
    border-radius: 0 0 3px 3px;
}

.info-panel__mouse--pan span::before {
    top: 15px;
    left: 3px;
    width: 12px;
    height: 9px;
    border-radius: 0 0 8px 8px;
}

.info-panel__description {
    margin: 0 0 10px;
    max-width: none;
    font-size: 13px;
    line-height: 1.4;
    color: #365577;
}

.info-panel__description--wide {
    max-width: 100%;
}

.info-panel__description--compact {
    max-width: none;
    margin-top: 10px;
    margin-bottom: 0;
}

.info-panel__details-copy {
    margin: 0;
    font-size: 12px;
    line-height: 1.45;
    color: #56718f;
}

.info-panel__button {
    width: 100%;
    min-height: 34px;
    border: 1px solid #004a97;
    border-radius: 4px;
    background: #004a97;
    color: #ffffff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.info-panel__button:hover {
    background: #003f80;
    border-color: #003f80;
}

.info-panel__button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 74, 151, 0.16);
}

#json-message-output {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    white-space: pre-wrap;
    padding: 15px;
    font-size: 11px;
    color: #444;
    background-color: #fcfcfc;
    word-break: break-all;
}

/* --- POPUP CONTAINER (Fixed Z-Index) --- */
#popup-container {
  display: none;
  position: absolute;
  background-color: rgba(255, 255, 255, 0.5);
  border: 1px solid #c7d5e6;
  border-radius: 12px;
  padding: 14px 18px 16px;
  font-family: "Roboto Flex", "Open Sans", sans-serif;
  font-size: 13px;
  color: #27496b;
  box-shadow: 0 8px 24px rgba(28, 54, 88, 0.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: auto; 
  max-width: 250px;
  z-index: 2000; 
}

#popup-container h3 {
  margin: 0 0 10px 0;
  font-size: 14px;
  line-height: 1.25;
  border-bottom: none;
  padding-bottom: 0;
  font-weight: 500;
  color: #0f355d;
  cursor: move;
  user-select: none;
}
#popup-container h4 {
  margin-top: 14px;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #0f355d;
  text-transform: none;
  letter-spacing: 0;
}
#popup-container p {
  margin: 3px 0;
  line-height: 1.45;
  font-size: 12px;
  color: #35597d;
}
#popup-container p strong {
  font-weight: 500;
  color: #27496b;
}

#popup-container .popup-controlling-dr {
  text-align: center;
}

@media (max-width: 720px) {
  .startup-modal {
    padding: 18px;
  }

  .startup-modal__panel {
    min-height: auto;
    padding: 24px 20px 28px;
  }

  .startup-modal__brand img {
    width: 132px;
  }

  .startup-modal__content h1 {
    margin: 24px 0 20px;
    font-size: clamp(24px, 8vw, 32px);
  }

  .startup-modal__cta {
    width: 100%;
    min-width: 0;
    font-size: 15px;
  }

  .terms-modal {
    padding: 18px;
  }

  .terms-modal__panel {
    min-height: auto;
    max-height: 84vh;
    padding: 22px 20px 24px;
  }

  .terms-modal__content {
    margin-top: 16px;
  }

  .terms-modal__content p {
    font-size: 14px;
  }

  .terms-modal__body h3 {
    font-size: 16px;
  }

  .terms-modal__body p {
    font-size: 13px;
  }
}
