.embedded-sheet {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: white;
}
.embedded-sheet th {
  background: #eef3fa;
  color: #243951;
  text-align: left;
  position: sticky;
  top: 0;
}
.embedded-sheet td,
.embedded-sheet th {
  padding: 12px 16px;
  border: 1px solid #dde4ed;
}
.embedded-sheet tbody tr:nth-child(even) {
  background: #f8fafc;
}

/* =========================================================
   RESULT LOGIC WARNING
   ========================================================= */

.embedded-sheet td.result-cell-warning {
  background: #fef3c7 !important;
  color: #78350f;
  font-weight: 650;
  box-shadow: inset 0 0 0 1px #f59e0b;
  cursor: help;
}

.embedded-sheet tbody tr:nth-child(even) td.result-cell-warning {
  background: #fef3c7 !important;
}

.embedded-sheet td.result-cell-warning:hover,
.embedded-sheet td.result-cell-warning:focus {
  background: #fde68a !important;
  outline: none;
}

/* =========================================================
   RESULT WARNING TOOLTIP
   ========================================================= */

#result-warning-tooltip {
  position: fixed;
  z-index: 10000;

  width: max-content;
  max-width: min(360px, calc(100vw - 24px));

  padding: 9px 11px;

  border: 1px solid #334155;
  border-radius: 8px;

  background: #0f172a;
  color: #f8fafc;

  font-size: 11px;
  font-weight: 500;
  line-height: 1.45;

  white-space: normal;
  overflow-wrap: anywhere;

  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.22);

  opacity: 0;
  visibility: hidden;

  pointer-events: none;

  transform: translateY(2px);

  transition:
    opacity 0.12s ease,
    transform 0.12s ease,
    visibility 0.12s ease;
}

#result-warning-tooltip.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.embedded-sheet input {
  width: 100%;
  min-width: 90px;
  border: 0;
  background: transparent;
  padding: 6px;
}
.sheet-wrap {
  overflow: auto;
  max-height: 440px;
  border-radius: 8px;
  margin: 16px 0;
}
.back-link {
  margin-bottom: 20px;
}
.project-manage {
  position: relative;
  padding: 10px;
}
.project-manage button {
  display: block;
  padding: 8px 18px;
  background: white;
  border: 1px solid #e2e8f0;
  width: 100%;
}
summary {
  cursor: pointer;
}
.panel-group summary {
  padding: 8px 0;
}
.visual-tabs select {
  max-width: 240px;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 6px;
}
#result-integrate {
  padding: 20px;
  background: #f0f5fb;
  border-radius: 10px;
  margin-top: 20px;
}
#generalModal .modal {
  max-width: 1100px;
}
#upgrade-form input {
  padding: 10px;
  margin: 10px;
  border: 1px solid #ccd6e0;
  border-radius: 6px;
}
.panel-group details > button {
  width: 100%;
}
#visual-chart,
#visual-map {
  overflow: auto;
}
#result-chart,
#result-map {
  min-width: 720px;
}

/* Modern controls added after the original prototype. */
:root {
  --hv-ink: #0f172a;
  --hv-muted: #64748b;
  --hv-border: #dbe3ee;
  --hv-soft: #f8fafc;
  --hv-primary: #172033;
  --hv-primary-hover: #26344d;
  --hv-focus: #2563eb;
  --hv-danger: #b42318;
  --hv-shadow: 0 12px 32px rgba(15, 23, 42, 0.1);
}
button,
.primary-btn,
.secondary-btn,
.danger-btn,
.data-action,
.visual-tab,
.project-manage summary,
#downloadPngBtn {
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-weight: 600;
  letter-spacing: 0.005em;
  transition:
    background-color 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}
button:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.2);
  outline-offset: 2px;
  border-color: var(--hv-focus) !important;
}
button:disabled,
.primary-btn:disabled,
.secondary-btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none !important;
}
.primary-btn {
  min-height: 38px;
  padding: 9px 15px;
  border-radius: 9px;
  background: var(--hv-primary);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}
.primary-btn:hover:not(:disabled) {
  background: var(--hv-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 7px 16px rgba(15, 23, 42, 0.14);
}
.secondary-btn,
.data-action,
.visual-tab,
#downloadPngBtn {
  min-height: 38px;
  padding: 6px 12px;
  border: 0px solid var(--hv-border);
  border-radius: 9px;
  background: transparent;
  color: #334155;
}
.secondary-btn:hover:not(:disabled),
.data-action:hover:not(:disabled),
.visual-tab:hover:not(.active),
#downloadPngBtn:hover {
  background: #c1c1fa63;
  border-color: #a5b4fc;
  border-width: 1px;
}
.danger-btn {
  min-height: 38px;
  border-radius: 9px;
  color: var(--hv-danger);
}
.visual-tab.active {
  background: var(--hv-primary);
  border-color: var(--hv-primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.16);
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 18px;
}
.project-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
}
.breadcrumb-home {
  border: 0;
  background: transparent;
  padding: 0;
  color: #2563eb;
  font:
    600 12px Inter,
    "Segoe UI",
    Arial,
    sans-serif;
  cursor: pointer;
}
.breadcrumb-home:hover {
  text-decoration: underline;
  color: #1d4ed8;
}
.breadcrumb-project {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--hv-ink);
  font:
    700 12px Inter,
    "Segoe UI",
    Arial,
    sans-serif;
  cursor: pointer;
}
.breadcrumb-project:hover {
  color: #1d4ed8;
  text-decoration: underline;
}

/* Library destination fields. */
.library-target-field {
  display: grid !important;
  grid-template-columns: 190px minmax(260px, 520px);
  align-items: center;
  gap: 12px;
  width: min(100%, 720px);
  margin: 20px 0 22px;
  padding: 14px 16px;
  border: 1px solid var(--hv-border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.library-target-field > .library-target-copy {
  font-size: 12px;
  font-weight: 700;
  color: #334155;
}
#library-project.library-target-select,
#model-destination.library-target-select {
  box-sizing: border-box;
  width: 100%;
  height: 40px;
  padding: 8px 36px 8px 12px;
  border: 1px solid var(--hv-border);
  border-radius: 9px;
  background-color: #f8fafc;
  color: var(--hv-ink);
  font:
    600 13px Inter,
    "Segoe UI",
    Arial,
    sans-serif;
  outline: none;
}
#library-project.library-target-select:hover,
#model-destination.library-target-select:hover {
  border-color: #b9c7da;
  background: #fff;
}
#library-project.library-target-select:focus,
#model-destination.library-target-select:focus {
  border-color: var(--hv-focus);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Compact book-like Model Library cards. */
.model-library-grid {
  display: grid;
  /* Keep grid cards readable; four narrow cards squeeze the action row. */
  grid-template-columns: repeat(auto-fill, minmax(260px, 300px));
  justify-content: start;
  gap: 14px;
  align-items: stretch;
}
.model-library-system-header {
  grid-column: 1/-1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 0 -2px;
  padding: 6px 2px;
  border-bottom: 1px solid var(--hv-border);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--hv-ink);
}
.model-library-system-header:first-child {
  margin-top: 0;
}
.model-library-system-header small {
  font-size: 10px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--hv-muted);
}
.model-library-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 150px;
  margin: 0 !important;
  padding: 13px !important;
  border-radius: 12px !important;
  overflow: hidden;
}
.model-library-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--model-accent, #2563eb);
}

.model-library-card h3 {
  min-height: auto;
  margin: 0 0 5px;
  font-size: 13px;
  line-height: 1.3;
  color: var(--hv-ink);
}
.model-formula {
  margin: 0 0 8px;
  padding: 7px 8px;
  border-left: 3px solid var(--model-accent, #2563eb);
  border-radius: 0 7px 7px 0;
  background: #f8fafc;
  color: #334155;
  font-size: 10px;
  line-height: 1.4;
}
.model-formula span {
  display: block;
  margin-bottom: 3px;
  color: #64748b;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.model-formula code {
  display: block;
  overflow-wrap: anywhere;
  color: #0f172a;
  font:
    600 11px/1.4 ui-monospace,
    SFMono-Regular,
    Consolas,
    monospace;
}
.model-library-card > p {
  min-height: auto;
  margin: 0 0 6px;
  color: var(--hv-muted);
  font-size: 11px;
  line-height: 1.45;
}

.model-library-more summary::-webkit-details-marker {
  display: none;
}
.model-library-more[open] summary {
  margin-bottom: 6px;
}
.model-library-more > p {
  min-height: auto !important;
  margin: 0 0 6px !important;
}
.model-library-card details {
  margin: 0 0 8px;
  font-size: 11px;
  color: #475569;
}
.model-library-card details pre {
  max-height: 150px;
  overflow: auto;
  padding: 10px;
  border-radius: 8px;
  background: #0f172a;
  color: #dbeafe;
  font-size: 9px;
}

.model-library-tabs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 20px;
}

.model-library-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 4px;
  width: fit-content;
  border: 1px solid #5586cb5d;
  border-radius: 10px;
  background: transparent;
}

.model-library-tab {
  min-height: 34px;
  padding: 7px 14px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.model-library-tab:hover {
  background: #eef2f7;
  color: #334155;
}

.model-library-tab.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}

.workspace-model-library-description {
  margin: 0 0 18px;
  color: var(--hv-muted);
  font-size: 12px;
}

.workspace-model-library-card > p {
  min-height: auto;
}

/* Workspace Model action buttons */
.workspace-model-library-card .model-library-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.workspace-model-library-card .model-library-actions .secondary-btn,
.workspace-model-library-card .model-library-actions .primary-btn {
  width: auto;
  min-width: 0;
  flex: 0 0 auto;
}

.code-expand-btn {
  margin: 7px 0 0;
  padding: 5px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #334155;
  font-size: 10px;
  cursor: pointer;
}
.code-expand-btn:hover {
  background: #f8fafc;
}
.model-library-card details.code-expanded pre {
  max-height: 60vh;
  font-size: 11px;
}
.model-library-actions {
  align-self: stretch;
}
.workspace-library-card > [data-use-workspace] {
  align-self: flex-start;
  margin-top: auto;
  min-height: 32px;
  padding: 6px 10px;
  font-size: 11px;
}
.workspace-library-origin {
  min-height: auto !important;
  margin-bottom: 5px !important;
  padding-right: 4px;
  color: #64748b !important;
}
.workspace-library-card h3 {
  min-height: auto;
}
.workspace-model-flow code {
  white-space: normal;
  line-height: 1.5;
  max-height: 54px;
  overflow: auto;
  display: block;
}
.workspace-library-card > p:not(.workspace-library-origin) {
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.workspace-library-stats {
  display: flex;
  gap: 6px;
  margin: 0 0 10px;
}
.workspace-library-stats span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 7px;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #003d7b;
  color: #64748b;
  font-size: 10px;
}
.workspace-library-stats strong {
  color: #253047;
}
.library-empty {
  grid-column: 1/-1;
  padding: 24px;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  background: #fff;
  color: #64748b;
  text-align: center;
}
.library-model-delete {
  position: absolute;
  top: 30px;
  right: 9px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0px solid #fecaca;
  border-radius: 9px;
  background: transparent;
  color: #b42318;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.15s ease;
}
.library-model-delete:hover {
  background: #d22f3a;
  border-color: #fda4af;
  transform: translateY(-1px);
}
.library-model-delete:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.25);
  outline-offset: 2px;
}
.library-model-delete svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Workspace initials replace placeholder icons. */
.workspace-file-icon {
  border-radius: 10px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 13px;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px #e0e7ff;
}
.workspace-file:nth-child(2n) .workspace-file-icon {
  background: #ecfdf5;
  color: #047857;
  box-shadow: inset 0 0 0 1px #d1fae5;
}
.workspace-file:nth-child(3n) .workspace-file-icon {
  background: #fff7ed;
  color: #c2410c;
  box-shadow: inset 0 0 0 1px #ffedd5;
}
.workspace-file:nth-child(4n) .workspace-file-icon {
  background: #f5f3ff;
  color: #6d28d9;
  box-shadow: inset 0 0 0 1px #ede9fe;
}

