:root {
  color-scheme: dark;
  --bg: #08101f;
  --bg-alt: #0d1629;
  --panel: #111b31;
  --panel-2: #182445;
  --panel-3: #0b1428;
  --text: #edf2ff;
  --muted: #9aa8cd;
  --accent: #7fd1ff;
  --accent-2: #53d18a;
  --accent-3: #f3c46a;
  --border: #233357;
  --border-strong: #31456f;
  --warn: #ffb366;
  --error: #ff8d8d;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", ui-sans-serif, system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(127, 209, 255, 0.09), transparent 24%),
    linear-gradient(180deg, #0a1221 0%, #07111d 48%, #060c17 100%);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(180px, auto) minmax(0, 1fr);
  grid-template-areas:
    "brand context"
    "nav context";
  align-items: start;
  gap: 0.75rem;
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid rgba(35, 51, 87, 0.9);
  background: rgba(6, 11, 21, 0.86);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-left {
  display: contents;
}

.topbar-left > div:first-child {
  grid-area: brand;
  min-width: 0;
}

.brand {
  font-size: 0.94rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.subtitle {
  color: var(--muted);
  font-size: 0.76rem;
  margin-top: 0.12rem;
}

.nav {
  grid-area: nav;
  display: flex;
  gap: 0.38rem;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
  align-self: end;
}

.nav a {
  color: #dbe7ff;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(53, 88, 152, 0.72);
  background: linear-gradient(180deg, rgba(41, 74, 135, 0.5), rgba(27, 47, 89, 0.5));
  font-size: 0.84rem;
  font-weight: 650;
}

.nav a:hover,
.nav a:focus-visible {
  color: var(--text);
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(48, 86, 155, 0.78), rgba(31, 56, 105, 0.78));
}

.topbar-context {
  grid-area: context;
  display: grid;
  grid-template-rows: auto auto;
  gap: 0.32rem;
  justify-items: end;
  min-width: 0;
  max-width: min(100%, 920px);
}

.topbar-controls {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 0.4rem;
  flex-wrap: wrap;
  min-width: 0;
}

.topbar-field {
  display: grid;
  min-width: 92px;
  max-width: 360px;
  gap: 0.2rem;
  font-size: 0.7rem;
  color: var(--muted);
  min-width: 0;
}

.topbar-field select,
.topbar-field input {
  min-width: 0;
  max-width: 100%;
  padding: 0.32rem 0.48rem;
  font-size: 0.8rem;
  min-height: 2.2rem;
}

.topbar-field select {
  text-overflow: ellipsis;
}

#globalUserSelect {
  width: min(280px, 28vw);
}

#globalStrategySelect {
  width: min(430px, 36vw);
}

#globalAsOfInput {
  width: 150px;
}

.topbar-meta {
  display: flex;
  gap: 0.34rem;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
}

