:root {
  --bg-top: #f4fbff;
  --bg-bottom: #dceff5;
  --panel: rgba(255, 255, 255, 0.84);
  --panel-border: #b7d2df;
  --ink: #0b2735;
  --muted: #3f5d6b;
  --accent: #12698a;
  --accent-strong: #0e4f67;
  --accent-soft: #d4ecf6;
  --warning: #b96322;
  --shadow: 0 16px 34px rgba(6, 43, 63, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
}

body {
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 13% 14%, rgba(127, 195, 222, 0.34), transparent 42%),
    radial-gradient(circle at 86% 80%, rgba(176, 221, 193, 0.24), transparent 39%),
    linear-gradient(155deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
}

.misi-app {
  height: 100%;
  width: 100%;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.app-header {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  backdrop-filter: blur(5px);
}

.app-header h1 {
  margin: 0;
  font-size: clamp(1.05rem, 2vw, 1.34rem);
  letter-spacing: 0.01em;
}

.app-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.misi-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr);
  grid-template-rows: minmax(0, 1.15fr) minmax(0, 0.85fr);
  grid-template-areas:
    "canvas controls"
    "canvas charts";
  gap: 14px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(5px);
}

.canvas-panel {
  grid-area: canvas;
  padding: 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

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

.panel-head h2,
.controls-head h2 {
  margin: 0;
  font-size: 0.98rem;
  letter-spacing: 0.02em;
}

.panel-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.3;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(74px, 1fr));
  gap: 8px;
}

.metric {
  border: 1px solid #c9dde7;
  border-radius: 9px;
  padding: 6px 7px;
  background: rgba(243, 251, 255, 0.86);
}

.metric-label {
  display: block;
  color: #335264;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 3px;
}

.metric-value {
  display: block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.76rem;
  color: #163549;
}

.canvas-wrap {
  flex: 1;
  min-height: 260px;
  margin-top: 10px;
  border: 1px solid #9ec6d8;
  border-radius: 12px;
  overflow: hidden;
  background:
    radial-gradient(circle at 14% 16%, rgba(230, 248, 255, 0.45), transparent 40%),
    radial-gradient(circle at 85% 78%, rgba(163, 212, 236, 0.32), transparent 44%),
    linear-gradient(180deg, #d9eef9 0%, #8eb8cf 100%);
  box-shadow:
    inset 0 0 0 1px rgba(230, 247, 255, 0.44),
    inset 0 -22px 36px rgba(6, 44, 67, 0.12);
}

#profileCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.controls-panel {
  grid-area: controls;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.controls-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.status-badge {
  border: 1px solid #bad9e8;
  border-radius: 999px;
  background: #eff8fd;
  color: #16445e;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 5px 9px;
  font-weight: 600;
}

.status-badge.running {
  border-color: #a7d4b5;
  background: #edf8f1;
  color: #185832;
}

.control-group {
  padding: 10px;
  border: 1px solid #c7ddea;
  border-radius: 10px;
  background: rgba(247, 252, 255, 0.9);
}

.control-group label {
  font-size: 0.85rem;
  color: #1c3f53;
  font-weight: 500;
}

.section-title {
  margin: 0 0 8px;
  color: #32596d;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 700;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
  font-size: 0.84rem;
  font-weight: 500;
  color: #1a4358;
}

.check-row:last-of-type {
  margin-bottom: 0;
}

.check-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #1e7fa6;
  cursor: pointer;
}

.check-row span {
  line-height: 1.2;
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.label-row output {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.74rem;
  color: #1f4f68;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  margin-top: 6px;
  border: 1px solid #9fc2d4;
  border-radius: 8px;
  background: #ffffff;
  color: #113247;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.86rem;
  padding: 7px 8px;
}

input[type="range"] {
  appearance: none;
  margin-top: 7px;
  background: transparent;
  position: relative;
  z-index: 0;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #9ed0e4 0%, #2c8fb4 100%);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  margin-top: -7px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  background: #106788;
  box-shadow: 0 2px 4px rgba(6, 38, 55, 0.3);
}

input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #9ed0e4 0%, #2c8fb4 100%);
}

input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  background: #106788;
  box-shadow: 0 2px 4px rgba(6, 38, 55, 0.3);
}

.control-hint {
  margin: 6px 0 0;
  color: #4f6978;
  font-size: 0.74rem;
  line-height: 1.2;
}

.button-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  position: relative;
  z-index: 2;
}

.btn {
  border: 1px solid transparent;
  border-radius: 9px;
  min-height: 36px;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
}

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

.btn-primary {
  background: var(--accent);
  color: #e8f7ff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-strong);
}

.btn-secondary {
  background: #edf6fb;
  color: #1c4a63;
  border-color: #b6d3e1;
}

.btn-ghost {
  background: transparent;
  color: #14435a;
  border-color: #9fc0d0;
}

.btn-warning {
  background: #ffefe1;
  color: #7f3f18;
  border-color: #e6b695;
}

.btn-warning:hover:not(:disabled) {
  background: #ffe4cc;
}

.single-action {
  grid-template-columns: 1fr;
}

.controls-panel .button-row:last-of-type {
  position: sticky;
  bottom: 0;
  z-index: 3;
  padding-top: 8px;
  background: linear-gradient(180deg, rgba(247, 252, 255, 0) 0%, rgba(247, 252, 255, 0.96) 42%);
}

.charts-panel {
  grid-area: charts;
  padding: 12px;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
  min-height: 0;
}

.chart-card {
  border: 1px solid #c4dae6;
  border-radius: 10px;
  background: rgba(248, 253, 255, 0.94);
  padding: 8px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chart-card h3 {
  margin: 0 0 5px;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  color: #1b4054;
}

.chart-wrap {
  flex: 1;
  min-height: 120px;
}

.chart-wrap canvas {
  width: 100%;
  height: 100%;
}

@media (max-width: 1100px) {
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .misi-app {
    padding: 8px;
    gap: 8px;
  }

  .misi-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(340px, 52dvh) auto minmax(320px, 42dvh);
    grid-template-areas:
      "canvas"
      "controls"
      "charts";
    gap: 8px;
  }

  .canvas-panel,
  .controls-panel,
  .charts-panel {
    padding: 10px;
  }

  .panel-head {
    flex-direction: column;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .button-row {
    grid-template-columns: 1fr;
  }
}
