:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --panel: #ffffff;
  --panel-soft: #eef2f1;
  --ink: #17211f;
  --muted: #64716e;
  --line: #d9e0de;
  --accent: #0f766e;
  --accent-soft: #dff4ef;
  --bad: #b42318;
  --shadow: 0 16px 42px rgba(19, 33, 30, 0.08);
}

/* Base */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
}

/* App shell */

.shell {
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(260px, 1fr);
  align-items: center;
  gap: 20px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
}

.brand h1,
.section-heading h2,
.report-head h2 {
  margin: 4px 0 0;
  font-size: 26px;
  line-height: 1.05;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.view-tabs,
.segmented {
  display: grid;
  grid-auto-flow: column;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
  background: var(--panel-soft);
}

.view-tabs button,
.segmented button {
  position: relative;
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.view-tabs button {
  min-width: 94px;
  padding: 0 18px;
}

.view-tabs button.selected,
.segmented button.selected {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
}

.health {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.health span,
.ttl-note,
.download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 8px;
  white-space: nowrap;
}

.health span,
.ttl-note {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
}

.health .ok {
  color: var(--accent);
}

.health .bad,
.run-state.failed h3 {
  color: var(--bad);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.auth-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-panel h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0;
}

.auth-copy {
  margin: 0;
  color: var(--muted);
}

.auth-error {
  margin: 0;
  color: var(--bad);
  font-size: 13px;
}

.auth-text-link {
  justify-self: start;
  margin: -4px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #8B959F;
  font-size: 12px;
  font-weight: 400;
  text-decoration: underline;
  cursor: pointer;
}

.auth-text-link:hover {
  color: #1FADA8;
}

.hidden {
  display: none !important;
}

/* Workspace */

.workspace-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  padding: 28px;
}

.workbench,
.history-panel,
.empty-state,
.run-state,
.report-panel,
.table-panel,
.docs-head,
.endpoint-row,
figure {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.workbench,
.history-panel,
.empty-state,
.run-state,
.report-panel,
.table-panel,
.docs-head,
.endpoint-row {
  padding: 22px;
}

.admin-form,
.admin-users {
  display: grid;
  gap: 10px;
}

.admin-form {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: end;
}

.admin-user-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) 110px 110px repeat(3, minmax(120px, 1fr)) 80px;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfd;
}

.admin-user-header {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) 110px 110px repeat(3, minmax(120px, 1fr)) 80px;
  gap: 8px;
  padding: 0 10px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.admin-key-row {
  display: grid;
  grid-template-columns: 130px minmax(180px, 1fr) 130px minmax(160px, 1fr) 80px 90px;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfd;
}

/* Forms and controls */

.inline-check {
  display: flex;
  grid-auto-flow: column;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.inline-check input {
  width: auto;
}

.annual-return-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(140px, 0.95fr);
  gap: 10px;
  align-items: end;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfd;
}

.annual-return-row.disabled {
  opacity: 0.58;
}

.annual-principal input:disabled {
  color: var(--muted);
}

.section-heading,
.report-head,
.run-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.section-heading.compact h2 {
  font-size: 22px;
}