.topbar-meta .status-pill {
  max-width: min(340px, 30vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#authUserStatus {
  max-width: min(360px, 32vw);
}

.topbar-meta .auth-logout-link {
  max-width: none;
  white-space: nowrap;
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0.7rem 0.9rem 1.25rem;
  display: grid;
  gap: 0.75rem;
  min-width: 0;
  width: 100%;
}

.hero,
.panel {
  background: linear-gradient(180deg, rgba(17, 27, 49, 0.96), rgba(10, 18, 35, 0.96));
  border: 1px solid rgba(49, 69, 111, 0.9);
  border-radius: 14px;
  padding: 0.82rem;
  box-shadow: var(--shadow);
  min-width: 0;
  overflow: hidden;
}

.hero h1,
.panel h1 {
  margin-top: 0;
  margin-bottom: 0.25rem;
  font-size: clamp(1.3rem, 1.8vw, 1.75rem);
}

.hero p,
.panel > p,
.page-note {
  color: var(--muted);
  margin-top: 0;
  margin-bottom: 0;
  line-height: 1.45;
}

.page-note + .page-note {
  margin-top: 0.3rem;
}

.shell-note {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.6rem;
  padding: 0.42rem 0.55rem;
  border-radius: 10px;
  border: 1px solid rgba(49, 69, 111, 0.8);
  background: rgba(8, 13, 28, 0.74);
  color: var(--muted);
  font-size: 0.8rem;
}

.shell-note strong {
  color: #d8e2ff;
  font-size: 0.76rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.control-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.7rem;
  align-items: end;
  margin: 0.9rem 0 0;
  padding: 0.85rem;
  border-radius: 12px;
  border: 1px solid rgba(49, 69, 111, 0.78);
  background: rgba(7, 14, 28, 0.72);
}

.control-bar .actions {
  align-self: stretch;
}

.dashboard-shell {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.65rem;
  min-width: 0;
}

.dashboard-groups {
  display: grid;
  gap: 0.65rem;
  min-width: 0;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
  min-width: 0;
}

.dashboard-group,
.content-group {
  display: grid;
  gap: 0.65rem;
}

.dashboard-section {
  display: grid;
  gap: 0.48rem;
  padding: 0.68rem;
  border: 1px solid rgba(62, 88, 143, 0.78);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(18, 31, 58, 0.9), rgba(10, 18, 35, 0.9)),
    rgba(13, 22, 41, 0.9);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.dashboard-section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.dashboard-section-title {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.dashboard-section-meta {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.dashboard-section > .summary {
  margin-top: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
  min-width: 0;
}

.dashboard-section-note {
  margin-top: 0.1rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.dashboard-status-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.58rem;
  margin-top: 0.58rem;
  padding: 0.42rem 0.55rem;
  border: 1px solid rgba(49, 69, 111, 0.72);
  border-radius: 12px;
  background: rgba(7, 14, 28, 0.62);
  color: var(--muted);
  min-width: 0;
  max-width: 100%;
}

.kv-row {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  min-width: 0;
}

.kv-row strong {
  color: var(--text);
  font-weight: 700;
}

.dashboard-status-message {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.dashboard-kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.38rem;
  min-width: 0;
  max-width: 100%;
}

.dashboard-kv-item {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
  padding: 0.44rem 0.5rem;
  border: 1px solid rgba(49, 69, 111, 0.52);
  border-radius: 9px;
  background: rgba(6, 12, 24, 0.48);
}

.dashboard-kv-wide {
  grid-column: span 2;
}

.dashboard-kv-label {
  color: var(--muted);
  font-size: 0.66rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.dashboard-kv-value {
  min-width: 0;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: normal;
}

.text-wrap {
  overflow-wrap: anywhere;
}

.text-truncate .dashboard-kv-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mono-path .dashboard-kv-value {
  font-family: "IBM Plex Mono", "Cascadia Mono", ui-monospace, SFMono-Regular, monospace;
  font-size: 0.76rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid rgba(49, 69, 111, 0.8);
  padding: 0.12rem 0.45rem;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-chip.subtle {
  background: rgba(8, 13, 28, 0.55);
}

.status-chip-ok {
  color: var(--accent-2);
  border-color: rgba(83, 209, 138, 0.44);
}

.status-chip-warn {
  color: var(--accent-3);
  border-color: rgba(243, 196, 106, 0.44);
}

.status-chip-error {
  color: var(--error);
  border-color: rgba(255, 141, 141, 0.5);
}

.status-chip-busy {
  color: var(--accent);
  border-color: rgba(127, 209, 255, 0.44);
}

.group-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}

.group-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.group-subtitle {
  color: var(--muted);
  font-size: 0.84rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.card {
  padding: 0.85rem;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(24, 36, 69, 0.96), rgba(13, 22, 41, 0.96));
  border: 1px solid rgba(49, 69, 111, 0.75);
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
}

.card h2 {
  margin: 0 0 0.35rem;
}

.card p {
  color: var(--muted);
  margin: 0;
  font-size: 0.92rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.7rem;
  margin: 0.85rem 0 0.65rem;
  align-items: end;
}

.split-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 0.85rem;
  align-items: start;
}

.run-history-list {
  display: grid;
  gap: 0.75rem;
}

.run-history-card {
  border: 1px solid rgba(49, 69, 111, 0.86);
  background: rgba(5, 12, 28, 0.48);
  border-radius: 12px;
  padding: 0.75rem;
  min-width: 0;
}

.run-history-header,
.run-history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.75rem;
  align-items: center;
}

.run-history-header {
  color: var(--text);
}

.run-history-message {
  margin-top: 0.45rem;
  color: var(--muted);
  line-height: 1.35;
}

.run-history-meta {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.run-history-meta span {
  min-width: 0;
}

.run-history-meta .log-path {
  max-width: min(520px, 100%);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run-history-steps {
  margin-top: 0.6rem;
}

label {
  display: grid;
  gap: 0.28rem;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
}

input,
button,
select,
textarea {
  box-sizing: border-box;
  min-width: 0;
  border-radius: 10px;
  border: 1px solid rgba(49, 69, 111, 0.95);
  background: var(--panel-3);
  color: var(--text);
  padding: 0.62rem 0.78rem;
  font: inherit;
}

input:focus,
button:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid rgba(127, 209, 255, 0.4);
  outline-offset: 1px;
}

button {
  cursor: pointer;
  background: linear-gradient(180deg, #294a87, #1b2f59);
  border-color: #355898;
  font-weight: 650;
  transition: transform 120ms ease, border-color 120ms ease, opacity 120ms ease;
  white-space: nowrap;
}

button:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

button.button-warning {
  background: linear-gradient(180deg, #7c3f24, #4d2517);
  border-color: #b56a3d;
  color: #fff3df;
}

button.button-warning:hover {
  border-color: var(--warn);
}

button.button-danger {
  background: linear-gradient(180deg, #75313a, #4a1d25);
  border-color: rgba(255, 141, 141, 0.55);
  color: #ffd5d5;
}

button.button-danger:hover {
  border-color: var(--error);
}

button:disabled {
  cursor: wait;
  opacity: 0.6;
  transform: none;
}

button.button-warning:disabled {
  cursor: not-allowed;
}

.actions {
  display: flex;
  gap: 0.5rem;
  align-items: end;
  flex-wrap: wrap;
}

.page-actions {
  margin-top: 0.8rem;
}

.primary-actions {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  flex-wrap: wrap;
}

.related-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.65rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid rgba(83, 126, 191, 0.35);
  border-radius: 12px;
  background: rgba(7, 14, 28, 0.42);
}

.related-links-label {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-right: 0.25rem;
}

.quiet-link,
.secondary-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.95rem;
  padding: 0.34rem 0.65rem;
  border: 1px solid #355898;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(41, 74, 135, 0.82), rgba(27, 47, 89, 0.82));
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
}

.quiet-link:hover,
.quiet-link:focus-visible,
.secondary-link-button:hover,
.secondary-link-button:focus-visible {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(48, 86, 155, 0.9), rgba(31, 56, 105, 0.9));
}

.secondary-link-button.is-active {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(115, 204, 246, 0.28), rgba(41, 74, 135, 0.9));
  color: #ffffff;
}

.artifact-note {
  margin-top: 0.55rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.artifact-note a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.artifact-note a:hover,
.artifact-note a:focus-visible {
  text-decoration: underline;
}

.row-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.sim-action-note {
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0.62rem 0.78rem;
  border-radius: 10px;
  border: 1px solid #355898;
  background: linear-gradient(180deg, rgba(41, 74, 135, 0.82), rgba(27, 47, 89, 0.82));
  color: var(--text);
  font-weight: 650;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.action-link:hover,
.action-link:focus-visible {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(48, 86, 155, 0.9), rgba(31, 56, 105, 0.9));
  transform: translateY(-1px);
}

.quick-actions {
  padding-top: 0.75rem;
}

.manual-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.manual-card {
  border: 1px solid var(--line);
  background: rgba(5, 12, 28, 0.42);
  border-radius: 12px;
  padding: 1rem;
  min-width: 0;
  overflow: hidden;
}

.manual-form {
  display: grid;
  gap: 0.7rem;
  margin-top: 0.7rem;
  align-items: end;
}

.manual-cash-form {
  grid-template-columns: minmax(120px, 0.9fr) minmax(140px, 1fr) minmax(130px, 1fr);
}

.manual-trade-form {
  grid-template-columns: minmax(120px, 0.8fr) minmax(170px, 1.2fr) minmax(120px, 0.8fr);
}

.manual-form label,
.manual-form input,
.manual-form select {
  width: 100%;
}

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

.manual-form-actions {
  grid-column: 1 / -1;
  align-items: center;
}

.manual-form-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.manual-card .table-block {
  overflow-x: auto;
}

.manual-card .data-table {
  min-width: 0;
}

.strategy-editor-panel {
  margin-top: 1rem;
  overflow: visible;
}

#configUserEditorPanel {
  border-color: rgba(126, 203, 255, 0.46);
  background:
    linear-gradient(180deg, rgba(22, 45, 86, 0.42), rgba(10, 18, 34, 0.88)),
    var(--panel-2);
}

.strategy-editor-grid,
.strategy-config-fields .strategy-editor-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.strategy-editor-grid label {
  min-width: 0;
  overflow: visible;
}

.strategy-editor-grid input,
.strategy-editor-grid select {
  width: 100%;
}

.checkbox-label {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
}

.input-help {
  display: block;
  flex-basis: 100%;
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.user-editor-grid input[type="email"],
.data-table td {
  overflow-wrap: anywhere;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.table-actions button {
  min-height: 2rem;
  padding: 0.42rem 0.7rem;
  font-size: 0.8rem;
}

.danger-button {
  border-color: rgba(255, 116, 116, 0.55);
  background: linear-gradient(180deg, rgba(150, 55, 55, 0.92), rgba(97, 30, 42, 0.92));
}

.danger-button:hover {
  border-color: rgba(255, 146, 146, 0.78);
}

.auth-logout-link {
  min-height: auto;
  padding: 0.28rem 0.52rem;
  font-size: 0.78rem;
}

.login-panel {
  max-width: 680px;
  margin: 10vh auto 0;
}

.field-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 1rem;
  height: 1rem;
  margin-left: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  cursor: help;
  flex: 0 0 auto;
  vertical-align: middle;
  overflow: visible;
}

.field-help::after {
  content: attr(data-help);
  display: none;
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.55rem);
  transform: translateX(-50%);
  z-index: 60;
  width: min(420px, 82vw);
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(5, 12, 28, 0.98);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.36);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.45;
  text-transform: none;
  white-space: pre-line;
  text-align: left;
  pointer-events: none;
}

.field-help::before {
  content: "";
  display: none;
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.22rem);
  transform: translateX(-50%) rotate(45deg);
  z-index: 61;
  width: 0.55rem;
  height: 0.55rem;
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  background: rgba(5, 12, 28, 0.98);
}

