﻿:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #1a222f;
  --muted: #556173;
  --accent: #136f63;
  --accent-strong: #0d5a50;
  --accent-soft: #d9f1ec;
  --border: #d6e0ea;
  --danger: #b0242f;
  --danger-soft: #ffe7ea;
  --ok: #1a7f44;
  --ok-soft: #e4f6ea;
  --spider-node-hover-grow-duration: 700ms;
  --spider-edge-flow-duration: 8.5s;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Segoe UI", Tahoma, sans-serif;
  background:
    radial-gradient(circle at 6% 4%, #e0f3ef 0%, transparent 30%),
    radial-gradient(circle at 95% 12%, #e7eef7 0%, transparent 28%),
    var(--bg);
}

body.dark-theme {
  --bg: #0f1318;
  --panel: #161c24;
  --text: #e7edf5;
  --muted: #9eaab9;
  --accent: #2b82ff;
  --accent-strong: #1f6edc;
  --accent-soft: #20344c;
  --border: #2b3645;
  --danger: #d75f6c;
  --danger-soft: #45242a;
  --ok: #57bf7f;
  --ok-soft: #223c2d;
  background:
    radial-gradient(circle at 6% 4%, rgba(46, 77, 113, 0.42) 0%, transparent 30%),
    radial-gradient(circle at 95% 12%, rgba(66, 46, 99, 0.34) 0%, transparent 28%),
    var(--bg);
}

body.startup-active {
  overflow: hidden;
}

body.password-gate-active {
  overflow: hidden;
}

.startup-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 360ms ease, visibility 0s linear 360ms;
}

.startup-overlay.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.startup-overlay video {
  width: 50%;
  height: 50%;
  display: block;
  object-fit: contain;
}

.password-gate {
  position: fixed;
  inset: 0;
  z-index: 4900;
  background: rgba(255, 255, 255, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

body.dark-theme .password-gate {
  background: rgba(10, 14, 20, 0.9);
}

.password-gate[hidden] {
  display: none !important;
}

.password-gate-card {
  width: min(420px, 96vw);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  padding: 18px;
  box-shadow: 0 12px 30px rgba(26, 34, 47, 0.1);
}

.password-gate-card h2 {
  margin: 0 0 8px;
}

.password-gate-card p {
  margin: 0 0 12px;
  color: var(--muted);
}

.password-gate-card form {
  display: grid;
  gap: 8px;
}

.password-gate-card form label {
  margin: 0;
}

.password-gate-card form input {
  margin: 0;
}

#passwordGateBtn {
  margin-top: 0;
}

.password-gate-message {
  margin: 10px 0 0;
  color: #b0242f;
  min-height: 1.1em;
}

.app-layout {
  max-width: 1800px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.container {
  max-width: none;
  margin: 0;
  padding: 0;
}

.project-pane {
  position: sticky;
  top: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 10px 24px rgba(26, 34, 47, 0.05);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.project-pane h2 {
  margin: 0 0 10px;
}

.project-list-search {
  display: block;
  margin-bottom: 10px;
}

.project-list-search input {
  margin-top: 4px;
}

.project-list-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.project-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.project-tree-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fbff;
  padding: 8px;
  display: grid;
  gap: 6px;
  transition: border-color 120ms ease, background 120ms ease;
}

.project-tree-item:hover {
  border-color: #bac8d9;
}

.project-tree-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.project-toggle-btn {
  border: 1px solid transparent;
  background: transparent;
  color: #3c4f65;
  font-size: 0.86rem;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  padding: 0;
  cursor: pointer;
}

.project-toggle-btn:hover {
  border-color: #c4d2e0;
  background: #eef4fb;
}

.project-name-btn {
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  padding: 5px 6px;
  border-radius: 7px;
  color: #243447;
  font-size: 0.9rem;
  font-weight: 600;
  min-width: 0;
  cursor: pointer;
}

.project-name-btn:hover {
  background: #eef4fb;
}

.project-tree-row.active .project-name-btn {
  border-color: #bdafff;
  background: #eee8ff;
  color: #32245f;
}

.project-tree-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.project-tree-actions .btn-mini {
  white-space: nowrap;
  margin: 0;
}

.project-pane-icon-btn {
  width: 26px;
  min-width: 26px;
  height: 26px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-size: 0.95rem;
  font-weight: 800;
}

.project-add-btn {
  background: #5d6b7d;
  color: #ffffff;
}

.project-add-btn:hover {
  background: #495667;
}

.project-product-list {
  list-style: none;
  margin: 0;
  padding: 0 0 0 40px;
  margin-left: 6px;
  border-left: 1px solid #d6e1ee;
  display: grid;
  gap: 6px;
}

.project-product-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
  align-items: center;
}

.project-product-btn {
  border: 1px solid var(--border);
  background: #f2f7fe;
  text-align: left;
  padding: 6px 8px;
  border-radius: 7px;
  color: #243447;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  min-width: 0;
}

.project-product-btn:hover {
  border-color: #c4d2e0;
  background: #ecf3fb;
}

.project-product-btn.active {
  border-color: #bdafff;
  background: #eee8ff;
  color: #32245f;
}

.project-list .is-typing {
  white-space: nowrap;
  overflow: hidden;
}

.project-list .is-typing::after {
  content: "";
  display: inline-block;
  width: 1px;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.12em;
  background: #243447;
  animation: project-caret-blink 500ms steps(1, end) infinite;
}

.project-list-actions {
  margin: 0 0 10px;
}

.project-pane-context-menu {
  position: fixed;
  z-index: 4300;
  min-width: 220px;
  max-width: min(320px, calc(100vw - 20px));
  padding: 8px;
  border-radius: 10px;
  border: 1px solid #c5d2e0;
  background: #ffffff;
  box-shadow: 0 14px 32px rgba(17, 26, 39, 0.24);
}

.project-pane-context-title {
  margin: 0 0 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #2a3a4f;
}

.project-pane-context-btn {
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid #d6e0ea;
  border-radius: 7px;
  background: #f4f8fd;
  color: #25354a;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: left;
}

.project-pane-context-btn:hover {
  background: #eaf1fb;
}

.project-pane-context-btn.danger {
  border-color: #e8bdc2;
  background: #fff3f5;
  color: #922d39;
}

.project-pane-context-btn.danger:hover {
  background: #ffe8ec;
}

#newProjectBtn {
  width: 100%;
  margin-top: 0;
}

