/* NMC Simulation Workbench — Asymptotic dark theme */

:root {
  --brand-blue: var(--blue-400);
  --brand-blue-hover: var(--accent-hover);
  --brand-blue-soft: var(--accent-soft);

  --bg-app: var(--bg);
  --bg-panel: var(--bg-elev-1);
  --bg-subtle: var(--n-200);
  --bg-inset: var(--n-50);

  --text-primary: var(--fg-1);
  --text-secondary: var(--fg-2);
  --text-tertiary: var(--fg-3);
  --text-muted: var(--fg-4);

  --border: var(--border-default);
  --border-strong: var(--border-strong);

  --shadow-sm: var(--shadow-1);
  --shadow-md: var(--shadow-2);

  --radius-sm: var(--r-md);
  --radius-md: var(--r-lg);
  --radius-lg: var(--r-xl);

  --series-sim: var(--chart-1);
  --series-ref: var(--chart-5);
  --series-current: var(--chart-4);
  --series-soc: var(--chart-7);

  --surface-input: var(--n-300);
  --surface-active: var(--bg-elev-2);
  --overlay-scrim: rgba(0, 0, 0, 0.62);
  --overlay-panel: rgba(28, 28, 30, 0.92);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
}

button, input, select {
  font: inherit;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 28px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.demo-banner {
  position: relative;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--blue-600);
  border: 1px solid rgba(17, 85, 204, 0.35);
  flex-shrink: 0;
  cursor: help;
}

.demo-banner-tip {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 20;
  width: max-content;
  max-width: min(320px, calc(100vw - 32px));
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--overlay-panel);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md);
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 1.45;
  letter-spacing: normal;
  text-transform: none;
  color: var(--text-secondary);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition:
    opacity var(--dur-1) var(--ease-standard),
    transform var(--dur-1) var(--ease-standard),
    visibility var(--dur-1) var(--ease-standard);
  pointer-events: none;
}

.demo-banner:hover .demo-banner-tip,
.demo-banner:focus-visible .demo-banner-tip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.demo-banner.hidden {
  display: none;
}

/* Showcase mode — simplified marketing explorer */
.showcase-mode [data-showcase-hidden] {
  display: none !important;
}

.showcase-mode .showcase-experiment-hint {
  display: block;
}

.showcase-experiment-hint {
  display: none;
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px 12px;
  margin-bottom: 12px;
  align-items: end;
}

.setup-grid .field {
  margin-bottom: 0;
}

.setup-thermal {
  margin: 0;
  align-self: end;
  padding-bottom: 8px;
  white-space: nowrap;
}

.showcase-mode .panel-section--setup .setup-head {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.showcase-mode .panel-section--setup .experiment-toolbar {
  width: 100%;
}

.showcase-mode .setup-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.showcase-mode .setup-thermal {
  grid-column: 1 / -1;
  padding-bottom: 0;
}

.showcase-mode .topbar {
  gap: 16px;
}

.showcase-mode .brand-home {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.showcase-mode .brand-home img {
  display: block;
  border-radius: 8px;
}

.showcase-mode .brand-mark {
  display: none;
}

.showcase-mode .preset-select {
  width: 100%;
}

.showcase-mode .layout {
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
}

.showcase-mode .add-curve-to-graph,
.showcase-mode .remove-graph {
  display: none;
}

.brand-home {
  text-decoration: none;
}

.brand-home:hover {
  opacity: 0.88;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
  min-width: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-blue), var(--brand-blue-light));
  color: var(--fg-on-blue);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 16px;
}

.brand-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}

.brand-subtitle {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}

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

.status-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.status-pill.running {
  background: var(--accent-soft);
  color: var(--blue-600);
  border-color: rgba(17, 85, 204, 0.35);
}

.status-pill.error {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(229, 72, 77, 0.35);
}

/* Buttons */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

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

.btn-primary {
  background: var(--brand-blue);
  color: var(--fg-on-blue);
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-blue-hover);
}

.btn-secondary {
  background: var(--bg-subtle);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-active);
}

