* { box-sizing: border-box; }

:root {
  --brand-blue: #0066ca;
  --brand-sky: #3fa9f5;
  --brand-light: #e5f3ff;
  --brand-deep: #0b1d33;
  --text-main: #0f172a;
  --text-muted: #334155;
  --border-soft: rgba(0, 102, 202, 0.14);
  --surface: #ffffff;
  --surface-tint: #f8fbff;
  --shadow-soft: 0 14px 32px rgba(0, 102, 202, 0.1);
  --success-bg: #e8f7ef;
  --success-border: #b5e2c2;
  --success-text: #0b5d36;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at 10% 10%, #e5f3ff 0, #c8e7ff 18%, #f8fbff 55%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
}

.page {
  max-width: 1040px;
  width: 100%;
}

header {
  margin-bottom: 20px;
}

header h1 {
  font-size: 28px;
  margin: 0 0 6px;
}

.section-lead {
  margin: 0;
  color: var(--text-muted);
  font-size: 15px;
  max-width: 720px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.brand-logo {
  height: 44px;
  width: auto;
  filter: drop-shadow(0 8px 18px rgba(0,102,202,0.22));
}

header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-deep);
  margin-bottom: 10px;
}

.pill span.dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--brand-blue);
  box-shadow: 0 0 12px rgba(0,102,202,0.35);
}

.mobile-flow {
  display: none;
  margin-bottom: 16px;
  background: linear-gradient(135deg, rgba(0,102,202,0.08), rgba(63,169,245,0.12));
  border: 1px solid var(--border-soft);
}

.mobile-flow-title {
  font-weight: 700;
  margin: 0 0 10px;
  color: var(--brand-deep);
}

.mobile-flow-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mobile-flow-step {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.mobile-flow-icon {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid var(--border-soft);
  box-shadow: 0 10px 20px rgba(0,102,202,0.12);
}

.mobile-flow-step-title { font-weight: 700; margin: 0; }

.mobile-flow-text {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.mobile-step-switcher {
  display: none;
  gap: 8px;
  margin: 12px 0 6px;
}

.mobile-step-tab {
  width: 100%;
  border: 1px solid var(--border-soft);
  background: #f8fbff;
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 700;
  color: var(--brand-deep);
  box-shadow: 0 10px 20px rgba(0, 102, 202, 0.06);
  cursor: pointer;
}

.mobile-step-tab.active {
  background: linear-gradient(135deg, rgba(0,102,202,0.12), rgba(63,169,245,0.16));
  border-color: rgba(0,102,202,0.3);
  box-shadow: 0 12px 26px rgba(0,102,202,0.14);
}

.mobile-step-panel {
  width: 100%;
}

.mobile-step-panel[hidden] {
  display: none;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 24px;
}

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

@media (max-width: 860px) {
  body {
    padding: 16px 12px 28px;
    align-items: flex-start;
  }

  .card {
    padding: 20px 16px;
  }

  .mobile-flow {
    display: block;
  }

  .hero-actions {
    flex-direction: column;
    gap: 8px;
  }

  .hero-actions .link-button {
    width: 100%;
    justify-content: center;
  }

  .layout {
    gap: 12px;
  }

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

  .abc-form-grid {
    grid-template-columns: 1fr;
  }

  .inline-actions {
    align-items: flex-start;
  }

  .btn-row {
    flex-direction: column;
  }

  .btn-row button {
    width: 100%;
  }

  .abc-ribbon-tabs {
    flex-wrap: wrap;
  }

  .abc-ribbon-tab {
    flex: 1 1 0;
    justify-content: center;
  }
}

@media (max-width: 768px) {
  body {
    padding: 12px 10px 22px;
  }

  .card {
    padding: 16px 14px;
  }

  .abc-panel {
    padding: 14px;
  }

  .mobile-step-switcher {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    position: sticky;
    top: 0;
    z-index: 50;
    background: radial-gradient(circle at 14% 20%, rgba(63,169,245,0.16), rgba(255,255,255,0.95));
    padding: 8px;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    box-shadow: 0 16px 36px rgba(0,102,202,0.16);
  }

  .mobile-step-panel {
    margin-top: 6px;
  }

  .mobile-step-panel:not(.active) {
    display: none;
  }

  .upload-drop-area {
    padding: 14px;
    min-height: 180px;
    gap: 14px;
  }

  .drop-title {
    font-size: 15px;
  }

  .btn-row {
    position: sticky;
    bottom: 10px;
    z-index: 40;
    background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(255,255,255,0.9));
    padding: 10px;
    border-radius: 14px;
    box-shadow: 0 16px 36px rgba(0,102,202,0.16);
  }

  .btn-row button {
    min-height: 48px;
    font-size: 15px;
  }

  .abc-ribbon-tabs {
    gap: 8px;
  }

  .abc-ribbon-tab {
    min-height: 46px;
  }

  .legend-filters {
    flex-direction: column;
    align-items: stretch;
  }

  .legend-filter-group {
    width: 100%;
  }

  .treemap-legend,
  .scatter-legend {
    flex-direction: column;
    align-items: flex-start;
  }

  .scatter-controls {
    flex-wrap: wrap;
    gap: 8px;
  }

  .dynamics-grid {
    display: flex;
    flex-direction: column;
  }

  .treemap,
  .scatter-card,
  .dynamics-card,
  .forecast-chart,
  .forecast-table {
    overflow-x: auto;
    min-width: 520px;
  }

  .scatter-plot-wrapper,
  .treemap-surface,
  .dynamics-grid,
  .forecast-config {
    min-width: 480px;
  }

  .table-scroll table {
    min-width: 480px;
  }
}

@media (max-width: 480px) {
  .hero-actions {
    flex-direction: column;
  }

  .mobile-step-switcher {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 10px;
  }

  .treemap,
  .scatter-card,
  .dynamics-card,
  .forecast-chart,
  .forecast-table {
    min-width: 440px;
  }

  .table-scroll table {
    min-width: 420px;
  }

  .legend-toggle,
  .ghost-button,
  button {
    padding: 10px 14px;
  }
}

.info-grid { align-items: stretch; }

.info-card h2 {
  margin-top: 4px;
  margin-bottom: 8px;
}

.info-card .muted { margin-top: 12px; }

.eyebrow {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0,102,202,0.08);
  color: var(--brand-deep);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--brand-light);
  color: var(--brand-deep);
  font-size: 12px;
  border: 1px solid var(--border-soft);
  box-shadow: 0 8px 20px rgba(0, 102, 202, 0.12);
}