#newProjectFromExcelBtn {
  width: 100%;
  margin-top: 8px;
  background: #1f7244 !important;
}

#newProjectFromExcelBtn:hover {
  background: #1a633b !important;
}

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

.workspace-section.workspace-fade-in {
  animation: workspace-fade-in 260ms ease;
}

@keyframes workspace-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes project-caret-blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

h1 {
  margin: 0 0 4px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.page-header > div {
  min-width: 0;
}

.subtitle {
  margin: 0 0 16px;
  color: var(--muted);
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: 0 10px 24px rgba(26, 34, 47, 0.05);
}

h2 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

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

.section-heading h2 {
  margin: 0;
}

.dfmea-version {
  margin-left: auto;
  padding: 4px 10px;
  border: 1px solid #cfd7e6;
  border-radius: 999px;
  background: #eef4f9;
  color: #2f3b52;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.dfmea-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fbff;
  padding: 10px;
}

.dfmea-panel > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.dfmea-panel > summary::-webkit-details-marker {
  display: none;
}

.dfmea-panel > summary::before {
  content: "▸ ";
  color: var(--muted);
}

.dfmea-panel[open] > summary::before {
  content: "▾ ";
}

.dfmea-content {
  margin-top: 10px;
}

.panel-expand-btn {
  width: 30px;
  height: 30px;
  margin: 0 0 0 6px;
  padding: 0;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: #eef4f9;
  color: #435268;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-size: 0.88rem;
  font-weight: 700;
  flex: 0 0 auto;
}

.panel-expand-btn:hover {
  background: #e1ebf5;
  color: #2f3f53;
}

.panel-expand-btn:focus-visible {
  outline: 2px solid #6e8fdb;
  outline-offset: 2px;
}

.panel-expand-btn[data-maximized="true"] {
  background: #d7e6f6;
  color: #22334a;
  border-color: #bdcfe4;
}

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

.table-search-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.table-search-label {
  flex: 1 1 300px;
  margin-bottom: 0;
}

.table-search-row button {
  width: auto;
  margin-top: 0;
  padding: 8px 14px;
  flex: 0 0 auto;
}

label {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 8px;
}

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

input,
textarea,
button {
  width: 100%;
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 8px 10px;
  margin-top: 6px;
}

textarea,
pre,
td input,
td textarea {
  font-family: Consolas, "Courier New", monospace;
}

#assumptions {
  overflow-y: hidden;
  resize: none;
}

button {
  border: 0;
  color: white;
  background: var(--accent);
  cursor: pointer;
  font-weight: 600;
  transition: background 120ms ease;
  position: relative;
  overflow: hidden;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.9;
}

.theme-toggle-switch {
  width: auto;
  margin-top: 0;
  padding: 2px;
  border: 0;
  background: transparent;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  overflow: visible;
}

.theme-toggle-switch:hover {
  background: transparent;
  color: var(--text);
}

.theme-toggle-switch:focus-visible {
  outline: 2px solid #6f3cff;
  outline-offset: 2px;
}

.theme-toggle-label {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--muted);
}

.theme-toggle-track {
  position: relative;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid #bcc9db;
  background: #d8e0ec;
  transition: background-color 180ms ease, border-color 180ms ease;
}

.theme-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(26, 34, 47, 0.35);
  transition: transform 180ms ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-icon {
  position: absolute;
  font-size: 12px;
  line-height: 1;
  transition: opacity 140ms ease;
}

.theme-icon-sun {
  color: #f3a300;
  opacity: 1;
}

.theme-icon-moon {
  color: #e8f0ff;
  opacity: 0;
}

.theme-toggle-switch[aria-checked="true"] .theme-toggle-track {
  background: #6f3cff;
  border-color: #6f3cff;
}

.theme-toggle-switch[aria-checked="true"] .theme-toggle-thumb {
  transform: translateX(20px);
}

.theme-toggle-switch[aria-checked="true"] .theme-icon-sun {
  opacity: 0;
}

.theme-toggle-switch[aria-checked="true"] .theme-icon-moon {
  opacity: 1;
}

body.dark-theme .theme-toggle-label {
  color: #c7d2e3;
}

body.dark-theme .theme-toggle-track {
  border-color: #4c5f79;
  background: #2a374a;
}

.onboarding-next {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.btn-next {
  width: auto;
  margin-top: 0;
  padding: 6px 12px;
  border: 1px solid #c7d2df;
  border-radius: 7px;
  background: #f0f4f9;
  color: #37465a;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.2;
}

.btn-next:hover {
  background: #e5ebf3;
}

.btn-next:disabled {
  opacity: 0.65;
}

#autoBtn {
  background: #6f3cff !important;
  box-shadow: 0 8px 20px rgba(111, 60, 255, 0.35);
}

#autoBtn:hover {
  background: #5f2eea !important;
}

#generateDfmeaBtn,
#generateDvprBtn {
  width: auto;
  margin-top: 0;
  padding: 8px 14px;
  justify-self: start;
  background: #6f3cff !important;
  box-shadow: 0 8px 20px rgba(111, 60, 255, 0.35);
}

#generateDfmeaBtn:hover,
#generateDvprBtn:hover {
  background: #5f2eea !important;
}

#exportBtn {
  background: #1f7244 !important;
}

#exportBtn:hover {
  background: #1a633b !important;
}

#resetDfmeaViewBtn,
#resetDvprViewBtn {
  width: auto;
  margin-top: 0;
  padding: 8px 14px;
}