.btn-ghost {
  background: transparent;
  color: var(--blue-600);
  border-color: transparent;
  padding: 6px 10px;
}

.btn-ghost:hover {
  background: var(--accent-soft);
  color: var(--blue-700);
}

.btn-sm {
  font-size: 12px;
}

/* Layout — single full-width column */
.layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: min(1280px, 100%);
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 28px 28px;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  min-width: 0;
  width: 100%;
}

.setup-panel {
  padding: 0;
}

.setup-panel .panel-section {
  margin: 0;
  border-bottom: none;
}

.panel-section--setup .setup-head {
  margin-bottom: 10px;
}

.panel-section--setup .experiment-source-tabs {
  margin-bottom: 10px;
}

.panel-section--setup .showcase-experiment-hint {
  margin-bottom: 10px;
}

.panel-section--setup .section-head-inline {
  margin-bottom: 8px;
}

.results-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.panel-section {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-section:last-child {
  border-bottom: none;
}

.panel-section.compact {
  padding-top: 12px;
  padding-bottom: 12px;
}

.panel-heading {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

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

.section-head .panel-heading {
  margin: 0;
}

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

.preset-select {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  background: var(--surface-input);
  color: var(--text-secondary);
  font-size: 12px;
  max-width: 180px;
}

.experiment-source-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}

.source-tab {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.source-tab:hover {
  color: var(--text-primary);
}

.source-tab.active {
  background: var(--surface-active);
  color: var(--blue-600);
  box-shadow: var(--shadow-sm);
}

.data-upload-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.file-upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-strong);
  background: var(--bg-inset);
  color: var(--blue-600);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.file-upload-btn:hover {
  background: var(--accent-soft);
  border-color: var(--brand-blue);
}

.sample-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

.sample-links a {
  color: var(--blue-600);
  text-decoration: none;
}

.sample-links a:hover {
  text-decoration: underline;
  color: var(--blue-700);
}

.sample-links-label {
  color: var(--text-tertiary);
}

.data-empty {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(229, 72, 77, 0.35);
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  font-size: 12px;
  color: var(--danger);
  line-height: 1.5;
}

.data-empty strong {
  display: block;
  margin-bottom: 2px;
  font-size: 13px;
}

.data-empty.hidden {
  display: none;
}

.data-summary {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.data-summary strong {
  color: var(--text-primary);
}

.field-error {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--danger);
}

.comparison-panel {
  margin: 0 0 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--bg-panel) 0%, var(--bg-inset) 100%);
}

.comparison-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.metric-card {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}

.metric-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 500;
  color: var(--text-primary);
}

.metric-value.good {
  color: var(--success);
}

.metric-value.warn {
  color: var(--warning);
}

.metric-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.metric-card-wide {
  grid-column: 1 / -1;
}

.comparison-panel-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.experiment-mode-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}

.mode-tab {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.mode-tab:hover {
  color: var(--text-primary);
}

.mode-tab.active {
  background: var(--surface-active);
  color: var(--blue-600);
  box-shadow: var(--shadow-sm);
}

.experiment-mode-panel.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.section-head-inline {
  margin-bottom: 10px;
}

.hint-inline {
  margin: 0;
  flex: 1;
}

.instructions-editor {
  width: 100%;
  min-height: 160px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--surface-input);
  resize: vertical;
}

.instructions-editor:focus {
  outline: none;
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(17, 85, 204, 0.22);
}

.instructions-editor::placeholder {
  color: var(--text-muted);
}

#instructions-error {
  min-height: 1.2em;
  color: var(--danger);
}

#instructions-error:empty {
  display: none;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.field input,
.field select {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--surface-input);
  color: var(--text-primary);
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(17, 85, 204, 0.22);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.hint {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--text-tertiary);
}

details summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  user-select: none;
}

details[open] summary {
  margin-bottom: 12px;
}