/* Keep Project actions together instead of spreading them across the card. */
.project-card {
  position: relative;
  padding: 20px 22px;
  overflow: visible;
  z-index: 1;
}

.project-card:has(.project-manage[open]) {
  z-index: 500;
}
.project-card .card-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
}
.project-actions {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  white-space: nowrap;
}
.project-manage,
.project-manage[open] {
  padding: 0;
  position: relative;
  height: 38px;
}
.project-manage summary {
  list-style: none;
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border: 0px solid var(--hv-border);
  border-radius: 9px;
  background: #3b373745;
  color: #fbfcfc;
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
}
.project-manage summary::-webkit-details-marker {
  display: none;
}
.project-manage summary::marker {
  content: "";
}
.project-manage summary::before {
  content: "•••";
  margin-right: 7px;
  letter-spacing: 1px;
  color: #64748b;
  font-size: 11px;
  line-height: 1;
}
.project-manage[open] summary {
  background: #3b373745;
  border-color: #cbd5e1;
}
.project-manage[open] {
  z-index: 600;
}
.project-manage > button {
  position: absolute;
  right: 0;
  width: 172px;
  z-index: 600;
  padding: 10px 12px;
  text-align: left;
  border: 0;
  border-left: 1px solid var(--hv-border);
  border-right: 1px solid var(--hv-border);
  background: #fff;
  color: #334155;
}
.project-card .card-header {
  position: relative;
  overflow: visible;
}

.project-manage {
  overflow: visible;
}
.project-manage > button:first-of-type {
  top: 44px;
  border-top: 1px solid var(--hv-border);
  border-radius: 10px 10px 0 0;
  box-shadow: var(--hv-shadow);
}
.project-manage > button:nth-of-type(2) {
  top: 82px;
}
.project-manage > button:nth-of-type(3) {
  top: 120px;
}
.project-manage > button:nth-of-type(4) {
  top: 158px;
  color: var(--hv-danger);
}
.project-manage > button:nth-of-type(5) {
  top: 196px;
  border-bottom: 1px solid var(--hv-border);
  border-radius: 0 0 10px 10px;
  box-shadow: 0 12px 20px rgba(15, 23, 42, 0.08);
}
.project-manage > button:hover {
  background: #f8fafc;
}
.project-manage > button[data-op="delete"]:hover {
  background: #fff1f2;
}

/* =========================================================
   PROJECT OUTLINE
   ========================================================= */
.project-outline-page {
  width: min(980px, 100%);
  margin: 0 auto;
  padding-bottom: 32px;
}
.project-outline-page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}
.project-outline-page-header .back-link {
  display: inline-flex;
  margin: 0 0 16px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--hv-blue, #2563eb);
  cursor: pointer;
}
.project-outline-counter {
  flex: 0 0 auto;
  padding: 8px 11px;
  border: 1px solid var(--hv-border, #dbe3ee);
  border-radius: 999px;
  color: var(--hv-muted, #64748b);
  font-size: 12px;
  font-weight: 700;
}
.project-outline-counter.limit-reached {
  border-color: #f59e0b;
  color: #b45309;
}
.project-outline-form {
  display: grid;
  gap: 12px;
}
.project-outline-section {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--hv-border, #dbe3ee);
  border-radius: 14px;
  background: #fff;
}
.project-outline-section-number {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: #eaf2ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 800;
}
.project-outline-section-content {
  display: grid;
  gap: 10px;
  min-width: 0;
}
.project-outline-section-content h2,
.project-outline-label {
  margin: 0;
  color: var(--hv-ink, #0f172a);
  font-size: 14px;
  font-weight: 750;
}
.project-outline-general-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(3, minmax(120px, 0.7fr));
  gap: 10px;
}
.project-outline-general-grid label {
  display: grid;
  gap: 6px;
  color: var(--hv-muted, #64748b);
  font-size: 11px;
  font-weight: 700;
}
.project-outline-form input,
.project-outline-form textarea {
  width: 100%;
  border: 1px solid var(--hv-border, #dbe3ee);
  border-radius: 9px;
  background: #fff;
  color: var(--hv-ink, #0f172a);
}
.project-outline-form input {
  min-height: 40px;
  padding: 8px 10px;
}
.project-outline-form textarea {
  min-height: 96px;
  padding: 11px 12px;
  line-height: 1.55;
  resize: vertical;
}
.project-outline-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  min-height: 42px;
}
#project-outline-message {
  color: var(--hv-muted, #64748b);
  font-size: 12px;
}
@media (max-width: 900px) {
  .project-outline-general-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 620px) {
  .project-outline-page-header {
    align-items: flex-start;
    flex-direction: column;
  }
  .project-outline-general-grid {
    grid-template-columns: 1fr;
  }
  .project-outline-section {
    grid-template-columns: 1fr;
  }
  .project-outline-actions {
    align-items: stretch;
    flex-direction: column;
  }
}

/* Forms, modal actions, and library cards use one visual language. */
#generalModal .modal {
  width: min(820px, calc(100vw - 40px));
  padding: 24px;
  border: 1px solid rgba(219, 227, 238, 0.8);
  border-radius: 16px;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.22);
}
#generalModal .modal-title {
  font-size: 19px;
  color: var(--hv-ink);
}
#generalModal input:not([type="checkbox"]):not([type="radio"]),
#generalModal select,
.card input:not([type="checkbox"]):not([type="radio"]),
.card select,
.card textarea,
#result-target,
#chart-type {
  box-sizing: border-box;
  border: 1px solid var(--hv-border);
  border-radius: 9px;
  background: #fff;
  color: var(--hv-ink);
  padding: 9px 11px;
  font:
    13px Inter,
    "Segoe UI",
    Arial,
    sans-serif;
}
.embedded-sheet input:not([type="checkbox"]):not([type="radio"]) {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 6px;
  width: 100%;
  min-width: 90px;
}
.card label,
#generalModal label {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}
.card textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
}
.modal-actions {
  padding-top: 16px;
}
.form-error {
  min-height: 18px;
  color: var(--hv-danger);
  font-size: 12px;
  margin: 10px 0 0;
}
#grid-row,
#grid-column {
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid var(--hv-border);
  border-radius: 9px;
  background: #fff;
  color: #334155;
  font-weight: 600;
}
#grid-row:hover,
#grid-column:hover {
  background: #f1f5f9;
}
#grid-save {
  margin-left: 4px;
}

/* Import experience. */
.import-intro {
  font-size: 13px;
  color: var(--hv-muted);
  line-height: 1.6;
  margin-bottom: 14px;
}
.import-dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 190px;
  padding: 24px;
  border: 1.5px dashed #94a3b8;
  border-radius: 14px;
  background: var(--hv-soft);
  color: #334155;
  cursor: pointer;
}
.import-dropzone:hover,
.import-dropzone.is-dragging {
  border-color: var(--hv-focus);
  background: #eff6ff;
}
.import-dropzone.is-loading {
  opacity: 0.65;
  pointer-events: none;
}
.import-dropzone input {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0;
  pointer-events: none;
}
.import-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #e2e8f0;
  color: #334155;
  font-size: 22px;
}
.import-dropzone strong {
  font-size: 14px;
  color: var(--hv-ink);
}
.import-dropzone span,
.import-dropzone small {
  font-size: 11px;
  color: #64748b;
}
.import-file-meta {
  margin-top: 13px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}
.import-preview-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 8px;
}
.import-preview-head .form-select {
  width: auto;
  min-width: 190px;
}
.import-actions {
  justify-content: flex-end;
}

/* Visualization toolbar and responsive chart surface. */
.visual-tabs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
}
.visual-tabs select {
  height: 38px;
  max-width: 260px;
}
.chart-split {
  display: inline-flex;
  align-items: stretch;
}
.chart-split > .visual-tab {
  border-radius: 9px 0 0 9px;
  border-right: 0;
}
.chart-type-wrap {
  display: flex;
  align-items: center;
  margin: 0;
}
#chart-type {
  width: 112px;
  min-width: 112px;
  height: 38px;
  border-radius: 0 9px 9px 0;
  padding: 8px 30px 8px 11px;
  background-color: #fff;
  font-weight: 600;
}
.chart-split:has(.visual-tab.active) #chart-type {
  border-color: var(--hv-primary);
  background: #fff;
  color: #172033;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
#visual-chart,
#visual-map,
#visual-table {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  padding: 14px;
}
#visual-chart {
  overflow: hidden;
  padding: 0;
  border: 0;
  background: transparent;
}

/* =========================================================
   RESULT INTERPRETATION
   ========================================================= */

.result-interpretation {
  margin-top: 16px;
}

.interpret-section-head {
  margin-bottom: 10px;

  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;

  color: #64748b;
  text-transform: uppercase;
}

.interpret-card-grid {
  display: grid;

  grid-template-columns: repeat(var(--interpret-card-count, 3), minmax(0, 1fr));

  gap: 12px;
}

/* CARD */

.interpret-card {
  position: relative;

  min-width: 0;
  padding: 15px 16px;

  border: 1px solid transparent;
  border-radius: 12px;

  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    border-color 0.16s ease;
}