#exportBtn::after {
  content: "";
  display: inline-block;
  width: 20px;
  height: 20px;
  margin-left: 8px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='2' y='3' width='20' height='18' rx='2' fill='%231f7244'/%3E%3Crect x='11' y='3' width='11' height='18' fill='%232fa866'/%3E%3Cpath d='M6 8h2l1.3 2.2L10.6 8h2L10.5 12l2.1 4h-2l-1.3-2.2L8 16H6l2.1-4z' fill='%23fff'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 20px 20px;
  background-position: center;
  transform: translateY(4px);
}

#reportBtn {
  background: #d83b3b !important;
  box-shadow: 0 8px 20px rgba(216, 59, 59, 0.35);
}

#reportBtn:hover {
  background: #bf2f2f !important;
}

#reportBtn::after {
  content: "";
  display: inline-block;
  width: 20px;
  height: 20px;
  margin-left: 8px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 2h8l4 4v16H6z' fill='%23ffffff'/%3E%3Cpath d='M14 2v4h4' fill='%23ffd8d8'/%3E%3Crect x='7.5' y='10.5' width='9' height='6' rx='1' fill='%23d83b3b'/%3E%3Ctext x='12' y='15.1' text-anchor='middle' font-size='3.8' font-family='Arial' fill='%23ffffff'%3EPDF%3C/text%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 20px 20px;
  background-position: center;
  transform: translateY(4px);
}

#autoBtn.is-loading::before,
#generateDfmeaBtn.is-loading::before,
#generateDvprBtn.is-loading::before {
  content: "";
  position: absolute;
  top: 0;
  left: -45%;
  width: 45%;
  height: 3px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.1), #ffffff, rgba(255, 255, 255, 0.1));
  animation: auto-progress 1s linear infinite;
}

@keyframes auto-progress {
  from {
    left: -45%;
  }
  to {
    left: 100%;
  }
}

.btn-secondary {
  background: #5d6b7d;
}

.btn-secondary:hover {
  background: #495667;
}

.toolbar {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-bottom: 10px;
}

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

.table-footer-actions button {
  width: auto;
  min-width: 120px;
}

.validation {
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
  font-size: 0.9rem;
  border: 1px solid transparent;
}

.validation.inline-validation {
  margin-bottom: 0;
  min-height: 38px;
  flex: 1 1 260px;
}

.validation.ok {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: #a9e2bb;
}

.validation.error {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #f3b2ba;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  --actions-sticky-width: 150px;
}

body.panel-maximized-active {
  overflow: hidden;
}

.workspace-section.panel-maximized {
  position: fixed;
  inset: 12px;
  margin: 0;
  z-index: 3800;
  border-radius: 12px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: 0 22px 44px rgba(16, 24, 38, 0.26);
}

.workspace-section.panel-maximized .dfmea-panel,
.workspace-section.panel-maximized .dvpr-panel,
.workspace-section.panel-maximized .spider-panel {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.workspace-section.panel-maximized .dfmea-content,
.workspace-section.panel-maximized .spider-content {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.workspace-section.panel-maximized .dfmea-content .table-wrap,
.workspace-section.panel-maximized .dvpr-panel > .table-wrap,
.workspace-section.panel-maximized .spider-content .spider-graph-wrap {
  flex: 1 1 auto;
  min-height: 0;
}

.workspace-section.panel-maximized .dfmea-content .table-wrap,
.workspace-section.panel-maximized .dvpr-panel > .table-wrap {
  overflow-y: auto;
  overflow-x: hidden;
}

.workspace-section.panel-maximized .spider-content .spider-graph-wrap {
  min-height: calc(100vh - 240px);
  max-height: none;
}

.workspace-section.panel-maximized table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.workspace-section.panel-maximized thead th,
.workspace-section.panel-maximized thead .th-sort {
  white-space: normal;
}

.workspace-section.panel-maximized .row-actions {
  min-width: 0;
  flex-wrap: wrap;
}

.workspace-section.panel-maximized .rpn-cell {
  min-width: 0;
  width: 100%;
}

.workspace-section.panel-maximized td input.num {
  width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1450px;
  background: white;
}

thead th {
  position: sticky;
  top: 0;
  background: #eef4f9;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 0.82rem;
  white-space: nowrap;
  padding: 8px;
  z-index: 1;
  user-select: none;
}

thead th:last-child {
  right: 0;
  z-index: 4;
  box-shadow: -1px 0 0 #dbe4ef;
}

.dfmea-table thead th:first-child {
  left: 0;
  z-index: 5;
  box-shadow: 1px 0 0 #dbe4ef;
}

.dvpr-table thead th:first-child {
  left: 0;
  z-index: 5;
  box-shadow: 1px 0 0 #dbe4ef;
}

.dfmea-table thead th:nth-last-child(2) {
  right: var(--actions-sticky-width);
  z-index: 3;
  box-shadow: -1px 0 0 #dbe4ef;
}

thead .th-sort {
  width: auto;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
  font-weight: 700;
  line-height: 1.2;
  position: static;
  overflow: visible;
  box-shadow: none;
}

thead .th-sort:hover {
  background: transparent;
  color: #304155;
}

thead .th-sort::after {
  content: " \2195";
  color: #6e7c8f;
  font-size: 0.72rem;
}

thead .th-sort.active-sort[data-sort-dir="asc"]::after {
  content: " \25B2";
  color: #304155;
}

thead .th-sort.active-sort[data-sort-dir="desc"]::after {
  content: " \25BC";
  color: #304155;
}

thead th .col-resizer {
  position: absolute;
  top: 0;
  right: -4px;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
  z-index: 3;
}

thead th .col-resizer::after {
  content: "";
  position: absolute;
  top: 15%;
  bottom: 15%;
  left: 3px;
  width: 1px;
  background: transparent;
}

thead th:hover .col-resizer::after {
  background: #b8c4d3;
}

body.col-resize-active,
body.col-resize-active * {
  cursor: col-resize !important;
  user-select: none !important;
}

td {
  border-top: 1px solid #ecf1f6;
  padding: 6px;
  vertical-align: top;
}

tbody td:last-child {
  position: sticky;
  right: 0;
  z-index: 2;
  background: #ffffff;
  box-shadow: -1px 0 0 #dbe4ef;
}

.dfmea-table tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  background: #ffffff;
  box-shadow: 1px 0 0 #dbe4ef;
}

.dvpr-table tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  background: #ffffff;
  box-shadow: 1px 0 0 #dbe4ef;
}

