:root {
  --mg-bg: #05070d;
  --mg-panel: rgba(16, 23, 39, 0.82);
  --mg-panel-strong: rgba(21, 30, 50, 0.94);
  --mg-line: rgba(139, 169, 255, 0.22);
  --mg-line-strong: rgba(142, 180, 255, 0.42);
  --mg-text: #edf4ff;
  --mg-muted: #a8b6cf;
  --mg-soft: #cbd6e8;
  --mg-blue: #72a7ff;
  --mg-green: #9ff0bb;
  --mg-amber: #f6d579;
  --mg-red: #ff8c98;
  --mg-radius: 18px;
}

body {
  background:
    radial-gradient(circle at 18% 12%, rgba(95, 151, 255, 0.14), transparent 32%),
    radial-gradient(circle at 82% 8%, rgba(246, 213, 121, 0.08), transparent 28%),
    linear-gradient(180deg, #05070d 0%, #0b111d 42%, #05070d 100%);
  color: var(--mg-text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.mg-page {
  min-height: 100vh;
  padding: 110px 0 70px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.mg-wrap {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.mg-demo-page .mg-wrap {
  width: min(1720px, calc(100% - 48px));
}

.mg-hero {
  padding: 86px 0 52px;
}

.mg-eyebrow {
  color: var(--mg-green);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 800;
  margin-bottom: 18px;
}

.mg-hero h1 {
  margin: 0;
  font-size: clamp(3rem, 9vw, 7.5rem);
  line-height: 0.94;
  letter-spacing: 0;
}

.mg-lead {
  max-width: 880px;
  margin: 26px 0 0;
  color: var(--mg-soft);
  font-size: clamp(1.1rem, 2.6vw, 1.65rem);
  line-height: 1.55;
}

.mg-actions,
.mg-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.mg-btn,
button.mg-btn {
  appearance: none;
  border: 1px solid var(--mg-line-strong);
  border-radius: 14px;
  padding: 13px 18px;
  background: rgba(15, 22, 38, 0.82);
  color: var(--mg-text);
  font: inherit;
  font-weight: 850;
  text-decoration: none;
  cursor: pointer;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mg-btn.primary {
  border-color: rgba(123, 174, 255, 0.7);
  background: linear-gradient(135deg, #72a7ff, #8d7cf2);
  color: #06101f;
}

.mg-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.mg-btn:hover:not(:disabled),
.mg-btn:focus-visible {
  border-color: rgba(159, 240, 187, 0.62);
  box-shadow: 0 0 0 3px rgba(114, 167, 255, 0.08), 0 0 28px rgba(114, 167, 255, 0.12);
}

.mg-section {
  padding: 32px 0;
}

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

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

.mg-card {
  border: 1px solid var(--mg-line);
  border-radius: var(--mg-radius);
  background: linear-gradient(180deg, var(--mg-panel-strong), var(--mg-panel));
  padding: 24px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
  min-width: 0;
  overflow: hidden;
}

.mg-card h2,
.mg-card h3 {
  margin: 0 0 12px;
  line-height: 1.12;
}

.mg-card p {
  margin: 0 0 14px;
  color: var(--mg-muted);
  line-height: 1.62;
}

.mg-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 7px 12px;
  border: 1px solid rgba(137, 181, 255, 0.36);
  border-radius: 999px;
  color: #cfe4ff;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-weight: 850;
}

.mg-tag::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mg-green);
  box-shadow: 0 0 16px rgba(159, 240, 187, 0.8);
}

.mg-kpi {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border: 1px solid rgba(139, 169, 255, 0.22);
  border-radius: 16px;
  padding: 10px 14px;
  background: rgba(5, 9, 18, 0.58);
  font-size: clamp(1.35rem, 3vw, 2.35rem);
  font-weight: 950;
  line-height: 1.05;
  margin: 8px 0 10px;
  overflow-wrap: normal;
  word-break: normal;
  white-space: nowrap;
}

.mg-kpi.green { color: var(--mg-green); }
.mg-kpi.amber { color: var(--mg-amber); }
.mg-kpi.red { color: var(--mg-red); }

.mg-note {
  border-left: 3px solid var(--mg-amber);
  padding: 14px 16px;
  color: var(--mg-soft);
  background: rgba(246, 213, 121, 0.08);
  border-radius: 0 12px 12px 0;
}

.mg-demo-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.88fr) minmax(0, 1.35fr);
  gap: 18px;
  align-items: start;
}

.mg-demo-page .mg-hero {
  padding: 54px 0 30px;
}

.mg-demo-page .mg-hero h1 {
  font-size: clamp(2.7rem, 6vw, 5.8rem);
}

.mg-demo-page .mg-lead {
  max-width: 1080px;
}

.mg-demo-page .mg-section {
  padding-top: 14px;
}

.mg-demo-page .mg-demo-layout {
  grid-template-columns: minmax(380px, 0.72fr) minmax(0, 1.45fr);
  gap: 24px;
}

.mg-demo-page .mg-textarea {
  min-height: 160px;
}

.mg-demo-page .mg-chart {
  height: 420px;
}

.mg-demo-page .mg-chart-wrap {
  min-height: 400px;
}

.mg-input,
.mg-select,
.mg-textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--mg-line);
  border-radius: 12px;
  background: rgba(5, 9, 18, 0.86);
  color: var(--mg-text);
  padding: 12px 13px;
  font: inherit;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 750;
  min-height: 46px;
}