.interpret-card:hover {
  transform: translateY(-2px);

  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

/* HEADER */

.interpret-card-head {
  display: flex;
  align-items: center;

  gap: 8px;

  margin-bottom: 14px;
}

.interpret-icon {
  display: inline-grid;
  place-items: center;

  width: 28px;
  height: 28px;

  border-radius: 8px;

  transition: transform 0.16s ease;
}

.interpret-card:hover .interpret-icon {
  transform: scale(1.06);
}

.interpret-icon svg {
  width: 16px;
  height: 16px;

  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.interpret-title {
  font-size: 10px;
  font-weight: 750;

  letter-spacing: 0.08em;
}

/* FINDING */

.interpret-findings {
  display: grid;
  gap: 12px;
}

.interpret-finding + .interpret-finding {
  padding-top: 11px;

  border-top: 1px solid rgba(148, 163, 184, 0.18);
}

.interpret-phrase {
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;

  color: #334155;
}

.interpret-value {
  margin-top: 3px;

  font-size: 14px;
  font-weight: 750;
  line-height: 1.3;

  color: #0f172a;
}

/* =========================================================
   INSIGHT — HIDROVISI BLUE
   ========================================================= */

.interpret-card.insight {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.interpret-card.insight:hover {
  border-color: #60a5fa;
}

.interpret-card.insight .interpret-icon {
  background: #dbeafe;
  color: #2563eb;
}

.interpret-card.insight .interpret-title {
  color: #1d4ed8;
}

/* =========================================================
   PATTERN — GREEN
   ========================================================= */

.interpret-card.pattern {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.interpret-card.pattern:hover {
  border-color: #4ade80;
}

.interpret-card.pattern .interpret-icon {
  background: #dcfce7;
  color: #16a34a;
}

.interpret-card.pattern .interpret-title {
  color: #15803d;
}

/* =========================================================
   WARNING / ANOMALY — YELLOW
   ========================================================= */

.interpret-card.warning {
  background: #fffbeb;
  border-color: #fde68a;
}

.interpret-card.warning:hover {
  border-color: #fbbf24;
}

.interpret-card.warning .interpret-icon {
  background: #fef3c7;
  color: #d97706;
}

.interpret-card.warning .interpret-title {
  color: #b45309;
}

/* LOADING */

.interpret-loading {
  padding: 12px 2px;

  font-size: 12px;
  color: #64748b;
}

/* RESPONSIVE */

@media (max-width: 900px) {
  .interpret-card-grid {
    grid-template-columns: 1fr;
  }
}
.visual-illustration {
  overflow: hidden;
  padding: 0 !important;
  background: linear-gradient(135deg, #f8fafc, #eef6ff) !important;
}
.illustration-surface {
  overflow: hidden;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.06);
}
.illustration-empty {
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
  color: #64748b;
  text-align: center;
}
.illustration-empty-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: 10px;
  border-radius: 12px;
  background: #eff6ff;
  color: #2563eb;
  font-size: 22px;
}
.illustration-empty h3 {
  margin: 0 0 6px;
  color: #172033;
  font-size: 15px;
}
.illustration-empty p {
  margin: 0;
  font-size: 12px;
}
.illustration-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px 10px;
}
.illustration-heading h3 {
  margin: 3px 0 0;
  color: var(--hv-ink);
  font-size: 17px;
}
.illustration-eyebrow {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #94a3b8;
}
.illustration-caption {
  margin: 0;
  padding: 0 20px 10px;
  color: #64748b;
  font-size: 11px;
  line-height: 1.5;
}
.illustration-stage {
  position: relative;
  padding: 0 10px 12px;
}
.illustration-stage canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  background: #f8fafc;
}
.illustration-tooltip {
  position: absolute;
  z-index: 2;
  display: none;
  min-width: 150px;
  padding: 9px 11px;
  border: 1px solid #dbe3ee;
  border-radius: 9px;
  background: rgba(15, 23, 42, 0.94);
  color: #fff;
  font:
    11px Inter,
    "Segoe UI",
    Arial,
    sans-serif;
  pointer-events: none;
  transform: translate(12px, -110%);
}
.illustration-tooltip.visible {
  display: block;
}
.illustration-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0 20px 16px;
}
.illustration-controls button {
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--hv-border);
  border-radius: 8px;
  background: #fff;
  color: #475569;
  font-size: 11px;
}
.illustration-controls button.active {
  border-color: #2563eb;
  background: #eff6ff;
  color: #1d4ed8;
}
.chart-surface {
  overflow: hidden;
  border: 1px solid #dfe7f1;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.06);
}
.chart-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 10px;
}
.chart-heading h3 {
  margin: 4px 0 0;
  color: var(--hv-ink);
  font-size: 17px;
  line-height: 1.25;
}
.chart-eyebrow {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #94a3b8;
}
.chart-type-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #4376b73d;
  border: 1px solid #4376b73d;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 700;
}
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding: 0 22px 8px;
  color: #64748b;
  font-size: 11px;
}
.chart-axis-settings {
  display: grid;
  grid-template-columns: minmax(170px, 0.7fr) minmax(260px, 1.6fr) minmax(
      260px,
      1.2fr
    );
  gap: 12px;
  margin: 2px 22px 12px;
  padding: 12px;
  border: 1px solid #4376b73d;
  border-radius: 12px;
  background: transparent;
}
.chart-axis-settings > label,
.chart-axis-settings fieldset {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.chart-y-scale {
  grid-template-columns: repeat(3, minmax(70px, 1fr));
}
.chart-y-scale legend,
.chart-y-scale .chart-scale-message {
  grid-column: 1 / -1;
}
.chart-y-scale label {
  display: grid;
  gap: 4px;
  color: #64748b;
  font-size: 10px;
  font-weight: 700;
}
.chart-y-scale input {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 8px;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  background: #fff;
}
.chart-y-scale #chart-y-auto {
  grid-column: 1 / -1;
  min-height: 32px;
}
.chart-scale-message {
  color: #b91c1c;
  font-size: 10px;
}
.chart-axis-settings > label > span,
.chart-axis-settings legend {
  padding: 0;
  color: #475569;
  font-size: 11px;
  font-weight: 700;
}
.chart-axis-settings select {
  width: 100%;
  height: 36px;
  background: #fff;
}
.chart-series-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chart-series-options label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  background: #417bc64f;
  color: #475569;
  font-size: 11px;
  cursor: pointer;
}
.chart-series-options label:has(input:checked) {
  border-color: #93c5fd;
  background: #417bc64f;
  color: #1d4ed8;
}
.chart-series-options input {
  margin: 0;
}
.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.chart-legend i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--series-color);
}
.chart-plot {
  padding: 0 10px 10px;
}
.chart-plot canvas {
  display: block;
  width: 100%;
  height: auto;
  min-width: 0;
  border-radius: 10px;
}
.chart-plot {
  position: relative;
}
.chart-tooltip {
  position: absolute;
  z-index: 5;
  display: none;
  min-width: 130px;
  padding: 9px 11px;
  border: 1px solid #dbe3ee;
  border-radius: 9px;
  background: rgba(15, 23, 42, 0.94);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.18);
  color: #fff;
  font:
    11px Inter,
    "Segoe UI",
    Arial,
    sans-serif;
  pointer-events: none;
  transform: translate(12px, -110%);
}
.chart-tooltip.visible {
  display: grid;
  gap: 4px;
}
.chart-tooltip strong {
  font-size: 11px;
}
.chart-tooltip span {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #e2e8f0;
}
.chart-tooltip i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tooltip-color);
}
#result-chart,
#result-map {
  min-width: 0;
  border-radius: 8px;
  display: block;
}
#result-integrate {
  border: 1px solid #dbe7f4;
  background: #f6f9fd;
  padding: 20px 22px;
}
#result-integrate h3 {
  margin-top: 0;
  color: var(--hv-ink);
}
#result-target {
  min-width: 210px;
  margin-right: 8px;
}

/* Help workflow mirrors the documented MVP lifecycle. */
.help-intro {
  margin: 0 0 18px;
  color: var(--hv-muted);
  font-size: 13px;
  line-height: 1.6;
}
.help-workflow {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.help-workflow li {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 116px;
  padding: 13px 12px;
  border: 1px solid var(--hv-border);
  border-radius: 12px;
  background: #f8fafc;
}
.help-workflow li:not(:last-child)::after {
  content: "→";
  position: absolute;
  right: -10px;
  top: 24px;
  z-index: 2;
  color: #94a3b8;
  font-weight: 800;
}
.help-workflow li > span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: #172033;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}
.help-workflow strong {
  display: block;
  color: var(--hv-ink);
  font-size: 12px;
}
.help-workflow small {
  display: block;
  margin-top: 5px;
  color: #64748b;
  font-size: 10px;
  line-height: 1.45;
}
.help-note {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #eff6ff;
  color: #475569;
  font-size: 11px;
  line-height: 1.5;
}

/* Guided demo: one focused Rainfall → Hydrology → Channel Capacity tour. */
.guided-tour-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: transparent;
}
.guided-tour-highlight {
  position: fixed;
  z-index: 2001;
  border: 2px solid #3b82f6;
  border-radius: 14px;
  background: transparent;
  box-shadow:
    0 0 0 9999px rgba(15, 23, 42, 0.56),
    0 0 0 5px rgba(147, 197, 253, 0.35);
  pointer-events: none;
  transition:
    left 0.18s ease,
    top 0.18s ease,
    width 0.18s ease,
    height 0.18s ease;
}
.guided-tour-tooltip {
  position: fixed;
  z-index: 2002;
  box-sizing: border-box;
  padding: 18px;
  border: 1px solid #bfdbfe;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 20px 55px rgba(15, 23, 42, 0.28);
  color: var(--hv-ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}
.guided-tour-tooltip h3 {
  margin: 5px 0 7px;
  font-size: 17px;
}
.guided-tour-tooltip p {
  margin: 0;
  color: #526177;
  font-size: 12px;
  line-height: 1.6;
}
.guided-tour-progress {
  color: #2563eb;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.guided-tour-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}
.guided-tour-actions span {
  flex: 1;
}
.guided-tour-actions button {
  min-height: 35px;
  padding: 7px 11px;
}
.guided-tour-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

/* Explicit destructive-action verification. */
.delete-confirmation {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 15px;
  border: 1px solid #fecaca;
  border-radius: 12px;
  background: #fff7f7;
}
.delete-confirmation > span {
  display: grid;
  place-items: center;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: #fee2e2;
  color: #b42318;
  font-size: 14px;
  font-weight: 900;
}
.delete-confirmation strong {
  display: block;
  color: #7f1d1d;
  font-size: 13px;
}
.delete-confirmation p {
  margin: 5px 0;
  color: #475569;
  font-size: 12px;
  line-height: 1.5;
}
.delete-confirmation small {
  color: #64748b;
  font-size: 11px;
}
.modal-actions .danger-btn {
  border: 1px solid #b42318;
  background: #b42318;
  color: #fff;
  font-weight: 700;
}
.modal-actions .danger-btn:hover {
  background: #912018;
}

/* Server account dialog. */
.server-account-dialog {
  width: min(640px, 90vw) !important;
  padding: 28px !important;
  border: 1px solid var(--hv-border) !important;
  border-radius: 16px !important;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.24);
  font-family: Inter, "Segoe UI", Arial, sans-serif !important;
}
.server-account-dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(2px);
}
.server-account-dialog h2 {
  margin: 0 0 20px;
  color: var(--hv-ink);
  font-size: 21px;
}
.server-account-dialog h3 {
  margin: 22px 0 10px;
  color: var(--hv-ink);
}
.server-account-dialog form {
  display: grid;
  gap: 12px;
  margin: 0 0 14px;
}
.server-account-dialog form p {
  margin: 0;
}
.server-account-dialog label {
  display: grid;
  grid-template-columns: 110px minmax(220px, 1fr);
  align-items: center;
  gap: 12px;
  color: #475569;
  font-weight: 600;
}
.server-account-dialog button {
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid var(--hv-border);
  border-radius: 9px;
  background: #fff;
  color: #334155;
  font-weight: 600;
  cursor: pointer;
}
.server-account-dialog button:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}
.server-account-dialog button[type="submit"] {
  border-color: var(--hv-primary);
  background: var(--hv-primary);
  color: #fff;
}
.server-account-dialog input,
.server-account-dialog select {
  box-sizing: border-box;
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--hv-border);
  border-radius: 9px;
  font:
    13px Inter,
    "Segoe UI",
    Arial,
    sans-serif;
}
.server-account-dialog #account-close {
  width: 38px;
  padding: 0;
  font-size: 18px;
}
.server-account-dialog #switch-auth {
  margin-top: 2px;
}