.settings-group-label {
  margin: 14px 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.settings-group-label:first-of-type {
  margin-top: 4px;
}

.checkbox-hint {
  margin: 4px 0 0 24px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 8px;
}

/* Step table */
.step-table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.step-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.step-table th,
.step-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.step-table th {
  background: var(--bg-inset);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
}

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

.step-table select,
.step-table input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  background: var(--surface-input);
  color: var(--text-primary);
}

.step-table .remove-step {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 16px;
  line-height: 1;
}

.step-table .remove-step:hover {
  color: var(--danger);
}

.field-hint {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.4;
}

.field select option.option-coming-soon {
  color: var(--text-tertiary);
  font-style: italic;
}

.field select option:disabled {
  color: var(--fg-disabled);
}

.preview-hint {
  margin-top: 0;
  margin-bottom: 10px;
}

.preview-chart-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
  padding: 8px;
  min-height: 200px;
  position: relative;
}

.preview-chart-wrap.is-loading {
  pointer-events: none;
}

.preview-chart-wrap.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--overlay-panel);
  border-radius: var(--radius-sm);
}

.preview-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 8px;
  z-index: 2;
  color: var(--text-tertiary);
  font-size: 12px;
}

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

/* Results panel */
.results-panel {
  padding: 0;
  min-height: 480px;
}

.results-builder.hidden {
  display: none;
}

.graphs-area {
  position: relative;
  min-height: 320px;
}

.graphs-grid {
  padding: 16px 20px 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr));
  gap: 16px;
}

.showcase-mode .graphs-grid {
  grid-template-columns: 1fr;
  max-width: 640px;
  margin-inline: auto;
}

.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.results-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.results-meta {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-tertiary);
}

.run-id-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.run-id-pill.hidden {
  display: none;
}

.graph-toolbar {
  padding: 16px 20px;
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  border-bottom: 1px solid var(--border);
}

.graph-toolbar .field {
  margin-bottom: 0;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-bottom: 2px;
  position: relative;
  z-index: 12;
}

.pending-curves {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-inset);
}

.pending-curves.hidden {
  display: none;
}

.graph-hint {
  margin: 0;
  padding: 0 20px 12px;
  font-size: 12px;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border);
}

.graph-hint strong {
  font-weight: 600;
  color: var(--text-secondary);
}

.pending-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-right: 4px;
}

.curve-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 10px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
  box-shadow: inset 3px 0 0 var(--chip-color, var(--brand-blue));
}

.curve-chip-remove {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}

.curve-chip-remove:hover {
  color: var(--danger);
}

.variable-picker {
  position: relative;
  display: grid;
  gap: 6px;
}

.variable-search {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--surface-input);
  color: var(--text-primary);
  width: 100%;
}

.variable-search:disabled {
  background: var(--bg-inset);
  color: var(--text-muted);
}

.variable-search:focus {
  outline: none;
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(17, 85, 204, 0.22);
}

.variable-options {
  position: absolute;
  z-index: 9;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
  box-shadow: var(--shadow-md);
  padding: 6px;
  display: none;
}

.variable-picker.open .variable-options {
  display: grid;
}

.variable-option {
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  text-align: left;
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
}

.variable-option:hover,
.variable-option.active {
  background: var(--accent-soft);
  color: var(--blue-700);
}

.variable-empty {
  color: var(--text-muted);
  padding: 8px 10px;
  font-size: 13px;
}

.graphs-area .results-loading {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--overlay-panel);
  backdrop-filter: blur(4px);
  margin: 0;
  padding: 24px;
}

.results-loading.hidden {
  display: none;
}

.loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--brand-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.loading-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.loading-copy strong {
  font-size: 14px;
  color: var(--text-primary);
}

.loading-copy span {
  font-size: 12px;
  color: var(--text-tertiary);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.graph-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-inset);
  overflow: hidden;
}

.graph-card-empty {
  grid-column: 1 / -1;
}

.graph-card-empty .graph-card-meta {
  text-transform: none;
  letter-spacing: normal;
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 1.45;
}

.graph-card-head {
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
}