.card {
  background: #ffffff;
  border-radius: 18px;
  padding: 22px 20px;
  box-shadow: 0 18px 50px rgba(0, 102, 202, 0.1);
  border: 1px solid var(--border-soft);
}

.card h2 {
  margin: 0 0 12px;
  font-size: 20px;
}

.card p {
  margin: 4px 0;
  font-size: 14px;
  color: var(--text-muted);
}

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

.nav-links {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.nav-links a {
  color: var(--brand-blue);
  text-decoration: none;
  margin-right: 12px;
}

.nav-links a:hover { text-decoration: underline; }

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

.pill-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(0,102,202,0.08);
  color: var(--brand-deep);
  font-weight: 600;
  border: 1px solid var(--border-soft);
  box-shadow: 0 10px 26px rgba(0,102,202,0.12);
}

.step-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 12px 0 14px;
}

.step-card {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #f8fbff;
  border: 1px solid var(--border-soft);
  box-shadow: 0 10px 20px rgba(0, 102, 202, 0.08);
}

.step-badge {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand-blue), var(--brand-sky));
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  box-shadow: 0 10px 20px rgba(0,102,202,0.25);
}

.step-title {
  font-weight: 700;
  color: var(--text-main);
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.step-icon,
.panel-icon,
.tab-icon {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: var(--brand-light);
  color: var(--brand-deep);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-soft);
  box-shadow: 0 10px 20px rgba(0,102,202,0.12);
}

.tab-icon {
  font-size: 14px;
}

.inline-error {
  font-size: 13px;
  color: #f97316;
  margin-bottom: 6px;
  min-height: 16px;
}

.game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

canvas {
  background: #f1f5f9;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  image-rendering: pixelated;
}