.dfmea-table tbody td:nth-last-child(2) {
  position: sticky;
  right: var(--actions-sticky-width);
  z-index: 1;
  background: #ffffff;
  box-shadow: -1px 0 0 #dbe4ef;
}

tbody tr.ai-row td {
  background: #f2e9ff;
}

tbody tr.ai-row td input {
  background: #f2e9ff;
  border-color: #cbb3ff;
}

tbody tr.ai-row td textarea.table-cell-textarea {
  background: #f2e9ff;
  border-color: #cbb3ff;
}

tbody tr.ai-row td input.invalid {
  background: #fff3f5;
}

tbody tr.ai-row td textarea.table-cell-textarea.invalid {
  background: #fff3f5;
}

tbody tr.ai-row .rpn-cell {
  background: #eadbff;
  border-color: #c3a3ff;
}

tbody tr.ai-row td:last-child {
  background: #ffffff;
}

tbody tr.spider-selected-row td {
  position: relative;
}

tbody tr.spider-selected-row td::after {
  content: "";
  position: absolute;
  inset: 1px;
  border: 2px solid #6f7fff;
  border-radius: 6px;
  pointer-events: none;
}

.dfmea-table tbody tr.ai-row td:first-child {
  background: #f2e9ff;
}

.dvpr-table tbody tr.ai-row td:first-child {
  background: #f2e9ff;
}

.dfmea-table tbody tr.ai-row td:nth-last-child(2) {
  background: #f2e9ff;
}

td input {
  width: 100%;
  margin: 0;
  padding: 7px;
  border-radius: 6px;
  border: 1px solid #d4deea;
  font-size: 0.82rem;
}

td textarea.table-cell-textarea {
  width: 100%;
  margin: 0;
  padding: 7px;
  border-radius: 6px;
  border: 1px solid #d4deea;
  font-size: 0.82rem;
  line-height: 1.24;
  resize: none;
  min-height: calc(1.24em * 3 + 14px);
  height: auto;
  overflow: hidden;
}

td input.num {
  width: 74px;
  transition: background-color 140ms linear, border-color 140ms linear, color 140ms linear;
}

td input.invalid {
  border-color: #dd5463;
  background: #fff3f5;
}

td textarea.table-cell-textarea.invalid {
  border-color: #dd5463;
  background: #fff3f5;
}

.rpn-cell {
  min-width: 74px;
  padding: 7px;
  border-radius: 6px;
  border: 1px solid #d4deea;
  background: #f2f6fb;
  color: #243447;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
  transition: background-color 140ms linear, border-color 140ms linear, color 140ms linear;
}

.row-actions {
  display: flex;
  gap: 6px;
  min-width: 138px;
}

.btn-mini {
  width: auto;
  margin: 0;
  padding: 6px 8px;
  font-size: 0.78rem;
  background: #5d6b7d;
}

.row-airy-btn {
  background: #6f3cff;
  min-width: 66px;
}

.row-airy-btn:hover {
  background: #5f2eea;
}

.row-airy-btn.complete,
.row-airy-btn.complete:hover {
  background: #9aa4b2;
  color: #eef2f6;
  box-shadow: none;
}

.row-airy-btn.loading,
.row-airy-btn.loading:hover {
  background: #6f3cff;
  opacity: 0.9;
}

.row-airy-btn.loading .airy-loading-dots {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
  line-height: 1;
}

.row-airy-btn.loading .airy-loading-dots span {
  display: inline-block;
  transform: translateY(0);
  animation: airy-row-dot-bounce 900ms ease-in-out infinite;
}

.row-airy-btn.loading .airy-loading-dots span:nth-child(2) {
  animation-delay: 120ms;
}

.row-airy-btn.loading .airy-loading-dots span:nth-child(3) {
  animation-delay: 240ms;
}

@keyframes airy-row-dot-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-3px);
  }
}

.btn-mini:hover {
  background: #495667;
}

.btn-mini.danger {
  background: #af2d37;
}

.btn-mini.danger:hover {
  background: #931f29;
}

.actions {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.dvpr-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fbff;
  padding: 10px;
}

.dvpr-panel > summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  list-style: none;
}

.dvpr-panel > summary::-webkit-details-marker {
  display: none;
}

.dvpr-panel > summary::before {
  content: "▸ ";
  color: var(--muted);
}

.dvpr-panel[open] > summary::before {
  content: "▾ ";
}

.input-collapse > summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  list-style: none;
}

.input-collapse > summary::-webkit-details-marker {
  display: none;
}

.input-collapse > summary::before {
  content: "▸ ";
  color: var(--muted);
}

.input-collapse[open] > summary::before {
  content: "▾ ";
}

.input-collapse-content {
  margin-top: 10px;
}

.dvpr-hint {
  margin: 8px 0 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

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

.dvpr-wrap table {
  min-width: 1100px;
}

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

.dvpr-footer-actions button {
  width: auto;
  min-width: 130px;
}

.spider-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fbff;
  padding: 10px;
}

.spider-panel > summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  list-style: none;
}

.spider-panel > summary .panel-expand-btn {
  margin-left: auto;
}

.spider-panel > summary::-webkit-details-marker {
  display: none;
}

.spider-panel > summary::before {
  content: "▸ ";
  color: var(--muted);
}

.spider-panel[open] > summary::before {
  content: "▾ ";
}