.graph-card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.graph-card-meta {
  margin-top: 4px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

.remove-graph,
.zoom-graph,
.add-curve-to-graph,
.modal-close {
  border: 1px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border-radius: 999px;
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  cursor: pointer;
}

.remove-graph:hover,
.zoom-graph:hover,
.add-curve-to-graph:hover,
.modal-close:hover {
  color: var(--text-primary);
  border-color: var(--brand-blue);
  background: var(--accent-soft);
}

.status-line {
  padding: 12px 20px 18px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-top: 1px solid var(--border);
}

.status-line .ready {
  color: var(--success);
}

.chart-empty {
  min-height: 220px;
  display: grid;
  place-items: center;
  gap: 6px;
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 13px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
  margin: 12px;
}

.graphs-grid > .chart-empty {
  min-height: 280px;
  margin: 0;
  background: var(--bg-inset);
}

.chart-empty strong {
  display: block;
  color: var(--text-secondary);
  font-weight: 600;
}

.chart-empty span {
  font-size: 12px;
  color: var(--text-tertiary);
  max-width: 420px;
}

.preview-chart-wrap .chart-empty {
  min-height: 160px;
  margin: 0;
  border: none;
}

/* SVG charts */
svg.chart {
  width: 100%;
  height: auto;
  aspect-ratio: 776 / 362;
  max-height: 380px;
  display: block;
  background: var(--bg-inset);
}

svg.chart.chart-preview {
  height: 200px;
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
  background: var(--bg-inset);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.chart .grid,
.chart-svg .grid {
  stroke: var(--chart-grid);
  stroke-width: 1;
}

.chart .axis,
.chart-svg .axis {
  stroke: var(--border-strong);
  stroke-width: 1.2;
}

.chart .axis-label,
.chart-svg .axis-label {
  fill: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 10px;
}

.chart .axis-title,
.chart-svg .axis-title {
  fill: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
}

.chart .series-main,
.chart-svg .series {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart .series-main.series-current {
  stroke: var(--series-current);
}

.legend-label {
  fill: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
}

.chart-svg .series-sim { stroke: var(--series-sim); }
.chart-svg .series-current { stroke: var(--series-current); }
.chart-svg .series-soc { stroke: var(--series-soc); }

.hover-line {
  stroke: rgba(79, 134, 232, 0.45);
  stroke-width: 1;
  stroke-dasharray: 4 4;
  opacity: 0;
}

.hover-dot {
  fill: var(--brand-blue);
  stroke: var(--bg-panel);
  stroke-width: 2;
  opacity: 0;
}

.tooltip {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  min-width: 170px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
  box-shadow: var(--shadow-md);
  padding: 10px 12px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
  transform: translate(-50%, calc(-100% - 12px));
  z-index: 3;
}

.tooltip strong {
  display: block;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: var(--overlay-scrim);
  backdrop-filter: blur(4px);
}

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

.modal-panel {
  width: min(1120px, 100%);
  max-height: min(820px, 92vh);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  box-shadow: var(--shadow-3);
  overflow: hidden;
}

.modal-head {
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.modal-meta {
  margin-top: 4px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.modal-chart-wrap {
  position: relative;
  padding: 18px;
}

.modal-chart-wrap svg.chart {
  max-height: min(560px, 62vh);
  aspect-ratio: 1000 / 534;
}

.step-na {
  color: var(--text-muted);
  text-align: center;
}

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

  .setup-thermal {
    grid-column: 1 / -1;
    padding-bottom: 0;
  }
}

@media (max-width: 720px) {
  .layout,
  .topbar {
    padding-left: 16px;
    padding-right: 16px;
    flex-wrap: wrap;
    gap: 12px;
  }

  .topbar-brand {
    flex: 1;
  }

  .topbar-right {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    row-gap: 8px;
  }

  .brand-subtitle {
    white-space: normal;
    text-align: left;
  }

  .results-head {
    flex-direction: column;
    align-items: stretch;
  }

  .results-head-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .graph-toolbar {
    grid-template-columns: 1fr;
  }

  .toolbar-actions {
    justify-content: flex-end;
  }

  .modal-overlay {
    padding: 12px;
  }
}