/* Schema-driven input configuration per selected Model. */
.adaptive-model-input {
  margin: 14px 0 18px;
  padding: 16px;
  border: 1px solid #dde5ef;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.025);
}
.adaptive-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.adaptive-head small {
  color: #64748b;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
}
.adaptive-head h3 {
  margin: 5px 0 4px;
  color: #172033;
  font-size: 17px;
}
.adaptive-head p {
  max-width: 720px;
  margin: 0;
  color: #64748b;
  font-size: 12px;
  line-height: 1.5;
}
.input-state,
.model-input-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-weight: 750;
}
.input-state {
  padding: 7px 10px;
  font-size: 11px;
  white-space: nowrap;
}
.model-input-badge {
  margin-left: 8px;
  padding: 3px 7px;
  font-size: 9px;
  vertical-align: middle;
}
.input-state.ready,
.model-input-badge.ready {
  background: #068349b8;
  color: #166534;
}
.input-state.missing,
.model-input-badge.missing {
  background: #ef444457;
  color: #9a3412;
}
.input-source {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin: 14px 0;
  padding: 11px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
}
.input-source label {
  display: grid;
  flex: 1;
  gap: 5px;
}
.input-source span,
.adaptive-fields label > span,
.mapping-row > span {
  color: #475569;
  font-size: 11px;
  font-weight: 700;
}
.input-source select,
.adaptive-fields input,
.adaptive-fields select,
.mapping-row select {
  box-sizing: border-box;
  width: 100%;
  height: 36px;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid #dbe4f0;
  border-radius: 8px;
  background: #fff;
  color: #172033;
  font:
    12px Inter,
    "Segoe UI",
    Arial,
    sans-serif;
}
.model-output-preview {
  flex: 1 1 100%;
  margin-top: 4px;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  overflow: hidden;
  background: #fff;
}
.model-output-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 11px;
  background: #eef3fa;
  border-bottom: 1px solid #dde4ed;
}
.model-output-preview-header strong {
  font-size: 11px;
  font-weight: 700;
  color: #243951;
}
.model-output-preview-actions {
  display: flex;
  gap: 5px;
}
.model-output-preview-actions button {
  width: 26px;
  height: 26px;
  border: 1px solid #d8dee8;
  border-radius: 6px;
  background: #fff;
  color: #475569;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
.model-output-preview-actions button:hover {
  background: #f1f5f9;
}
.model-output-preview-actions button[data-preview-toggle="maximize"] {
  display: none;
}
.model-output-preview-body .sheet-wrap {
  max-height: 220px;
  margin: 0;
}
.model-output-preview.expanded .model-output-preview-body .sheet-wrap {
  max-height: 520px;
}
.model-output-preview.collapsed .model-output-preview-body {
  display: none;
}
.model-output-preview-empty {
  margin: 0;
  padding: 12px;
  font-size: 11px;
  color: #64748b;
}
.adaptive-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 9px;
}
.adaptive-fields label {
  display: grid;
  gap: 5px;
}
.adaptive-fields label[hidden] {
  display: none;
}
.series-editor-actions {
  display: flex;
  gap: 7px;
  align-items: center;
}
.series-editor-head > div:first-child {
  display: grid;
  gap: 2px;
}
.model-parameter-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 12px;
  background: #fff;
}
.model-parameter-table th,
.model-parameter-table td {
  border: 1px solid #ffffff2b;
  padding: 9px 11px;
  text-align: left;
}
.model-parameter-table thead th {
  background: #f8fafc;
  color: #475569;
  font-size: 11px;
}
.model-parameter-table tbody th {
  width: 38%;
  font-weight: 600;
  color: #475569;
  background: #fbfdff;
}
.model-parameter-table input,
.model-parameter-table select {
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid #dbe4f0;
  border-radius: 7px;
  background: #fff;
  color: #172033;
  font:
    12px Inter,
    "Segoe UI",
    Arial,
    sans-serif;
}
.model-parameter-table tr[hidden] {
  display: none;
}
.model-series-editor {
  margin-top: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.series-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}
.series-editor-head div {
  display: grid;
  gap: 2px;
}
.series-editor-head strong {
  color: #253047;
  font-size: 12px;
}
.series-editor-head small {
  color: #758197;
  font-size: 10px;
}
.series-editor-head button {
  min-height: 34px;
  padding: 7px 10px;
  white-space: nowrap;
}
.model-input-table {
  width: 100%;
  min-width: max-content;
  border-collapse: collapse;
}
.series-row-action {
  width: 36px;
}
.series-row-action .icon-btn {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #94a3b8;
  font-size: 18px;
  cursor: pointer;
}
.series-row-action .icon-btn:hover {
  background: #fee2e2;
  color: #b91c1c;
}
.adaptive-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid #edf1f5;
}
.adaptive-actions button {
  min-height: 36px;
  padding: 7px 11px;
  font-size: 11px;
}
#model-input-message {
  margin: 9px 0 0;
  color: #64748b;
  font-size: 11px;
}
.mapping-row {
  display: grid;
  grid-template-columns: minmax(150px, 0.7fr) 1fr;
  align-items: center;
  gap: 12px;
  margin: 9px 0;
}
.setting-box .select-input {
  height: 42px;
  min-height: 42px;
  padding: 8px 36px 8px 12px;
  border-radius: 9px;
  background: #fff;
  color: #172033;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
}
.modal-field {
  display: grid;
  gap: 7px;
}
.modal-field input {
  width: 100%;
  min-height: 40px;
}

@media (max-width: 720px) {
  .adaptive-head,
  .input-source,
  .series-editor-head {
    align-items: stretch;
    flex-direction: column;
  }
  .adaptive-actions button {
    flex: 1 1 45%;
  }
  .mapping-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }
}

/* Immersive water login. */
.login-experience {
  position: fixed;
  inset: 0;
  z-index: 5000;
  overflow: hidden;
  background: linear-gradient(135deg, #22519d 0%, #a0abb1 48%, #fcffff 100%);
  color: #fff;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  transition:
    opacity 0.45s ease,
    transform 0.45s ease;
}
.login-experience.leaving {
  opacity: 0;
  transform: scale(1.025);
  pointer-events: none;
}
.login-water-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
  opacity: 0.5;
}
.login-brand {
  position: absolute;

  top: 25%;
  right: calc(3vw + 425px);

  transform: translateY(-50%);

  display: flex;
  align-items: center;

  z-index: 3;
}

.login-brand-logo {
  display: block;

  height: 60px;
  width: auto;

  max-width: 190px;

  object-fit: contain;

  transform: rotate(-90deg);
  transform-origin: center;
}

.login-glass-card {
  position: absolute;
  top: 50%;
  right: 9vw;
  width: min(410px, calc(100vw - 40px));
  box-sizing: border-box;
  padding: 38px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 28px;
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.18),
    rgba(255, 255, 255, 0.08)
  );
  box-shadow: 0 35px 90px rgba(0, 15, 28, 0.38);
  backdrop-filter: blur(24px);
  transform: translateY(-50%);
}
.login-kicker {
  margin-bottom: 13px;
  color: #1b3160;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
}
.login-glass-card h1 {
  margin: 0 0 15px;
  font-size: 38px;
  line-height: 1.08;
  letter-spacing: -0.035em;
}
.login-glass-card h1 em {
  color: #1b3160;
  font-style: normal;
}
.login-lead {
  margin: 0 0 25px;
  color: #1b3160;
  font-size: 12px;
  line-height: 1.65;
}
.login-form {
  display: grid;
  gap: 14px;
}
.login-form label {
  display: grid;
  gap: 7px;
}
.login-form label > span {
  color: #1b3160;
  font-size: 11px;
  font-weight: 700;
}
.login-form input {
  box-sizing: border-box;
  width: 100%;
  height: 44px;
  padding: 10px 13px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  background: rgba(3, 31, 48, 0.34);
  color: #fff;
  font: 13px inherit;
  outline: none;
}
.login-form input::placeholder {
  color: #91afbf;
}
.login-form input:focus {
  border-color: #67e8f9 !important;
  box-shadow: 0 0 0 3px rgba(103, 232, 249, 0.13);
}
.login-password {
  position: relative;
}
.login-password input {
  padding-right: 58px;
}
.login-reveal {
  position: absolute;
  right: 7px;
  top: 7px;
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #f6f7f8;
  font-size: 10px;
  cursor: pointer;
}
.water-login-button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;

  gap: 12px;

  width: 100%;
  height: 44px;

  margin-top: 4px;

  overflow: hidden;

  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 12px;

  background: linear-gradient(115deg, #06b6d4, #148ab8);

  box-shadow:
    0 10px 24px rgba(6, 182, 212, 0.25),
    inset 0 1px rgba(255, 255, 255, 0.45);

  color: #fff;

  cursor: pointer;

  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}
.water-login-button:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow:
    0 18px 38px rgba(6, 182, 212, 0.42),
    inset 0 1px rgba(255, 255, 255, 0.55);
}
.water-login-button:active {
  transform: scale(0.985);
}
.water-login-button b {
  position: relative;
  font-size: 13px;
  letter-spacing: 0.01em;
}
.water-login-button i {
  position: relative;
  font-size: 18px;
  font-style: normal;
}
.water-button-shine {
  position: absolute;
  width: 120%;
  height: 220%;
  left: -110%;
  top: -60%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.28),
    transparent
  );
  transform: rotate(18deg);
  transition: left 0.55s ease;
}
.water-login-button:hover .water-button-shine {
  left: 90%;
}
.water-login-button.loading {
  animation: waterPulse 1.1s ease-in-out infinite;
}
.login-error {
  min-height: 0;
  margin: 0;
  color: #fecaca;
  font-size: 11px;
  line-height: 1.4;
}
.login-error:empty {
  display: none;
}
.login-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 17px 0 12px;
  color: #9cc6d4;
  font-size: 10px;
}
.login-divider::before,
.login-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: rgba(255, 255, 255, 0.17);
}
.login-local {
  width: 100%;
  padding: 8px;
  border: 0;
  background: transparent;
  color: #1b3160;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.login-local:hover {
  text-decoration: underline;
}
.login-footnote {
  margin: 12px 0 0;
  color: #1b3160;
  font-size: 9px;
  line-height: 1.5;
  text-align: center;
}
@keyframes waterPulse {
  50% {
    filter: brightness(1.15);
    transform: scale(0.99);
  }
}
@media (max-width: 700px) {
  .login-brand {
    top: 352px;
    left: 52px;
  }
  .login-glass-card {
    right: 20px;
    padding: 29px;
    top: 54%;
  }
  .login-glass-card h1 {
    font-size: 31px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .login-experience,
  .water-login-button,
  .water-button-shine {
    transition: none !important;
    animation: none !important;
  }
}

@media (max-width: 720px) {
  .project-card .card-header {
    grid-template-columns: 1fr;
  }
  .project-actions {
    justify-content: flex-start;
  }
  .library-target-field {
    grid-template-columns: 1fr;
    gap: 7px;
  }
  .visual-tabs {
    align-items: stretch;
  }
  .visual-tabs > * {
    flex: 1 1 auto;
  }
  .chart-split {
    flex: 1 1 210px;
  }
  .chart-split > .visual-tab {
    flex: 1;
  }
  .chart-type-wrap {
    margin-left: 0;
  }
  .chart-axis-settings {
    grid-template-columns: 1fr;
    margin-inline: 14px;
  }
  .model-library-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .help-workflow {
    grid-template-columns: 1fr 1fr;
  }
  .help-workflow li {
    min-height: 88px;
  }
  .help-workflow li::after {
    display: none;
  }
  #result-target {
    width: 100%;
    margin: 0 0 8px;
  }
  .import-preview-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .server-account-dialog label {
    grid-template-columns: 1fr;
    gap: 5px;
  }
}
/* Structured Model Composition contract. */
.model-composition-form {
  display: grid;
  gap: 18px;
}

.composition-section {
  padding: 18px;
  border: 1px solid #dbe3ee;
  border-radius: 12px;
  background: #fff;
}

.composition-section h3 {
  margin: 0 0 12px;
}

.composition-section p {
  margin: 6px 0 12px;
  color: #64748b;
}

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

.composition-grid label,
.composition-section > label,
.parameter-count {
  display: grid;
  gap: 6px;
  color: #334155;
  font-size: 12px;
  font-weight: 650;
}

.composition-grid input,
.composition-grid select,
.parameter-count input,
.parameter-definition-table input,
.parameter-definition-table select {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #172033;
}

.composition-span {
  grid-column: 1 / -1;
}