.spider-hint {
  margin: 8px 0 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.spider-content {
  margin-top: 2px;
}

.spider-graph-wrap {
  position: relative;
  min-height: 340px;
  max-height: 560px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
}

.spider-svg {
  display: block;
  width: 100%;
  min-width: 980px;
}

.spider-edge {
  fill: none;
  stroke-linecap: round;
  opacity: 0.45;
  pointer-events: none;
}

.spider-flow-dot {
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .spider-flow-dot {
    display: none;
  }
}

.spider-stage-label {
  fill: #4b5a70;
  font-size: 12px;
  font-weight: 700;
  text-anchor: middle;
}

.spider-function-hover-zone {
  pointer-events: all;
}

.spider-function-add-bubble {
  pointer-events: all;
  transition: opacity 120ms ease;
}

.spider-function-add-bubble.hidden {
  opacity: 0;
  pointer-events: none;
}

.spider-function-add-bubble circle {
  fill: rgba(69, 92, 122, 0.28);
  stroke: rgba(69, 92, 122, 0.56);
  stroke-width: 1.2;
}

.spider-function-add-bubble text {
  fill: #f5f9ff;
  font-size: 20px;
  font-weight: 700;
  pointer-events: none;
}

.spider-function-add-bubble:hover circle {
  fill: rgba(62, 84, 114, 0.46);
}

.spider-node circle {
  stroke: #b8c8da;
  stroke-width: 2;
  transition: r var(--spider-node-hover-grow-duration) ease, transform 180ms ease, stroke-color 140ms ease;
  transform-box: fill-box;
  transform-origin: center;
}

.spider-node text {
  fill: #243447;
  font-size: 11px;
  text-anchor: middle;
  pointer-events: none;
}

.spider-node text.inside {
  fill: #111111;
  font-size: 10px;
  font-weight: 700;
}

.spider-node:not(.hovered):hover circle {
  transform: scale(1.25);
}

.spider-svg.spider-hover-active .spider-stage-label,
.spider-svg.spider-hover-active .spider-edge,
.spider-svg.spider-hover-active .spider-flow-dot,
.spider-svg.spider-hover-active .spider-node:not(.hovered),
.spider-svg.spider-hover-active .spider-function-add-bubble {
  opacity: 0.2;
  filter: saturate(0.72) brightness(0.8);
}

.spider-svg.spider-hover-active .spider-node.hovered {
  opacity: 1;
  filter: none;
}

.spider-node.selected circle {
  stroke: #6f3cff;
  stroke-width: 3;
}

.spider-context-menu {
  position: fixed;
  z-index: 4300;
  min-width: 260px;
  max-width: min(360px, calc(100vw - 20px));
  padding: 8px;
  border-radius: 10px;
  border: 1px solid #c5d2e0;
  background: #ffffff;
  box-shadow: 0 14px 32px rgba(17, 26, 39, 0.24);
}

.spider-context-title {
  margin: 0 0 2px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #2a3a4f;
}

.spider-context-meta {
  margin: 0 0 8px;
  font-size: 0.77rem;
  color: #607187;
}

.spider-context-btn {
  width: 100%;
  margin: 0 0 6px;
  padding: 7px 9px;
  border: 1px solid #d6e0ea;
  border-radius: 7px;
  background: #f4f8fd;
  color: #25354a;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: left;
}

.spider-context-btn:hover:not(:disabled) {
  background: #eaf1fb;
}

.spider-context-btn.airy {
  border-color: #7a5cf5;
  background: linear-gradient(135deg, #6f3cff 0%, #4f6fff 100%);
  color: #ffffff;
}

.spider-context-btn.airy:hover:not(:disabled) {
  background: linear-gradient(135deg, #6436ee 0%, #4664ed 100%);
}

.spider-context-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.spider-context-btn.danger {
  border-color: #e8bdc2;
  background: #fff3f5;
  color: #922d39;
}

.spider-context-btn.danger:hover:not(:disabled) {
  background: #ffe8ec;
}

.spider-context-menu .spider-context-btn:last-child {
  margin-bottom: 0;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
  padding: 18px;
}

pre {
  min-height: 180px;
  margin: 0;
  overflow: auto;
  border-radius: 8px;
  background: #111a27;
  color: #e2ebf7;
  padding: 12px;
}

@media (max-width: 1100px) {
  .app-layout {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .project-pane {
    position: static;
    max-height: none;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }
}

.output-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fbff;
  padding: 10px;
}

.output-panel > summary {
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  list-style: none;
}

.output-panel > summary::-webkit-details-marker {
  display: none;
}

.output-panel > summary::before {
  content: "▸ ";
  color: var(--muted);
}

.output-panel[open] > summary::before {
  content: "▾ ";
}

.output-panel > pre {
  margin-top: 10px;
}

.app-version-tag {
  position: fixed;
  right: 14px;
  bottom: 10px;
  z-index: 12;
  font-size: 0.74rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  opacity: 0.72;
  pointer-events: none;
  user-select: none;
}

.airybot-orb {
  position: fixed;
  right: 18px;
  bottom: 42px;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 1px solid rgba(118, 79, 248, 0.68);
  background:
    radial-gradient(circle at 28% 24%, rgba(255, 255, 255, 0.72) 0%, rgba(255, 255, 255, 0.02) 36%),
    radial-gradient(circle at 70% 70%, rgba(63, 123, 255, 0.72) 0%, rgba(111, 60, 255, 0.96) 54%, #4f2ac3 100%);
  color: #f8f6ff;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  z-index: 4450;
  box-shadow: 0 10px 30px rgba(91, 54, 214, 0.44), inset 0 0 16px rgba(225, 214, 255, 0.25);
  transition: transform 140ms ease, box-shadow 140ms ease;
  overflow: hidden;
  isolation: isolate;
  animation: airybot-core-scale 2.6s ease-in-out infinite;
}

.airybot-orb::before {
  content: "";
  position: absolute;
  inset: -22%;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    rgba(190, 168, 255, 0.05) 0deg,
    rgba(98, 166, 255, 0.44) 75deg,
    rgba(133, 88, 255, 0.78) 165deg,
    rgba(190, 168, 255, 0.05) 310deg,
    rgba(190, 168, 255, 0.05) 360deg
  );
  filter: blur(7px);
  opacity: 0.5;
  z-index: 0;
  pointer-events: none;
  animation: airybot-wave-spin 7.4s linear infinite, airybot-wave-pulse 2.6s ease-in-out infinite;
}

.airybot-orb::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 1px solid rgba(129, 95, 245, 0.6);
  box-shadow: 0 0 0 0 rgba(111, 60, 255, 0.36);
  animation: airybot-ripple 2.2s ease-out infinite;
  pointer-events: none;
  z-index: 0;
}

.airybot-orb:hover {
  transform: translateY(-1px) scale(1.03);
  box-shadow: 0 12px 34px rgba(91, 54, 214, 0.52), inset 0 0 16px rgba(225, 214, 255, 0.3);
}

.airybot-orb.active {
  transform: translateY(-1px) scale(1.03);
}

.airybot-orb span {
  position: relative;
  z-index: 2;
  display: inline-block;
  transform: translateY(1px);
}

@keyframes airybot-core-scale {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@keyframes airybot-wave-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes airybot-wave-pulse {
  0%,
  100% {
    opacity: 0.38;
  }
  50% {
    opacity: 0.68;
  }
}

@keyframes airybot-ripple {
  0% {
    transform: scale(0.96);
    box-shadow: 0 0 0 0 rgba(111, 60, 255, 0.42);
    opacity: 0.6;
  }
  72% {
    transform: scale(1.22);
    box-shadow: 0 0 0 14px rgba(111, 60, 255, 0);
    opacity: 0;
  }
  100% {
    transform: scale(1.22);
    box-shadow: 0 0 0 0 rgba(111, 60, 255, 0);
    opacity: 0;
  }
}

.airybot-panel {
  position: fixed;
  right: 18px;
  bottom: 118px;
  width: min(390px, calc(100vw - 28px));
  height: min(560px, 72vh);
  border: 1px solid #d7d0ef;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 20px 42px rgba(24, 31, 43, 0.28);
  z-index: 4460;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

.airybot-panel[hidden] {
  display: none !important;
}

.airybot-panel.maximized {
  right: 18px;
  bottom: 12px;
  width: clamp(320px, 33vw, 680px);
  height: calc(100vh - 24px);
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px);
}

.airybot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid #ece8fb;
  background: linear-gradient(180deg, #f5f1ff 0%, #ffffff 100%);
}

.airybot-header h3 {
  margin: 0;
  color: #35235f;
}

.airybot-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.airybot-close-btn,
.airybot-maximize-btn {
  margin: 0;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid #d6d9ea;
  background: #f5f7fd;
  color: #3e4c66;
  line-height: 1;
  font-size: 1.1rem;
  cursor: pointer;
}

.airybot-close-btn:hover,
.airybot-maximize-btn:hover {
  background: #ebf0f9;
}

.airybot-messages {
  padding: 12px;
  overflow-y: auto;
  background: linear-gradient(180deg, #ffffff 0%, #faf9ff 100%);
  display: grid;
  align-content: start;
  gap: 10px;
}

.airybot-message {
  max-width: 90%;
  padding: 9px 11px;
  border-radius: 10px;
  font-size: 0.88rem;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
}

.airybot-message.user {
  justify-self: end;
  background: #e9f1ff;
  border: 1px solid #cfdffb;
  color: #243751;
}

.airybot-message.assistant {
  justify-self: start;
  background: #f0eaff;
  border: 1px solid #ddd0ff;
  color: #342659;
}

.airybot-message.assistant.loading {
  opacity: 0.85;
}

.airybot-form {
  border-top: 1px solid #ece8fb;
  padding: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  background: #fcfbff;
}

.airybot-form textarea {
  margin: 0;
  min-height: 52px;
  max-height: 130px;
  resize: vertical;
  border-radius: 10px;
}

.airybot-form button {
  margin: 0;
  width: auto;
  background: #6f3cff;
}

.airybot-form button:hover {
  background: #5f2eea;
}

body.excel-picker-open {
  overflow: hidden;
}

.excel-picker-modal {
  position: fixed;
  inset: 0;
  z-index: 4700;
  background: rgba(18, 26, 38, 0.36);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.excel-picker-modal[hidden] {
  display: none !important;
}

.excel-picker-card {
  width: min(1040px, 96vw);
  max-height: min(88vh, 900px);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  padding: 14px;
  box-shadow: 0 16px 38px rgba(17, 26, 39, 0.24);
  display: grid;
  gap: 10px;
}

.excel-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.excel-picker-header h3 {
  margin: 0;
}

.excel-picker-close-btn {
  margin: 0;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f3f7fb;
  color: #344963;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
}

.excel-picker-close-btn:hover {
  background: #e7eef6;
}

.excel-picker-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.excel-picker-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.excel-picker-controls label {
  margin: 0;
  min-width: 240px;
}

.excel-picker-range-info {
  font-size: 0.9rem;
  color: var(--muted);
}

#excelPickerRangeValue {
  display: inline-block;
  margin-left: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f6f9fd;
  color: #2b3e57;
  font-weight: 600;
}

.excel-picker-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.excel-picker-grid-wrap {
  min-height: 220px;
  max-height: 50vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfdff;
}

.excel-picker-grid {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.8rem;
}

.excel-picker-grid th,
.excel-picker-grid td {
  border: 1px solid #dbe5ef;
  padding: 6px;
  vertical-align: top;
}

.excel-picker-grid th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #edf3fa;
  color: #324860;
  font-weight: 700;
}

.excel-picker-grid th.row-label {
  left: 0;
  z-index: 3;
}

.excel-picker-grid td.row-label {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #f3f7fc;
  color: #4a5d74;
  text-align: right;
  font-weight: 600;
}

.excel-picker-grid td.selectable {
  cursor: pointer;
  background: #ffffff;
  color: #1f2d3f;
  word-break: break-word;
}

.excel-picker-grid td.selectable:hover {
  background: #e9f1fb;
}

.excel-picker-grid td.selectable.selected {
  background: #dcd4ff;
}

.excel-picker-grid td.selectable.selection-edge {
  background: #c6b8ff;
  box-shadow: inset 0 0 0 1px #6f3cff;
}

.excel-picker-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

#excelPickerImportBtn {
  background: #6f3cff !important;
  box-shadow: 0 8px 20px rgba(111, 60, 255, 0.32);
}

#excelPickerImportBtn:hover:not(:disabled) {
  background: #5f2eea !important;
}

#excelPickerImportBtn:disabled {
  opacity: 0.62;
  cursor: not-allowed;
}