.field-help:hover::after,
.field-help:focus::after,
.field-help:hover::before,
.field-help:focus::before {
  display: block;
}

.quick-action-links {
  margin-top: 0.2rem;
}

.dashboard-actions {
  margin-top: 0.7rem;
}

.dashboard-quick-links .quick-action-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0;
}

.dashboard-quick-links .action-link {
  min-height: 1.9rem;
  padding: 0.32rem 0.6rem;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(41, 74, 135, 0.72), rgba(27, 47, 89, 0.72));
  border-color: rgba(53, 88, 152, 0.82);
  color: var(--text);
  font-size: 0.8rem;
}

.compact-field {
  max-width: 190px;
}

.compact-field input {
  min-height: 2.45rem;
}

.composition-bar {
  display: flex;
  width: 100%;
  height: 16px;
  overflow: hidden;
  border: 1px solid rgba(49, 69, 111, 0.7);
  border-radius: 999px;
  background: rgba(7, 14, 28, 0.72);
}

.composition-segment {
  min-width: 0;
  transition: width 160ms ease;
}

.composition-etf {
  background: #7fd1ff;
}

.composition-cash {
  background: #ffb366;
}

.composition-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.8rem;
  margin-top: 0.55rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.composition-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
}

.etf-dot {
  background: #7fd1ff;
}