.composition-section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

.parameter-count {
  width: 150px;
  flex: 0 0 auto;
}

.parameter-table-wrap {
  overflow-x: auto;
}

.math-definition-subsection + .math-definition-subsection {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid #e2e8f0;
}

.math-definition-subsection h4 {
  margin: 0 0 10px;
}

.composition-subsection-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.solving-task-table {
  min-width: 980px;
}

.solving-task-table .task-remove {
  min-width: 34px;
  padding: 7px 10px;
}

.task-binding-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 8px;
  min-width: 280px;
}

.task-binding-field {
  display: grid;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
}

.task-binding-field input {
  min-width: 0;
}

.implementation-mode {
  display: flex;
  gap: 10px;
  margin: 0 0 14px;
  padding: 0;
  border: 0;
}

.implementation-mode legend {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
}

.implementation-mode label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
}

.implementation-mode input {
  width: auto;
  min-height: auto;
}

.parameter-definition-table {
  width: 100%;
  border-collapse: collapse;
}

.parameter-definition-table th,
.parameter-definition-table td {
  padding: 8px;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  vertical-align: middle;
}

.parameter-definition-table th:first-child,
.parameter-definition-table td:first-child {
  width: 40px;
  color: #64748b;
  text-align: center;
}

@media (max-width: 760px) {
  .composition-grid {
    grid-template-columns: 1fr;
  }
  .composition-span {
    grid-column: auto;
  }
  .composition-section-head {
    align-items: stretch;
    flex-direction: column;
  }
  .composition-subsection-head {
    align-items: stretch;
    flex-direction: column;
  }
  .parameter-count {
    width: 100%;
  }
}

.formula-guide {
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid #3f95fd;
  border-radius: 10px;
  background: #4460a330;
}

.formula-guide summary {
  cursor: pointer;
  font-weight: 700;
  color: #a6beff;
}
.formula-guide p {
  margin: 8px 0;
  color: #334155;
}
.formula-guide div {
  display: grid;
  grid-template-columns: minmax(160px, 0.45fr) 1fr;
  gap: 10px;
  padding: 6px 0;
  border-top: 1px solid #dbeafe;
}
.formula-guide code {
  overflow-wrap: anywhere;
  color: #1e40af;
}

#adaptiveModelInput input.formula-valid {
  border-color: #16a34a;
  background: #f0fdf4;
  box-shadow: inset 0 0 0 1px #16a34a;
}

#adaptiveModelInput input.formula-invalid {
  border-color: #dc2626;
  background: #fef2f2;
  box-shadow: inset 0 0 0 1px #dc2626;
}

.formula-status-mark {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-left: 5px;
  border-radius: 50%;
  color: #fff;
  font-weight: 800;
  font-size: 12px;
}
.formula-status-mark.valid {
  background: #16a34a;
}
.formula-status-mark.invalid {
  background: #dc2626;
}
.run-solution,
.run-blocked-warning {
  color: #334155;
}
.run-blocked-warning > strong {
  color: #991b1b;
}

@media (max-width: 760px) {
  .formula-guide div {
    grid-template-columns: 1fr;
  }
}

/* HidroVisi Formula Engine: formula cells, floating formula bar, syntax highlight */
.embedded-sheet input.formula-valid {
  border-color: #16a34a;
  background: #f0fdf4;
  box-shadow: inset 0 0 0 1px #16a34a;
}
.embedded-sheet input.formula-invalid {
  border-color: #dc2626;
  background: #fef2f2;
  box-shadow: inset 0 0 0 1px #dc2626;
}

.formula-bar {
  position: absolute;
  z-index: 4000;
  max-width: 420px;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.35);
  padding: 10px 12px;
  font-size: 13px;
}
.formula-bar-line {
  font-family: "Cascadia Code", Consolas, monospace;
  margin-bottom: 6px;
  word-break: break-all;
}
.formula-bar-hint {
  color: #93c5fd;
  margin-bottom: 6px;
}
.formula-bar-status {
  font-weight: 700;
  margin-bottom: 4px;
}
.formula-bar-status.valid {
  color: #4ade80;
}
.formula-bar-status.invalid {
  color: #f87171;
}
.formula-suggest {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  max-height: 200px;
  overflow-y: auto;
}
.formula-suggest li {
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.formula-suggest li strong {
  color: #f8fafc;
}
.formula-suggest li small {
  color: #94a3b8;
}
.formula-suggest li.active,
.formula-suggest li:hover {
  background: #1e293b;
}

.output-formula-menu {
  position: absolute;
  z-index: 4100;
  display: grid;
  max-width: 420px;
  max-height: 220px;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
}
.output-formula-menu button {
  padding: 7px 9px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #0f172a;
  text-align: left;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 12px;
}
.output-formula-menu button:hover,
.output-formula-menu button:focus-visible {
  background: #eff6ff;
}
.output-formula-menu button:disabled {
  color: #64748b;
  font-style: italic;
  cursor: default;
}

.tok-eq,
.tok-op,
.tok-punct {
  color: #94a3b8;
}
.tok-fn {
  color: #38bdf8;
  font-weight: 700;
}
.tok-name {
  color: #f87171;
}
.tok-ref {
  color: #facc15;
}
.tok-num {
  color: #a78bfa;
}
.tok-str {
  color: #4ade80;
}

.formula-column-list ul {
  list-style: none;
  margin: 8px 0;
  padding: 0;
}
.formula-column-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
}

/* =========================================================
   LIBRARY VIEW SWITCHER — GRID / LIST
   ========================================================= */

.library-view-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin: -8px 0 16px;
}

.model-library-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#model-view-switch-host,
#workspace-view-switch-host {
  margin-left: auto;
}

.library-view-toolbar.model-library-view-toolbar {
  margin: 0;
}

.library-view-switch {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: transparent;
  border: 1px solid #5586cb5d;
  border-radius: 9px;
}

.library-view-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 6px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.library-view-btn:hover {
  background: #fff;
  color: #334155;
}

.library-view-btn.active {
  background: #fff;
  color: #172033;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

/* =========================
   MODEL LIBRARY — LIST
   ========================= */

body.library-model-list .model-library-grid {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

body.library-model-list .model-library-system-header {
  width: 100%;
  margin-top: 12px;
}

.model-library-system-group {
  border: 0;
}

.model-library-system-group > .model-library-system-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 2px 8px;
  cursor: pointer;
  list-style: none;
}

.model-library-system-group
  > .model-library-system-header::-webkit-details-marker {
  display: none;
}

.model-library-system-group > .model-library-system-header::after {
  content: "⌄";
  margin-left: 8px;
  color: #64748b;
}

.model-library-system-group:not([open]) > .model-library-system-header::after {
  transform: rotate(-90deg);
}

.workspace-library-system-group {
  grid-column: 1 / -1;
}

.workspace-library-system-group > .model-library-system-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 2px 8px;
  cursor: pointer;
  list-style: none;
}

.workspace-library-system-group
  > .model-library-system-header::-webkit-details-marker {
  display: none;
}

.workspace-library-system-group > .model-library-system-header::after {
  content: "⌄";
  margin-left: 8px;
  color: #64748b;
}

.workspace-library-system-group:not([open])
  > .model-library-system-header::after {
  transform: rotate(-90deg);
}

.workspace-library-system-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 300px));
  justify-content: start;
  gap: 14px;
}

body.library-model-list .model-library-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 4px 18px;
  width: 100%;
  min-height: 0;
  padding: 14px 92px 14px 14px !important;
  position: relative;
}

body.library-model-list .model-library-card::before {
  width: 3px;
}

body.library-model-list .model-library-card .model-book-mark {
  margin: 0;
}

body.library-model-list .model-library-card h3 {
  margin: 0;
  grid-column: 1;
  grid-row: 1;
}

body.library-model-list .model-library-card > p {
  margin: 0;
  grid-column: 1;
  grid-row: 2;
}

body.library-model-list .model-formula {
  margin: 0;
}

body.library-model-list .model-library-more {
  display: none;
}

body.library-model-list .model-library-card details {
  display: none;
}

/* =========================================================
   MODEL LIBRARY ACTIONS
   ========================================================= */

.model-library-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: auto;
}

.model-library-actions .secondary-btn {
  white-space: nowrap;
}

.model-library-actions .primary-btn {
  flex: 1;
}

/* LIST VIEW */

body.library-model-list .model-library-actions {
  margin: 0;
  padding: 0;
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  justify-self: end;
  white-space: nowrap;
}

body.library-model-list .model-library-card .model-library-meta {
  position: absolute;
  top: 9px;
  right: 12px;
}

/* Workspace Models retain their Project and Workspace context while using the same aligned action column. */
body.library-model-list .workspace-model-library-card {
  grid-template-rows: auto auto auto;
}

body.library-model-list .workspace-model-library-card > p:first-of-type {
  grid-column: 1;
  grid-row: 1;
}

body.library-model-list .workspace-model-library-card h3 {
  grid-column: 1;
  grid-row: 2;
}

body.library-model-list .workspace-model-library-card > p:nth-of-type(2),
body.library-model-list .workspace-model-library-card > p:nth-of-type(3) {
  grid-column: 1;
  grid-row: 3;
}

body.library-model-list .workspace-model-library-card .model-library-actions {
  grid-column: 2;
  grid-row: 1 / span 3;
}

body.library-model-list .model-library-actions .primary-btn {
  flex: none;
}

.model-library-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
  margin: 0;
}

.model-library-meta small {
  color: #64748b;
}

.model-info-btn {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #64748b;
  cursor: pointer;
}

.model-info-btn:hover,
.model-info-btn:focus-visible {
  background: #e8eef8;
  color: #1d4ed8;
  outline: none;
}

.model-detail-dialog h3 {
  margin: 0 0 8px;
}
.model-detail-dialog > p {
  margin: 0 0 16px;
  color: #475569;
}
.model-detail-dialog dl {
  display: grid;
  gap: 10px;
  margin: 0;
}
.model-detail-dialog dl > div {
  padding: 9px 10px;
  border-radius: 8px;
  background: #f8fafc;
}
.model-detail-dialog dt {
  margin-bottom: 3px;
  font-size: 11px;
  font-weight: 800;
  color: #475569;
}
.model-detail-dialog dd {
  margin: 0;
  font-size: 13px;
  color: #172033;
}
.model-detail-dialog h4 {
  margin: 16px 0 7px;
  font-size: 12px;
}
.model-reference-links {
  margin: 0;
  padding-left: 18px;
}
.model-reference-links a {
  color: #1d4ed8;
}

/* =========================================================
   DARK MODE — FINAL CASCADE
   Loaded after the base document styles so every screen keeps readable contrast.
   ========================================================= */
body.dark-mode .brand,
body.dark-mode .canvas,
body.dark-mode .canvas-inner,
body.dark-mode .canvas h1,
body.dark-mode .canvas h2,
body.dark-mode .canvas h3,
body.dark-mode .canvas h4,
body.dark-mode .canvas h5,
body.dark-mode .canvas h6,
body.dark-mode .canvas label,
body.dark-mode .canvas legend,
body.dark-mode .canvas th,
body.dark-mode .canvas td,
body.dark-mode .canvas li,
body.dark-mode .canvas strong {
  color: #e8f0fb !important;
}

body.dark-mode .canvas [class*="card"],
body.dark-mode .canvas [class*="panel"],
body.dark-mode .canvas [class*="editor"],
body.dark-mode .canvas [class*="form"],
body.dark-mode .canvas [class*="table"],
body.dark-mode .canvas [class*="result"],
body.dark-mode .canvas [class*="workspace"],
body.dark-mode .canvas [class*="project"],
body.dark-mode .canvas [class*="composition"],
body.dark-mode .canvas table,
body.dark-mode .modal {
  background-color: #172033 !important;
  border-color: #3b4b62 !important;
}