.form {
  display: grid;
  gap: 22px;
  padding-top: 24px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
select {
  width: 100%;
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfd;
  color: var(--ink);
}

input:focus,
select:focus {
  outline: 2px solid rgba(15, 118, 110, 0.18);
  border-color: rgba(15, 118, 110, 0.5);
}

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

.wide-field {
  grid-column: 1 / -1;
}

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

.section-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.label-with-info {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.info-dot {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: var(--accent);
  cursor: help;
  font-size: 11px;
  font-weight: 850;
  line-height: 1;
}

.info-dot:focus-visible {
  outline: 2px solid rgba(15, 118, 110, 0.2);
  outline-offset: 2px;
}

.has-tooltip {
  position: relative;
}

.has-tooltip::before,
.has-tooltip::after {
  position: absolute;
  left: 50%;
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
}

.has-tooltip::before {
  content: "";
  bottom: calc(100% + 5px);
  width: 10px;
  height: 10px;
  border-right: 1px solid rgba(17, 24, 39, 0.14);
  border-bottom: 1px solid rgba(17, 24, 39, 0.14);
  background: #17211f;
  transform: translate(-50%, 5px) rotate(45deg);
}

.has-tooltip::after {
  content: attr(data-tooltip);
  bottom: calc(100% + 10px);
  width: max-content;
  max-width: min(310px, calc(100vw - 44px));
  padding: 10px 12px;
  border: 1px solid rgba(17, 24, 39, 0.14);
  border-radius: 8px;
  background: #17211f;
  box-shadow: 0 14px 34px rgba(19, 33, 30, 0.18);
  color: #ffffff;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.4;
  text-align: left;
  white-space: normal;
  transform: translate(-50%, 7px);
}

.has-tooltip:hover::before,
.has-tooltip:hover::after,
.has-tooltip:focus-visible::before,
.has-tooltip:focus-visible::after {
  opacity: 1;
}

.has-tooltip:hover::before,
.has-tooltip:focus-visible::before {
  transform: translate(-50%, 0) rotate(45deg);
}

.has-tooltip:hover::after,
.has-tooltip:focus-visible::after {
  transform: translate(-50%, 0);
}

.info-dot.has-tooltip::before {
  left: 9px;
}

.info-dot.has-tooltip::after {
  left: 0;
  transform: translate(0, 7px);
}

.info-dot.has-tooltip:hover::after,
.info-dot.has-tooltip:focus-visible::after {
  transform: translate(0, 0);
}

.segmented[data-name="mode"] .has-tooltip:nth-child(odd)::before {
  left: 22px;
}

.segmented[data-name="mode"] .has-tooltip:nth-child(odd)::after {
  left: 0;
  transform: translate(0, 7px);
}

.segmented[data-name="mode"] .has-tooltip:nth-child(odd):hover::after,
.segmented[data-name="mode"] .has-tooltip:nth-child(odd):focus-visible::after {
  transform: translate(0, 0);
}

.segmented[data-name="mode"] .has-tooltip:nth-child(even)::before {
  right: 22px;
  left: auto;
  transform: translate(50%, 5px) rotate(45deg);
}

.segmented[data-name="mode"] .has-tooltip:nth-child(even)::after {
  right: 0;
  left: auto;
  transform: translate(0, 7px);
}

.segmented[data-name="mode"] .has-tooltip:nth-child(even):hover::after,
.segmented[data-name="mode"] .has-tooltip:nth-child(even):focus-visible::after {
  transform: translate(0, 0);
}

.segmented[data-name="mode"] .has-tooltip:nth-child(even):hover::before,
.segmented[data-name="mode"] .has-tooltip:nth-child(even):focus-visible::before {
  transform: translate(50%, 0) rotate(45deg);
}

.segmented {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.segmented[data-name="mode"] {
  grid-auto-flow: row;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.legs {
  display: grid;
  gap: 9px;
}

.leg-row {
  display: grid;
  grid-template-columns: minmax(84px, 0.7fr) minmax(84px, 0.7fr) minmax(0, 0.8fr) minmax(0, 0.7fr) minmax(0, 0.7fr) 36px 36px;
  align-items: end;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfd;
}

.indicator-list {
  display: grid;
  gap: 9px;
}

.indicator-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr) minmax(0, 0.9fr) 36px;
  align-items: end;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfd;
}

.signal-panel {
  display: grid;
  gap: 12px;
}

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

.icon-button,
.ghost-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.icon-button {
  width: 36px;
  height: 36px;
}

.ghost-button {
  min-height: 36px;
  padding: 0 12px;
}

.ghost-button.full {
  width: 100%;
  margin-top: 14px;
}

.chips {
  display: grid;
  gap: 12px;
}

.chip-group {
  display: grid;
  gap: 8px;
}

.chip-group-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
  text-transform: uppercase;
}

.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.weekday-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfd;
  cursor: pointer;
}

.chip input {
  width: auto;
}

.chip.active {
  border-color: rgba(15, 118, 110, 0.42);
  background: var(--accent-soft);
  color: var(--ink);
}

.chip.disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.chip.disabled input {
  cursor: not-allowed;
}

.run-button,
.download {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 820;
  cursor: pointer;
  text-decoration: none;
  transition: transform 140ms ease, box-shadow 140ms ease;
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.2);
}

.download {
  background: var(--ink);
  box-shadow: none;
}

.icon-button:hover,
.ghost-button:hover,
.download:hover,
.run-button:hover,
.history-select:hover,
.history-delete:hover {
  transform: translateY(-1px);
}

.history-panel {
  align-self: start;
  position: sticky;
  top: 96px;
}

.muted,
.history-empty,
.muted-panel,
.empty-state p,
.report-head p,
.run-state p {
  color: var(--muted);
}

.history-list {
  display: grid;
  gap: 9px;
  margin-top: 16px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfd;
  color: inherit;
  transition: transform 140ms ease, border-color 140ms ease;
}

