.mcsim,
.mcsim * {
  box-sizing: border-box;
}

.mcsim {
  --bg-color: #142227;
  --bg-color-deep: #0f1b1f;
  --card-bg: #142227;
  --card-bg-secondary: #1d3239;
  --text-main: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.8);
  --text-label: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.6);
  --text-subtle: rgba(255, 255, 255, 0.5);
  --primary: #65bda3;
  --primary-hover: #7ad1b8;
  --info: #99dbff;
  --warning: #ffe699;
  --error: #cc0029;
  --success: #65bda3;
  --border: rgba(255, 255, 255, 0.2);
  --border-subtle: rgba(255, 255, 255, 0.1);
  --ghost-bg: rgba(255, 255, 255, 0.05);
  --table-header: #1d3239;
  --accent-border: #26414b;
  --mc-color: #99dbff;
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.28);
  margin: 24px 0;
  padding: 20px;
  background:
    radial-gradient(
      circle at top,
      rgba(101, 189, 163, 0.16) 0%,
      rgba(101, 189, 163, 0) 38%
    ),
    linear-gradient(180deg, var(--bg-color) 0%, var(--bg-color-deep) 100%);
  color: var(--text-main);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  min-height: 100vh;
}

.mcsim h1,
.mcsim h2,
.mcsim h3,
.mcsim p {
  margin: 0;
}

.mcsim button,
.mcsim input,
.mcsim table {
  font: inherit;
}

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

.mcsim .header h1 {
  font-size: 2rem;
  line-height: 1.1;
  color: var(--text-main);
  letter-spacing: -0.03em;
}

.mcsim .tabs {
  display: flex;
  gap: 10px;
  background: var(--ghost-bg);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  backdrop-filter: blur(16px);
}

.mcsim .tab-btn {
  padding: 8px 16px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  transition:
    background-color 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease;
}

.mcsim .tab-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.mcsim .tab-btn.active {
  background: var(--primary);
  color: var(--bg-color);
  box-shadow: 0 10px 24px rgba(101, 189, 163, 0.24);
}

.mcsim .tab-btn.active[data-mode="mc"] {
  color: var(--bg-color);
}

.mcsim .container {
  display: flex;
  gap: 20px;
}

.mcsim .sidebar {
  width: 360px;
  background: linear-gradient(
    145deg,
    var(--bg-color-deep),
    var(--card-bg-secondary)
  );
  padding: 20px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(101, 189, 163, 0.2);
  height: fit-content;
  flex-shrink: 0;
}

.mcsim .sidebar h2 {
  font-size: 1.25rem;
  margin-bottom: 20px;
  color: var(--text-main);
}

.mcsim .input-group {
  margin-bottom: 15px;
}

.mcsim .input-group label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-label);
}

.mcsim .label-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.mcsim .mc-label {
  display: none;
  font-size: 0.75rem;
  color: var(--info);
  font-weight: 400;
}

.mcsim .variance-toggle {
  display: none;
  align-items: center;
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.mcsim .variance-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  cursor: pointer;
}

.mcsim.mode-mc .variance-toggle {
  display: inline-flex;
}

.mcsim .toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  transition: background-color 0.2s ease;
  cursor: pointer;
}

.mcsim .toggle-slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: var(--text-main);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
  transition: transform 0.2s ease;
}

.mcsim .variance-toggle input:checked + .toggle-slider {
  background: var(--mc-color);
}

.mcsim .variance-toggle input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

.mcsim .input-wrapper {
  position: relative;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mcsim .input-wrapper input {
  width: 100%;
  flex: 1 1 90px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--ghost-bg);
  color: var(--text-main);
  font-size: 0.95rem;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
  text-align: center;
}

.mcsim .input-wrapper input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.mcsim .input-wrapper input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(101, 189, 163, 0.2);
}

.mcsim .mc-input {
  display: none;
}

.mcsim.mode-mc .variance-group.variance-enabled .mc-input {
  display: block;
  border-color: rgba(153, 219, 255, 0.45);
  background-color: rgba(153, 219, 255, 0.08);
}

.mcsim.mode-mc .variance-group.variance-enabled .mc-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(101, 189, 163, 0.2);
}

.mcsim.mode-mc .variance-group.variance-enabled .mc-label {
  display: inline;
}

.mcsim .btn-run-mc {
  display: none;
  width: 100%;
  padding: 12px;
  background-color: var(--primary);
  color: var(--bg-color);
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 20px;
  transition: background-color 0.2s ease;
  box-shadow: 0 12px 24px rgba(101, 189, 163, 0.2);
}