body.dark-mode .canvas p,
body.dark-mode .canvas small,
body.dark-mode .canvas [class*="description"],
body.dark-mode .canvas [class*="hint"],
body.dark-mode .canvas [class*="note"],
body.dark-mode .canvas [class*="subtitle"],
body.dark-mode .canvas [class*="meta"] {
  color: #bfd0e6 !important;
}

body.dark-mode .canvas input,
body.dark-mode .canvas select,
body.dark-mode .canvas textarea,
body.dark-mode .canvas .model-formula,
body.dark-mode .canvas pre,
body.dark-mode .canvas code {
  background: #0d1728 !important;
  border-color: #52647c !important;
  color: #f1f5f9 !important;
}

body.dark-mode .canvas input::placeholder,
body.dark-mode .canvas textarea::placeholder {
  color: #a9bad0 !important;
  opacity: 1;
}

body.dark-mode .canvas button.secondary-btn,
body.dark-mode .canvas button:not(.primary-btn):not(.danger-btn),
body.dark-mode .modal button:not(.primary-btn):not(.danger-btn) {
  color: #eef5ff !important;
  border-color: transparent !important;
}

body.dark-mode .canvas .primary-btn,
body.dark-mode .modal .primary-btn {
  background: #2563eb !important;
  border-color: #3b82f6 !important;
  color: #ffffff !important;
}

body.dark-mode .canvas .primary-btn:hover,
body.dark-mode .modal .primary-btn:hover {
  background: #3b82f6 !important;
}

body.dark-mode .canvas .danger-btn,
body.dark-mode .canvas .library-model-delete,
body.dark-mode .modal .danger-btn {
  background: #3f1d24 !important;
  border-color: #fb7185 !important;
  color: #fecdd3 !important;
}

body.dark-mode .canvas a,
body.dark-mode .modal a {
  color: #93c5fd !important;
}

body.dark-mode .canvas hr,
body.dark-mode .canvas td,
body.dark-mode .canvas th,
body.dark-mode .canvas tr {
  border-color: #3b4b62 !important;
}

/* Named components in legacy pages use direct colors rather than inherited text. */
body.dark-mode .workspace-file-name,
body.dark-mode .workspace-card-name,
body.dark-mode .system-name,
body.dark-mode .model-library-system-header,
body.dark-mode .model-library-system-header span,
body.dark-mode .workspace-library-card h3,
body.dark-mode .workspace-model-library-card h3,
body.dark-mode [class*="-title"],
body.dark-mode [class*="-name"] {
  color: #f1f5f9 !important;
}

body.dark-mode .workspace-file-meta,
body.dark-mode .workspace-file-updated,
body.dark-mode .workspace-card-desc,
body.dark-mode .system-lock,
body.dark-mode .workspace-library-origin,
body.dark-mode .model-library-system-header small,
body.dark-mode [class*="-meta"],
body.dark-mode [class*="-updated"],
body.dark-mode [class*="-desc"] {
  color: #bfd0e6 !important;
}

body.dark-mode .workspace-file-icon,
body.dark-mode .workspace-card,
body.dark-mode .system-card {
  background: #172033 !important;
  border-color: #3b4b62 !important;
}

/* Fallback for legacy widgets that render white with inline or unclassified surfaces. */
body.dark-mode
  .canvas
  :not(button):not(input):not(select):not(textarea):not(option):not(svg):not(
    path
  ):not(i) {
  background-color: #172033 !important;
  color: #e8f0fb !important;
  border-color: #3b4b62 !important;
}

body.dark-mode .canvas table,
body.dark-mode .canvas thead,
body.dark-mode .canvas tbody,
body.dark-mode .canvas tr,
body.dark-mode .canvas th,
body.dark-mode .canvas td {
  background-color: #172033 !important;
  color: #e8f0fb !important;
  border-color: #52647c !important;
}

body.dark-mode .dropdown-menu,
body.dark-mode .dropdown-menu button,
body.dark-mode .modal-overlay .dropdown-menu,
body.dark-mode .modal-overlay .dropdown-menu button {
  background: #172033 !important;
  color: #eef5ff !important;
  border-color: #52647c !important;
}

body.dark-mode .dropdown-menu button:hover {
  background: #334155 !important;
  color: #ffffff !important;
}

body.dark-mode .canvas .primary-btn,
body.dark-mode .canvas .secondary-btn,
body.dark-mode .canvas .danger-btn,
body.dark-mode .canvas input,
body.dark-mode .canvas select,
body.dark-mode .canvas textarea,
body.dark-mode .canvas option {
  color: #f8fbff !important;
}

body.dark-mode button:disabled,
body.dark-mode .canvas button:disabled,
body.dark-mode .modal button:disabled {
  background: #263449 !important;
  border-color: #52647c !important;
  color: #aebdd0 !important;
  opacity: 1 !important;
  cursor: not-allowed;
}

.model-origin-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 3px 7px;
  border-radius: 5px;
  font-size: 9px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.model-origin-badge.system {
  background: #e8eef8;
  color: #334e78;
}

.model-origin-badge.user {
  background: #ecfdf5;
  color: #047857;
}

/* =========================
   WORKSPACE LIBRARY — LIST
   ========================= */

/* Container aktual:
   .model-library-grid.workspace-library-grid
*/
body.library-workspace-list .workspace-library-grid {
  display: flex !important;
  flex-direction: column !important;
  gap: 7px !important;
}

body.library-workspace-list .workspace-library-system-group {
  width: 100%;
}

body.library-workspace-list .workspace-library-system-cards {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

/* Card aktual:
   .model-library-card.workspace-library-card
*/
body.library-workspace-list .workspace-library-card {
  display: grid !important;

  grid-template-columns:
    387px
    minmax(129px, 0.8fr)
    minmax(77px, 1.5fr)
    auto;

  align-items: start; /* sebelumnya center */
  gap: 4px;

  width: 100%;
  min-height: 0 !important;
  padding: 10px 14px !important;
}
/* tombol delete sejajar dengan bagian paling atas card */
body.library-workspace-list .workspace-library-card .library-model-delete {
  position: static !important;
  grid-column: 4;
  grid-row: 1;
  justify-self: end;
  align-self: start;
}

/* icon berada di kiri atas */
body.library-workspace-list .workspace-library-card .model-book-mark {
  grid-column: 1;
  grid-row: 1;
  margin: 0 !important;
  align-self: start;
}

/* informasi utama workspace */
body.library-workspace-list .workspace-library-origin,
body.library-workspace-list .workspace-library-card h3,
body.library-workspace-list .workspace-library-card > p {
  align-self: start;
}

/* icon / initial */
body.library-workspace-list .workspace-library-card .model-book-mark {
  margin: 0 !important;
}

/* judul */
body.library-workspace-list .workspace-library-card h3 {
  margin: 0 !important;
}

/* asal project */
body.library-workspace-list .workspace-library-origin {
  margin: 0 !important;
}

/* deskripsi */
body.library-workspace-list .workspace-library-card > p {
  margin: 0 !important;
}

/* workflow */
body.library-workspace-list .workspace-model-flow {
  margin: 0 !important;
}

/* statistik */
body.library-workspace-list .workspace-library-stats {
  margin: 0 !important;
}

/* tombol Add to Project */
body.library-workspace-list .workspace-library-card > [data-use-workspace] {
  margin: 0 !important;
  align-self: center;
  justify-self: end;
  width: min(100%, 220px);
}

/* detail panjang tidak perlu pada list */
body.library-workspace-list .workspace-library-card .model-library-more {
  display: none;
}

/* delete tetap kanan */
body.library-workspace-list .workspace-library-card .library-model-delete {
  position: static;
  justify-self: end;
}
/* =========================
   RESPONSIVE
   ========================= */

@media (max-width: 800px) {
  body.library-model-list .model-library-card {
    grid-template-columns: 36px 1fr auto;
  }

  body.library-model-list .model-formula,
  body.library-model-list .model-library-card > p {
    display: none;
  }

  body.library-workspace-list .workspace-library-card {
    grid-template-columns: 34px 1fr auto;
  }

  body.library-workspace-list .workspace-library-card > p,
  body.library-workspace-list .workspace-model-flow {
    display: none;
  }

  body.library-workspace-list .workspace-library-card > [data-use-workspace] {
    width: auto;
  }
}

/* Author display rules must not override the hidden state. */
.output-formula-menu[hidden] {
  display: none !important;
}

/* =========================================================
   PROJECT WORKSPACE DATA STATUS
   ========================================================= */

.workspace-data-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  margin-top: 6px;
  padding: 4px 8px;

  border-radius: 999px;

  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
}

.workspace-data-status-dot {
  width: 7px;
  height: 7px;

  border-radius: 50%;

  flex: 0 0 7px;
}

/* READY */

.workspace-data-status.ready {
  background: #01391fb8;
  color: #047857;
}

.workspace-data-status.ready .workspace-data-status-dot {
  background: #10b981;
}

/* NOT READY */

.workspace-data-status.not-ready {
  background: #8315153a;
  color: #b91c1c;
}

.workspace-data-status.not-ready .workspace-data-status-dot {
  background: #ef4444;
}

.workspace-file.workspace-running {
  opacity: 0.72;
  pointer-events: none;
}

.workspace-file.workspace-running::after {
  content: "Running…";

  justify-self: end;

  color: #2563eb;

  font-size: 10px;
  font-weight: 700;
}

.run-readiness-error > p {
  margin: 14px 0 8px;

  color: #475569;

  font-size: 12px;

  line-height: 1.55;
}

.run-readiness-error > ul {
  margin: 0;

  padding-left: 20px;

  color: #7f1d1d;

  font-size: 11px;

  line-height: 1.6;
}

/* =========================================================
   MODEL DATA — CUSTOM COLUMNS
   ========================================================= */

.model-custom-column-head {
  min-width: 150px;
}

.model-custom-column-title {
  display: flex;
  align-items: center;
  gap: 6px;
}

.model-custom-column-title input {
  width: 100%;
  min-width: 110px;

  border: 1px solid transparent;
  border-radius: 6px;

  background: transparent;
  color: inherit;

  padding: 5px 7px;

  font-size: inherit;
  font-weight: 700;
}

.model-custom-column-title input:hover {
  border-color: #cbd5e1;
  background: #ffffff;
}