.cash-dot {
  background: #ffb366;
}

.operator-details {
  display: block;
}

.operator-details summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 700;
}

.operator-details[open] {
  display: grid;
}

.config-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.config-card {
  display: block;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(5, 12, 28, 0.5);
  color: var(--text);
  text-decoration: none;
}

.config-card:hover {
  border-color: var(--accent);
  background: rgba(22, 45, 86, 0.42);
}

.config-card p {
  margin: 0.45rem 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.status,
.meta {
  margin-top: 0.4rem;
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.24rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(49, 69, 111, 0.9);
  background: rgba(8, 13, 28, 0.85);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
}

.status-pill-ok {
  color: var(--accent-2);
  border-color: rgba(83, 209, 138, 0.45);
}

.status-pill-warn {
  color: var(--accent-3);
  border-color: rgba(243, 196, 106, 0.45);
}

.status-pill-busy {
  color: var(--accent);
  border-color: rgba(127, 209, 255, 0.45);
}

.status-pill-error {
  color: var(--error);
  border-color: rgba(255, 141, 141, 0.45);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
  gap: 0.55rem;
  margin-top: 0.55rem;
}

.metric-grid-compact {
  grid-template-columns: repeat(auto-fit, minmax(112px, 180px));
  align-items: stretch;
  gap: 0.45rem;
  margin-top: 0;
}

.metric-card {
  background: rgba(8, 13, 28, 0.78);
  border: 1px solid rgba(49, 69, 111, 0.82);
  border-radius: 10px;
  padding: 0.7rem 0.75rem;
  min-height: 84px;
}

.metric-card-compact {
  min-height: 0;
  min-width: 112px;
  max-width: 220px;
  padding: 0.52rem 0.62rem;
  background: rgba(6, 12, 24, 0.7);
  border-color: rgba(62, 88, 143, 0.58);
}

.metric-label {
  color: var(--muted);
  font-size: 0.74rem;
  margin-bottom: 0.18rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-value {
  font-size: 0.96rem;
  font-weight: 650;
  word-break: break-word;
  line-height: 1.25;
}

.metric-card-compact .metric-label {
  font-size: 0.68rem;
  margin-bottom: 0.12rem;
}

.metric-card-compact .metric-value {
  font-size: 0.9rem;
}

.summary,
.table-block,
.table-wrap,
.chart {
  margin-top: 0.7rem;
  padding: 0.8rem;
  border-radius: 12px;
  border: 1px solid rgba(49, 69, 111, 0.82);
  background: rgba(8, 13, 28, 0.74);
  overflow-x: auto;
  max-width: 100%;
  min-width: 0;
}

.result-group {
  margin-top: 0.75rem;
}

.result-group .summary {
  margin-top: 0.35rem;
}

.chart {
  min-height: 290px;
}

.etf-chart {
  min-height: 420px;
}

.chart-head {
  display: grid;
  gap: 0.18rem;
  margin-bottom: 0.75rem;
}

.chart-title {
  font-size: 1rem;
  font-weight: 650;
  color: #dbe7ff;
}

.chart-subtitle {
  color: var(--muted);
  font-size: 0.86rem;
}

.chart svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart text {
  fill: var(--muted);
  font-size: 12px;
}

.chart-legend {
  display: flex;
  gap: 0.9rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.portfolio-chart-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr);
  gap: 0.85rem;
  margin-top: 0.85rem;
}

.chart-card-block {
  display: grid;
  gap: 0.7rem;
  padding: 0.9rem;
  border-radius: 12px;
  border: 1px solid rgba(49, 69, 111, 0.82);
  background: rgba(8, 13, 28, 0.74);
}

.chart-card-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.toggle-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  padding: 0.4rem 0.62rem;
  border-radius: 999px;
  border: 1px solid rgba(49, 69, 111, 0.82);
  background: rgba(10, 18, 35, 0.78);
  color: #dbe7ff;
  font-size: 0.84rem;
  line-height: 1.1;
}