.hud {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 400px;
  font-size: 14px;
  color: var(--text-main);
}

.hud span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.hud-label {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.abc-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 12px;
}

.abc-panel {
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 16px;
  background: rgba(255,255,255,0.8);
  box-shadow: 0 12px 26px rgba(0, 102, 202, 0.08);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.panel-title {
  font-weight: 700;
  color: var(--text-main);
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.badge {
  display: inline-flex;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(0,102,202,0.1);
  color: var(--brand-deep);
  font-weight: 700;
  font-size: 12px;
  border: 1px solid var(--border-soft);
}

.input-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  margin-bottom: 4px;
}

.input-control {
  width: 100%;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: #f8fbff;
  color: var(--text-main);
  font-size: 13px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
}

.helper-text {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.mapping-hint {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  background: #f8fbff;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  margin-top: 10px;
}

.mapping-hint .hint-line {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  line-height: 1.4;
}

.mapping-hint .hint-icon {
  flex: 0 0 auto;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 10px 0;
}

.ghost-button {
  flex: 0 0 auto;
  border: 1px solid rgba(59,130,246,0.3);
  background: rgba(59,130,246,0.08);
  color: #0b4aa6;
  padding: 7px 12px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(59,130,246,0.18);
}

.ghost-button:hover {
  background: rgba(59,130,246,0.15);
}

.ghost-button.small {
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11px;
  box-shadow: none;
}

.section-inline-header {
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.section-inline-title {
  font-size: 13px;
  color: #e5e7eb;
  font-weight: 700;
}

.export-buttons {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.data-preview {
  margin-top: 12px;
}

.upload-drop-area {
  border: 1px dashed rgba(59,130,246,0.6);
  border-radius: 16px;
  padding: 14px;
  background: rgba(15,23,42,0.6);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.upload-drop-area:focus {
  outline: none;
  border-color: var(--brand-sky);
  box-shadow: 0 0 0 2px rgba(14,165,233,0.25);
}

.upload-drop-area.drop-active {
  background: rgba(59,130,246,0.12);
  border-color: var(--brand-sky);
  box-shadow: 0 12px 28px rgba(59,130,246,0.15);
}

.drop-hint {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.drop-title {
  font-weight: 700;
  color: #e5e7eb;
}

.drop-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.preview-shell {
  max-height: 200px;
  overflow: auto;
  border-radius: 12px;
  border: 1px solid rgba(55,65,81,0.9);
  background: rgba(15,23,42,0.7);
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.highlight {
  color: #0ea5e9;
  font-weight: 700;
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 4px;
  width: 100%;
  max-width: 400px;
  flex-wrap: wrap;
}

button {
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--brand-blue), var(--brand-sky));
  color: #ffffff;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1 1 auto;
  transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
  box-shadow: 0 10px 25px rgba(0,102,202,0.35);
  white-space: nowrap;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: linear-gradient(135deg, var(--brand-blue), var(--brand-sky));
  color: #ffffff;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  box-shadow: 0 12px 28px rgba(0,102,202,0.28);
  transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
}

.link-button:hover {
  background: linear-gradient(135deg, #0d74d9, #60b7ff);
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(0,102,202,0.32);
}

.link-button:active {
  transform: translateY(0);
  box-shadow: 0 10px 22px rgba(0,102,202,0.25);
}

.link-button.secondary {
  background: #ffffff;
  color: var(--brand-blue);
  border-color: var(--border-soft);
  box-shadow: 0 10px 24px rgba(0, 102, 202, 0.08);
}

.link-button.secondary:hover {
  background: #f4f9ff;
  border-color: rgba(0,102,202,0.25);
  color: var(--brand-deep);
}

button:hover {
  background: linear-gradient(135deg, #0d74d9, #60b7ff);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
  box-shadow: 0 6px 18px rgba(0,102,202,0.3);
}

.btn-secondary {
  background: #ffffff;
  color: var(--brand-blue);
  box-shadow: 0 6px 18px rgba(0,102,202,0.08);
  border: 1px solid var(--border-soft);
  flex: 0 0 auto;
  min-width: 120px;
}

.status-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 4px;
  font-size: 14px;
}

.table-scroll {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

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

.table-scroll thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
}

.table-scroll--frost thead th {
  background: rgba(15,23,42,0.9);
  color: #e5e7eb;
}

.status-table th,
.status-table td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid rgba(0,102,202,0.12);
}

.status-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

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

.status-ok { color: #0f9f6e; font-weight: 600; }
.status-deg { color: #b45309; font-weight: 600; }

.tag {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(0,102,202,0.2);
  font-size: 11px;
  color: var(--text-muted);
  background: #f8fbff;
}

.footer-note {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.btn-secondary:hover {
  background: rgba(31,41,55,0.9);
}

.status {
  margin-top: 6px;
  font-size: 13px;
  color: #9ca3af;
  text-align: center;
  min-height: 18px;
}

.status strong { color: #f97316; }

.onboarding-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.66);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 1200;
}

.onboarding-overlay:not([hidden]) {
  display: flex;
}

.onboarding-panel {
  width: min(520px, 100%);
  background: radial-gradient(circle at 20% 20%, rgba(59,130,246,0.1), rgba(15,23,42,0.92));
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 16px;
  padding: 18px 18px 14px;
  box-shadow: 0 28px 60px rgba(0,0,0,0.35);
  color: #e5e7eb;
}

.onboarding-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.onboarding-step {
  font-size: 12px;
  color: #9ca3af;
  margin-top: 4px;
}

.onboarding-text {
  font-size: 14px;
  color: #e5e7eb;
  line-height: 1.6;
  margin: 8px 0;
}

.onboarding-action {
  font-size: 13px;
  color: #bfdbfe;
  padding: 10px;
  border-radius: 12px;
  background: rgba(59,130,246,0.08);
  border: 1px dashed rgba(59,130,246,0.35);
}

.onboarding-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.onboarding-actions-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.onboarding-close {
  background: rgba(248, 250, 252, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.45);
  color: #e5e7eb;
  border-radius: 10px;
  width: 34px;
  height: 34px;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  transition: background 0.2s ease, transform 0.2s ease;
}

.onboarding-close:hover {
  background: rgba(248, 250, 252, 0.2);
  transform: scale(1.02);
}

.onboarding-highlight {
  position: relative;
  box-shadow: 0 0 0 4px rgba(59,130,246,0.28), 0 0 0 2px rgba(96,165,250,0.36);
  border-radius: 10px;
  transition: box-shadow 0.2s ease;
}

body.onboarding-open {
  overflow: hidden;
}

.controls-hint {
  margin-top: 10px;
  font-size: 12px;
  color: #6b7280;
  text-align: center;
}

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(15,23,42,0.8);
  border: 1px solid rgba(75,85,99,0.9);
  font-size: 11px;
  margin: 0 2px;
  color: #e5e7eb;
}

.game-selector {
  display: inline-flex;
  gap: 8px;
  margin: 10px 0 12px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(15,23,42,0.9);
  border: 1px solid rgba(55,65,81,0.9);
}

.game-tab {
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  border: none;
  background: transparent;
  color: #9ca3af;
  box-shadow: none;
  flex: 0 0 auto;
  cursor: pointer;
}

.game-tab:hover {
  background: rgba(30,64,175,0.25);
  color: #e5e7eb;
}

.game-tab.active {
  background: #111827;
  color: #e5e7eb;
  border: 1px solid #3b82f6;
  box-shadow: 0 0 0 1px rgba(37,99,235,0.5);
}

.game-panel { display: none; }
.game-panel.active { display: block; }

.meta-list {
  margin-top: 10px;
  font-size: 13px;
  color: #9ca3af;
}

.meta-list li { margin-bottom: 4px; }


.treemap {
  position: relative;
  width: 100%;
  min-height: 320px;
  border-radius: 16px;
  border: 1px solid rgba(55,65,81,0.9);
  background: rgba(2,6,23,0.78);
  overflow: hidden;
}

.treemap-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

.treemap-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(15,23,42,0.75);
  background: rgba(2,6,23,0.85);
}

.treemap-header button {
  flex: 0 0 auto;
  box-shadow: none;
}

.treemap-back {
  border: 1px solid rgba(59,130,246,0.4);
  background: rgba(15,23,42,0.6);
  color: #e5e7eb;
  font-size: 11px;
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
  transition: background 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.treemap-back:disabled {
  opacity: 0.4;
  cursor: default;
  border-color: rgba(59,130,246,0.2);
}

.treemap-path {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 11px;
  color: #a5b4fc;
}

.treemap-crumb {
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 2px 6px;
  cursor: pointer;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  box-shadow: none;
}

.treemap-crumb:hover:not(.active):not(:disabled) {
  background: rgba(59,130,246,0.15);
}

.treemap-crumb.active {
  color: #f97316;
  cursor: default;
}

.treemap-crumb:disabled {
  cursor: default;
}

.treemap-crumb-sep {
  color: rgba(148,163,184,0.7);
}

.treemap-surface {
  position: relative;
  flex: none;
  width: 100%;
  overflow: hidden;
  padding: 10px;
  aspect-ratio: 1 / 1;
  min-height: 320px;
}

@supports not (aspect-ratio: 1 / 1) {
  .treemap-surface {
    min-height: 0;
  }

  .treemap-surface::before {
    content: '';
    display: block;
    padding-top: 100%;
    pointer-events: none;
  }
}

.treemap-cell {
  position: absolute;
  border-radius: 12px;
  padding: 10px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  color: #f8fafc;
  box-shadow: inset 0 0 0 1px rgba(15,23,42,0.4);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.treemap-cell:hover {
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 1px rgba(248,250,252,0.4);
}

.treemap-cell-inner {
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-shadow: 0 1px 6px rgba(2,6,23,0.8);
}

.treemap-cell-title {
  font-size: 12px;
  font-weight: 600;
  display: flex;
  gap: 6px;
  align-items: center;
  word-break: break-word;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.treemap-cell-meta {
  font-size: 11px;
  color: rgba(248,250,252,0.85);
  word-break: break-word;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.treemap-cell-hint {
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(248,250,252,0.8);
}

.treemap-cell--group {
  box-shadow: inset 0 0 0 1px rgba(248,250,252,0.35);
}

.treemap-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  letter-spacing: 0.05em;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(15,23,42,0.55);
}

.treemap-cell--compact .treemap-cell-meta,
.treemap-cell--compact .treemap-cell-hint {
  display: none;
}

.treemap-cell--micro {
  padding: 6px;
}

.treemap-cell--micro .treemap-cell-inner {
  display: none;
}

.treemap-cell--micro::after {
  content: attr(data-label);
  display: block;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  pointer-events: none;
  text-shadow: 0 1px 6px rgba(2,6,23,0.8);
}

.treemap-empty {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 12px;
  color: #94a3b8;
  padding: 0 20px;
}

.treemap-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 6px;
  font-size: 11px;
  color: #0f172a;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  margin-right: 6px;
  box-shadow: 0 0 0 1px rgba(15,23,42,0.1);
}

.legend-dot-x { background: linear-gradient(135deg, #34d399, #15803d); }
.legend-dot-y { background: linear-gradient(135deg, #facc15, #d97706); }
.legend-dot-z { background: linear-gradient(135deg, #fb923c, #c2410c); }

.scatter-card {
  margin-top: 16px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  box-shadow: 0 8px 24px rgba(15,23,42,0.06);
  color: #0f172a;
}

.scatter-header {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  align-items: flex-start;
}

.scatter-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
  color: #0f172a;
}

.scatter-subtitle {
  font-size: 12px;
  color: #334155;
}

.scatter-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  font-size: 12px;
  color: #0f172a;
}

.legend-label {
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #475569;
  margin-bottom: 4px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 12px;
}

.legend-shape {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid #e5e7eb;
  border-radius: 4px;
}

.legend-shape--triangle {
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 12px solid #e5e7eb;
  border-radius: 0;
  transform: translateY(2px);
}

.legend-shape--square { border-radius: 2px; }

.legend-shape--circle { border-radius: 999px; }

.scatter-plot-wrapper {
  position: relative;
  margin-top: 14px;
}

#abcScatterSvg {
  width: 100%;
  height: auto;
  border-radius: 14px;
  background: linear-gradient(180deg, #f8fafc, #e2e8f0);
  box-shadow: inset 0 0 0 1px rgba(15,23,42,0.08);
}

.scatter-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 12px;
  color: #475569;
  padding: 0 20px;
  pointer-events: none;
}

.scatter-axis {
  stroke: #0f172a;
  stroke-width: 1.2;
}

.scatter-grid-line {
  stroke: rgba(100,116,139,0.35);
  stroke-dasharray: 6 6;
}

.scatter-tick-label {
  fill: #1e293b;
  font-size: 11px;
}

.scatter-axis-label {
  fill: #0f172a;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.scatter-ref-line {
  stroke: rgba(59,130,246,0.75);
  stroke-dasharray: 6 6;
}

.scatter-ref-line--horizontal { stroke: rgba(239,68,68,0.75); }

.scatter-point path,
.scatter-point rect,
.scatter-point circle {
  stroke: #0f172a;
  stroke-width: 1.2;
  fill: #f8fafc;
}

.scatter-point text {
  fill: #0f172a;
  font-size: 9px;
  font-weight: 600;
}

.scatter-point[data-xyz="X"] path,
.scatter-point[data-xyz="X"] rect,
.scatter-point[data-xyz="X"] circle { fill: #34d399; }

.scatter-point[data-xyz="Y"] path,
.scatter-point[data-xyz="Y"] rect,
.scatter-point[data-xyz="Y"] circle { fill: #facc15; }

.scatter-point[data-xyz="Z"] path,
.scatter-point[data-xyz="Z"] rect,
.scatter-point[data-xyz="Z"] circle { fill: #f97316; }

@media (max-width: 600px) {
  .scatter-header { flex-direction: column; }
  .legend-item { margin-right: 0; }
}

#abcResultWrapper {
  background: #ffffff;
  border: 1px solid #e2e8f0 !important;
  box-shadow: 0 8px 24px rgba(15,23,42,0.06);
}

#abcResultTable {
  color: #0f172a;
}

#abcResultTable th {
  color: #0f172a;
  background: #f1f5f9;
}

#abcResultTable td {
  color: #0f172a;
  border-bottom: 1px solid #e2e8f0;
}

#abcResultTable tbody tr:nth-child(even) td {
  background: #f8fafc;
}

.abc-views-wrapper { margin-top: 16px; }

.abc-ribbon {
  margin-top: 20px;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  background: linear-gradient(180deg, #e0f2fe 0%, #f8fafc 100%);
  box-shadow: 0 16px 32px rgba(15,23,42,0.08);
  overflow: hidden;
}

.abc-ribbon-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  background: linear-gradient(90deg, rgba(59,130,246,0.1), rgba(14,165,233,0.14));
  border-bottom: 1px solid #cbd5e1;
}

.abc-ribbon-tab {
  border: 1px solid transparent;
  background: transparent;
  color: #0f172a;
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.abc-ribbon-tab:hover {
  background: rgba(255,255,255,0.76);
  border-color: #bfdbfe;
  box-shadow: 0 8px 18px rgba(59,130,246,0.18);
}

.abc-ribbon-tab.active {
  background: #0ea5e9;
  color: #0b1d33;
  border-color: #0284c7;
  box-shadow: 0 12px 20px rgba(14,165,233,0.25);
}

.abc-ribbon-panels {
  padding: 12px;
  background: #f8fafc;
}

.abc-ribbon-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.abc-ribbon-panel[hidden] { display: none; }

.ribbon-group {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), 0 10px 22px rgba(15,23,42,0.06);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ribbon-group-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ribbon-group-body { display: flex; flex-direction: column; gap: 8px; }
.ribbon-group-body.ribbon-row { flex-direction: row; flex-wrap: wrap; align-items: center; }
.ribbon-group-body.ribbon-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.ribbon-group-body.ribbon-column { gap: 10px; }

.ribbon-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #0f172a; }
.ribbon-field select,
.ribbon-field input { width: 100%; }

.ribbon-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ribbon-row.compact { gap: 6px; }

.ribbon-command {
  background: linear-gradient(180deg, #e2f3ff 0%, #dbeafe 100%);
  border: 1px solid #bfdbfe;
  color: #0f172a;
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 700;
  box-shadow: 0 8px 16px rgba(14,165,233,0.22);
}

.ribbon-command.ghost-button {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: none;
}

.export-inline-hint {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.abc-view { display: none; margin-top: 18px; }
.abc-view.active { display: block; }

.forecast-lead {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 12px;
}

.forecast-config {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 10px;
}

.forecast-config label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.forecast-config select,
.forecast-config input {
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  color: var(--text-main);
  font-size: 13px;
  padding: 10px 12px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.03);
}

.forecast-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  background: var(--surface-tint);
}

.forecast-hint {
  font-size: 12px;
  color: var(--text-muted);
  flex: 1 1 220px;
}

.forecast-status {
  font-size: 12px;
  color: var(--text-main);
  margin-bottom: 12px;
  background: var(--surface-tint);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 10px 12px;
}

.forecast-auto-metrics {
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  background: var(--surface);
  padding: 12px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-soft);
}

.forecast-auto-metrics__header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.forecast-auto-metrics__title {
  font-weight: 700;
  font-size: 13px;
  color: var(--text-main);
}

.forecast-auto-metrics__hint {
  font-size: 12px;
  color: var(--text-muted);
}

#forecastAutoMetricsTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

#forecastAutoMetricsTable th,
#forecastAutoMetricsTable td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(0, 102, 202, 0.12);
  text-align: left;
}

#forecastAutoMetricsTable th {
  color: var(--text-main);
  background: var(--surface-tint);
  position: sticky;
  top: 0;
}

#forecastAutoMetricsTable td:nth-child(2),
#forecastAutoMetricsTable td:nth-child(3) {
  text-align: right;
}

#forecastAutoMetricsTable tr.best-metric td {
  background: var(--success-bg);
  color: var(--success-text);
  font-weight: 700;
  border-bottom-color: var(--success-border);
}

.forecast-chart {
  position: relative;
  border-radius: 16px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  padding: 12px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-soft);
}

.forecast-chart-header {
  margin-top: 0;
  margin-bottom: 6px;
}

#forecastChart {
  width: 100%;
  height: auto;
}

.forecast-chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.forecast-table {
  border-radius: 16px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  padding: 12px;
  box-shadow: var(--shadow-soft);
}

.forecast-table-header {
  margin-top: 0;
}

.forecast-table-title {
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--text-main);
  font-weight: 700;
}

#forecastResultWrapper {
  max-height: 260px;
  overflow: auto;
  border-radius: 10px;
}

#forecastResultTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

#forecastResultTable th,
#forecastResultTable td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(0,102,202,0.14);
  text-align: left;
}

#forecastResultTable th {
  color: var(--text-main);
  position: sticky;
  top: 0;
  background: var(--surface-tint);
}

#forecastResultTable td:nth-child(2),
#forecastResultTable td:nth-child(3) {
  text-align: right;
}

#forecastResultTable tr.future td {
  color: var(--brand-deep);
  background: var(--brand-light);
  font-weight: 600;
}

#forecastResultTable tr.future td:first-child {
  color: var(--brand-blue);
}

.dynamics-card {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(55, 65, 81, 0.9);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.7);
}

.dynamics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.dynamics-block {
  background: rgba(15, 23, 42, 0.35);
  border: 1px solid rgba(55, 65, 81, 0.7);
  border-radius: 10px;
  padding: 10px;
}

.dynamics-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.dynamics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.dynamics-table th,
.dynamics-table td {
  padding: 6px 8px;
  border: 1px solid rgba(55, 65, 81, 0.6);
  text-align: center;
}

.dynamics-table th {
  background: rgba(15, 23, 42, 0.6);
  font-weight: 600;
}

.dynamics-table td {
  background: rgba(15, 23, 42, 0.3);
  color: #e5e7eb;
}

.dynamics-list {
  margin: 0;
  padding-left: 20px;
  color: #e5e7eb;
}

.dynamics-list li + li {
  margin-top: 4px;
}