.model-custom-column-title input:focus {
  border-color: #2563eb;
  background: #ffffff;
  outline: none;

  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.model-column-delete {
  flex: 0 0 auto;

  width: 24px;
  height: 24px;

  padding: 0;

  border-radius: 5px;

  color: #94a3b8;
}

.model-column-delete:hover {
  color: #b42318;
  background: #fee2e2;
}

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

/* =========================================================
   DATA EDITOR
   MASS FORMULA FILL / COLUMN RESIZE / DATA PREVIEW
   ========================================================= */

.data-editor-toolbar {
  display: grid;
  gap: 12px;
  margin: 4px 0 12px;
}

.data-editor-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* =========================================================
   FORMULA FILL
   ========================================================= */

.formula-fill-panel {
  border: 1px solid var(--hv-border, #dbe3ee);
  border-radius: 10px;
  padding: 12px;
  background: var(--hv-soft, #f8fafc);
}

.formula-fill-head,
.data-preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.formula-fill-head span {
  color: var(--hv-muted, #64748b);
  font-size: 12px;
  font-weight: 600;
}

.formula-fill-controls {
  display: grid;

  grid-template-columns:
    minmax(220px, 1.6fr)
    minmax(220px, 1.25fr)
    minmax(130px, 0.75fr)
    auto
    auto;

  gap: 8px;
  align-items: end;
}

.formula-fill-controls label {
  display: grid;
  gap: 5px;
}

.formula-fill-controls label > span {
  color: var(--hv-muted, #64748b);
  font-size: 11px;
  font-weight: 700;
}

.formula-fill-controls input,
.formula-fill-controls select {
  min-height: 38px;

  border: 1px solid var(--hv-border, #dbe3ee);

  border-radius: 7px;

  background: #fff;

  padding: 8px 10px;

  color: var(--hv-ink, #0f172a);
}

/* =========================================================
   DATA TABLE
   ========================================================= */

.data-editor-sheet {
  position: relative;
  max-height: 470px;
}

.data-editor-table {
  width: max-content;
  min-width: 100%;
  table-layout: fixed;
}

.data-editor-table th {
  position: sticky;
  top: 0;

  z-index: 2;

  min-width: 80px;

  padding-right: 8px;
}

.data-editor-table td {
  min-width: 80px;
}

.data-editor-table input {
  min-width: 0;
}

/* active cell */

.data-editor-table .data-cell-input.active-grid-cell {
  outline: 2px solid var(--hv-focus, #2563eb);

  outline-offset: -2px;

  background: #eff6ff;
}

/* =========================================================
   COLUMN RESIZE HANDLE
   ========================================================= */

.column-resize-handle {
  position: absolute;

  top: 0;
  right: -3px;

  width: 7px;
  height: 100%;

  cursor: col-resize;

  user-select: none;

  touch-action: none;

  z-index: 4;
}

.column-resize-handle::after {
  content: "";

  position: absolute;

  top: 20%;
  bottom: 20%;

  left: 3px;

  width: 1px;

  background: #cbd5e1;
}

.column-resize-handle:hover::after,
.column-resize-handle:active::after {
  background: var(--hv-focus, #2563eb);

  width: 2px;
}

/* =========================================================
   DATA PREVIEW
   ========================================================= */

.data-preview-section {
  margin-top: 18px;

  border-top: 1px solid var(--hv-border, #dbe3ee);

  padding-top: 16px;
}

.data-preview-heading h3 {
  margin: 2px 0 0;

  font-size: 17px;

  color: var(--hv-ink, #0f172a);
}

.data-editor-chart-surface {
  margin-top: 0;
}

.data-editor-chart-surface .chart-legend {
  display: flex;

  gap: 10px;

  flex-wrap: wrap;

  margin: 8px 0;

  color: var(--hv-muted, #64748b);

  font-size: 12px;
}

.data-editor-chart-surface .chart-plot canvas {
  width: 100%;

  height: auto;

  min-width: 720px;
}

/* =========================================================
   FOOTER
   ========================================================= */

.data-editor-footer {
  display: flex;

  align-items: center;

  gap: 12px;

  margin-top: 16px;
}

.data-editor-footer #grid-error {
  margin: 0;

  color: var(--hv-danger, #b42318);
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 1100px) {
  .formula-fill-controls {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .formula-fill-controls {
    grid-template-columns: 1fr;
  }

  .formula-fill-head,
  .data-preview-heading {
    align-items: flex-start;

    flex-direction: column;
  }
}

/* =========================================================
   MODEL DATA TABLE — FORMULA FILL / RESIZE / VISUALIZATION
   ========================================================= */

.model-resizable-column {
  position: relative;
  box-sizing: border-box;
}

.model-column-resize-handle {
  position: absolute;
  top: 0;
  right: -4px;

  width: 8px;
  height: 100%;

  cursor: col-resize;

  touch-action: none;
  user-select: none;

  z-index: 8;
}

.model-column-resize-handle::after {
  content: "";

  position: absolute;

  top: 18%;
  bottom: 18%;
  left: 4px;

  width: 1px;

  background: #cbd5e1;
}

.model-column-resize-handle:hover::after {
  width: 2px;
  background: #2563eb;
}

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

/* =========================================================
   FORMULA FILL
   ========================================================= */

.model-formula-fill-dialog {
  display: grid;
  gap: 16px;
}

.model-formula-fill-dialog > label {
  display: grid;
  gap: 6px;
}

.model-formula-fill-dialog input[type="text"],
.model-formula-fill-dialog input[type="number"] {
  width: 100%;
}

.model-fill-row-range {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.model-fill-row-range label {
  display: grid;
  gap: 6px;
}

.model-fill-columns {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.model-fill-columns label {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  padding: 6px 9px;

  border: 1px solid #dbe3ee;
  border-radius: 8px;

  background: #fff;

  cursor: pointer;
}

.model-fill-columns label:has(input:checked) {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
}

/* =========================================================
   MODEL DATA VISUALIZATION
   ========================================================= */

.model-series-data-preview {
  border-top: 1px solid #e2e8f0;
  background: #fff;
}

.model-series-data-preview > summary {
  padding: 11px 13px;

  background: #f8fafc;

  color: #334155;

  font-size: 11px;
  font-weight: 700;

  cursor: pointer;

  list-style: none;
}

.model-series-data-preview > summary::-webkit-details-marker {
  display: none;
}

.model-series-data-preview > summary::before {
  content: "▾";

  display: inline-block;

  margin-right: 7px;

  color: #64748b;

  transition: transform 0.15s ease;
}

.model-series-data-preview:not([open]) > summary::before {
  transform: rotate(-90deg);
}

.model-series-chart-body {
  padding: 12px;
}

.model-series-chart-settings {
  margin: 0 0 10px;
}

.model-series-chart-settings fieldset {
  min-width: 0;
}

.model-series-chart-body .chart-plot {
  overflow-x: auto;
  padding: 0;
}

.model-series-chart-body canvas {
  display: block;

  width: 100%;
  min-width: 620px;

  height: auto;

  border: 1px solid #e2e8f0;
  border-radius: 9px;

  background: #fff;
}

@media (max-width: 760px) {
  .model-fill-row-range {
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   CALCULATION TRACE
   ========================================================= */

.workspace-run-toolbar {
  display: flex;
  align-items: end;
  flex-wrap: wrap;

  gap: 10px;

  margin: 14px 0;
}

.trace-mode-control {
  display: grid;
  gap: 4px;

  min-width: 160px;
}

.trace-mode-control > span {
  color: #64748b;

  font-size: 10px;
  font-weight: 700;

  text-transform: uppercase;

  letter-spacing: 0.04em;
}

#traceModeSelect {
  min-height: 38px;

  padding: 7px 32px 7px 10px;

  border: 1px solid #dbe3ee;
  border-radius: 9px;

  background: #fff;
  color: #172033;

  font-size: 12px;
  font-weight: 600;
}

/* TRACE CONTAINER */

.calculation-trace-panel {
  margin-top: 14px;

  border: 1px solid #dbe3ee;
  border-radius: 12px;

  overflow: hidden;

  background: #f8fafc;
}

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

/* HEADER */

.calculation-trace-header {
  display: flex;

  align-items: center;
  justify-content: space-between;

  gap: 12px;

  padding: 11px 14px;

  border-bottom: 1px solid #dbe3ee;

  background: #fff;
}

.calculation-trace-header > div {
  display: grid;
  gap: 2px;
}

.calculation-trace-header small {
  color: #64748b;

  font-size: 9px;
  font-weight: 800;

  letter-spacing: 0.08em;
}

.calculation-trace-header strong {
  color: #172033;

  font-size: 13px;
}

#calculationTraceStatus {
  padding: 4px 8px;

  border-radius: 999px;

  background: #f1f5f9;
  color: #64748b;

  font-size: 10px;
  font-weight: 700;
}

#calculationTraceStatus.running {
  background: #eff6ff;
  color: #2563eb;
}

#calculationTraceStatus.success {
  background: #ecfdf5;
  color: #047857;
}

#calculationTraceStatus.error {
  background: #fef2f2;
  color: #b91c1c;
}

/* BODY */

.calculation-trace-body {
  display: block;

  max-height: 650px;

  padding: 12px;

  overflow: auto;

  background: #f8fafc;

  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

.trace-empty {
  padding: 24px;

  color: #64748b;

  font-size: 11px;

  text-align: center;
}

/* STATUS MESSAGES */

.calculation-trace-message {
  margin: 0 0 7px;

  padding: 7px 9px;

  border-radius: 7px;

  background: #fff;

  color: #64748b;

  font-size: 10px;
}

.calculation-trace-message.start,
.calculation-trace-message.model {
  color: #334155;

  font-weight: 700;
}

.calculation-trace-message.success {
  color: #047857;
}

.calculation-trace-message.warning {
  background: #fffbeb;
  color: #92400e;
}

.calculation-trace-message.error {
  background: #fef2f2;
  color: #b91c1c;
}

/* MODEL */

.calculation-trace-model {
  margin: 9px 0;

  border: 1px solid #dbe3ee;
  border-radius: 10px;

  overflow: hidden;

  background: #fff;
}

.calculation-trace-model > summary {
  display: grid;

  grid-template-columns:
    auto
    minmax(0, 1fr)
    auto;

  align-items: center;

  gap: 10px;

  padding: 10px 12px;

  cursor: pointer;

  list-style: none;

  background: #fff;
}

.calculation-trace-model > summary::-webkit-details-marker {
  display: none;
}

.trace-model-status {
  display: grid;

  place-items: center;

  width: 24px;
  height: 24px;

  border-radius: 50%;

  font-size: 11px;
  font-weight: 800;
}

.trace-model-status.success {
  background: #dcfce7;
  color: #15803d;
}

.trace-model-heading {
  display: grid;
  gap: 2px;

  min-width: 0;
}

.trace-model-heading strong {
  overflow: hidden;

  color: #172033;

  font-size: 11px;

  text-overflow: ellipsis;
  white-space: nowrap;
}

.trace-model-heading small {
  color: #64748b;

  font-size: 9px;
}

.trace-step-count {
  color: #64748b;

  font-size: 9px;
  font-weight: 700;
}

/* MODEL BODY */

.calculation-trace-model-body {
  display: grid;

  gap: 12px;

  padding: 12px 14px;

  border-top: 1px solid #e2e8f0;
}

.trace-section {
  display: grid;

  gap: 7px;
}

.trace-label {
  color: #64748b;

  font-size: 9px;
  font-weight: 800;

  letter-spacing: 0.06em;

  text-transform: uppercase;
}

.trace-main-formula,
.trace-formula,
.trace-substitution {
  display: block;

  width: fit-content;
  max-width: 100%;

  padding: 6px 8px;

  border-radius: 6px;

  background: #f1f5f9;
  color: #172033;

  font-family: "Cascadia Code", Consolas, monospace;

  font-size: 10px;

  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.trace-json {
  max-height: 220px;

  margin: 0;

  padding: 10px;

  overflow: auto;

  border-radius: 8px;

  background: #0f172a;
  color: #dbeafe;

  font:
    10px/1.55 "Cascadia Code",
    Consolas,
    monospace;
}

/* SUMMARY */

.trace-summary-grid {
  display: grid;

  grid-template-columns: repeat(3, minmax(0, 1fr));

  gap: 8px;
}

.trace-summary-grid > div {
  display: grid;

  gap: 3px;

  padding: 8px 10px;

  border: 1px solid #e2e8f0;
  border-radius: 8px;

  background: #f8fafc;
}

.trace-summary-grid span {
  color: #64748b;

  font-size: 9px;
}

.trace-summary-grid strong {
  color: #172033;

  font-size: 11px;
}

/* STEPS */

.trace-steps {
  display: grid;

  gap: 7px;
}

.trace-step {
  display: grid;

  grid-template-columns:
    25px
    minmax(0, 1fr);

  gap: 9px;

  align-items: start;
}

.trace-step-number {
  display: grid;

  place-items: center;

  width: 23px;
  height: 23px;

  border-radius: 50%;

  background: #e0e7ff;
  color: #3730a3;

  font-size: 9px;
  font-weight: 800;
}

.trace-step-content {
  display: grid;

  gap: 5px;

  padding-top: 3px;

  color: #334155;

  font-size: 10px;

  line-height: 1.5;
}

.trace-step-content p {
  margin: 0;
}

.trace-result {
  color: #475569;

  font-size: 10px;
}

.trace-result strong {
  color: #047857;
}

/* FALLBACK NOTE */

.trace-engine-note {
  margin: 5px 0 0;

  padding: 8px 10px;

  border-left: 3px solid #94a3b8;

  background: #f8fafc;
  color: #64748b;

  font-size: 9px;

  line-height: 1.5;
}

/* WARNINGS */

.trace-warning-section {
  padding: 9px 10px;

  border: 1px solid #fde68a;
  border-radius: 8px;

  background: #fffbeb;
}

.trace-warning-section ul {
  margin: 0;

  padding-left: 18px;

  color: #92400e;

  font-size: 10px;
}

/* RESPONSIVE */

@media (max-width: 720px) {
  .workspace-run-toolbar {
    align-items: stretch;

    flex-direction: column;
  }

  .trace-mode-control {
    width: 100%;
  }

  #traceModeSelect {
    width: 100%;
  }

  .trace-summary-grid {
    grid-template-columns: 1fr;
  }
}
/* =========================================================
   NATIVE MODEL ENGINE BADGE
   ========================================================= */

.model-engine-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;

  gap: 7px;

  margin: 7px 0 8px;
}

.model-engine-badge {
  display: inline-flex;
  align-items: center;

  min-height: 22px;

  padding: 3px 8px;

  border: 1px solid #bfdbfe;
  border-radius: 999px;

  background: #eff6ff;
  color: #1d4ed8;

  font-size: 9px;
  font-weight: 800;

  letter-spacing: 0.03em;
}

.native-engine-status {
  display: inline-flex;
  align-items: center;

  min-height: 22px;

  padding: 3px 8px;

  border-radius: 999px;

  font-size: 9px;
  font-weight: 800;
}

.native-engine-status.checking {
  background: #f1f5f9;
  color: #64748b;
}

.native-engine-status.connected {
  background: #ecfdf5;
  color: #047857;
}

.native-engine-status.offline {
  background: #fef2f2;
  color: #b91c1c;
}

#visual-table {
  min-height: 0;
}

#visual-table .sheet-wrap {
  max-height: 520px;
  overflow: auto;
}
.forecast-chart-mode {
  display: inline-flex;
  gap: 4px;
  margin: 0 0 12px;
  padding: 3px;

  border: 1px solid #795ef7;
  border-radius: 9px;

  background: #121e2f;
}

.forecast-chart-mode button {
  min-height: 30px;
  padding: 5px 11px;

  border: 0;
  border-radius: 7px;

  background: transparent;
  color: #64748b;

  font-size: 11px;
  font-weight: 700;

  cursor: pointer;
}

.forecast-chart-mode button.active {
  background: #795ef7;
  color: #fff;
}
.forecast-mapping {
  display: grid;
  gap: 14px;
}

.forecast-feature-mapping {
  display: grid;
  gap: 7px;

  margin-top: 4px;
  padding: 12px;

  border: 1px solid #dbe3ee;
  border-radius: 9px;

  background: #f8fafc;
}

.forecast-feature-mapping strong {
  font-size: 12px;
  color: #172033;
}

.forecast-feature-mapping small {
  color: #64748b;
  font-size: 10px;
}

.forecast-feature-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));

  gap: 6px;
}

.forecast-feature-option {
  display: flex;
  align-items: center;
  gap: 7px;

  min-height: 34px;

  padding: 7px 9px;

  border: 1px solid #e2e8f0;
  border-radius: 7px;

  background: #fff;

  font-size: 11px;
}

.forecast-feature-option:has(input:checked) {
  border-color: #93c5fd;
  background: #eff6ff;
}

.forecast-feature-option:has(input:disabled) {
  opacity: 0.45;
}
.model-mode-notice {
  margin: 8px 0;
  padding: 9px 11px;

  border: 1px solid #fde68a;
  border-radius: 8px;

  background: #6e5f24cf;
  color: #ffffff;

  font-size: 10px;
  line-height: 1.45;
}
.chart-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chart-heading-title {
  min-width: 0;
}

.chart-heading-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.chart-heading-actions .forecast-chart-mode {
  margin: 0;
}
/* =========================================================
   MODEL RUNTIME / AUDIT STATUS
   ========================================================= */

.model-runtime-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;

  margin: 5px 0 7px;
}

.model-runtime-badges span {
  display: inline-flex;
  align-items: center;

  min-height: 20px;
  padding: 3px 7px;

  border: 1px solid #dbe3ee;
  border-radius: 999px;

  background: #5b086b82;
  color: #475569;

  font-size: 9px;
  font-weight: 700;
  line-height: 1;
}

/* AUDIT */

.model-audit-badge.verified {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.model-audit-badge.experimental {
  border-color: #fde68a;
  background: #fffbeb;
  color: #92400e;
}

.model-audit-badge.custom {
  border-color: #c7d2fe;
  background: #eef2ff;
  color: #4338ca;
}

.model-audit-badge.deprecated {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

/* RUNTIME */

.model-runtime-badge {
  border-color: #bfdbfe !important;
  background: #eff6ff !important;
  color: #1d4ed8 !important;
}

/* ENGINE */

.model-engine-badge {
  background: #f8fafc;
  color: #334155;
}

/* CONNECTION */

.model-connection-badge.connected {
  border-color: #bbf7d0 !important;
  background: #72bb32 !important;
  color: #15803d !important;
}

.model-connection-badge.offline {
  border-color: #fecaca !important;
  background: #bb3232 !important;
  color: #b91c1c !important;
}

.model-connection-badge.checking {
  border-color: #fde68a !important;
  background: #fffbeb !important;
  color: #a16207 !important;
}

.model-connection-badge.local {
  border-color: #e2e8f0 !important;
  background: #4c4848cc !important;
  color: #64748b !important;
}

/* MODEL LIBRARY */

.library-model-runtime {
  margin-bottom: 4px;
}

/* WORKSPACE MODEL */

.workspace-model-runtime {
  margin-top: 2px;
}

/* =========================================================
   RESULT INTERPRETATION — ADAPTIVE KPI CARDS
   ========================================================= */

.result-interpretation {
  margin-top: 16px;
}

.interpret-section-head {
  margin: 0 0 10px;

  color: #64748b;

  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------------------------------------------------------
   GRID
   --------------------------------------------------------- */

.interpret-card-grid {
  display: grid;

  grid-template-columns: repeat(3, minmax(0, 1fr));

  gap: 12px;

  align-items: stretch;
}

/* ---------------------------------------------------------
   CARD
   --------------------------------------------------------- */

.interpret-card {
  position: relative;

  display: flex;
  flex-direction: column;

  width: 100%;
  min-width: 0;

  min-height: 190px;

  padding: 12px 14px;

  border: 1px solid;
  border-radius: 12px;

  overflow: visible;

  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);

  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    border-color 0.16s ease;
}

.interpret-card:hover {
  transform: translateY(-3px);

  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.09);
}

/* ---------------------------------------------------------
   CARD HEADER
   --------------------------------------------------------- */

.interpret-card-head {
  display: flex;
  align-items: center;

  gap: 6px;

  min-height: 24px;

  margin-bottom: 6px;
}

.interpret-icon {
  display: grid;
  place-items: center;

  flex: 0 0 auto;

  width: 24px;
  height: 24px;

  border-radius: 7px;

  transition: transform 0.16s ease;
}

.interpret-card:hover .interpret-icon {
  transform: scale(1.08);
}

.interpret-icon svg {
  width: 13px;
  height: 13px;

  fill: none;

  stroke: #384341;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.interpret-title {
  font-size: 10px;
  font-weight: 800;

  letter-spacing: 0.07em;

  text-transform: uppercase;
}

/* ---------------------------------------------------------
   FINDINGS
   --------------------------------------------------------- */

.interpret-findings {
  display: flex;

  flex: 1;
  flex-direction: column;

  min-height: 0;
}

.interpret-finding {
  display: flex;
  flex: 1;
  flex-direction: column;

  justify-content: center;

  min-width: 0;

  padding: 9px 0;

  overflow: visible;
}

.interpret-finding + .interpret-finding {
  border-top: 1px solid rgba(100, 116, 139, 0.16);
}

/* ---------------------------------------------------------
   FINDING LABEL
   --------------------------------------------------------- */

.interpret-phrase {
  margin-bottom: 3px;

  color: #64748b;

  font-size: 9px;
  font-weight: 650;

  line-height: 1.2;
}

/* ---------------------------------------------------------
   FINDING VALUE
   --------------------------------------------------------- */

.interpret-value {
  color: #172033;

  font-size: 13px;
  font-weight: 760;

  line-height: 1.25;

  letter-spacing: -0.01em;

  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------
   INSIGHT — HIDROVISI BLUE
   --------------------------------------------------------- */

.interpret-card.insight {
  background: #f4f8ff;

  border-color: #bfdbfe;
}

.interpret-card.insight:hover {
  border-color: #60a5fa;
}

.interpret-card.insight .interpret-icon {
  background: #dbeafe;

  color: #2563eb;
}

.interpret-card.insight .interpret-title {
  color: #2563eb;
}

/* ---------------------------------------------------------
   PATTERN — GREEN
   --------------------------------------------------------- */

.interpret-card.pattern {
  background: #f3fcf6;

  border-color: #bbf7d0;
}

.interpret-card.pattern:hover {
  border-color: #4ade80;
}

.interpret-card.pattern .interpret-icon {
  background: #dcfce7;

  color: #16a34a;
}

.interpret-card.pattern .interpret-title {
  color: #15803d;
}

/* ---------------------------------------------------------
   WARNING / ANOMALY — YELLOW
   --------------------------------------------------------- */

.interpret-card.warning {
  background: #fffaf0;

  border-color: #fde68a;
}

.interpret-card.warning:hover {
  border-color: #fbbf24;
}

.interpret-card.warning .interpret-icon {
  background: #fef3c7;

  color: #d97706;
}

.interpret-card.warning .interpret-title {
  color: #b45309;
}

/* ---------------------------------------------------------
   DARK MODE
   --------------------------------------------------------- */

body.dark-mode .canvas .interpret-card.insight {
  background: #17243a !important;

  border-color: #315a91 !important;
}

body.dark-mode .canvas .interpret-card.pattern {
  background: #152a23 !important;

  border-color: #28704d !important;
}

body.dark-mode .canvas .interpret-card.warning {
  background: #2e2817 !important;

  border-color: #8a691c !important;
}

body.dark-mode .canvas .interpret-card .interpret-value {
  color: #f8fafc !important;
}

body.dark-mode .canvas .interpret-card .interpret-phrase {
  color: #b8c6d8 !important;
}

/* ---------------------------------------------------------
   RESPONSIVE
   --------------------------------------------------------- */

@media (max-width: 900px) {
  .interpret-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .interpret-card-grid {
    grid-template-columns: 1fr;
  }

  .interpret-card {
    min-height: 0;
  }
}
