:root {
  --bg: #f4efe5;
  --panel: rgba(255, 251, 245, 0.9);
  --panel-strong: #fffaf2;
  --line: rgba(30, 41, 59, 0.12);
  --text: #172033;
  --muted: #60708a;
  --accent: #ef6c3d;
  --accent-2: #00958f;
  --accent-3: #f4b942;
  --accent-4: #173f5f;
  --good: #198754;
  --warn: #c17c00;
  --danger: #b03a2e;
  --shadow: 0 24px 60px rgba(23, 32, 51, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Aptos", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(0, 149, 143, 0.16), transparent 24%),
    radial-gradient(circle at top left, rgba(239, 108, 61, 0.18), transparent 28%),
    linear-gradient(180deg, #faf5ea 0%, #f3ede3 100%);
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(23, 32, 51, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 32, 51, 0.03) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.42), transparent 80%);
}

main {
  width: min(1400px, calc(100% - 32px));
  margin: 28px auto 48px;
  position: relative;
  z-index: 1;
}

.hero {
  position: relative;
  background: linear-gradient(135deg, rgba(255, 250, 242, 0.96), rgba(255, 245, 229, 0.94));
  border: 1px solid rgba(23, 32, 51, 0.08);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 28px;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  width: 280px;
  height: 280px;
  top: -120px;
  right: -80px;
  background: radial-gradient(circle, rgba(244, 185, 66, 0.32), transparent 70%);
  pointer-events: none;
}

.hero-top {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 26px;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Bahnschrift", "Trebuchet MS", sans-serif;
  letter-spacing: -0.03em;
}

h1 {
  font-size: clamp(34px, 5vw, 56px);
  line-height: 0.98;
  max-width: 10ch;
  margin-top: 12px;
}

.hero-meta {
  min-width: min(360px, 100%);
  display: grid;
  gap: 14px;
}

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

.badge {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(23, 32, 51, 0.08);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.badge strong {
  display: block;
  font-size: 24px;
  margin-top: 6px;
}

.badge span {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

.progress-shell {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(23, 32, 51, 0.08);
  border-radius: var(--radius-lg);
  padding: 22px 22px 18px;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 18px;
  margin-bottom: 14px;
}

.progress-head h2 {
  font-size: 18px;
}

.progress-head .big-number {
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1;
}

.progress-sub {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  margin-bottom: 14px;
}

.progress-scale {
  position: relative;
}

.bar-track {
  position: relative;
  height: 20px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(23, 32, 51, 0.08), rgba(23, 32, 51, 0.04));
  overflow: hidden;
}

.bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: linear-gradient(90deg, var(--accent), #f59f45 40%, #ffd166 100%);
  border-radius: inherit;
  box-shadow: 0 0 22px rgba(239, 108, 61, 0.26);
}

.target-marker {
  position: absolute;
  top: -8px;
  bottom: -8px;
  width: 2px;
  background: rgba(23, 63, 95, 0.9);
  border-radius: 999px;
}

.target-marker::after {
  content: "Goal";
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-4);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.progress-axis {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 22px 0 0;
}

.stat-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 18px;
}

.stat-card span {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

.stat-card strong {
  display: block;
  margin-top: 12px;
  font-size: clamp(28px, 4vw, 38px);
  line-height: 1;
}

.stat-card small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.5;
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.95fr);
  gap: 18px;
  margin-top: 18px;
}

.panel {
  padding: 20px;
}

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

.panel-top p {
  margin: 8px 0 0;
  color: var(--muted);
}

.chart {
  width: 100%;
  min-height: 420px;
}

.panel-tree {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.panel-tree .panel-top {
  flex: 0 0 auto;
}

.chart-tree {
  flex: 1 1 auto;
  min-height: clamp(520px, 58vh, 760px);
}

.tree-shell {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 22px;
  align-items: center;
  min-height: 100%;
}

.tree-shell.tree-shell-stacked {
  grid-template-columns: 1fr;
  align-items: start;
}

.tree-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 440px;
  padding: 8px 0 4px;
}

.tree-svg {
  width: min(100%, 520px);
  height: auto;
  overflow: visible;
  display: block;
}

.tree-center-kicker {
  fill: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tree-center-value {
  fill: var(--text);
  font-size: 30px;
  font-weight: 800;
}

.tree-legend {
  display: grid;
  gap: 14px;
}

.tree-group {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(23, 32, 51, 0.08);
  border-left: 6px solid var(--tree-team-color);
  border-radius: 18px;
  padding: 16px 16px 14px;
  box-shadow: 0 16px 32px rgba(23, 32, 51, 0.08);
}

.tree-group-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.tree-group-swatch {
  width: 12px;
  height: 12px;
  margin-top: 5px;
  border-radius: 999px;
  background: var(--tree-team-color);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--tree-team-color) 16%, transparent);
}

.tree-group-label {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.25;
}

.tree-group-summary {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.tree-group-list {
  display: grid;
  gap: 10px;
}

.tree-item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 12px 12px 10px;
  border-radius: 14px;
  background: rgba(255, 250, 242, 0.92);
  border: 1px solid rgba(23, 32, 51, 0.06);
}

.tree-item-dot {
  width: 12px;
  height: 12px;
  margin-top: 4px;
  border-radius: 999px;
}

.tree-item-copy {
  min-width: 0;
}

.tree-item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.tree-item-name {
  min-width: 0;
  display: grid;
  gap: 2px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}

.tree-item-name span {
  display: block;
  overflow-wrap: anywhere;
}

.tree-item-value {
  font-size: 15px;
  line-height: 1.2;
  white-space: nowrap;
}

.tree-item-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.project-list {
  display: grid;
  gap: 12px;
}

.project-card {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(23, 32, 51, 0.08);
  border-radius: 18px;
  padding: 16px;
}

.project-card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.project-card h3 {
  font-size: 18px;
}

.project-card-side {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.project-card .ratio {
  color: var(--accent-4);
  font-weight: 700;
}

.project-card .micro {
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
}

.project-status {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.project-status[data-state="above-target"] {
  background: rgba(25, 135, 84, 0.1);
  color: var(--good);
}

.project-status[data-state="near-goal"] {
  background: rgba(244, 185, 66, 0.16);
  color: #9a6a00;
}

.project-status[data-state="below-goal"] {
  background: rgba(239, 108, 61, 0.12);
  color: #a0481f;
}

.project-status[data-state="no-target"] {
  background: rgba(23, 32, 51, 0.08);
  color: var(--muted);
}

.project-bar {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: rgba(23, 32, 51, 0.08);
  margin-top: 14px;
  overflow: hidden;
}

.project-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), #41c7c2);
}

button {
  border: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-4), var(--accent-2));
  color: white;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
}

button.secondary {
  background: rgba(23, 32, 51, 0.08);
  color: var(--text);
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
}

@media (max-width: 1100px) {
  .hero-top,
  .layout-grid,
  .mini-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

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

  .chart-tree {
    min-height: 500px;
  }
}

@media (max-width: 720px) {
  main {
    width: min(100% - 20px, 1400px);
    margin-top: 10px;
  }

  .hero,
  .panel,
  .stat-card {
    padding: 16px;
  }

  .badge-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .chart {
    min-height: 340px;
  }

  .chart-tree {
    min-height: 380px;
  }

  .meta-row,
  .progress-sub,
  .project-card-top {
    display: grid;
  }

  .meta-row dd,
  .project-card-side {
    justify-items: start;
    text-align: left;
  }
}