body.dark-theme .project-tree-item {
  background: #1a2431;
  border-color: #314256;
}

body.dark-theme .project-tree-item:hover {
  border-color: #4b6079;
}

body.dark-theme .project-toggle-btn,
body.dark-theme .project-name-btn,
body.dark-theme .project-product-btn {
  color: #d7e3f2;
}

body.dark-theme .project-product-btn {
  background: #1f2b3a;
  border-color: #314256;
}

body.dark-theme .project-product-list {
  border-left-color: #32445c;
}

body.dark-theme .project-toggle-btn:hover,
body.dark-theme .project-name-btn:hover,
body.dark-theme .project-product-btn:hover {
  background: #223142;
  border-color: #425974;
}

body.dark-theme .project-tree-row.active .project-name-btn,
body.dark-theme .project-product-btn.active {
  border-color: #6f5cae;
  background: #2f2a45;
  color: #efe8ff;
}

body.dark-theme .project-add-btn {
  background: #5d6b7d;
  color: #ffffff;
}

body.dark-theme .project-add-btn:hover {
  background: #6f8096;
}

body.dark-theme .project-list .is-typing::after {
  background: #d7e3f2;
}

body.dark-theme .project-pane-context-menu {
  border-color: #3a4b61;
  background: #18212d;
  box-shadow: 0 16px 34px rgba(7, 11, 17, 0.5);
}