.toggle-chip input {
  margin: 0;
  accent-color: var(--accent);
}

.toggle-chip.is-disabled {
  opacity: 0.48;
}

.range-preset-row {
  display: flex;
  gap: 0.42rem;
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
}

.range-preset {
  min-height: 32px;
  padding: 0.32rem 0.62rem;
  border-radius: 999px;
  border: 1px solid rgba(49, 69, 111, 0.82);
  background: rgba(10, 18, 35, 0.78);
  color: var(--muted);
  font-size: 0.82rem;
}

.range-preset:hover,
.range-preset:focus-visible,
.range-preset.is-active {
  color: #06101f;
  border-color: transparent;
  background: var(--accent);
}

.donut-wrap {
  display: grid;
  gap: 0.75rem;
}

.donut-shell {
  display: grid;
  place-items: center;
}

.donut-shell svg {
  width: min(100%, 320px);
  height: auto;
}

.donut-center-label {
  font-size: 0.84rem;
  fill: var(--muted);
}

.donut-center-value {
  font-size: 1rem;
  font-weight: 700;
  fill: var(--text);
}

.donut-legend {
  display: grid;
  gap: 0.45rem;
}

.donut-legend-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 0.55rem;
  align-items: center;
  font-size: 0.85rem;
}

.donut-legend-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 999px;
}

.donut-legend-label {
  min-width: 0;
}

.donut-legend-value,
.donut-legend-weight {
  color: var(--muted);
  text-align: right;
}

.exposure-section {
  display: grid;
  gap: 0.8rem;
  margin-top: 0.85rem;
  padding: 0.9rem;
  border-radius: 12px;
  border: 1px solid rgba(49, 69, 111, 0.82);
  background: rgba(8, 13, 28, 0.74);
}

.exposure-range-row {
  width: auto;
  justify-content: flex-end;
}