.mg-select {
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, #edf4ff 50%) calc(100% - 20px) 50% / 7px 7px no-repeat,
    linear-gradient(135deg, #edf4ff 50%, transparent 50%) calc(100% - 15px) 50% / 7px 7px no-repeat,
    rgba(5, 9, 18, 0.86);
  padding-right: 42px;
}

.mg-input[type="file"] {
  padding: 8px;
}

.mg-input[type="file"]::file-selector-button {
  appearance: none;
  border: 1px solid rgba(123, 174, 255, 0.7);
  border-radius: 12px;
  margin-right: 12px;
  padding: 11px 15px;
  background: linear-gradient(135deg, rgba(91, 205, 171, 0.75), rgba(114, 167, 255, 0.95));
  color: #edf4ff;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.mg-textarea {
  min-height: 240px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  resize: vertical;
}

.mg-field {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.mg-field label {
  color: var(--mg-soft);
  font-weight: 800;
}

.mg-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 14px;
}

.mg-table th,
.mg-table td {
  padding: 12px;
  border-bottom: 1px solid rgba(139, 169, 255, 0.16);
  text-align: left;
  color: var(--mg-soft);
}

.mg-table th {
  color: var(--mg-text);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  text-transform: uppercase;
  font-size: 0.86rem;
}

.mg-result {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.mg-mini {
  border: 1px solid var(--mg-line);
  border-radius: 14px;
  padding: 16px;
  background: rgba(7, 12, 24, 0.72);
}

.mg-mini strong {
  display: block;
  font-size: clamp(1rem, 1.6vw, 1.35rem);
  line-height: 1.15;
  overflow-wrap: normal;
  word-break: normal;
}

.mg-mini span {
  display: block;
  margin-top: 8px;
  color: var(--mg-muted);
}

.mg-source {
  margin: 14px 0 0;
  padding: 11px 13px;
  border: 1px solid rgba(159, 240, 187, 0.24);
  border-radius: 12px;
  background: rgba(159, 240, 187, 0.07);
  color: var(--mg-soft);
  font-size: 0.95rem;
  line-height: 1.45;
}

#decisionTitle span {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: normal;
  word-break: normal;
}

.mg-status-continue { color: var(--mg-green); }
.mg-status-stop { color: var(--mg-red); }
.mg-status-neutral { color: var(--mg-amber); }

.mg-bars {
  display: grid;
  gap: 12px;
  margin: 22px 0 18px;
}

.mg-bar-row {
  display: grid;
  grid-template-columns: 128px minmax(120px, 1fr) 86px;
  gap: 12px;
  align-items: center;
  color: var(--mg-soft);
}

.mg-bar-row strong {
  color: var(--mg-text);
  text-align: right;
}

.mg-bar-track {
  height: 12px;
  border-radius: 999px;
  background: rgba(139, 169, 255, 0.13);
  overflow: hidden;
}

.mg-bar-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mg-green), var(--mg-blue));
}

