:root {
  /* GigaCalc desktop palette */
  --bg: #d9dde1;
  --panel: #f2f2f2;
  --panel-soft: #e7e7ea;
  --border: #aeb4bc;
  --border-strong: #7e858f;
  --text: #101010;
  --muted: #3f4550;
  --blue: #3c6fb5;
  --blue-soft: #d9e2f0;
  --blue-soft-border: #b2bfd1;
  --green-soft: #c3edc6;
  --green-border: #7fb887;
  --amber-soft: #f8e6c9;
  --amber-border: #d5b682;
  --red-soft: #f4d1d1;
  --red-border: #c48f8f;
  --mint: #6fc56b;
  --purple-soft: #e1d6f4;
  --purple-border: #b5a3d6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #e6e7ea 0%, #d2d5d9 100%);
  color: var(--text);
  font-family: "Tahoma", "Segoe UI", sans-serif;
  font-size: 13px;
}

.top-bar {
  display: block;
  background: linear-gradient(180deg, #f2f2f3 0%, #d1d3d7 100%);
  border-bottom: 2px solid var(--border-strong);
  box-shadow: inset 0 1px 0 #ffffff, 0 1px 2px rgba(0, 0, 0, 0.08);
}

.top-bar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.logo-mark {
  height: 40px;
  width: auto;
  max-width: 180px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.1));
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-link {
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.top-link:hover,
.top-link:focus-visible {
  color: var(--text);
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.6);
  outline: none;
}

.top-link.active {
  color: #b11919;
}

.btn-info {
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 6px 12px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: inset 0 1px 0 #ffffff, 0 2px 6px rgba(0, 0, 0, 0.08);
}

.btn-info:hover,
.btn-info:focus-visible {
  background: #f7f7f9;
  transform: translateY(-1px);
  outline: none;
}

.splash-logo {
  width: min(420px, 75vw);
  height: auto;
}

.splash-tagline {
  margin: 12px 0 4px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: #b11919;
}

.splash-details {
  margin-top: 16px;
  display: grid;
  gap: 12px;
  max-width: 720px;
  width: 100%;
  text-align: left;
}

.splash-details .feature-grid,
.splash-details .info-panels {
  max-width: none;
  margin: 0;
}

.splash-loader {
  width: 92px;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(177, 25, 25, 0.2), rgba(177, 25, 25, 0.6), rgba(177, 25, 25, 0.2));
  background-size: 200% 100%;
  animation: splash-shimmer 1.2s ease-in-out infinite;
}

#splash-screen {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.9), rgba(217, 221, 225, 0.95));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px 14px;
  overflow-y: auto;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

#splash-screen.fade-out {
  opacity: 0;
  visibility: hidden;
}

.splash-content {
  position: relative;
  text-align: center;
  padding: 26px 30px 32px;
  border-radius: 16px;
  background: linear-gradient(145deg, #ffffff 0%, #f1f2f4 100%);
  border: 1px solid rgba(161, 170, 180, 0.5);
  box-shadow:
    0 12px 30px rgba(18, 32, 54, 0.18),
    inset 0 1px 0 #ffffff;
  width: min(840px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  animation: splash-pop 0.5s ease-out;
}

.splash-close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: none;
  background: rgba(0, 0, 0, 0.04);
  color: var(--muted);
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.splash-close:hover,
.splash-close:focus-visible {
  background: rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
  outline: none;
}

.splash-skip #splash-screen {
  display: none !important;
}

@media (max-width: 780px) {
  #splash-screen {
    align-items: flex-start;
    padding: 16px 10px;
  }

  .splash-content {
    padding: 20px 16px 22px;
    border-radius: 14px;
    max-height: calc(100vh - 32px);
  }

  .splash-logo {
    width: min(280px, 82vw);
  }

  .splash-tagline {
    font-size: 14px;
  }

  .splash-loader {
    width: 72px;
  }

  .splash-details {
    gap: 10px;
  }

  .splash-details .feature-grid,
  .splash-details .info-panels {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .splash-close {
    top: 6px;
    right: 8px;
  }
}

@media (max-width: 480px) {
  .splash-content {
    padding: 18px 14px 20px;
  }

  .splash-tagline {
    font-size: 13px;
  }

  .splash-loader {
    width: 64px;
  }

  .splash-details {
    font-size: 13px;
  }
}

.info-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.info-modal.open {
  display: flex;
}

.info-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(2px);
}

.info-dialog {
  position: relative;
  max-width: 900px;
  width: min(900px, 94vw);
  max-height: 86vh;
  overflow-y: auto;
  background: linear-gradient(145deg, #ffffff 0%, #f3f4f7 100%);
  border-radius: 16px;
  border: 1px solid var(--border-strong);
  padding: 16px 16px 18px;
  box-shadow:
    0 14px 32px rgba(20, 32, 54, 0.28),
    inset 0 1px 0 #ffffff;
}

.info-close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  color: var(--muted);
}

.info-close:hover,
.info-close:focus-visible {
  background: rgba(0, 0, 0, 0.05);
  outline: none;
}

.info-body {
  margin-top: 10px;
}

.info-note {
  color: var(--muted);
  font-size: 13px;
}

.info-hero {
  margin-bottom: 12px;
}

body.info-open {
  overflow: hidden;
}

