:root {
  --blue-main: #0d6efd;
  --blue-dark: #0b2e59;
  --blue-mid: #1f5faf;
  --blue-light: #eaf3ff;
  --app-bg: #f5f8fc;
  --app-surface: #fff;
  --app-text: #1f2937;
  --app-muted: #6b7280;
  --app-border: #d9e2ec;
  --cartilla-columns: 6;
  --number-picker-max-width: 28rem;
}

html[data-cartilla-columns="5"] {
  --cartilla-columns: 5;
  --number-picker-max-width: 22.5rem;
}

html[data-cartilla-columns="4"] {
  --cartilla-columns: 4;
  --number-picker-max-width: 18rem;
}

html[data-cartilla-columns="7"] {
  --cartilla-columns: 7;
  --number-picker-max-width: 32rem;
}

body {
  background: var(--app-bg);
  color: var(--app-text);
}

.app-navbar {
  background: var(--blue-dark);
}

.theme-control {
  align-items: center;
  display: flex;
  gap: .45rem;
}

.theme-toggle-button {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: #fff;
  display: inline-grid;
  font-size: .62rem;
  font-weight: 800;
  gap: .18rem;
  justify-items: center;
  line-height: 1;
  min-height: 2.35rem;
  min-width: 3.6rem;
  padding: .2rem .35rem;
  text-transform: uppercase;
  transition: background .18s ease, transform .18s ease;
}

.theme-toggle-button:hover {
  background: rgba(255, 255, 255, .08);
  transform: translateY(-1px);
}

.theme-toggle-button:focus-visible {
  outline: 3px solid rgba(96, 165, 250, .35);
  outline-offset: 3px;
}

.theme-toggle-button[aria-pressed="true"] {
  background: transparent;
}

.theme-toggle-track {
  background: #f8fafc;
  border: 1px solid rgba(255, 255, 255, .45);
  border-radius: 999px;
  display: block;
  height: .95rem;
  position: relative;
  width: 2rem;
}

.theme-toggle-knob {
  background: #1f2937;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
  display: block;
  height: .7rem;
  left: .12rem;
  position: absolute;
  top: .09rem;
  transition: transform .18s ease, background .18s ease;
  width: .7rem;
}

.theme-toggle-button[aria-pressed="true"] .theme-toggle-track {
  background: #f8fafc;
}

.theme-toggle-button[aria-pressed="true"] .theme-toggle-knob {
  background: #111827;
  transform: translateX(1.03rem);
}

.theme-toggle-label {
  color: rgba(255, 255, 255, .88);
  white-space: nowrap;
}

.app-panel {
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 1rem;
}

.app-footer {
  border-top: 1px solid var(--app-border);
  color: var(--app-muted);
  font-size: .85rem;
  line-height: 1.4;
  margin-top: 1.5rem;
  padding: 1rem 0 5.5rem;
  text-align: center;
}

.random-combination-status {
  background: #f8fafc;
  border: 1px solid var(--app-border);
  border-left: 4px solid var(--blue-main);
  border-radius: 8px;
  color: var(--app-text);
  font-size: .9rem;
  font-weight: 700;
  padding: .65rem .75rem;
}

.section-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: .75rem;
}

.section-heading h2 {
  font-size: 1.15rem;
  margin: 0;
}

.metric-card {
  background: #fff;
  border: 1px solid var(--app-border);
  border-left: 4px solid var(--blue-main);
  border-radius: 8px;
  min-height: 100%;
  padding: 1rem;
}

.metric-label {
  color: var(--app-muted);
  font-size: .82rem;
  margin-bottom: .35rem;
}

.metric-value {
  font-size: 1.35rem;
  font-weight: 700;
}

.position-card {
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  min-height: 100%;
  padding: 1rem;
}

.position-card h3 {
  color: var(--blue-dark);
  font-size: 1.1rem;
  margin-bottom: .75rem;
}

.position-card-enhanced {
  display: grid;
  gap: .6rem;
}

.position-card-enhanced h3 {
  margin-bottom: .15rem;
}

.position-card-header {
  align-items: center;
  display: flex;
  gap: .75rem;
  justify-content: space-between;
}

.position-last-ball {
  align-items: center;
  background: var(--blue-light);
  border: 1px solid #bfd7f2;
  border-radius: 999px;
  color: var(--blue-dark);
  display: inline-flex;
  font-size: 1.15rem;
  font-weight: 900;
  height: 2.45rem;
  justify-content: center;
  min-width: 2.45rem;
  padding: 0 .6rem;
}

.position-score {
  background: #f8fafc;
  border: 1px solid #e5edf5;
  border-radius: 8px;
  padding: .5rem .6rem;
}