.mg-bar-track i.early {
  background: linear-gradient(90deg, var(--mg-amber), #8d7cf2);
}

.mg-advantage {
  display: inline-flex;
  width: fit-content;
  padding: 8px 12px;
  border: 1px solid rgba(159, 240, 187, 0.34);
  border-radius: 999px;
  color: var(--mg-green);
  background: rgba(159, 240, 187, 0.08);
  font-weight: 850;
}

.mg-chart-card {
  margin: 18px 0 4px;
  padding: 16px;
  border: 1px solid rgba(139, 169, 255, 0.20);
  border-radius: 18px;
  background: rgba(5, 8, 16, 0.55);
}

.mg-chart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.mg-chart-head h3 {
  margin: 0;
}

.mg-chart-head span {
  display: inline-flex;
  padding: 7px 10px;
  border: 1px solid rgba(246, 213, 121, 0.36);
  border-radius: 999px;
  color: var(--mg-amber);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-weight: 850;
  white-space: nowrap;
}

.mg-chart-wrap {
  position: relative;
  min-height: 320px;
  border: 1px solid rgba(139, 169, 255, 0.18);
  border-radius: 16px;
  overflow: hidden;
  background: #060a13;
}

.mg-chart {
  display: block;
  width: 100%;
  height: 340px;
}

.mg-tooltip {
  position: absolute;
  z-index: 5;
  min-width: 160px;
  padding: 9px 10px;
  border: 1px solid rgba(139, 169, 255, 0.34);
  border-radius: 10px;
  background: rgba(5, 7, 13, 0.94);
  color: var(--mg-soft);
  font-size: 0.9rem;
  pointer-events: none;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
}

.mg-tooltip strong {
  color: var(--mg-text);
}

.mg-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 12px;
  color: var(--mg-muted);
  font-size: 0.94rem;
}

.mg-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.mg-legend i {
  width: 20px;
  height: 3px;
  border-radius: 999px;
  background: var(--mg-soft);
}

.mg-legend i.train { background: var(--mg-green); }
.mg-legend i.val { background: var(--mg-blue); }
.mg-legend i.best { background: var(--mg-amber); }
.mg-legend i.guard { background: var(--mg-red); }
.mg-legend i.early { background: #ffb347; }

.mg-small {
  color: var(--mg-muted);
  font-size: 0.95rem;
}

@media (max-width: 920px) {
  .mg-grid,
  .mg-grid.two,
  .mg-demo-layout,
  .mg-demo-page .mg-demo-layout,
  .mg-result {
    grid-template-columns: 1fr;
  }
  .mg-page {
    padding-top: 86px;
  }
  .mg-wrap {
    width: min(100% - 28px, 1180px);
  }
  .mg-demo-page .mg-wrap {
    width: min(100% - 28px, 1180px);
  }
  .mg-demo-page .mg-chart,
  .mg-chart {
    height: 320px;
  }
  .mg-demo-page .mg-chart-wrap,
  .mg-chart-wrap {
    min-height: 300px;
  }
  .mg-hero h1 {
    font-size: clamp(2.55rem, 14vw, 4.2rem);
  }
  .mg-bar-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .mg-bar-row strong {
    text-align: left;
  }
  .mg-chart-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .mg-chart {
    height: 300px;
  }
}