.history-select {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1 1 auto;
  gap: 12px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.history-delete {
  display: inline-grid;
  place-items: center;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, color 140ms ease;
}

.history-delete:hover {
  border-color: rgba(190, 18, 60, 0.35);
  color: var(--bad);
}

.history-item.selected {
  border-color: rgba(15, 118, 110, 0.5);
  background: var(--accent-soft);
}

.history-item strong,
.history-item small {
  display: block;
}

.history-item small {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.35;
}

.task-id {
  display: block;
  margin-top: 4px;
  color: #8b9895;
  font-size: 11px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.history-item em {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 780;
  text-transform: uppercase;
}

.history-item em.completed {
  color: var(--accent);
}

.history-item em.failed {
  color: var(--bad);
}

.run-state {
  margin-top: 18px;
}

.run-state h3,
.empty-state h2 {
  margin: 8px 0;
  overflow-wrap: anywhere;
  font-size: 24px;
  line-height: 1.14;
}

.run-head strong {
  font-size: 30px;
}

.progress {
  height: 10px;
  margin-top: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--panel-soft);
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 220ms ease;
}

/* Reports and docs */

.report-view,
.docs-view {
  min-width: 0;
  padding: 28px;
}

.report-head {
  align-items: flex-end;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.artifact-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.run-context {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

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

.run-config div,
.run-legs {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.run-config span,
.run-legs-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  text-transform: uppercase;
}

.run-config strong,
.run-legs-grid strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.run-legs-title {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  text-transform: uppercase;
}

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

.kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-top: 22px;
}

.kpi {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

.kpi strong {
  display: block;
  margin-top: 10px;
  overflow-wrap: anywhere;
  font-size: 22px;
}

figure {
  margin: 0;
  padding: 14px;
}

figure.wide {
  grid-column: 1 / -1;
}

figcaption {
  margin-bottom: 10px;
  color: var(--muted);
  font-weight: 780;
}

figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
}

.interactive-chart-root {
  position: relative;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.chart-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  min-height: 42px;
  padding-right: 146px;
  margin-bottom: 10px;
}

.chart-toolbar h3 {
  margin: 2px 0 0;
  font-size: 18px;
}

.chart-axis-mode {
  grid-template-columns: repeat(2, minmax(58px, 1fr));
}

.chart-menu {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 30;
}

.chart-menu > summary {
  list-style: none;
}

.chart-menu > summary::-webkit-details-marker {
  display: none;
}

.chart-menu-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 780;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.chart-menu-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
}

.chart-menu[open] .chart-menu-button {
  border-color: rgba(15, 118, 110, 0.38);
  background: var(--accent-soft);
}

.chart-menu.stable .chart-menu-popover {
  animation: none;
}

.chart-menu-icon {
  position: relative;
  flex: 0 0 auto;
  width: 15px;
  height: 12px;
}

.chart-menu-icon,
.chart-menu-icon::before,
.chart-menu-icon::after,
.chart-menu-icon span {
  display: block;
}

.chart-menu-icon::before,
.chart-menu-icon::after,
.chart-menu-icon span {
  position: absolute;
  left: 0;
  width: 15px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  content: "";
}

.chart-menu-icon::before {
  top: 0;
}

.chart-menu-icon span {
  top: 5px;
}

.chart-menu-icon::after {
  bottom: 0;
}

.chart-menu-count {
  padding-left: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.chart-menu-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  width: min(560px, calc(100vw - 32px));
  max-height: min(72vh, 680px);
  gap: 12px;
  padding: 13px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 22px 50px rgba(15, 23, 42, 0.18);
  transform-origin: top right;
  animation: chart-menu-in 130ms ease-out;
}

.chart-menu-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.chart-menu-head div {
  display: grid;
  gap: 3px;
}

.chart-menu-head strong,
.chart-menu-section-title span:first-child {
  color: var(--ink);
  font-size: 13px;
  font-weight: 820;
}

.chart-menu-head span,
.chart-menu-section-title span:last-child,
.chart-control-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.chart-control-note {
  margin: 0;
  font-weight: 650;
}

.chart-menu-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chart-menu-actions .chart-axis-mode {
  min-width: 150px;
}

.chart-menu-actions .ghost-button {
  flex: 0 0 auto;
}

.chart-menu-section {
  display: grid;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.chart-menu-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chart-toggle-grid,
.series-toggle-list {
  display: grid;
  gap: 8px;
}

.chart-toggle-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.series-toggle-group {
  display: grid;
  gap: 7px;
}

.series-toggle-group > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
}

.series-toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chart-toggle,
.series-toggle {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 7px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 720;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.chart-toggle {
  width: 100%;
}

.chart-toggle input,
.series-toggle input {
  flex: 0 0 auto;
  width: auto;
}

.series-toggle i {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.chart-toggle.active,
.series-toggle.active {
  border-color: rgba(15, 118, 110, 0.42);
  background: var(--accent-soft);
  color: var(--ink);
}

@keyframes chart-menu-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.chart-canvas-wrap {
  position: relative;
  overflow-x: auto;
}

.frequency-chart-section {
  margin-top: 12px;
}

.native-chart {
  display: block;
  min-width: 760px;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.native-chart text {
  user-select: none !important;
  -webkit-user-select: none !important;
}

.chart-title {
  fill: #1f2937;
  font-size: 13px;
  font-weight: 780;
}

.chart-y-label,
.chart-axis-text,
.chart-legend {
  fill: #64748b;
  font-size: 10px;
  font-weight: 650;
}

.chart-grid {
  stroke: #cbd5e1;
  stroke-width: 1;
  stroke-dasharray: 2 4;
  opacity: 0.75;
}

.chart-zero {
  stroke: #94a3b8;
  stroke-width: 1;
  stroke-dasharray: 5 4;
  opacity: 0.8;
}

.chart-crosshair {
  stroke: #0f766e;
  stroke-width: 1;
  stroke-dasharray: 3 3;
  pointer-events: none;
}

.chart-brush-track {
  fill: #e2e8f0;
}

.chart-brush-window {
  fill: rgba(15, 118, 110, 0.22);
  stroke: rgba(15, 118, 110, 0.55);
  cursor: grab;
}

.chart-brush-handle {
  cursor: ew-resize;
}

.chart-brush-handle-hit {
  fill: transparent;
  pointer-events: all;
}

.chart-brush-handle-face {
  fill: #fff;
  stroke: #94a3b8;
  stroke-width: 1.5;
  filter: drop-shadow(0 2px 5px rgba(15, 23, 42, 0.2));
}

.chart-brush-grip {
  stroke: #64748b;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.chart-tooltip {
  position: absolute;
  z-index: 5;
  min-width: 230px;
  max-width: 300px;
  padding: 10px 12px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.18);
  color: var(--ink);
  pointer-events: none;
}

.chart-tooltip p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
}

.chart-tooltip div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-size: 12px;
  line-height: 1.5;
}

.chart-tooltip strong {
  font-variant-numeric: tabular-nums;
}

.chart-loading,
.chart-empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.report-panel,
.table-panel {
  margin-top: 22px;
}

pre {
  max-height: 440px;
  margin: 0;
  overflow: auto;
  color: #263330;
  white-space: pre-wrap;
  line-height: 1.55;
}

.table-scroll {
  overflow: auto;
}

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

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.empty-state {
  min-height: 320px;
  display: grid;
  place-items: center;
  text-align: center;
}

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

.docs-head h2 {
  margin: 4px 0 8px;
  font-size: 28px;
  line-height: 1.08;
}

.docs-head p {
  margin: 0;
  color: var(--muted);
}

.docs-status {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.docs-status div {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.docs-status span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

.docs-status strong {
  display: block;
  margin-top: 8px;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.endpoint-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.endpoint-row {
  display: grid;
  gap: 12px;
}

.endpoint-row p {
  margin: 0;
  color: var(--muted);
}

.endpoint-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.endpoint-title span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  min-height: 30px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 840;
}

.endpoint-title h3 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 20px;
}

.columns-line {
  padding: 10px 12px;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfd;
  color: #263330;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
}

.endpoint-row pre {
  max-height: none;
  padding: 12px;
  border-radius: 8px;
  background: #17211f;
  color: #edf6f3;
  font-size: 12px;
}

/* Responsive layout */

@media (max-width: 1120px) {
  .app-header,
  .workspace-view {
    grid-template-columns: 1fr;
  }

  .view-tabs {
    justify-self: start;
  }

  .health {
    justify-content: flex-start;
  }

  .history-panel {
    position: static;
  }

  .run-config,
  .run-legs-grid,
  .kpis,
  .docs-status {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .admin-form,
  .admin-user-header,
  .admin-user-row,
  .admin-key-row {
    grid-template-columns: 1fr;
  }

  .admin-user-header {
    display: none;
  }
}

@media (max-width: 760px) {
  .app-header,
  .workspace-view,
  .report-view,
  .docs-view {
    padding: 18px;
  }

  .field-grid,
  .control-grid,
  .annual-return-row,
  .leg-row,
  .indicator-row,
  .signal-rule-grid,
  .run-config,
  .run-legs-grid,
  .kpis,
  .docs-status {
    grid-template-columns: 1fr;
  }

  .view-tabs {
    grid-auto-flow: row;
    width: 100%;
  }

  .view-tabs button {
    width: 100%;
  }

  figure.wide {
    grid-column: auto;
  }

  .leg-row {
    align-items: stretch;
  }

  .section-heading,
  .report-head,
  .run-head,
  .docs-head,
  .endpoint-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .artifact-strip {
    justify-content: flex-start;
  }

  .chart-toolbar {
    align-items: flex-start;
    padding-right: 126px;
  }

  .chart-menu {
    top: 14px;
    right: 14px;
    left: auto;
    transform: none;
  }

  .chart-axis-mode,
  .chart-menu-actions .ghost-button {
    width: 100%;
  }

  .chart-menu-popover {
    right: 0;
    max-height: 68vh;
  }
}