body.dark-theme .project-pane-context-title {
  color: #e3ecf8;
}

body.dark-theme .project-pane-context-btn {
  border-color: #3b4f68;
  background: #1f2a38;
  color: #d7e4f6;
}

body.dark-theme .project-pane-context-btn:hover {
  background: #273649;
}

body.dark-theme .project-pane-context-btn.danger {
  border-color: #84444f;
  background: #311f27;
  color: #ffb7bf;
}

body.dark-theme .project-pane-context-btn.danger:hover {
  background: #412732;
}

body.dark-theme .dfmea-version {
  border-color: #34465d;
  background: #1f2a39;
  color: #d2ddec;
}

body.dark-theme .panel-expand-btn {
  border-color: #3a4d63;
  background: #202b39;
  color: #c5d3e4;
}

body.dark-theme .panel-expand-btn:hover {
  background: #273647;
  color: #e3ebf6;
}

body.dark-theme .panel-expand-btn[data-maximized="true"] {
  background: #2f4060;
  color: #f2f6ff;
  border-color: #556b88;
}

body.dark-theme .dfmea-panel,
body.dark-theme .dvpr-panel,
body.dark-theme .spider-panel,
body.dark-theme .output-panel {
  background: #131a24;
}

body.dark-theme table {
  background: #141c26;
  color: var(--text);
}

body.dark-theme thead th {
  background: #1d2734;
}

body.dark-theme td {
  border-top: 1px solid #2a3546;
}

body.dark-theme tbody td:last-child {
  background: #141c26;
  box-shadow: -1px 0 0 #2a3546;
}

body.dark-theme .dfmea-table tbody td:first-child,
body.dark-theme .dvpr-table tbody td:first-child {
  background: #141c26;
  box-shadow: 1px 0 0 #2a3546;
}

body.dark-theme .dfmea-table tbody td:nth-last-child(2) {
  background: #141c26;
  box-shadow: -1px 0 0 #2a3546;
}

body.dark-theme td input {
  background: #101722;
  color: var(--text);
  border-color: #34465d;
}

body.dark-theme td textarea.table-cell-textarea {
  background: #101722;
  color: var(--text);
  border-color: #34465d;
}

body.dark-theme td input.invalid {
  border-color: #d66b76;
  background: #43252b;
  color: #ffe5e8;
}

body.dark-theme td textarea.table-cell-textarea.invalid {
  border-color: #d66b76;
  background: #43252b;
  color: #ffe5e8;
}

body.dark-theme .rpn-cell {
  background: #1b2432;
  border-color: #34465d;
  color: #d8e5f3;
}

body.dark-theme pre {
  background: #0d1420;
  color: #deebfb;
}

body.dark-theme tbody tr.ai-row td {
  background: #a784f0;
  color: #10131a;
}

body.dark-theme tbody tr.ai-row td input {
  background: #b794ff;
  border-color: #8f6ada;
  color: #10131a;
}

body.dark-theme tbody tr.ai-row td textarea.table-cell-textarea {
  background: #b794ff;
  border-color: #8f6ada;
  color: #10131a;
}

body.dark-theme tbody tr.ai-row td input::placeholder {
  color: #2f3351;
}

body.dark-theme tbody tr.ai-row td textarea.table-cell-textarea::placeholder {
  color: #2f3351;
}

body.dark-theme .dfmea-table tbody tr.ai-row td:first-child,
body.dark-theme .dvpr-table tbody tr.ai-row td:first-child,
body.dark-theme .dfmea-table tbody tr.ai-row td:nth-last-child(2) {
  background: #a784f0;
}

body.dark-theme tbody tr.ai-row td:last-child {
  background: #141c26;
}

body.dark-theme tbody tr.spider-selected-row td::after {
  border-color: #9eaaff;
}

body.dark-theme tbody tr.ai-row .rpn-cell {
  background: #ac88f4;
  border-color: #8f6ada;
  color: #10131a;
}

body.dark-theme .spider-graph-wrap {
  background: #141c26;
  border-color: #34465d;
}

body.dark-theme .spider-stage-label {
  fill: #b9c7d9;
}

body.dark-theme .spider-function-add-bubble circle {
  fill: rgba(143, 122, 218, 0.34);
  stroke: rgba(187, 164, 255, 0.78);
}