@keyframes splash-pop {
  from {
    transform: scale(0.96);
    opacity: 0.6;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes splash-float {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes splash-shimmer {
  0% {
    background-position: 0% 50%;
  }
  100% {
    background-position: 200% 50%;
  }
}

.logo-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.logo-name {
  font-weight: 700;
  letter-spacing: 0.2px;
}

.logo-sub {
  color: var(--muted);
  font-size: 12px;
}

.footer {
  display: block;
  background: linear-gradient(180deg, #e3e4e7 0%, #d0d2d6 100%);
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  color: var(--muted);
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
}

.page-container {
  padding: 12px 14px 20px;
}

.iframe-mode {
  background: #ffffff;
  min-height: 100vh;
}

.iframe-mode .page-container {
  padding: 0;
  max-width: none;
  min-height: 100vh;
}

.iframe-mode .ep-shell {
  max-width: none;
  width: 100%;
  margin: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: #ffffff;
  min-height: 100vh;
}

.iframe-mode .mv-results-shell {
  border: none;
  border-radius: 0;
  padding: 12px 12px 16px;
  background: #ffffff;
}

.home-hero {
  max-width: 1160px;
  margin: 0 auto 18px;
  padding: 22px 22px 24px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: linear-gradient(145deg, #ffffff 0%, #eef0f4 100%);
  box-shadow: 0 12px 20px rgba(20, 32, 54, 0.12);
}

.home-hero h1 {
  margin: 0 0 8px;
  font-size: 26px;
  letter-spacing: 0.4px;
}

.home-hero p {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.btn-primary,
.btn-soft,
.btn-warn-light {
  cursor: pointer;
}

.btn-launch {
  background: #b11919;
  color: #ffffff;
  border: 1px solid #7e1515;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 4px 10px rgba(177, 25, 25, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
}

.btn-launch:hover,
.btn-launch:focus-visible {
  background: #c72222;
  box-shadow: 0 6px 14px rgba(177, 25, 25, 0.35);
  outline: none;
}

.btn-link {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background 0.2s ease, color 0.2s ease;
}

.btn-link:hover,
.btn-link:focus-visible {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
  outline: none;
}

.feature-grid {
  max-width: 1160px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.feature-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 14px 16px;
  box-shadow: inset 0 1px 0 #ffffff, 0 6px 14px rgba(20, 32, 54, 0.08);
}

.feature-card h3 {
  margin: 0 0 6px;
  font-size: 16px;
  color: #b11919;
}

.feature-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.info-panels {
  max-width: 1160px;
  margin: 18px auto 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.info-panel {
  background: linear-gradient(180deg, #f7f8fb 0%, #eef0f4 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  box-shadow: inset 0 1px 0 #ffffff, 0 6px 14px rgba(20, 32, 54, 0.08);
}

.info-panel h4 {
  margin: 0 0 8px;
  font-size: 15px;
}

.info-panel ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.55;
}

.ep-shell {
  max-width: 1160px;
  margin: 0 auto;
  background: linear-gradient(180deg, #fafafa 0%, var(--panel) 100%);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 12px 14px 14px;
  box-shadow:
    inset 0 1px 0 #ffffff,
    0 8px 18px rgba(20, 32, 54, 0.12);
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0 8px;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.eq-count {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar-left .btn,
.tabs-row .btn {
  align-self: center;
}

.tabs-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(180deg, #ededed 0%, #d9d9de 100%);
  box-shadow: inset 0 1px 0 #ffffff;
}

.toolbar-left .btn,
.tabs-row .btn {
  align-self: center;
}

.eq-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.eq-row {
  display: grid;
  grid-template-columns: 240px auto auto minmax(320px, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, #f0f0f0 0%, #e1e3e6 100%);
  box-shadow: inset 0 1px 0 #ffffff;
}

.save-with-data {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.save-with-data .inline-checkbox {
  margin: 0;
  white-space: nowrap;
}

.vars-decimals {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}

.fullwidth {
  width: 100%;
}

.eq-name-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
}

.eq-name-wrap input {
  flex: 1;
}

.eq-name-wrap .inline-checkbox {
  margin-left: 4px;
  white-space: nowrap;
}

.eq-name-row {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 6px 10px 10px;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  background: #f0f0f0;
  box-shadow: inset 0 1px 0 #ffffff;
}

.inline-label {
  color: var(--muted);
  font-weight: 600;
}

input[type="text"],
input[type="number"],
select,
textarea {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 13px;
  color: var(--text);
  background: #ffffff;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08);
}

textarea {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--blue-soft-border);
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.1),
    0 0 0 2px rgba(60, 111, 181, 0.12);
}

.input-spinner {
  width: 72px;
  text-align: center;
}

.workspace {
  display: grid;
  grid-template-columns: 5fr 2fr 5fr;
  gap: 12px;
  align-items: start;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  box-shadow: inset 0 1px 0 #ffffff;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.switch-chip {
  padding: 4px 8px;
  border-radius: 12px;
  background: #eef2fa;
  border: 1px solid var(--border);
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
}

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

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

.small-text {
  font-size: 12px;
}

.auto-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.inline-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inline-radio {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
}

.multi-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.multi-row {
  padding: 8px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: #f8faff;
}

.multi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.auto-card {
  margin-top: 10px;
  background: linear-gradient(180deg, #f3f4f6 0%, #eceef2 100%);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  box-shadow: inset 0 1px 0 #ffffff, 0 2px 6px rgba(0, 0, 0, 0.08);
}

.auto-title {
  font-weight: 700;
  color: var(--text);
  gap: 8px;
}

.auto-fields {
  margin-top: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f1f2f5;
  box-shadow: inset 0 1px 0 #ffffff;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cell-input.readonly {
  background: #000000;
  color: #ffe645;
  font-weight: 700;
  border-color: #3a3d42;
  box-shadow: inset 0 1px 0 #2b2d32;
}

.panel {
  background: linear-gradient(180deg, #fbfbfb 0%, #f0f1f3 100%);
  border: 1px solid #c6c6c6;
  border-radius: 10px;
  padding: 10px;
  box-shadow: inset 0 1px 0 #ffffff, 0 1px 3px rgba(0, 0, 0, 0.05);
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.inline-form {
  margin: 0;
}

.vars-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  border: 1px solid #c6c6c6;
  background: #f6f7f8;
  border-radius: 8px;
  overflow: hidden;
}

.vars-grid thead {
  display: none;
}

.vars-grid th,
.vars-grid td {
  border: 1px solid #c6c6c6;
  padding: 8px 10px;
  text-align: left;
  background: #ffffff;
}

.vars-grid .var-name {
  font-weight: 700;
  color: #101010;
}

.vars-grid th.col-index,
.vars-grid td.col-index {
  width: 44px;
  text-align: center;
  color: #6a6a6a;
  background: #efefef;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.vars-grid th.col-clear,
.vars-grid td.col-clear {
  width: 56px;
  text-align: center;
}

.vars-grid td:nth-child(3) {
  text-align: right;
}

.vars-grid .cell-input {
  text-align: right;
}
.vars-grid input.readonly {
  background: #000000;
  color: #ffe645;
  border-color: #3a3d42;
}

.vars-grid tbody tr:nth-child(even) {
  background: #f4f4f6;
}

.cell-input {
  width: 100%;
  border: 1px solid #c6c6c6;
  border-radius: 4px;
  padding: 6px 8px;
  background: #fff;
}

/* Small popover for variable values (shown when clicking VR, V1, V2, etc.) */
.value-popover {
  position: fixed;
  z-index: 11000;
  background: #111827;
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.35);
  pointer-events: none;
  display: none;
  max-width: 260px;
  word-break: break-word;
}
.value-popover::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #111827;
}

.cell-input:focus {
  border-color: var(--blue-soft-border);
  box-shadow: 0 0 0 2px rgba(60, 111, 181, 0.12);
}

.table-placeholder {
  padding: 20px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  background: #f0f2f4;
}

.actions-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.button-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.center-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.side-panel .btn.fullwidth {
  width: 100%;
}

.result-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(180deg, #e7e7ea 0%, #d9dce0 100%);
  box-shadow: inset 0 1px 0 #ffffff;
}

.result-value {
  font-weight: 700;
  color: #ffe645;
  background: #000000;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #404347;
  min-width: 96px;
  text-align: center;
}

.result-placeholder {
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

.auto-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.auto-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 700;
  color: var(--muted);
}

.auto-row label select,
.auto-row label input[type="text"] {
  width: 100%;
  font-weight: 600;
}

.auto-card input[type="text"],
.auto-card input[type="number"],
.auto-results-grid input[type="text"],
.auto-results-grid input[type="number"] {
  text-align: right;
}

.auto-row:first-of-type {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
}

.inline-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-weight: 600;
}

.auto-fields .inline-checkbox {
  color: var(--text);
  font-weight: 700;
  margin-top: 2px;
}

.save-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-bar {
  margin-top: 2px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(180deg, #ededed 0%, #dcdfe3 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: inset 0 1px 0 #ffffff;
}

.status-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.saved-select {
  min-width: 140px;
  background: #f6f6f6;
  border-color: var(--border-strong);
}

.eq-preview {
  flex: 1;
  min-width: 220px;
  background: #f4f4f4;
  border: 1px solid var(--border-strong);
}

.status-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  border-radius: 5px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff 0%, #e0e2e6 100%);
  padding: 6px 12px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  box-shadow: inset 0 1px 0 #ffffff, 0 1px 2px rgba(0, 0, 0, 0.12);
  transition: transform 0.05s ease, box-shadow 0.1s ease, filter 0.1s ease;
}

.btn:disabled,
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.btn:hover {
  box-shadow: inset 0 1px 0 #fff, 0 2px 6px rgba(0, 0, 0, 0.14);
  filter: brightness(1.03);
}

.btn:active {
  transform: translateY(1px);
}

.btn-soft {
  background: linear-gradient(180deg, #ffffff 0%, #e5e7eb 100%);
}

.btn-primary {
  background: linear-gradient(180deg, #efe5ff 0%, #d6c9f2 100%);
  border-color: var(--purple-border);
  color: #3f2d76;
}

.btn-calc {
  background: linear-gradient(180deg, #4ed76c 0%, #38b956 100%);
  border-color: #2f9d49;
  color: #0b3b1a;
  font-weight: 800;
}

.btn-warn {
  background: linear-gradient(180deg, var(--amber-soft) 0%, #fde9d1 100%);
  border-color: var(--amber-border);
  color: #75430e;
}

.btn-warn-light {
  background: linear-gradient(180deg, #fff9f1 0%, #ffe8cd 100%);
  border-color: var(--amber-border);
  color: #8a5314;
}

.btn-danger {
  background: linear-gradient(180deg, var(--red-soft) 0%, #f9dede 100%);
  border-color: var(--red-border);
  color: #7a1f1f;
}

.btn-danger-light {
  background: linear-gradient(180deg, #fff0f0 0%, #f7dada 100%);
  border-color: var(--red-border);
  color: #7a1f1f;
}

.btn-clear {
  padding: 4px 10px;
  background: linear-gradient(180deg, #f3caca 0%, #e0b3b3 100%);
  border-color: #c48f8f;
  color: #4a1919;
  border-radius: 6px;
}
.vars-grid .btn-clear {
  padding: 4px 8px;
  min-width: 40px;
}

.tab-btn {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #f7f7f8 0%, #dfdfe3 100%);
  border-radius: 6px;
  padding: 7px 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  box-shadow: inset 0 1px 0 #fff;
}

.tab-btn.active {
  background: linear-gradient(180deg, #dff4df 0%, #c6e8c6 100%);
  border-color: var(--green-border);
  color: #1d5b1d;
  box-shadow: inset 0 1px 0 #ffffff, 0 2px 6px rgba(0, 0, 0, 0.12);
}

.alert {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
  box-shadow: inset 0 1px 0 #ffffff;
}

.alert-error {
  background: var(--red-soft);
  border-color: var(--red-border);
  color: #7a1f1f;
}

.alert-info {
  background: #e9f2ff;
  border-color: var(--blue-soft-border);
  color: #1f4e8c;
}

.mv-tab-content.hidden {
  display: none;
}

.mv-settings {
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f7f9fc;
}

.error {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--red-border);
  background: var(--red-soft);
  color: #7a1f1f;
  margin: 8px 0;
}

.message {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f7f9fc;
  color: var(--text);
  margin: 8px 0;
}

.fx-shell {
  max-width: 900px;
  margin: 0 auto;
  border: 1px solid #8f8f8f;
  background: #d7dbe2;
  box-shadow: inset 0 1px 0 #ffffff, 0 2px 6px rgba(0, 0, 0, 0.15);
  padding: 8px;
}

.fx-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, #dfe2e6 0%, #c1c6ce 100%);
  border: 1px solid #8f8f8f;
  padding: 6px 8px;
  margin-bottom: 8px;
}

.fx-title {
  font-weight: 700;
  color: #1c1c1c;
}

.fx-window-controls {
  display: inline-flex;
  gap: 4px;
}

.fx-toolbar {
  background: #d3d7df;
  border: 1px solid #8f8f8f;
  padding: 8px;
  margin-bottom: 8px;
}

.fx-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.fx-label {
  font-weight: 700;
}

.fx-btn {
  border: 1px solid #8f8f8f;
  background: linear-gradient(180deg, #ffffff 0%, #e2e4e7 100%);
  padding: 4px 10px;
  font-weight: 700;
  color: #111;
  cursor: pointer;
}

.fx-btn.tiny {
  padding: 2px 6px;
}

.fx-body {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 8px;
  background: #d7dbe2;
}

.fx-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fx-list {
  width: 100%;
  height: 320px;
  border: 1px solid #8f8f8f;
  background: #ffffff;
  font-weight: 700;
}

.fx-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.fx-op {
  font-weight: 700;
  color: #0f0f0f;
}

.fx-right {
  display: flex;
  flex-direction: column;
}

.fx-desc {
  width: 100%;
  height: 320px;
  border: 1px solid #8f8f8f;
  background: #ffffff;
  padding: 8px;
  resize: none;
}

.wide-shell {
  max-width: 1200px;
}

.tall-panel {
  padding: 14px;
}

.table-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.chart-wrapper {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #d4d0c8;
  margin-bottom: 12px;
}

.results-table.compact th,
.results-table.compact td {
  padding: 6px 8px;
}

.stats-panel {
  margin-top: 10px;
  padding: 14px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.stats-runner {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
}

.chart-row {
  padding: 8px 0;
}

/* Auto results (table + right controls) */
.auto-results-grid {
  display: grid;
  grid-template-columns: minmax(520px, 2fr) minmax(320px, 1fr);
  gap: 16px;
  align-items: stretch;
}

.auto-table-panel {
  padding: 0;
}

.auto-table-shell {
  background: linear-gradient(180deg, #f8f9fb 0%, #e7eaef 100%);
  border: 1px solid #8a94a6;
  border-radius: 12px;
  box-shadow: inset 0 1px 0 #ffffff, 0 2px 8px rgba(19, 31, 51, 0.12);
  padding: 8px 10px 10px;
}

.auto-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 8px 8px;
  background: linear-gradient(180deg, #e8ebf1 0%, #d7dbe3 100%);
  border: 1px solid #9aa6b8;
  border-radius: 10px;
  box-shadow: inset 0 1px 0 #ffffff;
}

.sheet-title {
  font-weight: 800;
  color: #14263d;
  letter-spacing: 0.3px;
}

.sheet-subtitle {
  color: #4b5563;
  font-size: 12px;
  margin-top: 2px;
}

.record-chip {
  min-width: 118px;
  text-align: center;
  background: linear-gradient(180deg, #e8ecf3 0%, #d5d9e1 100%);
  border: 1px solid #9ba6b8;
  border-radius: 9px;
  padding: 6px 10px;
  box-shadow: inset 0 1px 0 #ffffff;
}

.chip-label {
  font-size: 11px;
  color: #4b5563;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.chip-value {
  font-weight: 800;
  color: #10253f;
  letter-spacing: 0.4px;
}

.auto-table-wrap {
  margin-top: 10px;
  border: 1px solid #8d98aa;
  border-radius: 10px;
  background: linear-gradient(180deg, #fdfefe 0%, #f1f4f9 100%);
  box-shadow: inset 0 1px 0 #ffffff;
  max-height: 540px;
  overflow: auto;
}

.auto-grid-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 340px;
}

.auto-grid-table thead th {
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, #1c4f8d 0%, #0f2f57 100%);
  color: #ffffff;
  text-align: center;
  padding: 8px 10px;
  border: 1px solid #0f2f57;
  letter-spacing: 0.4px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.auto-grid-table tbody td {
  border: 1px solid #9aa6b8;
  padding: 7px 10px;
  text-align: right;
  background: #ffffff;
  font-weight: 400;
}

.auto-grid-table tbody tr:nth-child(even) td {
  background: #eef3fb;
}

.auto-evaluate-shell .auto-grid-table tbody tr:nth-child(even) td {
  background: #ffffff;
}

.auto-grid-table tbody tr:hover td {
  background: #d7e6ff;
}

.auto-grid-table tbody tr.search-hit td,
.auto-grid-table tbody td.search-hit {
  background: #c8dcff !important;
}

.auto-grid-table tbody tr.search-active td,
.auto-grid-table tbody tr.search-active td {
  background: #9fc0ff !important;
  font-weight: 400;
}

.auto-grid-table tbody td.selected-cell {
  background: #ffe9c9 !important;
  outline: 2px solid #2f5fb5;
  box-shadow: inset 0 0 0 1px #2f5fb5;
}

.auto-grid-table.highlight-col-0 thead th:nth-child(1),
.auto-grid-table.highlight-col-0 tbody td:nth-child(1) {
  background: linear-gradient(180deg, #c8dcff 0%, #a9c8ff 100%);
  color: #0f2f57;
  font-weight: 500;
}

.auto-grid-table.highlight-col-1 thead th:nth-child(2),
.auto-grid-table.highlight-col-1 tbody td:nth-child(2) {
  background: linear-gradient(180deg, #c8dcff 0%, #a9c8ff 100%);
  color: #0f2f57;
  font-weight: 500;
}

.results-table td.neg,
.auto-grid-table tbody td.neg {
  color: #b00020 !important;
  font-weight: 400;
}

/* Keep negatives red but not bold, even in the highlighted "Quick Find" column. */
.auto-grid-table.highlight-col-0 tbody td.neg:nth-child(1),
.auto-grid-table.highlight-col-1 tbody td.neg:nth-child(2) {
  font-weight: 400;
}

.auto-side {
  padding: 0;
}

.auto-console {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, #f6f7f9 0%, #e4e6eb 100%);
  border: 1px solid #9aa6b8;
  box-shadow: inset 0 1px 0 #ffffff, 0 2px 8px rgba(19, 31, 51, 0.12);
}

.block-title {
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--muted);
}

.console-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.top-actions .btn {
  flex: 1 1 calc(50% - 10px);
  min-width: 120px;
}

.format-row {
  justify-content: space-between;
  background: #f9fafc;
  border: 1px solid #c7ceda;
  border-radius: 9px;
  padding: 8px 10px;
  box-shadow: inset 0 1px 0 #ffffff;
}

.search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.format-row .inline-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 700;
  color: #2f3743;
}

.format-row .inline-checkbox {
  color: #2f3743;
  font-weight: 700;
}

.search-stack {
  flex-direction: column;
  align-items: stretch;
  background: linear-gradient(180deg, #ffffff 0%, #edf0f5 100%);
  border: 1px solid #c0c8d4;
  border-radius: 10px;
  padding: 10px;
  box-shadow: inset 0 1px 0 #ffffff;
}

.search-stack .search-row {
  margin: 0;
}

.search-stack .search-row input {
  width: 100%;
}

.column-pills {
  gap: 12px;
  flex-wrap: wrap;
}

.auto-side .inline-radio {
  color: var(--text);
  font-weight: 600;
}

.stats-stack {
  flex-direction: column;
  align-items: stretch;
  background: #f2f3f6;
  border: 1px solid #c3c9d4;
  border-radius: 10px;
  padding: 10px;
  box-shadow: inset 0 1px 0 #ffffff;
}

.stats-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #e0e2e6;
  border: 1px solid #b2b9c6;
  border-radius: 8px;
  padding: 8px;
}

.stat-choice {
  font-weight: 700;
  color: #1f2937;
}

.stats-list {
  background: #f9fafc;
  border: 1px solid #aab4c4;
  border-radius: 8px;
  padding: 6px;
  height: 150px;
  font-weight: 700;
  color: #1f2937;
}

.calc-row {
  justify-content: space-between;
  align-items: stretch;
}

.calc-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  justify-content: center;
}

.calc-auto {
  font-weight: 700;
  color: #2f3743;
}

.calc-display {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border: 1px solid #b2b9c6;
  border-radius: 8px;
  background: #0e0e0e;
  box-shadow: inset 0 1px 0 #2b2d32;
}

.calc-display input {
  background: #0e0e0e;
  color: #e6f2ff;
  border: none;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.4px;
  padding: 4px 6px 2px;
}

.calc-label {
  color: #aab4c4;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.calc-row .btn-calc {
  align-self: center;
  min-width: 150px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.results-table.compact th,
.results-table.compact td {
  padding: 6px 8px;
}

/* Search popup (override `.modal-inner` sizing which is defined later in the file) */
.modal-inner.search-modal {
  /* Keep Search popup compact (draggable). */
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 10px;
  gap: 8px;
}
.modal-inner.search-modal input[type="text"],
.modal-inner.search-modal input[type="number"] {
  text-align: right;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: move;
}

.search-form {
  display: grid;
  /* Keep Column/Compare/Value on one row (plus +/-/to). */
  grid-template-columns: repeat(4, auto);
  justify-content: start;
  align-items: end;
  gap: 8px;
  margin: 6px 0;
}
.search-form label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 4px;
  white-space: nowrap;
}
.search-form select,
.search-form input[type="text"],
.search-form input[type="number"] {
  width: 120px;
  max-width: 140px;
}

.search-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  flex-wrap: wrap;
}

.modal-inner.search-modal .btn {
  min-width: 140px;
  text-align: center;
}

.modal-inner.export-modal {
  width: min(460px, calc(100vw - 32px));
  max-width: min(460px, calc(100vw - 32px));
  padding: 12px;
  gap: 12px;
}

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

.export-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 700;
  color: var(--muted);
}

.export-form input[type="text"] {
  width: 100%;
  text-align: left;
}

.export-note {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.export-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-inner.plot-modal {
  /* Bigger plot popup; keep it inside viewport and let controls wrap. */
  width: min(1280px, calc(100vw - 20px));
  max-width: min(1280px, calc(100vw - 20px));
  height: min(96vh, calc(100vh - 20px));
  max-height: calc(100vh - 20px);
  min-height: min(700px, calc(100vh - 20px));
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 12px 10px;
  display: flex;
  flex-direction: column;
}
.plot-modal .chart-wrapper {
  width: 100%;
  max-width: 100%;
  height: auto;
  min-height: 760px;
  margin: 0;
  flex: 1 0 auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.chart-highcharts {
  width: 100%;
  height: 100%;
  flex: 1 1 auto;
  min-height: 760px;
}
.chart-highcharts.hidden {
  display: none;
}
.plot-modal canvas {
  width: 100% !important;
  height: 100% !important;
  max-width: none;
  display: block;
  flex: 1 1 auto;
  min-height: 760px;
}
/* Let the plot resize freely with the resizable dialog (avoid forcing horizontal scroll). */
.plot-top-row {
  min-width: 0;
}
.plot-modal .chart-wrapper {
  min-width: 0;
}
.plot-modal #plot-canvas,
.plot-modal #mv-plot-canvas {
  min-width: 0;
}

.modal-inner[data-resizable] .resize-handle,
.plot-config .resize-handle {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  background:
    linear-gradient(135deg, transparent 0 50%, rgba(16, 37, 63, 0.28) 50% 60%, transparent 60%),
    linear-gradient(135deg, transparent 0 65%, rgba(16, 37, 63, 0.28) 65% 75%, transparent 75%),
    linear-gradient(135deg, transparent 0 80%, rgba(16, 37, 63, 0.28) 80% 90%, transparent 90%);
  opacity: 0.75;
  user-select: none;
  touch-action: none;
}
.modal-inner[data-resizable] .resize-handle:hover,
.plot-config .resize-handle:hover {
  opacity: 1;
}

.plot-top-row {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 8px 14px;
  margin: 0 0 8px;
  font-size: 13px;
  flex-shrink: 0;
}

.plot-controls-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin: 0;
}

.plot-actions-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 14px;
  margin: 0;
  padding: 4px 0 0;
  border-top: 1px solid var(--border, #d1d5db);
}

.plot-top-row .plot-controls {
  margin: 0;
  padding: 0;
  font-size: 13px;
}

.plot-top-row .plot-actions {
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.plot-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin: 0;
  font-size: 13px;
}

.plot-controls label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: normal;
}

.plot-settings-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 0;
  font-size: 13px;
}

.plot-advanced {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(135deg, #f7fbff 0%, #ffffff 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.plot-advanced + .plot-advanced {
  margin-top: 10px;
}

.plot-advanced-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 8px;
}

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

.plot-advanced-grid .inline-checkbox {
  align-items: center;
}

.plot-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.plot-chip {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid #d4dae6;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.plot-gradient-preview {
  height: 40px;
  border-radius: 10px;
  border: 1px solid #d4dae6;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.plot-inline-note {
  font-size: 12px;
  color: #5f6b7a;
}

.plot-settings-links .btn-link {
  background: transparent;
  border: none;
  padding: 4px 6px;
  color: #1b4f9c;
  text-decoration: underline;
  cursor: pointer;
  font-size: 13px;
}

.plot-config {
  position: fixed;
  inset: 8% auto auto 50%;
  transform: translateX(-50%);
  width: min(620px, calc(100vw - 20px));
  max-height: min(84vh, calc(100vh - 20px));
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(12, 24, 44, 0.25);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* needed for resize handle positioning */
  position: fixed;
}

.plot-config.hidden {
  display: none;
}

.plot-config-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: linear-gradient(135deg, #ecf4ff 0%, #fefefe 100%);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}

.plot-config-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px;
  overflow: auto;
}

.plot-config .plot-advanced {
  background: transparent;
  box-shadow: none;
  padding: 0;
  border: none;
}

#plot-canvas {
  width: 100% !important;
  height: 100% !important;
  margin: 0 auto;
  display: block;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 32, 54, 0.35);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10px;
  z-index: 9999;
  overflow: auto;
}

.modal.hidden {
  display: none;
}

.modal-inner {
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(20, 32, 54, 0.25);
  max-width: 960px;
  width: auto;
  max-height: 90vh;
  padding: 6px 10px 10px;
  display: inline-flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

@media (max-width: 1024px) {
  .modal-inner.plot-modal {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    height: calc(100vh - 16px);
    max-height: calc(100vh - 16px);
    min-height: 0;
    padding: 8px 10px 10px;
  }
}

@media (max-width: 760px) {
  .modal {
    padding: 8px;
  }

  .plot-controls {
    gap: 8px 10px;
  }

  .plot-controls label {
    flex-wrap: wrap;
  }

  .plot-controls label.inline-checkbox {
    flex-wrap: nowrap;
  }

  .plot-settings-links {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .plot-top-row .plot-actions .btn {
    flex: 1 1 120px;
  }

  .plot-modal .chart-wrapper,
  .chart-highcharts,
  .plot-modal canvas {
    min-height: 480px;
  }

  .plot-modal .chart-wrapper {
    width: 100%;
    height: auto;
  }

  .plot-config {
    inset: 8px auto auto 50%;
    width: min(620px, calc(100vw - 16px));
    max-height: calc(100vh - 16px);
  }
}

.modal-body {
  overflow: auto;
  flex: 1;
  padding: 0;
}

.modal-close {
  align-self: flex-end;
}

.modal-chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.modal-drag-handle {
  flex: 1;
  height: 14px;
  border-radius: 10px;
  background: linear-gradient(90deg, #eef1f7, #d7dde9);
  border: 1px solid #c3cad8;
  cursor: move;
  box-shadow: inset 0 1px 0 #ffffff;
}

.modal.dragging {
  cursor: grabbing;
}

.hidden-section {
  display: none !important;
}

.sw-alert.hidden {
  display: none;
}
.sw-alert {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sw-alert-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

/* ------------------------------------------------------------
   Print styles
------------------------------------------------------------ */
@media print {
  @page {
    margin: 12mm;
  }

  body {
    background: #fff !important;
    /* Force black & white printing (no gradients/colors). */
    -webkit-print-color-adjust: economy;
    print-color-adjust: economy;
  }

  /* Ensure the auto results table prints fully (no scroll box). */
  .auto-table-wrap {
    max-height: none !important;
    overflow: visible !important;
    box-shadow: none !important;
  }

  /* Black/white table styling for print. */
  .auto-table-shell,
  .auto-table-toolbar,
  .record-chip,
  .auto-grid-table,
  .auto-grid-table thead th,
  .auto-grid-table tbody td {
    background: #fff !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }
  .auto-grid-table thead th,
  .auto-grid-table tbody td,
  .auto-table-toolbar,
  .record-chip,
  .auto-table-wrap {
    border-color: #000 !important;
  }
  .auto-grid-table tbody tr:nth-child(even) td,
  .auto-grid-table tbody tr:hover td,
  .auto-grid-table tbody tr.search-hit td,
  .auto-grid-table tbody tr.search-active td,
  .auto-grid-table tbody td.search-hit,
  .auto-grid-table tbody td.search-active,
  .auto-grid-table tbody td.selected-cell {
    background: #fff !important;
    outline: none !important;
  }

  /* Extra spacing/legibility when printed. */
  .auto-grid-table {
    width: 100%;
  }
  .auto-grid-table th,
  .auto-grid-table td {
    padding: 9px 12px !important;
    line-height: 1.35;
    font-variant-numeric: tabular-nums;
  }
  .auto-grid-table th + th,
  .auto-grid-table td + td {
    padding-left: 18px !important;
  }
  #autoTable th,
  #autoTable td {
    min-width: 140px;
  }

  /* Sticky headers don't paginate well in print. */
  .auto-grid-table thead th {
    position: static !important;
  }

  /* Repeat table header on each printed page. */
  .auto-grid-table thead {
    display: table-header-group;
  }

  .auto-grid-table tbody {
    display: table-row-group;
  }

  .auto-grid-table tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* Remove UI chrome that wastes space on paper. */
  .auto-table-shell,
  .auto-table-toolbar,
  .record-chip {
    box-shadow: none !important;
  }
}
.sw-alert-box {
  position: relative;
  background: linear-gradient(180deg, #ffffff 0%, #f3f5f8 100%);
  border: 1px solid #8da0c3;
  border-radius: 14px;
  padding: 14px 16px;
  min-width: 280px;
  max-width: 460px;
  width: 88vw;
  box-shadow:
    0 14px 38px rgba(0, 0, 0, 0.18),
    0 6px 16px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 #ffffff;
  z-index: 1;
}
.sw-alert-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.sw-alert-title {
  font-weight: 800;
  color: #10253f;
  font-size: 16px;
}
.sw-alert-close {
  padding: 4px 10px;
  min-width: 32px;
}
.sw-alert-body {
  margin: 10px 0 12px;
  color: #1f2937;
  line-height: 1.4;
  font-weight: 600;
}
.sw-alert-actions {
  display: flex;
  justify-content: flex-end;
}

/* ------------------------------------------------------------
   Multi-variable details page styling
------------------------------------------------------------- */

.mv-panel-heading {
  font-weight: 700;
  color: #1c1c1c;
  padding-bottom: 4px;
  margin-bottom: 6px;
  border-bottom: 1px solid #8f8f8f;
  letter-spacing: 0.05px;
}
.mv-back-bar {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 12px;
}
.mv-back-link {
  font-weight: 700;
}
.mv-run-grid label,
.mv-inline-fields label {
  color: #1b1b1b;
  font-weight: 700;
  font-size: 13px;
}

.mv-run-card input.mv-input,
.mv-tabs-card input.mv-input,
.mv-run-card select.mv-input,
.mv-tabs-card select.mv-input {
  background: #ffffff;
  border: 1px solid #8f8f8f;
  border-radius: 4px;
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.1);
}
.mv-run-card input[type="text"],
.mv-run-card input[type="number"],
.mv-tabs-card input[type="text"],
.mv-tabs-card input[type="number"],
.mv-settings-card input[type="text"],
.mv-settings-card input[type="number"],
.mv-footer-bar input[type="text"],
.mv-footer-bar input[type="number"] {
  text-align: right;
}

.mv-panel-title {
  color: #3f4550;
  font-size: 13px;
  font-weight: 700;
}

.mv-run-card,
.mv-tabs-card,
.mv-values-card {
  border-radius: 8px;
  background: linear-gradient(180deg, #e3e4e7 0%, #d1d3d8 100%);
  border: 1px solid #8f8f8f;
  box-shadow: inset 0 1px 0 #ffffff, 0 1px 3px rgba(0, 0, 0, 0.08);
}

.mv-pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 8px 0;
}

.mv-auto-toggle,
.mv-restore-top {
  background: #000000;
  color: #ffffff;
  padding: 8px 10px;
  border-radius: 4px;
  border: 1px solid #4b4f55;
  box-shadow: inset 0 1px 0 #5a5a5a;
  font-weight: 700;
}

.mv-auto-toggle input,
.mv-restore-top input {
  accent-color: #1f1f1f;
}

.mv-pane-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 12px;
  align-items: start;
}

.mv-pane-left {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mv-input-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 700;
  color: #1b1b1b;
}

.mv-input-label input {
  background: #ffffff;
  border: 1px solid #8f8f8f;
  border-radius: 4px;
  padding: 6px 8px;
}

.mv-section-title {
  font-weight: 700;
  color: #3f4550;
  margin-bottom: 6px;
}

.mv-run-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: center;
}

.mv-input {
  width: 100%;
  font-weight: 600;
}

.mv-short {
  max-width: 200px;
}

.mv-save-each {
  margin-top: 8px;
}

.mv-tabs {
  display: inline-flex;
  gap: 2px;
  background: #d4d4d4;
  padding: 4px;
  border-radius: 6px;
  border: 1px solid #8f8f8f;
  margin-bottom: 10px;
}

.mv-equation-display {
  text-align: center;
  font-weight: 700;
  color: #1b2d46;
  margin: 8px 0 10px;
}
.mv-equation-display .muted {
  color: #6b7280;
  margin-right: 6px;
  font-weight: 600;
}

.mv-pill {
  border: 1px solid #8f8f8f;
  background: linear-gradient(180deg, #f3f3f3 0%, #e0e0e0 100%);
  padding: 6px 14px;
  border-radius: 4px;
  font-weight: 700;
  color: #1f1f1f;
  cursor: pointer;
  box-shadow: inset 0 1px 0 #ffffff;
}

.mv-pill.active {
  background: linear-gradient(180deg, #ffffff 0%, #f2f2f2 100%);
  border-color: #6f6f6f;
  color: #0e0e0e;
}

.mv-pane {
  margin-top: 12px;
  border: 1px solid #8f8f8f;
  border-radius: 10px;
  padding: 12px;
  background: linear-gradient(180deg, #e7e7ea 0%, #d9dbe0 100%);
  box-shadow: inset 0 1px 0 #ffffff;
}

.is-hidden {
  display: none;
}

.mv-inline-fields {
  margin-top: 8px;
}

.mv-settings-card {
  margin-top: 10px;
  border: 1px solid #4b4f55;
  border-radius: 14px;
  padding: 14px;
  background: linear-gradient(180deg, #6b6d71 0%, #57595d 100%);
  box-shadow: inset 0 1px 0 #8d8f93, 0 1px 6px rgba(0, 0, 0, 0.25);
}

.mv-settings-head {
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 10px;
}

.mv-settings-card label {
  color: #f3f3f3;
  font-weight: 700;
}

.mv-settings-card input,
.mv-settings-card select {
  background: #9a9a9e;
  color: #0e0e0e;
  border: 1px solid #3d3f44;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
}

.mv-settings-head {
  display: none;
}

.mv-var-chip {
  margin-left: auto;
  background: #3d3d3f;
  border: 1px solid #2f2f32;
  border-radius: 4px;
  padding: 4px 8px;
  color: #ffffff;
  font-weight: 700;
}

.mv-radio-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
  color: #ffffff;
}

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

.mv-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.mv-until-row label:last-child input {
  text-align: right;
}

.mv-value-field {
  display: flex;
  gap: 6px;
}

.mv-value-field input {
  width: 100%;
}

.mv-until-box {
  margin: 10px 0;
  padding: 10px;
  border: 1px solid #2f2f32;
  border-radius: 6px;
  background: #636466;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mv-until-title {
  color: #ffffff;
  font-weight: 700;
  margin-right: 4px;
}

.mv-restore {
  margin-top: 6px;
}

.mv-footer-bar {
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid #9fa6b0;
  border-radius: 10px;
  background: linear-gradient(180deg, #efefef 0%, #d8d8dc 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: inset 0 1px 0 #ffffff;
}

.mv-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.mv-footer-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.mv-actions .btn-primary {
  background: linear-gradient(180deg, #e7e7e7 0%, #d5d5d5 100%);
  border-color: #8f8f8f;
  color: #111;
  font-weight: 700;
}

.mv-actions .btn-soft {
  background: linear-gradient(180deg, #c3f1c8 0%, #a3d8aa 100%);
  border-color: #6fad75;
  color: #0f2d18;
  font-weight: 700;
}

.mv-actions .btn-warn {
  background: linear-gradient(180deg, #d8d6c5 0%, #c6c3b1 100%);
  border-color: #a49f8c;
  color: #3a3118;
}

.mv-empty-state {
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: #f9fbff;
}

/* ------------------------------------------------------------
   Multi-variable results (table view)
------------------------------------------------------------- */
.mv-results-shell {
  padding: 14px 16px 16px;
  background: #f2f5fa;
  border-radius: 12px;
  border: 1px solid #d9e1ec;
}

.mv-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.mv-pill {
  padding: 10px 18px;
  min-width: 42px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #f7fbff 0%, #eef3fb 100%);
  color: #375c92;
  font-weight: 700;
  font-size: 16px;
  box-shadow: inset 0 1px 0 #fff, 0 1px 3px rgba(0,0,0,0.08);
}

.mv-title {
  margin: 0;
}

.mv-columns-card {
  padding: 12px;
  border-radius: 12px;
  box-shadow: inset 0 1px 0 #fff, 0 1px 6px rgba(25, 45, 80, 0.06);
  margin-bottom: 10px;
}

.mv-soft {
  background: #f8fbff;
  border-color: #d6deeb;
}

.mv-columns-title {
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
}

.mv-columns-wrap {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f6f9ff;
  box-shadow: inset 0 1px 0 #fff;
}

.mv-col-item {
  color: var(--text);
  font-weight: 600;
}

.mv-table-card {
  padding: 12px;
  margin-top: 8px;
}

.mv-table-shell {
  border: 1px solid #d9e1ec;
  border-radius: 12px;
  background: #f5f7fb;
  padding: 10px;
  box-shadow: inset 0 1px 0 #fff;
  margin-top: 6px;
  box-shadow: inset 0 1px 0 #fff, 0 1px 8px rgba(22, 39, 71, 0.05);
}

.mv-table-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: auto;
  max-height: 520px;
  min-height: 260px;
  background: #fff;
  box-shadow: inset 0 1px 0 #fff, 0 1px 8px rgba(22, 39, 71, 0.05);
}

.mv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.mv-table thead th {
  background: linear-gradient(180deg, #eef2f8 0%, #e6ebf4 100%);
  border-bottom: 1px solid #dce3ed;
  padding: 11px 12px;
  text-align: left;
  color: #5f7085;
  font-weight: 700;
  border-right: 1px solid #e3e8f0;
}

.mv-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid #e4e9f2;
  vertical-align: middle;
  border-right: 1px solid #e9edf4;
}

.mv-table tbody tr:nth-child(even) {
  background: #f9fbff;
}

.mv-table tbody tr:hover {
  background: #eef3fb;
}

.mv-row-head {
  width: 46px;
  text-align: center;
  color: var(--muted);
  background: #f2f5fa;
  border-right: 1px solid #dfe4ed;
  font-weight: 700;
}

/* Multi-result: highlight currently selected "Quick Find" column (like auto-evaluate). */
.auto-grid-table thead th.mv-col-active,
.auto-grid-table tbody td.mv-col-active {
  background: linear-gradient(180deg, #c8dcff 0%, #a9c8ff 100%) !important;
  color: #0f2f57 !important;
  font-weight: 500;
}

/* Keep negatives red even when a column is highlighted. */
.auto-grid-table tbody td.mv-col-active.neg {
  color: #b00020 !important;
  font-weight: 400;
}

.mv-table thead th.mv-row-head {
  color: #7a8699;
}

.mv-table tbody tr:last-child td {
  border-bottom: none;
}

.mv-table th:last-child,
.mv-table td:last-child {
  border-right: none;
}

.mv-actions-bar {
  background: linear-gradient(180deg, #f8fbff 0%, #eef3fb 100%);
  border-color: #d6deeb;
}

/* ------------------------------------------------------------
   Print layout (home page)
------------------------------------------------------------- */
.print-preview {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 18px 24px;
  background: rgba(12, 18, 32, 0.55);
  backdrop-filter: blur(2px);
  z-index: 10000;
  overflow: auto;
}

.print-preview.hidden {
  display: none;
}

.print-preview-dialog {
  width: min(1100px, 96vw);
  background: #0f1423;
  border-radius: 16px;
  border: 1px solid #1f2a44;
  padding: 12px;
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.35);
}

.print-preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 12px;
  background: linear-gradient(90deg, #111a2f 0%, #0c1324 100%);
  border: 1px solid #1d2944;
  color: #e9edf5;
}

.print-preview-title {
  font-weight: 700;
  letter-spacing: 0.4px;
}

.print-preview-actions {
  display: flex;
  gap: 8px;
}

.print-preview-body {
  margin-top: 12px;
  background: linear-gradient(180deg, #f5f7fb 0%, #e8ecf4 100%);
  padding: 16px;
  border-radius: 12px;
  border: 1px solid #d9dfeb;
  max-height: calc(100vh - 160px);
  overflow: auto;
}

body.print-preview-open {
  overflow: hidden;
}

.print-preview .print-layout {
  display: block;
}

.print-preview-backdrop {
  position: absolute;
  inset: 0;
}

.print-layout {
  display: none;
  position: relative;
  z-index: 1;
}
.print-layout {
  display: none;
  position: relative;
  z-index: 1;
}

.print-sheet {
  width: 100%;
  max-width: 860px;
  margin: 6mm auto;
  padding: 34px 30px 54px;
  background: #ededed;
  border: 1px solid #d6d6d6;
}

.print-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 6px 14px;
  border-bottom: 1px solid #c9c9c9;
  font-weight: 700;
  color: #1f1f1f;
}

.print-title {
  font-size: 17px;
  font-family: "Arial", sans-serif;
}

.print-date {
  font-size: 15px;
  font-family: "Arial", sans-serif;
}

.print-line {
  border-top: 1px solid #c9c9c9;
  margin: 6px 0 10px;
}

.print-eq-row {
  margin: 12px 0;
  padding: 10px 6px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid transparent;
}

.print-eq-chip {
  background: #000;
  color: #fff;
  border-radius: 10px;
  padding: 6px 18px;
  font-weight: 700;
  min-width: 54px;
  text-align: center;
  font-family: "Arial", sans-serif;
}

.print-eq-value {
  flex: 1;
  background: #f8f8f8;
  border-radius: 6px;
  padding: 10px 12px;
  border: 1px solid #dedede;
  min-height: 36px;
  font-weight: 600;
  font-family: "Arial", sans-serif;
}

.print-body {
  display: grid;
  grid-template-columns: 1.8fr 1fr;
  gap: 12px;
  align-items: start;
  margin-top: 12px;
}

.print-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-family: "Arial", sans-serif;
}

.print-table th {
  background: #2f2f2f;
  color: #fff;
  padding: 9px 12px;
  text-align: left;
}

.print-table td {
  padding: 9px 12px;
  border: 1px solid #d0d0d0;
  background: #f4f4f4;
  font-weight: 600;
}

.print-table tbody tr:nth-child(even) td {
  background: #ffffff;
}

.print-result {
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 0;
  align-self: start;
}

.print-result-head {
  background: #b5b5b5;
  color: #000;
  padding: 11px 12px;
  font-weight: 700;
  text-align: left;
  border: 1px solid #c6c6c6;
  font-family: "Arial", sans-serif;
}

.print-result-value {
  background: #d9d9d9;
  padding: 12px 12px;
  border: 1px solid #c6c6c6;
  font-weight: 700;
  font-family: "Arial", sans-serif;
}

@media print {
  body {
    background: #fff;
    margin: 0;
  }
  .top-bar,
  .footer,
  .ep-shell,
  .modal {
    display: none !important;
  }
  #print-preview {
    display: block !important;
    background: transparent;
    padding: 0;
  }
  #print-preview .print-preview-bar,
  #print-preview .print-preview-backdrop {
    display: none !important;
  }
  #print-preview .print-preview-dialog {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
  }
  #print-preview .print-preview-body {
    padding: 0;
    border: none;
    background: transparent;
    max-height: none;
  }
  .print-layout {
    display: block !important;
  }
  .page-container {
    padding: 0;
  }
}

.mv-empty {
  padding: 12px;
  text-align: center;
  color: var(--muted);
  background: #f9fbff;
  border: 1px dashed var(--border);
  border-radius: 10px;
  margin-top: 10px;
}

.mv-actions-bar {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f7f9fc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.mv-actions-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.mv-chart-card {
  margin-top: 10px;
  padding: 12px;
}

.mv-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