.mcsim.mode-mc .btn-run-mc {
  display: block;
}

.mcsim .btn-run-mc:hover,
.mcsim .btn-run-mc:focus {
  background-color: var(--primary-hover);
}

.mcsim .main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.mcsim .top-stats {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.mcsim .top-stats.view-section[data-section="stats-standard"].active {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mcsim .top-stats.view-section[data-section="stats-mc"].active {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mcsim .stat-card {
  background: linear-gradient(
    145deg,
    var(--bg-color-deep),
    var(--card-bg)
  );
  padding: 20px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(101, 189, 163, 0.2);
  flex: 1;
  min-width: 180px;
}

.mcsim .risk-card {
  border-left: 4px solid var(--error);
}

.mcsim .stat-card h3 {
  font-size: 0.8rem;
  color: var(--text-label);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.mcsim .stat-card .value {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--primary);
}

.mcsim .stat-card .value.mc-val {
  color: var(--mc-color);
}

.mcsim .view-section {
  display: none;
}

.mcsim .view-section.active {
  display: block;
}

.mcsim .table-container {
  background: linear-gradient(
    145deg,
    var(--bg-color-deep),
    var(--card-bg)
  );
  border-radius: 8px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow-x: auto;
}

.mcsim .mc-detail-stack.active {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.mcsim .mc-sample-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
}

.mcsim .mc-sample-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.mcsim .mc-sample-heading h3 {
  font-size: 0.95rem;
  color: var(--text-main);
}

.mcsim .mc-sample-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.mcsim .mc-sample-table-wrap {
  overflow-x: auto;
}

.mcsim .mc-sample-table {
  table-layout: fixed;
}

.mcsim .mc-sample-table th:first-child,
.mcsim .mc-sample-table td:first-child {
  text-align: left;
  width: 220px;
}

.mcsim .mc-sample-table th:not(:first-child),
.mcsim .mc-sample-table td:not(:first-child) {
  text-align: right;
}

.mcsim .mc-carousel-dots {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.mcsim .mc-carousel-dot {
  width: 10px;
  height: 10px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  transition:
    transform 0.2s ease,
    background-color 0.2s ease;
}

.mcsim .mc-carousel-dot.active {
  background: var(--mc-color);
  transform: scale(1.15);
}

.mcsim table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  white-space: nowrap;
}

.mcsim th,
.mcsim td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.mcsim th {
  background-color: var(--table-header);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-label);
  position: sticky;
  top: 0;
}

.mcsim td {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.mcsim tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.mcsim tfoot td {
  background-color: var(--table-header);
  font-weight: 700;
  border-top: 2px solid var(--border);
}

.mcsim .align-left {
  text-align: left;
}

.mcsim .chart-container {
  background: linear-gradient(
    145deg,
    var(--bg-color-deep),
    var(--card-bg)
  );
  border-radius: 8px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 20px;
  height: 500px;
  position: relative;
}

.mcsim .chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

.mcsim .positive {
  color: var(--success);
}

.mcsim .negative {
  color: var(--error);
}

.mcsim .neutral {
  color: var(--text-muted);
}

.mcsim .highlight {
  background-color: rgba(255, 230, 153, 0.12) !important;
  border: 1px solid rgba(255, 230, 153, 0.25);
  color: var(--text-main);
  font-weight: 600;
}

@media (max-width: 1100px) {
  .mcsim .top-stats.view-section[data-section="stats-mc"].active {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1024px) {
  .mcsim .header {
    flex-direction: column;
    align-items: flex-start;
  }

  .mcsim .container {
    flex-direction: column;
  }

  .mcsim .sidebar {
    width: 100%;
  }
}

@media (max-width: 700px) {
  .mcsim .top-stats.view-section[data-section="stats-standard"].active {
    grid-template-columns: 1fr;
  }

  .mcsim .top-stats.view-section[data-section="stats-mc"].active {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .mcsim {
    padding: 16px;
  }

  .mcsim .header h1 {
    font-size: 1.6rem;
  }

  .mcsim .tabs {
    width: 100%;
    flex-wrap: wrap;
  }

  .mcsim .tab-btn {
    flex: 1 1 200px;
  }

  .mcsim .mc-sample-panel {
    display: none;
  }

  .mcsim .mc-sample-table th:first-child,
  .mcsim .mc-sample-table td:first-child {
    width: auto;
  }
}