body.dark-theme .spider-function-add-bubble text {
  fill: #f6f1ff;
}

body.dark-theme .spider-function-add-bubble:hover circle {
  fill: rgba(143, 122, 218, 0.52);
}

body.dark-theme .spider-node circle {
  stroke: #4b6079;
}

body.dark-theme .spider-node text {
  fill: #e1ebf9;
}

body.dark-theme .spider-node text.inside {
  fill: #10131a;
}

body.dark-theme .spider-node.selected circle {
  stroke: #b894ff;
}

body.dark-theme .spider-context-menu {
  border-color: #3a4b61;
  background: #18212d;
  box-shadow: 0 16px 34px rgba(7, 11, 17, 0.5);
}

body.dark-theme .spider-context-title {
  color: #e3ecf8;
}

body.dark-theme .spider-context-meta {
  color: #9dafc7;
}

body.dark-theme .spider-context-btn {
  border-color: #3b4f68;
  background: #1f2a38;
  color: #d7e4f6;
}

body.dark-theme .spider-context-btn:hover:not(:disabled) {
  background: #273649;
}

body.dark-theme .spider-context-btn.airy {
  border-color: #8b74ff;
  background: linear-gradient(135deg, #7a4bff 0%, #597dff 100%);
  color: #f7f9ff;
}

body.dark-theme .spider-context-btn.airy:hover:not(:disabled) {
  background: linear-gradient(135deg, #6d42e6 0%, #4c70ea 100%);
}

body.dark-theme .spider-context-btn.danger {
  border-color: #84444f;
  background: #311f27;
  color: #ffb7bf;
}

body.dark-theme .spider-context-btn.danger:hover:not(:disabled) {
  background: #412732;
}

body.dark-theme .row-airy-btn.loading,
body.dark-theme .row-airy-btn.loading:hover {
  background: #b794ff;
  color: #10131a;
}

body.dark-theme .app-version-tag {
  opacity: 0.62;
}

body.dark-theme .airybot-orb {
  border-color: rgba(169, 141, 255, 0.74);
  background:
    radial-gradient(circle at 28% 24%, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0.02) 34%),
    radial-gradient(circle at 70% 70%, rgba(84, 157, 255, 0.76) 0%, rgba(133, 90, 255, 0.95) 54%, #5c33d9 100%);
  color: #f7f4ff;
  box-shadow: 0 10px 30px rgba(68, 41, 150, 0.65), inset 0 0 16px rgba(220, 205, 255, 0.22);
}

body.dark-theme .airybot-orb::before {
  background: conic-gradient(
    from 0deg,
    rgba(179, 153, 255, 0.06) 0deg,
    rgba(103, 174, 255, 0.48) 82deg,
    rgba(151, 104, 255, 0.82) 178deg,
    rgba(179, 153, 255, 0.06) 330deg,
    rgba(179, 153, 255, 0.06) 360deg
  );
  opacity: 0.62;
}

body.dark-theme .airybot-orb::after {
  border-color: rgba(171, 138, 255, 0.78);
}

body.dark-theme .airybot-panel {
  border-color: #3c4d63;
  background: #121b26;
  box-shadow: 0 22px 44px rgba(5, 9, 14, 0.62);
}

body.dark-theme .airybot-header {
  border-bottom-color: #2f3f54;
  background: linear-gradient(180deg, #1a2433 0%, #121b26 100%);
}

body.dark-theme .airybot-header h3 {
  color: #e9eff8;
}

body.dark-theme .airybot-header p {
  color: #a9b7c9;
}

body.dark-theme .airybot-close-btn {
  border-color: #3d4f65;
  background: #1f2a38;
  color: #d5e2f3;
}

body.dark-theme .airybot-maximize-btn {
  border-color: #3d4f65;
  background: #1f2a38;
  color: #d5e2f3;
}

body.dark-theme .airybot-close-btn:hover,
body.dark-theme .airybot-maximize-btn:hover {
  background: #27384d;
}

body.dark-theme .airybot-messages {
  background: linear-gradient(180deg, #121b26 0%, #0f1822 100%);
}

body.dark-theme .airybot-message.user {
  background: #24344a;
  border-color: #35506e;
  color: #e1ecfb;
}

body.dark-theme .airybot-message.assistant {
  background: #2b2242;
  border-color: #4d3d74;
  color: #efe8ff;
}

body.dark-theme .airybot-form {
  border-top-color: #2f3f54;
  background: #111926;
}

body.dark-theme .excel-picker-modal {
  background: rgba(6, 10, 16, 0.64);
}

body.dark-theme .excel-picker-card {
  border-color: #36485d;
  box-shadow: 0 16px 38px rgba(6, 10, 16, 0.62);
}

body.dark-theme .excel-picker-close-btn {
  border-color: #3b4e66;
  background: #1c2735;
  color: #d7e4f6;
}

body.dark-theme .excel-picker-close-btn:hover {
  background: #253548;
}

body.dark-theme #excelPickerRangeValue {
  border-color: #3b4f68;
  background: #1f2b39;
  color: #d7e4f6;
}

body.dark-theme .excel-picker-grid-wrap {
  border-color: #36485d;
  background: #111823;
}

body.dark-theme .excel-picker-grid th {
  border-color: #34465d;
  background: #1d2836;
  color: #d7e3f3;
}

body.dark-theme .excel-picker-grid td,
body.dark-theme .excel-picker-grid th {
  border-color: #314357;
}

body.dark-theme .excel-picker-grid td.row-label {
  background: #172230;
  color: #aab8ca;
}

body.dark-theme .excel-picker-grid td.selectable {
  background: #101722;
  color: #d7e4f6;
}

body.dark-theme .excel-picker-grid td.selectable:hover {
  background: #1d2c3f;
}

body.dark-theme .excel-picker-grid td.selectable.selected {
  background: #7d67bb;
  color: #f7f3ff;
}

body.dark-theme .excel-picker-grid td.selectable.selection-edge {
  background: #a188eb;
  color: #10131a;
  box-shadow: inset 0 0 0 1px #cdbbff;
}