.position-signal-grid {
  display: grid;
  gap: .45rem .55rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.position-signal {
  align-items: flex-start;
  display: grid;
  gap: .25rem;
  min-width: 0;
}

.position-signal .badge {
  justify-self: start;
}

.position-confidence {
  align-items: center;
  border-top: 1px solid #e5edf5;
  display: flex;
  gap: .2rem;
  padding-top: .5rem;
}

.badge-soft {
  background: var(--blue-light);
  color: var(--blue-dark);
}

.badge-range {
  background: #e7f5ff;
  border: 1px solid #9ad0f5;
  color: #084c7d;
}

.table {
  margin-bottom: 0;
}

.table th {
  color: var(--blue-dark);
  white-space: nowrap;
}

.status-dot {
  border-radius: 999px;
  display: inline-block;
  height: .65rem;
  margin-right: .35rem;
  width: .65rem;
}

.status-strong { background: #198754; }
.status-medium { background: #0d6efd; }
.status-weak { background: #ffc107; }
.status-low { background: #dc3545; }

.top-percent {
  color: #198754;
  font-weight: 800;
}

.section-help {
  background: #f8fafc;
  border-left: 4px solid var(--blue-main);
  color: #4b5563;
  font-size: .9rem;
  padding: .75rem .9rem;
}

.probability-cell {
  min-width: 10rem;
}

.probability-meter {
  background: #edf2f7;
  border-radius: 999px;
  height: .45rem;
  margin-top: .45rem;
  overflow: hidden;
}

.probability-meter-bar {
  background: linear-gradient(90deg, #0d6efd, #20c997);
  border-radius: inherit;
  height: 100%;
  min-width: .2rem;
}

.range-probability {
  min-width: 11rem;
}

.matrix-percent-cell {
  min-width: 7.5rem;
}

.matrix-percent-cell.is-top {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: .35rem .45rem;
}

.signal-group {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  min-width: 12rem;
}

.transition-summary-card {
  min-height: auto;
}

.transition-ranking-list {
  display: grid;
  gap: .6rem;
}

.transition-ranking-row {
  align-items: center;
  background: #f8fafc;
  border: 1px solid #e5edf5;
  border-radius: 8px;
  display: grid;
  gap: .75rem;
  grid-template-columns: 3rem minmax(7rem, .7fr) minmax(10rem, 1fr);
  padding: .75rem;
}

.transition-rank {
  align-items: center;
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 999px;
  color: var(--blue-dark);
  display: inline-flex;
  font-weight: 800;
  height: 2.25rem;
  justify-content: center;
  width: 2.25rem;
}

.transition-ranking-meter {
  min-width: 10rem;
}

.transition-matrix th,
.transition-matrix td {
  min-width: 6.25rem;
}

.transition-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  min-width: 17rem;
}

.transition-chip {
  align-items: center;
  background: #f8fafc;
  border: 1px solid #e5edf5;
  border-radius: 999px;
  display: inline-flex;
  gap: .35rem;
  padding: .25rem .45rem;
}

.transition-arrow {
  color: var(--app-muted);
  font-size: .8rem;
  font-weight: 800;
}

.transition-number-groups {
  display: grid;
  gap: .75rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.transition-number-card {
  background: #f8fafc;
  border: 1px solid #e5edf5;
  border-radius: 8px;
  padding: .85rem;
}

.transition-ranking-detail {
  display: block;
}

.transition-ranking-summary {
  align-items: center;
  cursor: pointer;
  display: grid;
  gap: .75rem;
  grid-template-columns: auto minmax(0, .7fr) minmax(12rem, 1fr);
  list-style: none;
}

.transition-ranking-summary::-webkit-details-marker {
  display: none;
}

.transition-ranking-numbers {
  border-top: 1px solid var(--app-border);
  margin-top: .8rem;
  padding-top: .8rem;
}

.transition-number-list {
  display: grid;
  gap: .5rem;
}

.transition-number-detail > summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: .75rem;
  justify-content: space-between;
  list-style: none;
}

.transition-number-detail > summary::-webkit-details-marker {
  display: none;
}

.transition-number-detail > summary span:last-child {
  color: var(--app-muted);
  font-size: .85rem;
}

.transition-number-detail .transition-number-list {
  margin-top: .75rem;
}

.transition-number-item {
  align-items: center;
  display: grid;
  gap: .55rem;
  grid-template-columns: 2.4rem minmax(0, 1fr);
}

.transition-number-item.is-top .sample-ball {
  background: #d1e7dd;
  border-color: #75b798;
  color: #0f5132;
}

.transition-number-item.is-top strong {
  color: #008a4c;
}

.transition-number-meter {
  min-width: 0;
}

.cartilla-number-grid {
  display: grid;
  gap: .45rem;
  grid-template-columns: repeat(auto-fit, minmax(5.75rem, 1fr));
  width: 100%;
}

.cartilla-frequency-table table {
  table-layout: fixed;
  width: 100%;
}

.cartilla-frequency-table th:first-child,
.cartilla-frequency-table td:first-child {
  width: 8.5rem;
}

.cartilla-frequency-table th:nth-child(2),
.cartilla-frequency-table td:nth-child(2) {
  width: auto;
}

.cartilla-number-cell {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  display: flex;
  gap: .45rem;
  justify-content: space-between;
  padding: .45rem .55rem;
}

.cartilla-number-cell.is-top {
  background: #e8f7ef;
  border-color: #57b87d;
}

.cartilla-number-cell.is-top strong {
  color: #008a4c;
}

.summary-top-value,
.parity-summary-cell.is-top strong {
  color: #008a4c;
  font-weight: 800;
}

.summary-next-value {
  color: #b58100;
  font-weight: 800;
}

.parity-summary-cell.is-lower .probability-meter-bar {
  background: linear-gradient(90deg, #dc3545, #ff6b6b);
}

.joint-grid {
  display: grid;
  gap: .85rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.joint-position-card {
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: .85rem;
}

.joint-position-card h3 {
  color: var(--blue-dark);
  font-size: 1rem;
  margin: 0;
}

.joint-profile-item {
  background: #f8fafc;
  border: 1px solid #e5edf5;
  border-radius: 8px;
  padding: .7rem;
}

.joint-rank {
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 999px;
  color: var(--blue-dark);
  font-size: .8rem;
  font-weight: 800;
  min-width: 2.25rem;
  padding: .15rem .5rem;
  text-align: center;
}

.joint-profile-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}

.floating-actions {
  bottom: 1.5rem;
  display: grid;
  gap: .75rem;
  position: fixed;
  right: 1.5rem;
  z-index: 1040;
}

.floating-action {
  align-items: center;
  border: 0;
  border-radius: 999px;
  box-shadow: 0 12px 24px rgba(11, 46, 89, .22);
  color: #fff;
  display: inline-flex;
  font-size: 1.15rem;
  font-weight: 800;
  height: 3.25rem;
  justify-content: center;
  line-height: 1;
  width: 3.25rem;
}

.floating-action:hover {
  filter: brightness(.95);
  transform: translateY(-1px);
}

.floating-action:focus-visible {
  outline: 3px solid rgba(13, 110, 253, .28);
  outline-offset: 3px;
}

.floating-action-menu {
  background: #0b2e59;
  color: #fff;
  transition: transform .18s ease, filter .18s ease;
}

.floating-actions.is-open .floating-action-menu {
  transform: rotate(90deg);
}

.floating-action-item {
  opacity: 0;
  pointer-events: none;
  transform: translateY(1rem) scale(.88);
  transition: opacity .18s ease, transform .18s ease;
}

.floating-actions.is-open .floating-action-item {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.floating-actions.is-open .floating-action-item:nth-child(1) { transition-delay: .02s; }
.floating-actions.is-open .floating-action-item:nth-child(2) { transition-delay: .05s; }
.floating-actions.is-open .floating-action-item:nth-child(3) { transition-delay: .08s; }
.floating-actions.is-open .floating-action-item:nth-child(4) { transition-delay: .11s; }
.floating-actions.is-open .floating-action-item:nth-child(5) { transition-delay: .14s; }
.floating-actions.is-open .floating-action-item:nth-child(6) { transition-delay: .17s; }
.floating-actions.is-open .floating-action-item:nth-child(7) { transition-delay: .20s; }

.floating-action-history {
  background: #198754;
  color: #fff;
}

.floating-action-next {
  background: var(--blue-main);
  color: #fff;
}

.floating-action-stats {
  background: #ffc107;
  color: #3b2f00;
}

.floating-action-transition {
  background: #20c997;
  color: #063f31;
}

.floating-action-random {
  background: #0dcaf0;
  color: #053642;
}

.floating-action-plays {
  background: #6f42c1;
  color: #fff;
}

.floating-action-info {
  background: #6c757d;
  color: #fff;
}

.random-generator-status {
  background: #f8fafc;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 700;
  padding: .65rem .75rem;
}

.random-criteria-grid {
  display: grid;
  gap: .75rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.random-criteria-card {
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: .75rem;
}

.advanced-filter-grid {
  display: grid;
  gap: .75rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.advanced-filter-card {
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: .75rem;
}

.advanced-filter-card h4 {
  font-size: .95rem;
  margin: 0 0 .35rem;
}

.advanced-filter-help {
  color: var(--app-muted);
  font-size: .78rem;
  line-height: 1.35;
  margin: 0 0 .65rem;
}

.advanced-filter-card-wide {
  grid-column: 1 / -1;
}

.advanced-filter-summary {
  border-top: 1px solid var(--app-border);
  padding-top: .75rem;
}

.advanced-filter-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.advanced-filter-chip-list span {
  background: var(--blue-light);
  border: 1px solid #b9d7ff;
  border-radius: 999px;
  color: var(--blue-dark);
  font-size: .78rem;
  font-weight: 700;
  padding: .25rem .55rem;
}

.transition-position-sequence-list {
  display: grid;
  gap: .65rem;
}

.transition-position-sequence-row {
  align-items: center;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  display: grid;
  gap: .75rem;
  grid-template-columns: auto minmax(0, 1.25fr) minmax(12rem, .85fr);
  padding: .75rem;
}

.transition-position-sequence-row.is-top {
  background: var(--app-surface);
  border-color: var(--app-border);
}

.position-sequence-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}

.position-sequence-chip {
  border: 1px solid var(--app-border);
  border-radius: 999px;
  display: inline-flex;
  flex-direction: column;
  font-size: .78rem;
  font-weight: 800;
  padding: .22rem .5rem;
}

.position-sequence-label {
  line-height: 1.05;
}

.position-sequence-top {
  font-size: .68rem;
  font-weight: 700;
  line-height: 1.05;
  opacity: .82;
}

.position-sequence-chip.is-even {
  background: #eaf3ff;
  color: #0b2e59;
}

.position-sequence-chip.is-odd {
  background: #fff4d6;
  color: #6f4b00;
}

.generated-play-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}

.number-chip {
  align-items: center;
  background: var(--blue-light);
  border: 1px solid var(--app-border);
  border-radius: 999px;
  color: var(--blue-dark);
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  min-width: 2.1rem;
  padding: .25rem .55rem;
}

.random-result-board {
  margin-inline: auto;
}

body[data-theme="dark"] {
  --blue-main: #60a5fa;
  --blue-dark: #071426;
  --blue-mid: #93c5fd;
  --blue-light: #10243d;
  --app-bg: #0b1220;
  --app-surface: #111c2d;
  --app-text: #e5edf7;
  --app-muted: #a7b4c7;
  --app-border: #243449;
  background: var(--app-bg);
  color: var(--app-text);
}

body[data-theme="dark"] .app-navbar {
  background: #050b14;
  border-bottom: 1px solid #1d2b3d;
}

body[data-theme="dark"] .theme-toggle-button {
  background: transparent;
  color: #f8fbff;
}

body[data-theme="dark"] .app-panel,
body[data-theme="dark"] .metric-card,
body[data-theme="dark"] .position-card,
body[data-theme="dark"] .joint-position-card,
body[data-theme="dark"] .compare-result-card,
body[data-theme="dark"] .draw-summary-item,
body[data-theme="dark"] .latest-play-item,
body[data-theme="dark"] .random-criteria-card,
body[data-theme="dark"] .advanced-filter-card,
body[data-theme="dark"] .transition-position-sequence-row,
body[data-theme="dark"] .transition-ranking-row,
body[data-theme="dark"] .transition-number-card,
body[data-theme="dark"] .position-score,
body[data-theme="dark"] .random-generator-status {
  background: #111c2d;
  border-color: var(--app-border);
  color: var(--app-text);
}

body[data-theme="dark"] .accordion-item,
body[data-theme="dark"] .accordion-button {
  background: #111c2d;
  border-color: var(--app-border);
  color: var(--app-text);
}

body[data-theme="dark"] .accordion-button:not(.collapsed) {
  background: #12304f;
  color: #dbeafe;
}

body[data-theme="dark"] .advanced-filter-chip-list span {
  background: #12304f;
  border-color: #315f93;
  color: #dbeafe;
}

body[data-theme="dark"] .transition-position-sequence-row.is-top {
  background: #111c2d;
  border-color: #263b58;
}

body[data-theme="dark"] .position-sequence-chip.is-even {
  background: #12304f;
  border-color: #315f93;
  color: #dbeafe;
}

body[data-theme="dark"] .position-sequence-chip.is-odd {
  background: #3a2f10;
  border-color: #8a6a16;
  color: #fde68a;
}

body[data-theme="dark"] .advanced-filter-help {
  color: #a9bad0;
}

body[data-theme="dark"] .cartilla-number-cell {
  background: #0d1a2c;
  border-color: var(--app-border);
}

body[data-theme="dark"] .cartilla-number-cell.is-top {
  background: #123826;
  border-color: #2e8f62;
}

body[data-theme="dark"] .cartilla-number-cell.is-top strong {
  color: #5ee3a1;
}

body[data-theme="dark"] .summary-top-value,
body[data-theme="dark"] td .summary-top-value,
body[data-theme="dark"] td strong.summary-top-value,
body[data-theme="dark"] .parity-summary-cell.is-top strong {
  color: #5ee3a1 !important;
}

body[data-theme="dark"] .summary-next-value,
body[data-theme="dark"] td .summary-next-value,
body[data-theme="dark"] td strong.summary-next-value {
  color: #facc15 !important;
}

body[data-theme="dark"] .parity-summary-cell.is-lower .probability-meter-bar {
  background: linear-gradient(90deg, #ef4444, #fb7185);
}

body[data-theme="dark"] .metric-card {
  border-left-color: var(--blue-main);
}

body[data-theme="dark"] .position-card h3,
body[data-theme="dark"] .joint-position-card h3,
body[data-theme="dark"] .section-heading h2,
body[data-theme="dark"] h1,
body[data-theme="dark"] h2,
body[data-theme="dark"] h3,
body[data-theme="dark"] h4,
body[data-theme="dark"] h5,
body[data-theme="dark"] h6 {
  color: #f8fbff;
}

body[data-theme="dark"] .text-secondary,
body[data-theme="dark"] .form-text,
body[data-theme="dark"] .metric-label,
body[data-theme="dark"] .latest-play-date {
  color: var(--app-muted) !important;
}

body[data-theme="dark"] .section-help {
  background: #0d1a2c;
  border-left-color: var(--blue-main);
  color: #dbeafe !important;
}

body[data-theme="dark"] .random-combination-status {
  background: #0d1a2c;
  border-color: var(--app-border);
  border-left-color: var(--blue-main);
  color: #dbeafe;
}

body[data-theme="dark"] .section-help strong {
  color: #f8fbff;
}

body[data-theme="dark"] .form-control,
body[data-theme="dark"] .form-select {
  background-color: #0b1525;
  border-color: #30445f;
  color: var(--app-text);
}

body[data-theme="dark"] .form-control:focus,
body[data-theme="dark"] .form-select:focus {
  background-color: #0d1a2c;
  border-color: var(--blue-main);
  box-shadow: 0 0 0 .2rem rgba(96, 165, 250, .2);
  color: var(--app-text);
}

body[data-theme="dark"] .table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--app-text);
  --bs-table-border-color: var(--app-border);
  --bs-table-hover-bg: #17263b;
  --bs-table-hover-color: #f8fbff;
}

body[data-theme="dark"] .table thead,
body[data-theme="dark"] .table th {
  background: transparent;
  color: #dbeafe !important;
}

body[data-theme="dark"] .table td {
  color: var(--app-text);
}

body[data-theme="dark"] .form-label,
body[data-theme="dark"] label,
body[data-theme="dark"] .navbar-text {
  color: #dbeafe !important;
}

body[data-theme="dark"] .table strong,
body[data-theme="dark"] td strong,
body[data-theme="dark"] th strong {
  color: #f8fbff;
}

body[data-theme="dark"] .modal-content {
  background: #101a2a;
  border-color: var(--app-border);
  color: var(--app-text);
}

body[data-theme="dark"] .modal-header,
body[data-theme="dark"] .modal-footer {
  border-color: var(--app-border);
}

body[data-theme="dark"] .btn-close {
  filter: invert(1) grayscale(100%) brightness(1.8);
}

body[data-theme="dark"] .number-pick {
  background: #0d1a2c;
  border-color: #6b7c91;
  color: #f8fbff;
}

body[data-theme="dark"] .number-pick.is-selected,
body[data-theme="dark"] .hit-ball {
  background: #e03148;
  border-color: #e03148;
  color: #fff;
}

body[data-theme="dark"] .sample-ball,
body[data-theme="dark"] .number-chip,
body[data-theme="dark"] .position-last-ball,
body[data-theme="dark"] .stats-ball {
  background: #15365d;
  border-color: #315f93;
  color: #d9ecff;
}

body[data-theme="dark"] .sample-ball.hit-ball,
body[data-theme="dark"] .compare-result-card .hit-ball {
  background: #e03148;
  border-color: #ff5b70;
  color: #fff;
}

body[data-theme="dark"] .sample-ball.is-armed {
  background: rgba(255, 193, 7, .18);
  border-color: #ffc107;
  color: #ffe69c;
}

body[data-theme="dark"] .badge-soft,
body[data-theme="dark"] .badge-range {
  background: #122b47;
  border-color: #3b78af;
  color: #d9ecff;
}

body[data-theme="dark"] .probability-meter,
body[data-theme="dark"] .stats-bar-track {
  background: #1b2b40;
}

body[data-theme="dark"] .probability-meter-bar {
  background: linear-gradient(90deg, #60a5fa, #34d399);
}

body[data-theme="dark"] .stats-bar {
  background: linear-gradient(90deg, #f59e0b, #facc15);
}

body[data-theme="dark"] .matrix-percent-cell,
body[data-theme="dark"] .joint-profile-item,
body[data-theme="dark"] .transition-chip {
  background: #0d1a2c;
  border-color: var(--app-border);
  color: var(--app-text);
}

body[data-theme="dark"] .matrix-percent-cell.is-top,
body[data-theme="dark"] .transition-number-item.is-top .sample-ball {
  background: #123826;
  border-color: #2e8f62;
  color: #c8f7dc;
}

body[data-theme="dark"] .top-percent,
body[data-theme="dark"] .transition-number-item.is-top strong {
  color: #5ee3a1;
}

body[data-theme="dark"] .alert-warning {
  background: #3a2a0b;
  border-color: #8a681a;
  color: #ffe8a3;
}

body[data-theme="dark"] .alert-success {
  background: #10351f;
  border-color: #2f8b55;
  color: #cef5dc;
}

.sample-ball-list {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}

.sample-ball {
  background: var(--blue-light);
  border: 1px solid var(--app-border);
  border-radius: 999px;
  color: var(--blue-dark);
  font-weight: 700;
  min-width: 2.25rem;
  padding: .25rem .55rem;
  text-align: center;
}

.sample-ball.is-editable {
  cursor: pointer;
}

.sample-ball.is-editable:hover {
  filter: brightness(.95);
}

.sample-ball.is-armed {
  background: #fff8e1;
  border: 1px dashed #ffc107;
  color: #7a5b00;
}

.play-ball-input {
  font-weight: 700;
}

.latest-plays-list {
  display: grid;
  gap: .5rem;
  max-height: 12rem;
  overflow: auto;
}

.latest-play-item {
  align-items: center;
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  display: flex;
  gap: .75rem;
  justify-content: space-between;
  padding: .55rem .65rem;
}

.latest-play-button {
  text-align: left;
  width: 100%;
}

.latest-play-button:hover {
  background: var(--blue-light);
}

.latest-play-date {
  color: var(--app-muted);
  font-size: .78rem;
  white-space: nowrap;
}

.plays-ball-list {
  flex-wrap: nowrap;
}

.plays-action-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: .4rem;
  justify-content: flex-end;
}

.number-picker {
  display: grid;
  gap: .6rem;
  grid-template-columns: repeat(var(--cartilla-columns), minmax(2.35rem, 1fr));
  max-width: var(--number-picker-max-width);
}

.number-pick {
  align-items: center;
  background: #fff;
  border: 1px solid #9ca3af;
  border-radius: 999px;
  color: var(--app-text);
  display: inline-flex;
  font-weight: 700;
  height: 2.25rem;
  justify-content: center;
  line-height: 1;
  min-width: 2.25rem;
}

.number-pick.is-selected {
  background: #dc3545;
  border-color: #dc3545;
  color: #fff;
}

.number-pick.is-armed {
  border-color: #ffc107;
  box-shadow: 0 0 0 3px rgba(255, 193, 7, .45);
}

.hit-ball {
  background: #dc3545;
  border-color: #dc3545;
  color: #fff;
}

.compare-result-card {
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: .75rem;
}

.stats-grid {
  column-gap: 2rem;
  columns: 3 14rem;
}

.stats-row {
  align-items: center;
  break-inside: avoid;
  display: grid;
  gap: .5rem;
  grid-template-columns: 2.25rem minmax(7rem, 1fr) 3.25rem;
  margin-bottom: .4rem;
}

.stats-ball {
  align-items: center;
  background: #f3ff8f;
  border: 1px solid #8bc34a;
  border-radius: 999px;
  color: #003b10;
  display: inline-flex;
  font-weight: 800;
  height: 1.8rem;
  justify-content: center;
  width: 1.8rem;
}

.stats-bar-track {
  background: #f7fdf0;
  border: 1px solid #cde879;
  height: 1.05rem;
  overflow: hidden;
}

.stats-bar {
  background: linear-gradient(90deg, #b8f500, #ffe600);
  height: 100%;
  min-width: .15rem;
}

.stats-grid-orange .stats-ball {
  background: #fff2cc;
  border-color: #ff9800;
  color: #5f3400;
}

.stats-grid-orange .stats-bar-track {
  background: #fff8ed;
  border-color: #ffc46b;
}

.stats-grid-orange .stats-bar {
  background: linear-gradient(90deg, #ff8a00, #ffd166);
}

.stats-count {
  font-size: .85rem;
  text-align: right;
}

.history-row {
  cursor: pointer;
}

.history-row:hover td {
  background: var(--blue-light);
}

.sample-history-row {
  cursor: pointer;
}

.sample-history-row:hover td,
.sample-history-row.is-active td {
  background: var(--blue-light);
}

.sample-history-row.is-active td:first-child {
  border-left: 4px solid var(--blue-main);
}

.sample-history-filters {
  align-items: end;
  display: grid;
  gap: .75rem;
  grid-template-columns: minmax(12rem, 1fr) minmax(11rem, 14rem) auto;
}

.sample-history-filter-actions {
  display: flex;
  justify-content: flex-end;
}

.history-sorteo-link {
  background: transparent;
  border: 0;
  color: var(--blue-main);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: .18rem;
}

.history-sorteo-link:hover,
.history-sorteo-link:focus-visible {
  color: var(--blue-main);
}

.draw-summary-grid {
  display: grid;
  gap: .75rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.draw-summary-grid .draw-summary-item:first-child {
  grid-column: 1 / -1;
}

.draw-summary-item {
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: .75rem;
}

.number-analysis {
  border-top: 1px solid var(--app-border);
  padding-top: 1rem;
}

@media (max-width: 768px) {
  main.container-fluid {
    padding-left: .75rem;
    padding-right: .75rem;
  }

  .app-panel,
  .metric-card,
  .position-card {
    padding: .85rem;
  }

  .floating-actions {
    bottom: 1rem;
    right: 1rem;
  }

  .floating-action {
    height: 3rem;
    width: 3rem;
  }

  .number-picker {
    gap: .45rem;
    grid-template-columns: repeat(var(--cartilla-columns), 1fr);
  }

  .plays-table-wrap {
    overflow: visible;
  }

  .sample-history-filters {
    grid-template-columns: 1fr;
  }

  .sample-history-filter-actions,
  .sample-history-filter-actions .btn {
    width: 100%;
  }

  .plays-table {
    border-collapse: separate;
    border-spacing: 0 .75rem;
  }

  .plays-table thead {
    display: none;
  }

  .plays-table tbody,
  .plays-table tr,
  .plays-table td {
    display: block;
  }

  .plays-table tr {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 10px;
    padding: .8rem;
  }

  .plays-table tr + tr {
    margin-top: .75rem;
  }

  .plays-table td {
    border: 0;
    padding: .25rem 0;
  }

  .plays-table td::before {
    color: var(--app-muted);
    content: attr(data-label);
    display: block;
    font-size: .75rem;
    font-weight: 700;
    margin-bottom: .15rem;
  }

  .plays-table td[data-label="Bolillas"] {
    padding-bottom: .45rem;
  }

  .plays-table td[data-label="Bolillas"]::before {
    margin-bottom: .35rem;
  }

  .plays-table .plays-ball-list {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    max-width: 100%;
  }

  .plays-table .sample-ball {
    height: 2rem;
    min-width: 2rem;
    width: 2rem;
  }

  .plays-table td[data-label="Fecha"],
  .plays-table td[data-label="Pares"],
  .plays-table td[data-label="Impares"],
  .plays-table td[data-label="Amplitud"],
  .plays-table td[data-label="Status"],
  .plays-table td[data-label="Acciones"] {
    align-items: center;
    display: grid;
    grid-template-columns: 5.25rem minmax(0, 1fr);
    gap: .5rem;
  }

  .plays-table td[data-label="Fecha"]::before,
  .plays-table td[data-label="Pares"]::before,
  .plays-table td[data-label="Impares"]::before,
  .plays-table td[data-label="Amplitud"]::before,
  .plays-table td[data-label="Status"]::before,
  .plays-table td[data-label="Acciones"]::before {
    margin-bottom: 0;
  }

  .plays-table td[data-label="Acciones"] {
    text-align: left !important;
  }

  .plays-table td[data-label="Acciones"] .btn {
    justify-self: start;
    min-width: 2.25rem;
  }

  .plays-table .plays-action-list {
    justify-content: flex-start;
  }

  .random-criteria-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .advanced-filter-grid {
    grid-template-columns: 1fr;
  }

  .advanced-filter-card .row > [class*="col-"] {
    flex: 0 0 100%;
    max-width: 100%;
    width: 100%;
  }

  .transition-position-sequence-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .transition-ranking-summary {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .transition-position-sequence-row .transition-ranking-meter {
    grid-column: 1 / -1;
  }

  .transition-ranking-summary .transition-ranking-meter {
    grid-column: 1 / -1;
  }

  .draw-summary-grid.sample-history-summary {
    gap: .45rem;
  }

  .sample-history-summary .draw-summary-item {
    padding: .55rem;
  }

  .sample-history-summary .sample-ball {
    min-width: 1.85rem;
    padding: .2rem .4rem;
  }

  .probability-cell,
  .range-probability {
    min-width: 8.5rem;
  }

  .matrix-percent-cell {
    min-width: 7rem;
  }

  .signal-group {
    min-width: 10rem;
  }

  .transition-ranking-row {
    grid-template-columns: 2.5rem minmax(6rem, 1fr);
  }

  .transition-ranking-meter {
    grid-column: 1 / -1;
  }

  .transition-chip-list {
    min-width: 14rem;
  }

  .transition-number-groups {
    grid-template-columns: 1fr;
  }

  .cartilla-number-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
  }

  .cartilla-frequency-table table,
  .cartilla-frequency-table tbody,
  .cartilla-frequency-table tr,
  .cartilla-frequency-table td {
    display: block;
    width: 100%;
  }

  .cartilla-frequency-table thead {
    display: none;
  }

  .cartilla-frequency-row {
    border: 1px solid var(--app-border);
    border-radius: 8px;
    margin-bottom: .75rem;
    padding: .65rem;
  }

  .cartilla-frequency-row td {
    border-bottom: 0;
    padding: 0;
  }

  .cartilla-frequency-row td:first-child {
    margin-bottom: .55rem;
  }

  .cartilla-number-cell {
    min-width: 0;
  }

  .cartilla-number-cell .sample-ball {
    flex: 0 0 auto;
  }

  .joint-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 769px) and (max-width: 991px) {
  .transition-number-groups {
    grid-template-columns: 1fr;
  }

  .transition-number-card {
    width: 100%;
  }

  .transition-position-sequence-row {
    align-items: start;
    grid-template-columns: auto minmax(0, 1fr);
  }

  .transition-ranking-summary {
    align-items: start;
    grid-template-columns: auto minmax(0, 1fr);
  }

  .transition-position-sequence-row .transition-ranking-meter {
    grid-column: 2;
    min-width: 0;
    width: 100%;
  }

  .transition-ranking-summary .transition-ranking-meter {
    grid-column: 2;
    min-width: 0;
    width: 100%;
  }

  .position-sequence-chip-list {
    flex-wrap: nowrap;
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: .15rem;
  }

  .position-sequence-chip {
    flex: 0 0 auto;
    min-width: 4.6rem;
    text-align: center;
  }
}

@media (max-width: 420px) {
  .cartilla-number-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 577px) and (max-width: 991px) {
  .joint-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
/* Transicion: desglose expandible de patrones P/I */
.transition-position-sequence-row {
  cursor: pointer;
  grid-template-columns: 1fr;
  min-width: 0;
}

.transition-position-sequence-row.is-expanded {
  align-items: stretch;
  cursor: default;
}

.transition-position-sequence-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(180px, 0.9fr);
  gap: 1rem;
  align-items: center;
  width: 100%;
  min-width: 0;
}

.pattern-expanded-detail {
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--app-border);
}

.pattern-detail-toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.pattern-detail-toolbar > div,
.pattern-limit-control,
.pattern-temporal-grid,
.pattern-structure-row,
.pattern-window-list > div {
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background: var(--app-bg);
  padding: 0.75rem;
}

.pattern-limit-control {
  display: grid;
  gap: 0.35rem;
}

.pattern-limit-control span {
  color: var(--app-muted);
  font-size: 0.8rem;
}

.pattern-profile-table {
  overflow-x: auto;
  border: 1px solid var(--app-border);
  border-radius: 8px;
}

.pattern-profile-head,
.pattern-profile-row {
  display: grid;
  grid-template-columns: 0.7fr 0.8fr 1.35fr 1.35fr 1.2fr;
  min-width: 760px;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--app-border);
}

.pattern-profile-row small {
  color: var(--app-muted);
  display: block;
  font-size: .78rem;
  margin-top: .15rem;
}

.pattern-profile-head {
  color: var(--app-text);
  font-weight: 700;
}

.pattern-profile-row:last-child {
  border-bottom: 0;
}

.pattern-profile-detail {
  display: block;
}

.pattern-profile-detail > summary {
  cursor: pointer;
  list-style: none;
}

.pattern-profile-detail > summary::-webkit-details-marker {
  display: none;
}

.pattern-profile-detail[open] > .pattern-profile-row {
  background: var(--app-bg);
}

.pattern-profile-inline-detail {
  border-bottom: 1px solid var(--app-border);
  padding: .85rem;
}

.pattern-position-list {
  display: grid;
  gap: 0.5rem;
}

.pattern-position-detail {
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background: var(--app-bg);
  overflow: hidden;
}

.pattern-position-detail summary {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.pattern-position-body {
  padding: 0 0.75rem 0.75rem;
}

.pattern-range-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.pattern-range-detail {
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 0.5rem;
  background: var(--app-surface);
}

.pattern-range-detail summary,
.pattern-structure-row,
.pattern-history-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}

.pattern-number-mini-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.pattern-number-mini-list span {
  border: 1px solid var(--app-border);
  border-radius: 999px;
  padding: 0.15rem 0.45rem;
  font-size: 0.8rem;
}

.pattern-structure-list,
.pattern-window-list,
.pattern-history-list {
  display: grid;
  gap: 0.5rem;
}

.pattern-temporal-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 0.45rem 0.75rem;
}

.pattern-temporal-grid span {
  color: var(--app-muted);
}

.pattern-window-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pattern-section-detail {
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background: var(--app-bg);
  padding: .75rem;
}

.pattern-section-detail > summary {
  cursor: pointer;
  font-weight: 700;
}

.pattern-structure-card {
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background: var(--app-surface);
  display: grid;
  gap: .65rem;
  padding: .75rem;
}

.pattern-structure-grid {
  display: grid;
  grid-template-columns: repeat(var(--cartilla-columns), minmax(0, 1fr));
  gap: .35rem;
}

.pattern-structure-grid div {
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: .4rem;
  text-align: center;
}

.pattern-structure-grid span,
.pattern-comparison-card span {
  color: var(--app-muted);
  display: block;
  font-size: .75rem;
}

.pattern-comparison-cards {
  display: none;
}

.pattern-history-row {
  border-bottom: 1px solid var(--app-border);
  padding: 0.45rem 0;
}

.pattern-history-row:last-child {
  border-bottom: 0;
}

.pattern-history-row > span:last-child {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

@media (max-width: 991.98px) {
  .transition-position-sequence-summary {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .transition-position-sequence-summary .transition-ranking-meter {
    grid-column: 2;
  }

  .pattern-detail-toolbar,
  .pattern-window-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 575.98px) {
  .transition-position-sequence-summary {
    grid-template-columns: 1fr;
  }

  .transition-position-sequence-summary .transition-rank,
  .transition-position-sequence-summary .transition-ranking-meter {
    grid-column: auto;
  }

  .pattern-detail-toolbar,
  .pattern-range-list,
  .pattern-window-list {
    grid-template-columns: 1fr;
  }

  .pattern-profile-table {
    overflow: visible;
    border: 0;
  }

  .pattern-profile-head {
    display: none;
  }

  .pattern-profile-row {
    min-width: 0;
    grid-template-columns: 1fr;
    gap: .45rem;
    margin-bottom: .6rem;
    padding: .7rem;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: var(--app-bg);
  }

  .pattern-profile-row span {
    display: grid;
    gap: .1rem;
    min-width: 0;
    word-break: break-word;
  }

  .pattern-profile-row span::before {
    color: var(--app-muted);
    font-size: .75rem;
    font-weight: 600;
  }

  .pattern-profile-row span:nth-child(1)::before { content: "Posicion"; }
  .pattern-profile-row span:nth-child(2)::before { content: "Par / Impar"; }
  .pattern-profile-row span:nth-child(3)::before { content: "Rango mas frecuente"; }
  .pattern-profile-row span:nth-child(4)::before { content: "Segundo rango"; }
  .pattern-profile-row span:nth-child(5)::before { content: "Numero mas frecuente"; }

  .pattern-profile-inline-detail {
    border: 1px solid var(--app-border);
    border-top: 0;
    border-radius: 0 0 8px 8px;
    margin-top: -.6rem;
  }

  .pattern-comparison-table {
    display: none;
  }

  .pattern-comparison-cards {
    display: grid;
    gap: .5rem;
  }

  .pattern-comparison-card {
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: var(--app-surface);
    display: grid;
    gap: .5rem;
    padding: .7rem;
  }

  .pattern-structure-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pattern-temporal-grid {
    grid-template-columns: 1fr;
  }

  .pattern-position-detail summary,
  .pattern-range-detail summary,
  .pattern-structure-row,
  .pattern-history-row {
    align-items: flex-start;
    flex-direction: column;
  }
}

.analysis-disclaimer,
.analysis-interpretation,
.analysis-note {
  background: var(--app-bg);
  border-left: 4px solid var(--blue-main);
  border-radius: 6px;
  color: var(--app-text);
  line-height: 1.55;
  padding: .75rem .9rem;
}

.analysis-header-summary {
  display: grid;
  gap: .45rem;
  grid-template-columns: repeat(auto-fit, minmax(8.4rem, 1fr));
}

.analysis-export-json {
  background: var(--app-bg);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  margin: 0;
  max-height: 60vh;
  overflow: auto;
  padding: .85rem;
}

.analysis-export-json code {
  color: var(--app-text);
  font-size: .8rem;
  white-space: pre;
}

@media (max-width: 768px) {
  .analysis-export-json {
    max-height: 50vh;
  }

  .analysis-export-json code {
    font-size: .72rem;
  }
}

.analysis-header-summary span {
  background: var(--app-bg);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  display: grid;
  gap: .12rem;
  min-width: 0;
  padding: .45rem .55rem;
  line-height: 1.3;
  font-size: .87rem;
}

.analysis-header-summary b {
  color: var(--app-muted);
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.analysis-header-summary span.is-simulated {
  background: #fff8e1;
  border-color: #ffc107;
}

body[data-theme="dark"] .analysis-header-summary span.is-simulated {
  background: rgba(255, 193, 7, .14);
  border-color: #ffc107;
}

.analysis-filter-panel .form-label {
  font-weight: 700;
}

.analysis-date-input {
  cursor: pointer;
}

.analysis-date-input::-webkit-calendar-picker-indicator {
  cursor: pointer;
}

body[data-theme="dark"] .analysis-date-input::-webkit-calendar-picker-indicator {
  filter: invert(1);
  opacity: .85;
}

.analysis-kpi {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-left: 4px solid var(--blue-main);
  border-radius: 8px;
  display: grid;
  gap: .25rem;
  min-height: 100%;
  padding: .7rem .75rem;
}

.analysis-kpi span {
  color: var(--app-muted);
  font-size: .66rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.analysis-kpi strong {
  color: var(--app-text);
  font-size: 1rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.analysis-context-grid {
  display: grid;
  gap: .45rem;
  grid-template-columns: repeat(auto-fit, minmax(7.8rem, 1fr));
}

.analysis-context-grid span {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  display: grid;
  gap: .12rem;
  padding: .55rem .6rem;
  line-height: 1.3;
  font-size: .84rem;
}

.analysis-context-grid b {
  color: var(--app-muted);
  font-size: .62rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.analysis-series-panel {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: .85rem;
}

.analysis-series-panel summary {
  cursor: pointer;
  font-size: 1rem;
  font-weight: 900;
}

.analysis-series-toolbar {
  display: grid;
  gap: .75rem;
  grid-template-columns: repeat(2, minmax(0, 14rem));
  margin: .9rem 0;
}

.analysis-series-toolbar label {
  color: var(--app-muted);
  display: grid;
  font-size: .82rem;
  font-weight: 700;
  gap: .25rem;
}

.analysis-series-grid {
  display: grid;
  gap: .65rem;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
}

.analysis-ranking-grid {
  display: grid;
  gap: .55rem;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
}

.analysis-series-grid span,
.analysis-ranking-grid span {
  background: var(--app-bg);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  display: grid;
  gap: .25rem;
  min-height: 5.25rem;
  padding: .7rem;
}

.analysis-series-grid b,
.analysis-ranking-grid b {
  align-items: center;
  color: var(--app-muted);
  display: flex;
  font-size: .78rem;
  gap: .3rem;
}

.analysis-series-grid i {
  align-items: center;
  border: 1px solid var(--app-border);
  border-radius: 50%;
  display: inline-flex;
  font-size: .65rem;
  font-style: normal;
  height: 1rem;
  justify-content: center;
  width: 1rem;
}

.analysis-series-grid strong,
.analysis-ranking-grid strong {
  color: var(--app-text);
  font-size: 1.15rem;
}

.analysis-series-grid small,
.analysis-ranking-grid small {
  color: var(--app-muted);
  font-size: .75rem;
}

.analysis-chart {
  overflow-x: auto;
  padding-bottom: .25rem;
}

.analysis-chart-canvas {
  height: 23rem;
  position: relative;
  width: 100%;
}

.analysis-chart-canvas-tall {
  height: 28rem;
}

.analysis-chart-canvas-square {
  height: 26rem;
}

.analysis-chart-canvas canvas {
  max-width: 100%;
}

.analysis-sequence-overview-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.analysis-sequence-overview-grid-single-column {
  grid-template-columns: 1fr;
}

.analysis-sequence-overview-card {
  background: var(--app-bg);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  min-width: 0;
  padding: .85rem;
}

.analysis-sequence-overview-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .65rem;
}

.analysis-sequence-overview-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
}

.analysis-sequence-overview-control-label {
  align-items: center;
  color: var(--app-muted);
  display: inline-flex;
  gap: .45rem;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
  margin: 0;
  text-transform: uppercase;
}

.analysis-inline-sequence-select {
  min-width: 7.5rem;
  width: auto;
}

.analysis-sequence-overview-card h3 {
  color: var(--app-text);
  font-size: 1rem;
  font-weight: 900;
  margin: 0;
}

.analysis-sequence-overview-card .analysis-chart-canvas,
.analysis-sequence-overview-card .analysis-chart-canvas-tall,
.analysis-sequence-overview-card .analysis-chart-canvas-square {
  height: 18rem;
}


.analysis-line-grid {
  display: grid;
  gap: .75rem;
  min-width: 0;
  width: 100%;
}

.analysis-line-series {
  align-items: center;
  display: grid;
  gap: .65rem;
  grid-template-columns: minmax(3.5rem, 6rem) minmax(0, 1fr);
  width: 100%;
}

.analysis-chart-legend {
  color: var(--app-text);
  font-size: .86rem;
  font-weight: 800;
}

.analysis-sequence-legend {
  align-items: center;
  background: var(--app-bg);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: .45rem .65rem;
  margin-top: .85rem;
  padding: .65rem .75rem;
}

.analysis-sequence-legend-group {
  align-items: center;
  display: inline-flex;
  flex-wrap: wrap;
  gap: .45rem .55rem;
}

.analysis-sequence-legend-title {
  color: var(--app-muted);
  font-size: .78rem;
  font-weight: 900;
  margin-right: .15rem;
  text-transform: uppercase;
}

.analysis-sequence-legend-item {
  align-items: center;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 999px;
  color: var(--app-text);
  display: inline-flex;
  font-size: .82rem;
  gap: .35rem;
  padding: .28rem .55rem;
}

.analysis-sequence-legend-item i {
  border-radius: 999px;
  display: inline-block;
  height: .75rem;
  width: .75rem;
}

.analysis-run-selected {
  border-left: 3px solid var(--blue-main);
  display: grid;
  gap: .1rem;
  margin-top: .85rem;
  padding: .1rem 0 .1rem .75rem;
}

.analysis-run-selected span {
  color: var(--app-muted);
  font-size: .76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.analysis-run-selected strong {
  color: var(--app-text);
  font-size: .9rem;
  line-height: 1.15;
}

.analysis-run-selected small {
  color: var(--app-muted);
  font-size: .78rem;
}

.analysis-run-nav {
  display: flex;
  gap: .5rem;
  width: 100%;
}

.analysis-run-nav .btn {
  flex: 1 1 0;
  font-size: .85rem;
  font-weight: 700;
  padding: .3rem 1rem;
}

@media (max-width: 576px) {
  .run-analysis-grid {
    gap: .7rem;
  }

  .run-transition-grid {
    grid-template-columns: 1fr;
  }

  .analysis-table-panel {
    padding: .7rem;
  }

  .analysis-table-panel .table-responsive {
    margin-inline: -.15rem;
    width: calc(100% + .3rem);
  }

  .analysis-table-panel .app-table {
    font-size: .88rem;
    min-width: 36rem;
  }

  .analysis-table-panel .app-table thead th,
  .analysis-table-panel .app-table tbody th,
  .analysis-table-panel .app-table tbody td {
    padding: .48rem .55rem;
    white-space: nowrap;
  }

  .analysis-sequence-legend {
    align-items: stretch;
  }

  .analysis-sequence-legend-group,
  .analysis-run-nav {
    width: 100%;
  }

  .analysis-run-nav .btn {
    flex: 1 1 0;
  }

}

.analysis-amplitude-table tbody tr.analysis-amplitude-high > * {
  background: rgba(25, 135, 84, .12);
  color: var(--app-text);
}

.analysis-amplitude-table tbody tr.analysis-amplitude-low > * {
  background: rgba(220, 53, 69, .1);
  color: var(--app-text);
}

.analysis-amplitude-table tbody tr.analysis-amplitude-normal > * {
  background: transparent;
}

body[data-theme="dark"] .analysis-amplitude-table tbody tr.analysis-amplitude-high > * {
  background: rgba(45, 212, 137, .16);
}

body[data-theme="dark"] .analysis-amplitude-table tbody tr.analysis-amplitude-low > * {
  background: rgba(244, 63, 94, .14);
}

.run-analysis-grid {
  display: grid;
  gap: .85rem;
  max-width: 100%;
  min-width: 0;
}

.run-transition-grid {
  display: grid;
  gap: .6rem;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
}

.run-transition-card {
  background: var(--app-bg);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  display: grid;
  gap: .2rem;
  padding: .75rem;
}

.run-transition-card b,
.run-history-row.is-active td,
.run-history-row.is-active th {
  color: var(--blue-main);
}

.run-transition-card strong {
  color: var(--app-text);
  font-size: 1.05rem;
}

.run-transition-card small {
  color: var(--app-muted);
}

.run-history-row {
  cursor: pointer;
}

.run-history-row.is-active > * {
  background: rgba(13, 110, 253, .12);
}

body[data-theme="dark"] .run-history-row.is-active > * {
  background: rgba(96, 165, 250, .16);
}

.analysis-line-points {
  align-items: end;
  background: linear-gradient(to top, transparent 24%, rgba(125, 140, 165, .15) 25%, transparent 26%, transparent 49%, rgba(125, 140, 165, .15) 50%, transparent 51%, transparent 74%, rgba(125, 140, 165, .15) 75%, transparent 76%);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  display: grid;
  gap: .2rem;
  grid-auto-flow: column;
  height: 8rem;
  padding: .45rem;
}

.analysis-line-point {
  align-items: end;
  display: flex;
  height: 100%;
  min-width: 1rem;
}

.analysis-line-point span {
  background: linear-gradient(180deg, var(--series-color), #38d9c4);
  border-radius: 999px 999px 0 0;
  display: block;
  min-height: 3px;
  width: 100%;
}

.analysis-axis-labels {
  color: var(--app-muted);
  display: grid;
  font-size: .75rem;
  grid-auto-flow: column;
  margin-left: 8.65rem;
  min-width: 33rem;
  text-align: center;
}

.analysis-grouped-chart {
  display: grid;
  gap: .85rem;
}

.analysis-grouped-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem .85rem;
}

.analysis-grouped-legend span {
  align-items: center;
  color: var(--app-text);
  display: inline-flex;
  font-size: .82rem;
  font-weight: 800;
  gap: .35rem;
}

.analysis-grouped-legend i {
  border-radius: 999px;
  display: inline-block;
  height: .7rem;
  width: .7rem;
}

.analysis-grouped-scroll {
  overflow-x: auto;
  padding-bottom: .35rem;
}

.analysis-grouped-grid {
  align-items: end;
  background:
    linear-gradient(to top, transparent 24%, rgba(125, 140, 165, .15) 25%, transparent 26%),
    linear-gradient(to top, transparent 49%, rgba(125, 140, 165, .15) 50%, transparent 51%),
    linear-gradient(to top, transparent 74%, rgba(125, 140, 165, .15) 75%, transparent 76%);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  display: grid;
  gap: .7rem;
  grid-template-columns: repeat(var(--period-count), minmax(6.8rem, 1fr));
  min-height: 19rem;
  min-width: max(46rem, calc(var(--period-count) * 7rem));
  padding: .9rem .9rem .7rem;
}

.analysis-grouped-period {
  display: grid;
  gap: .5rem;
  min-height: 100%;
}

.analysis-grouped-bars {
  align-items: end;
  display: grid;
  gap: .16rem;
  grid-template-columns: repeat(var(--series-count), minmax(.35rem, 1fr));
  height: 15rem;
}

.analysis-grouped-bars span {
  background: linear-gradient(180deg, var(--bar-color), #38d9c4);
  border-radius: 999px 999px 0 0;
  box-shadow: 0 -8px 18px rgba(255, 255, 255, .08) inset;
  display: block;
  min-height: 2px;
}

.analysis-grouped-period strong {
  color: var(--app-muted);
  font-size: .78rem;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.analysis-bars,
.analysis-divergent {
  display: grid;
  gap: .7rem;
}

.analysis-bar-row,
.analysis-divergent-row {
  align-items: center;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  display: grid;
  gap: .75rem;
  grid-template-columns: minmax(7rem, .75fr) minmax(0, 2fr) auto;
  padding: .7rem;
}

.analysis-bar-line {
  align-items: center;
  display: grid;
  gap: .45rem;
  grid-template-columns: 5rem minmax(0, 1fr) 4rem;
}

.analysis-bar-line i {
  background: linear-gradient(90deg, #60a5fa, #34d399);
  border-radius: 999px;
  display: block;
  height: .45rem;
}

.analysis-bar-line-b i {
  background: linear-gradient(90deg, #f59e0b, #facc15);
}

.analysis-positive {
  color: #00875a !important;
  font-weight: 900;
}

.analysis-negative {
  color: #dc3545 !important;
  font-weight: 900;
}

.analysis-heatmap {
  display: grid;
  gap: .35rem;
  grid-template-columns: minmax(7rem, 1fr) repeat(var(--analysis-columns), minmax(5.5rem, 1fr));
  overflow-x: auto;
}

.analysis-heatmap-head,
.analysis-heatmap-label,
.analysis-heatmap-cell {
  border: 1px solid var(--app-border);
  border-radius: 6px;
  padding: .55rem;
}

.analysis-heatmap-head,
.analysis-heatmap-label {
  color: var(--app-text);
  font-weight: 900;
}

.analysis-heatmap-cell {
  background: color-mix(in srgb, #20c997 calc(var(--heat) * 100%), var(--app-surface));
  color: var(--app-text);
  font-weight: 800;
  text-align: center;
  cursor: pointer;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.analysis-heatmap-cell:hover,
.analysis-heatmap-cell.is-selected {
  border-color: var(--blue-main);
  box-shadow: 0 0 0 3px rgba(13, 110, 253, .2);
  transform: translateY(-1px);
}

.analysis-cell-panel {
  background: linear-gradient(180deg, var(--app-surface), color-mix(in srgb, var(--app-surface) 88%, var(--blue-light)));
  border: 1px solid var(--app-border);
  border-left: 4px solid var(--blue-main);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .06);
  padding: .9rem;
}

.analysis-cell-head {
  align-items: start;
  background: color-mix(in srgb, var(--blue-light) 52%, transparent);
  border: 1px solid color-mix(in srgb, var(--blue-main) 22%, var(--app-border));
  border-radius: 8px;
  display: flex;
  gap: .75rem;
  justify-content: space-between;
  margin-bottom: .8rem;
  padding: .75rem;
}

.analysis-cell-kpis,
.analysis-position-breakdown,
.analysis-cell-table {
  display: grid;
  gap: .5rem;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
}

.analysis-cell-kpis span,
.analysis-position-breakdown span,
.analysis-cell-table span {
  background: var(--app-bg);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  display: grid;
  gap: .18rem;
  min-height: 4.25rem;
  padding: .6rem .7rem;
  position: relative;
}

.analysis-cell-kpis span::before,
.analysis-cell-table span::before {
  background: linear-gradient(180deg, #60a5fa, #2dd4bf);
  border-radius: 999px;
  bottom: .55rem;
  content: "";
  left: .45rem;
  position: absolute;
  top: .55rem;
  width: 3px;
}

.analysis-cell-kpis span.is-primary,
.analysis-cell-table span.is-top {
  background: color-mix(in srgb, #10b981 12%, var(--app-bg));
  border-color: color-mix(in srgb, #10b981 45%, var(--app-border));
}

.analysis-cell-kpis span.is-positive strong {
  color: #047857;
}

.analysis-cell-kpis span.is-negative strong {
  color: #dc2626;
}

.analysis-cell-kpis b,
.analysis-position-breakdown b,
.analysis-cell-table b {
  color: var(--app-muted);
  font-size: .76rem;
}

.analysis-cell-kpis strong,
.analysis-position-breakdown strong,
.analysis-cell-table strong {
  color: var(--app-text);
  font-size: 1.05rem;
  font-weight: 900;
  line-height: 1.15;
}

.analysis-cell-kpis small,
.analysis-position-breakdown small,
.analysis-cell-table small {
  color: var(--app-muted);
  font-size: .76rem;
}

.analysis-period-compare {
  display: grid;
  gap: .5rem;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
}

.analysis-period-compare span {
  background: var(--app-bg);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  display: grid;
  gap: .2rem;
  padding: .65rem;
  text-align: center;
}

.analysis-period-compare span.is-selected {
  background: color-mix(in srgb, var(--blue-main) 10%, var(--app-bg));
  border-color: var(--blue-main);
  box-shadow: inset 0 0 0 1px var(--blue-main);
}

.analysis-section-detail {
  background: var(--app-bg);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  overflow: hidden;
  padding: 0;
}

.analysis-section-detail summary {
  align-items: center;
  background: color-mix(in srgb, var(--blue-light) 34%, transparent);
  cursor: pointer;
  display: flex;
  gap: .5rem;
  font-weight: 900;
  justify-content: space-between;
  padding: .7rem .8rem;
}

.analysis-section-detail summary::after {
  color: var(--app-muted);
  content: "Abrir";
  font-size: .72rem;
  font-weight: 800;
}

.analysis-section-detail[open] summary::after {
  content: "Cerrar";
}

.analysis-section-detail > :not(summary) {
  margin: .75rem;
}

.analysis-table-panel {
  max-width: 100%;
  min-width: 0;
  padding: .95rem;
}

.analysis-table-panel .section-heading {
  margin-bottom: .65rem;
}

.analysis-table-panel .table-responsive {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  max-width: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.analysis-table-panel .app-table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--app-text);
  min-width: 34rem;
}

.analysis-table-panel .app-table thead th {
  background: color-mix(in srgb, var(--blue-light) 42%, var(--app-surface));
  border-bottom: 1px solid var(--app-border);
  color: var(--blue-dark);
  font-size: .78rem;
  letter-spacing: .01em;
  padding: .65rem .75rem;
  position: sticky;
  text-transform: uppercase;
  top: 0;
  z-index: 1;
}

.analysis-table-panel .app-table tbody th,
.analysis-table-panel .app-table tbody td {
  border-color: var(--app-border);
  padding: .58rem .75rem;
  vertical-align: middle;
}

.analysis-table-panel .app-table tbody tr:hover {
  background: color-mix(in srgb, var(--blue-light) 20%, transparent);
}

.analysis-detail-panel {
  padding: 0;
}

.analysis-detail-panel .analysis-section-detail {
  background: transparent;
  border: 0;
}

.analysis-detail-panel .analysis-section-detail summary {
  border-radius: 8px;
  margin: .9rem;
}

.analysis-detail-panel .analysis-section-detail[open] summary {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  margin-bottom: 0;
}

.analysis-detail-panel .analysis-section-detail > :not(summary) {
  margin: .9rem;
}

.analysis-position-breakdown span small {
  display: flex;
  gap: .35rem;
  justify-content: space-between;
}

.analysis-position-breakdown span small em {
  color: var(--app-muted);
  font-style: normal;
  font-weight: 700;
}

.analysis-draw-detail {
  border-bottom: 1px solid var(--app-border);
  padding: .55rem 0;
}

.analysis-draw-detail summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: .75rem;
  justify-content: space-between;
}

.analysis-draw-detail-grid {
  display: grid;
  gap: .5rem;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  margin-top: .55rem;
}

.analysis-draw-detail-grid span {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  display: grid;
  padding: .55rem;
}

.analysis-timeline {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.analysis-timeline span {
  align-items: center;
  display: inline-flex;
  gap: .25rem;
}

.analysis-sequence-nav {
  align-items: center;
  background: var(--app-bg);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  display: grid;
  gap: .75rem;
  grid-template-columns: auto minmax(0, 1fr) auto minmax(10rem, 13rem);
  margin-top: .85rem;
  padding: .75rem;
}

.analysis-sequence-nav-top {
  margin-bottom: .85rem;
  margin-top: 0;
}

.analysis-sequence-nav-info {
  color: var(--app-text);
  display: grid;
  gap: .15rem;
  text-align: center;
}

.analysis-sequence-nav-info strong {
  font-size: .95rem;
}

.analysis-sequence-nav-info span {
  color: var(--app-muted);
  font-size: .82rem;
}

.analysis-sequence-step {
  display: grid;
  gap: .25rem;
  margin: 0;
}

.analysis-sequence-step span,
.analysis-sequence-step small {
  color: var(--app-muted);
  font-size: .78rem;
  font-weight: 700;
}

.analysis-divergent-track {
  background: var(--blue-light);
  border-radius: 999px;
  display: flex;
  height: .55rem;
  justify-content: center;
  overflow: hidden;
}

.analysis-divergent-left {
  background: #dc3545;
  border-radius: 999px 0 0 999px;
}

.analysis-divergent-right {
  background: #198754;
  border-radius: 0 999px 999px 0;
}

.analysis-scatter {
  aspect-ratio: 16 / 9;
  background: var(--app-bg);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  min-height: 18rem;
  position: relative;
}

.analysis-scatter-diagonal {
  background: rgba(13, 110, 253, .35);
  height: 2px;
  left: 4%;
  position: absolute;
  right: 4%;
  top: 50%;
  transform: rotate(-29deg);
  transform-origin: center;
}

.analysis-scatter-point {
  align-items: center;
  background: var(--blue-mid);
  border: 1px solid #7ab8ff;
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  font-size: .75rem;
  font-weight: 800;
  height: 1.8rem;
  justify-content: center;
  min-width: 1.8rem;
  padding: 0 .35rem;
  position: absolute;
  transform: translate(-50%, 50%);
}

.analysis-mini-grid,
.analysis-number-strip {
  display: grid;
  gap: .45rem;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
}

.analysis-mini-grid span,
.analysis-number-strip span {
  background: var(--app-bg);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  display: flex;
  gap: .45rem;
  justify-content: space-between;
  padding: .45rem .6rem;
}

.analysis-mini-grid em,
.analysis-number-strip em {
  color: var(--app-text);
  font-style: normal;
  font-weight: 900;
}

.analysis-number-strip-stacked span {
  align-items: flex-start;
  flex-direction: column;
  justify-content: center;
  min-height: 3.75rem;
}

.analysis-number-strip-stacked b {
  font-size: .95rem;
  line-height: 1.15;
}

.analysis-number-strip-stacked em {
  color: var(--app-muted);
  font-size: .76rem;
  line-height: 1.15;
}

.analysis-drill-summary {
  align-items: center;
  display: grid;
  gap: .5rem;
  grid-template-columns: minmax(4.5rem, .6fr) minmax(7rem, 1fr) minmax(4rem, .5fr) minmax(5rem, .8fr);
  width: 100%;
}

.analysis-drill-summary strong {
  font-weight: 900;
}

.analysis-drill-summary span {
  color: var(--app-muted);
  font-size: .85rem;
  font-weight: 700;
}

.analysis-drill-note {
  background: var(--app-bg);
  border-left: 4px solid var(--blue-main);
  border-radius: 6px;
  color: var(--app-muted);
  font-size: .88rem;
  line-height: 1.45;
  margin-bottom: .85rem;
  padding: .65rem .75rem;
}

.analysis-subtitle {
  color: var(--app-text);
  font-size: .9rem;
  font-weight: 900;
  margin: 0 0 .5rem;
}

.analysis-helper-text {
  color: var(--app-muted);
  font-size: .8rem;
  line-height: 1.35;
  margin: -.25rem 0 .55rem;
}

.analysis-top-cell {
  background: rgba(25, 135, 84, .14) !important;
  border-color: rgba(25, 135, 84, .55) !important;
}

.analysis-top-cell em,
.analysis-top-cell b {
  color: #00875a;
}

.analysis-empty {
  border: 1px dashed var(--app-border);
  border-radius: 8px;
  color: var(--app-muted);
  padding: 1rem;
  text-align: center;
}

.analysis-accordion-item {
  background: var(--app-surface);
  border-color: var(--app-border);
  color: var(--app-text);
}

body[data-theme="dark"] .analysis-positive {
  color: #64f4ac !important;
}

body[data-theme="dark"] .analysis-negative {
  color: #fb7185 !important;
}

body[data-theme="dark"] .analysis-heatmap-cell {
  background: color-mix(in srgb, #10b981 calc(var(--heat) * 72%), #102033);
  color: #f8fafc;
}

body[data-theme="dark"] .analysis-disclaimer,
body[data-theme="dark"] .analysis-interpretation,
body[data-theme="dark"] .analysis-note,
body[data-theme="dark"] .analysis-drill-note,
body[data-theme="dark"] .analysis-scatter,
body[data-theme="dark"] .analysis-context-grid span,
body[data-theme="dark"] .analysis-series-panel,
body[data-theme="dark"] .analysis-series-grid span,
body[data-theme="dark"] .analysis-ranking-grid span,
body[data-theme="dark"] .analysis-cell-panel,
body[data-theme="dark"] .analysis-cell-kpis span,
body[data-theme="dark"] .analysis-position-breakdown span,
body[data-theme="dark"] .analysis-cell-table span,
body[data-theme="dark"] .analysis-period-compare span,
body[data-theme="dark"] .analysis-section-detail,
body[data-theme="dark"] .analysis-draw-detail-grid span,
body[data-theme="dark"] .analysis-mini-grid span,
body[data-theme="dark"] .analysis-number-strip span {
  background: #0f1b2c;
  color: #e5edf7;
}

body[data-theme="dark"] .analysis-top-cell {
  background: rgba(16, 185, 129, .22) !important;
  border-color: rgba(52, 211, 153, .55) !important;
}

body[data-theme="dark"] .analysis-top-cell em,
body[data-theme="dark"] .analysis-top-cell b {
  color: #64f4ac;
}

body[data-theme="dark"] .analysis-cell-panel {
  background: linear-gradient(180deg, #101d30, #0d1828);
  box-shadow: 0 16px 34px rgba(0, 0, 0, .24);
}

body[data-theme="dark"] .analysis-cell-head,
body[data-theme="dark"] .analysis-section-detail summary,
body[data-theme="dark"] .analysis-period-compare span.is-selected {
  background: #12304f;
  border-color: #315f93;
}

body[data-theme="dark"] .analysis-table-panel .table-responsive {
  background: #0f1b2c;
  border-color: #263b58;
}

body[data-theme="dark"] .analysis-table-panel .app-table {
  --bs-table-color: #e5edf7;
}

body[data-theme="dark"] .analysis-table-panel .app-table thead th {
  background: #12304f;
  border-color: #315f93;
  color: #e5edf7;
}

body[data-theme="dark"] .analysis-table-panel .app-table tbody th,
body[data-theme="dark"] .analysis-table-panel .app-table tbody td {
  border-color: #263b58;
}

body[data-theme="dark"] .analysis-table-panel .app-table tbody tr:hover {
  background: rgba(96, 165, 250, .1);
}

body[data-theme="dark"] .analysis-cell-kpis span.is-primary,
body[data-theme="dark"] .analysis-cell-table span.is-top {
  background: rgba(16, 185, 129, .16);
  border-color: rgba(52, 211, 153, .5);
}

body[data-theme="dark"] .analysis-cell-kpis span.is-positive strong {
  color: #6ee7b7;
}

body[data-theme="dark"] .analysis-cell-kpis span.is-negative strong {
  color: #fca5a5;
}

body[data-theme="dark"] .analysis-number-strip-stacked em {
  color: #b8c4d6;
}

@media (max-width: 767.98px) {
  .analysis-cell-panel {
    padding: .7rem;
  }

  .analysis-cell-head {
    flex-direction: column;
    padding: .65rem;
  }

  .analysis-cell-head .btn {
    width: 100%;
  }

  .analysis-cell-kpis,
  .analysis-period-compare,
  .analysis-position-breakdown,
  .analysis-cell-table {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .analysis-cell-kpis span,
  .analysis-position-breakdown span,
  .analysis-cell-table span,
  .analysis-period-compare span {
    min-height: auto;
    padding: .55rem .6rem;
  }

  .analysis-section-detail > :not(summary) {
    margin: .6rem;
  }

  .analysis-table-panel {
    padding: .7rem;
  }

  .analysis-table-panel .app-table thead th,
  .analysis-table-panel .app-table tbody th,
  .analysis-table-panel .app-table tbody td {
    padding: .5rem .55rem;
  }

  .analysis-detail-panel .analysis-section-detail summary,
  .analysis-detail-panel .analysis-section-detail > :not(summary) {
    margin: .7rem;
  }
}

@media (max-width: 420px) {
  .analysis-cell-kpis,
  .analysis-period-compare,
  .analysis-position-breakdown,
  .analysis-cell-table {
    grid-template-columns: 1fr;
  }
}

body[data-theme="dark"] .analysis-chart-canvas {
  color: #e5edf7;
}

@media (max-width: 767.98px) {
  .analysis-line-series,
  .analysis-bar-row,
  .analysis-divergent-row {
    grid-template-columns: 1fr;
  }

  .analysis-line-grid {
    min-width: 32rem;
  }

  .analysis-axis-labels {
    margin-left: 0;
    min-width: 32rem;
  }

  .analysis-bar-line {
    grid-template-columns: 3.8rem minmax(0, 1fr) 3.5rem;
  }

  .analysis-heatmap {
    grid-template-columns: minmax(5.5rem, .75fr) repeat(var(--analysis-columns), minmax(4.5rem, 1fr));
  }

  .analysis-drill-summary {
    align-items: flex-start;
    grid-template-columns: 1fr;
  }

  .analysis-mini-grid,
  .analysis-number-strip {
    grid-template-columns: 1fr;
  }

  .analysis-series-toolbar {
    grid-template-columns: 1fr;
  }

  .analysis-sequence-nav {
    grid-template-columns: 1fr 1fr;
  }

  .analysis-sequence-nav-info {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .analysis-sequence-step {
    grid-column: 1 / -1;
  }

  .analysis-grouped-grid {
    grid-template-columns: repeat(var(--period-count), minmax(5.8rem, 1fr));
    min-width: max(34rem, calc(var(--period-count) * 5.8rem));
  }

  .analysis-grouped-bars {
    height: 12rem;
  }

  .analysis-chart-canvas,
  .analysis-chart-canvas-tall,
  .analysis-chart-canvas-square {
    height: 20rem;
  }

  .analysis-sequence-overview-grid {
    grid-template-columns: 1fr;
  }

  .analysis-sequence-overview-card .analysis-chart-canvas,
  .analysis-sequence-overview-card .analysis-chart-canvas-tall,
  .analysis-sequence-overview-card .analysis-chart-canvas-square {
    height: 18rem;
  }
}