.exposure-group {
  display: grid;
  gap: 0.7rem;
  padding-top: 0.25rem;
}

.exposure-group + .exposure-group {
  padding-top: 0.9rem;
  border-top: 1px solid rgba(49, 69, 111, 0.58);
}

.exposure-group-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.exposure-history-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}

.exposure-latest-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.bar-list {
  display: grid;
  gap: 0.58rem;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) minmax(120px, 2fr) auto auto;
  gap: 0.6rem;
  align-items: center;
  font-size: 0.85rem;
}

.bar-label {
  min-width: 0;
  color: #dbe7ff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 0.56rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(49, 69, 111, 0.54);
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #7fd1ff, #53d18a);
}

.bar-value,
.bar-money {
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

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

.overlay-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
}

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 16, 0.76);
  backdrop-filter: blur(6px);
}

.overlay-panel {
  position: relative;
  width: min(1120px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid rgba(49, 69, 111, 0.95);
  background: linear-gradient(180deg, rgba(17, 27, 49, 0.99), rgba(8, 13, 28, 0.99));
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.overlay-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1rem 0.6rem;
  border-bottom: 1px solid rgba(49, 69, 111, 0.6);
}

.overlay-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.overlay-subtitle {
  margin: 0.22rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.overlay-close {
  min-width: 88px;
}

.overlay-table {
  margin-top: 0;
  max-height: calc(100vh - 10rem);
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.etf-control-bar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
  margin-top: 0.9rem;
  padding: 0.95rem;
  border-radius: 12px;
  border: 1px solid rgba(49, 69, 111, 0.78);
  background: rgba(7, 14, 28, 0.72);
}

.etf-control-row {
  display: grid;
  gap: 0.75rem;
  align-items: end;
}

.etf-control-row + .etf-control-row {
  padding-top: 0.75rem;
  border-top: 1px solid rgba(49, 69, 111, 0.42);
}

.etf-control-row-top {
  grid-template-columns: repeat(3, minmax(220px, 1fr));
}

.etf-control-row-middle {
  grid-template-columns: minmax(180px, 220px) minmax(180px, 220px);
  max-width: 480px;
}

.etf-control-row-bottom {
  grid-template-columns: minmax(180px, 220px) minmax(220px, 280px);
  max-width: 520px;
}

.etf-control-row-actions {
  display: flex;
  justify-content: flex-start;
}

.etf-field {
  display: flex;
  flex-direction: column;
  gap: 0.38rem;
  min-width: 0;
  align-self: stretch;
  font-size: 0.92rem;
  line-height: 1.2;
}

.etf-field-small {
  min-width: 0;
}

.etf-field-series {
  min-width: 0;
}

.etf-field input,
.etf-field select {
  display: block;
  width: 100%;
  min-width: 0;
}

.etf-actions {
  align-self: end;
  justify-content: flex-start;
  flex-wrap: wrap;
  min-width: 0;
}

.etf-actions button {
  min-height: 42px;
  min-width: 120px;
}

.etf-context {
  margin-top: 0.55rem;
}

.etf-context-strip {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.etf-context-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  padding: 0.42rem 0.62rem;
  border-radius: 999px;
  border: 1px solid rgba(49, 69, 111, 0.85);
  background: rgba(8, 13, 28, 0.82);
  color: #dbe7ff;
  font-size: 0.84rem;
  line-height: 1.2;
}

.etf-context-chip-muted {
  color: var(--muted);
}

.etf-context-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.etf-context-value {
  font-weight: 650;
}

.warning-list {
  margin: 0.3rem 0 0;
  padding-left: 1.2rem;
  color: var(--warn);
  font-size: 0.9rem;
}

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

.info-list a,
.warning-list a {
  color: var(--accent);
  text-decoration: underline;
}

.section-label {
  color: var(--muted);
  font-size: 0.74rem;
  margin-bottom: 0.45rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.empty-state,
.muted {
  color: var(--muted);
}

.section-stack {
  display: grid;
  gap: 0.7rem;
  margin-top: 0.7rem;
}

.decision-section {
  border: 1px solid rgba(49, 69, 111, 0.82);
  border-radius: 10px;
  background: rgba(8, 13, 28, 0.74);
  overflow: hidden;
}

.decision-section summary {
  cursor: pointer;
  list-style: none;
  padding: 0.7rem 0.85rem;
  font-weight: 650;
  background: rgba(17, 27, 49, 0.82);
  font-size: 0.92rem;
}

.decision-section summary::-webkit-details-marker {
  display: none;
}

.decision-body {
  padding: 0.85rem;
  display: grid;
  gap: 0.75rem;
}

.mini-kv {
  display: grid;
  gap: 0.45rem;
}

.mini-kv-row {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr;
  gap: 0.7rem;
  padding-bottom: 0.28rem;
  border-bottom: 1px solid rgba(49, 69, 111, 0.35);
}

.mini-kv-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.76rem;
}

.mini-kv-value {
  word-break: break-word;
}

.raw-block {
  margin: 0;
  padding: 0.75rem;
  border-radius: 10px;
  background: rgba(5, 9, 20, 0.9);
  border: 1px solid rgba(49, 69, 111, 0.45);
  color: #d6def5;
  overflow-x: auto;
  white-space: pre-wrap;
  font-size: 0.85rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.data-table th,
.data-table td {
  padding: 0.5rem 0.58rem;
  text-align: left;
  border-bottom: 1px solid rgba(49, 69, 111, 0.55);
  vertical-align: top;
  white-space: nowrap;
  font-size: 0.88rem;
}

.data-table th {
  color: #d8e2ff;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
  background: rgba(8, 13, 28, 0.96);
  z-index: 1;
}

.data-table tbody tr:hover {
  background: rgba(127, 209, 255, 0.05);
}

.data-table td.num,
.data-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table tbody tr:nth-child(even) {
  background: rgba(17, 27, 49, 0.22);
}

.table-wrap {
  padding: 0;
  border: 0;
  background: transparent;
  margin-top: 0;
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "context"
      "nav";
  }

  .topbar-left > div:first-child,
  .topbar-context,
  .topbar-controls,
  .topbar-meta {
    width: 100%;
  }

  .topbar-context,
  .topbar-controls,
  .topbar-meta {
    justify-items: stretch;
    justify-content: flex-start;
  }

  .topbar-field {
    min-width: 0;
    flex: 1 1 150px;
  }

  .nav {
    width: 100%;
    gap: 0.4rem;
  }

  .page {
    padding: 1rem;
  }

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

  .portfolio-chart-grid {
    grid-template-columns: 1fr;
  }

  .exposure-history-grid,
  .exposure-latest-grid {
    grid-template-columns: 1fr;
  }

  .exposure-range-row {
    justify-content: flex-start;
  }

  .group-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .summary,
  .table-block,
  .table-wrap,
  .chart,
  .panel,
  .hero {
    border-radius: 12px;
  }

  .overlay-panel {
    width: calc(100vw - 1rem);
    max-height: calc(100vh - 1rem);
  }

  .overlay-header {
    flex-direction: column;
    align-items: stretch;
  }

  .overlay-close {
    width: 100%;
  }

  .etf-control-row-top,
  .etf-control-row-middle,
  .etf-control-row-bottom {
    grid-template-columns: 1fr;
  }

  .etf-actions {
    justify-content: stretch;
    flex-wrap: wrap;
    min-width: 0;
  }

  .etf-actions button {
    flex: 1 1 160px;
    min-width: 0;
  }
}

@media (max-width: 1080px) {
  .manual-grid {
    grid-template-columns: 1fr;
  }

  .manual-cash-form,
  .manual-trade-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .strategy-editor-grid,
  .strategy-config-fields .strategy-editor-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .etf-control-row-top {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .etf-control-row-middle {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    max-width: none;
  }

  .etf-control-row-bottom {
    grid-template-columns: minmax(180px, 1fr) minmax(220px, 1fr);
    max-width: none;
  }

  .etf-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

@media (max-width: 720px) {
  .manual-cash-form,
  .manual-trade-form {
    grid-template-columns: 1fr;
  }

  .strategy-editor-grid,
  .strategy-config-fields .strategy-editor-grid {
    grid-template-columns: 1fr;
  }

  .config-card-grid {
    grid-template-columns: 1fr;
  }

  .etf-control-row-top,
  .etf-control-row-middle,
  .etf-control-row-bottom {
    grid-template-columns: 1fr;
    max-width: none;
  }

  .etf-control-row-actions {
    display: block;
  }

  .etf-actions {
    justify-content: stretch;
    flex-wrap: wrap;
    min-width: 0;
  }

  .etf-actions button {
    flex: 1 1 160px;
    min-width: 0;
  }
}
