:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --ink: #18212f;
  --muted: #667085;
  --line: #d8dee8;
  --accent: #d72d3d;
  --accent-2: #0e8f7d;
  --focus: #2454ff;
  --shadow: 0 18px 45px rgba(22, 31, 46, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  background: #101820;
  color: #f8fafc;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 6px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 24px;
}

.brand h1,
.toolbar h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.15;
}

.brand p,
.toolbar p {
  margin: 4px 0 0;
  color: #9aa7b7;
}

.field {
  display: grid;
  gap: 7px;
  color: #cbd5e1;
}

.field span {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.field input,
.field select {
  width: 100%;
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  padding: 0 12px;
  outline: none;
}

.field select option {
  color: #111827;
}

.field input:focus,
.field select:focus,
.segmented button:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(36, 84, 255, 0.2);
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.metric-grid div {
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.metric-grid strong {
  display: block;
  font-size: 24px;
  line-height: 1;
}

.metric-grid span {
  color: #b7c1cf;
  font-size: 12px;
}

.structure-list {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding-right: 2px;
}

.structure-item {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.structure-item input {
  margin-top: 3px;
  accent-color: var(--accent);
}

.structure-item strong {
  display: block;
  overflow-wrap: anywhere;
}

.structure-item span {
  display: block;
  margin-top: 3px;
  color: #b7c1cf;
  font-size: 12px;
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(360px, 56vh) auto;
  gap: 18px;
  padding: 24px;
  min-width: 0;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.toolbar p {
  color: var(--muted);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #edf1f6;
}

.segmented button {
  min-width: 72px;
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.segmented button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(16, 24, 40, 0.12);
}

.chart-panel {
  position: relative;
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

#chart {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 360px;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  pointer-events: none;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.detail-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
  box-shadow: 0 8px 25px rgba(22, 31, 46, 0.04);
}

.detail-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
  overflow-wrap: anywhere;
}

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.fact {
  padding: 8px;
  border-radius: 6px;
  background: #f1f4f8;
}

.fact span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
}

.fact strong {
  display: block;
  margin-top: 2px;
}

.axis {
  stroke: #98a2b3;
  stroke-width: 1;
}

.grid-line {
  stroke: #e5e9f0;
  stroke-width: 1;
}

.tick-label {
  fill: #667085;
  font-size: 12px;
}

.series-label {
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .workspace {
    grid-template-rows: auto 420px auto;
  }

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