:root {
  --bg: #f4f8fc;
  --surface: #ffffff;
  --surface-soft: #f7faff;
  --ink: #20242a;
  --muted: #66758b;
  --line: #d7e0ea;
  --line-strong: #b9c8dc;
  --brand: #5155ff;
  --brand-strong: #4d50f6;
  --brand-soft: #eef0ff;
  --accent: #56c8ce;
  --rail: #172437;
  --rail-muted: #9aa8bd;
  --shadow: 0 18px 36px rgba(15, 30, 50, 0.08);
}

* {
  box-sizing: border-box;
}

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

.brand-rail {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 4;
  width: 210px;
  padding: 22px 10px;
  background: var(--rail);
  color: white;
}

.brand-logo {
  display: flex;
  align-items: baseline;
  gap: 2px;
  margin-bottom: 28px;
  font-size: 1.75rem;
  font-weight: 950;
  letter-spacing: -0.04em;
}

.brand-logo em {
  color: var(--rail-muted);
  font-style: italic;
  font-weight: 950;
}

.rail-active {
  display: flex;
  align-items: center;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 7px;
  padding: 0 18px;
  background: var(--brand-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  font-weight: 850;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none;
}

.dashboard-shell {
  width: auto;
  margin-left: 210px;
  padding: 32px 28px 48px;
}

.dashboard-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(2.8rem, 5vw, 4.2rem);
  font-weight: 950;
  letter-spacing: -0.04em;
  line-height: 0.92;
}

h2 {
  margin-bottom: 4px;
  font-size: 1.08rem;
}

.lede,
.panel-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.03rem;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.upload-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  margin-bottom: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.upload-panel.is-dragging {
  border-color: var(--accent);
  background: #eefbfc;
}

.upload-panel input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-panel strong {
  display: block;
  margin-bottom: 5px;
  font-size: 1.05rem;
}

.upload-panel p {
  margin-bottom: 0;
  color: var(--muted);
}

.mapping-panel {
  display: grid;
  grid-template-columns: minmax(170px, 0.7fr) repeat(3, minmax(170px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.builder-heading {
  display: grid;
  gap: 4px;
  align-self: center;
}

.builder-heading strong {
  color: var(--brand-strong);
  font-size: 1rem;
}

.builder-heading span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.mapping-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.mapping-panel select {
  min-height: 40px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  color: var(--ink);
  background: var(--surface-soft);
}

.primary-button,
.ghost-button {
  min-height: 42px;
  border-radius: 7px;
  padding: 0 14px;
  font-weight: 900;
}

.primary-button {
  border: 1px solid var(--brand-strong);
  color: white;
  background: var(--brand-strong);
}

.ghost-button {
  border: 1px solid #bcc9dd;
  color: var(--brand-strong);
  background: var(--surface);
}

.report-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.report-panel {
  padding: 18px;
}

.panel-toolbar {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.filter-pill {
  display: inline-flex;
  margin-bottom: 12px;
  border-radius: 5px;
  padding: 5px 9px;
  color: var(--brand-strong);
  background: var(--brand-soft);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.owner-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  min-height: 34px;
  margin-bottom: 16px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  font-size: 0.9rem;
}

.legend-item:not(.is-active) {
  color: #8a9aae;
  text-decoration: line-through;
}

.legend-item span,
.table-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.chart-wrap {
  position: relative;
  min-height: 360px;
  padding: 18px 0 0 62px;
  overflow-x: hidden;
}

.chart-grid {
  position: absolute;
  top: 18px;
  right: 0;
  left: 62px;
  height: 300px;
  background:
    repeating-linear-gradient(
      to top,
      transparent 0,
      transparent calc((100% / var(--tick-count)) - 1px),
      var(--line) calc(100% / var(--tick-count))
    );
  border-bottom: 1px solid #6b92c3;
  pointer-events: none;
}

.chart-grid::before {
  content: attr(data-labels);
  white-space: pre;
  position: absolute;
  left: -32px;
  top: -4px;
  color: var(--ink);
  font-size: 0.78rem;
  line-height: calc(300px / var(--tick-count));
}

.y-axis-title {
  position: absolute;
  left: 8px;
  top: 145px;
  transform: rotate(-90deg);
  color: var(--brand-strong);
  font-size: 0.82rem;
  font-weight: 900;
}

.bar-chart {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(var(--pipeline-count), minmax(0, 1fr));
  align-items: end;
  gap: clamp(14px, 3.5vw, 56px);
  height: 300px;
  padding: 0 34px 0 0;
  min-width: 0;
}

.bar-group {
  position: relative;
  display: block;
  height: 100%;
  border: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
}

.bar-stack {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: end;
  width: min(var(--bar-width), 82%);
  height: 100%;
  min-height: 3px;
  outline: 0 solid transparent;
  transition: outline 160ms ease;
}

.bar-group.is-selected .bar-stack,
.bar-group:hover .bar-stack {
  outline: 3px solid rgba(81, 85, 255, 0.18);
}

.bar-segment {
  display: block;
  width: 100%;
}

.bar-total {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.86rem;
  font-weight: 950;
}

.bar-label {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  min-height: 34px;
  padding-top: 9px;
  font-size: 0.82rem;
}

.chart-empty {
  align-self: center;
  justify-self: center;
  margin: 0;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.x-axis-title {
  text-align: center;
  color: var(--brand-strong);
  font-weight: 900;
}

.chart-tooltip {
  position: fixed;
  z-index: 10;
  min-width: 210px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: white;
  box-shadow: 0 14px 34px rgba(39, 60, 83, 0.24);
  pointer-events: none;
}

.chart-tooltip > strong {
  display: block;
  padding: 10px;
  color: white;
  background: var(--rail);
}

.chart-tooltip > span {
  display: block;
  padding: 9px 10px 5px;
  font-size: 0.8rem;
}

.chart-tooltip div,
.chart-tooltip footer {
  display: grid;
  grid-template-columns: 12px minmax(90px, 1fr) auto auto;
  gap: 6px;
  align-items: center;
  padding: 2px 10px;
  font-size: 0.83rem;
}

.chart-tooltip i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.chart-tooltip em {
  color: var(--muted);
  font-style: normal;
}

.chart-tooltip footer {
  grid-template-columns: 1fr auto;
  border-top: 1px solid var(--line);
  margin-top: 8px;
  padding: 8px 10px;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.75fr) minmax(360px, 1.25fr);
  gap: 12px;
  margin-top: 12px;
}

.breakdown-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.breakdown-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px 10px;
}

.breakdown-label,
.breakdown-value {
  display: flex;
  align-items: center;
  gap: 8px;
}

.breakdown-value span {
  color: var(--muted);
}

.meter {
  grid-column: 1 / -1;
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  background: #e7edf4;
}

.meter span {
  display: block;
  height: 100%;
}

.table-wrap {
  max-height: 360px;
  overflow: auto;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  background: var(--surface-soft);
  color: var(--brand-strong);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

td:nth-child(3),
td:nth-child(4) {
  font-weight: 800;
}

td:nth-child(2) {
  display: flex;
  align-items: center;
  gap: 8px;
}

.empty-state,
.status-message {
  color: var(--muted);
}

.status-message {
  min-height: 24px;
  margin: 12px 0 0;
  font-weight: 800;
}

@media (max-width: 820px) {
  .brand-rail {
    position: static;
    width: auto;
    padding: 16px;
  }

  .brand-logo {
    margin-bottom: 12px;
  }

  .rail-active {
    width: max-content;
    min-width: 160px;
  }

  .dashboard-shell {
    margin-left: 0;
    padding: 22px 14px 38px;
  }

  .dashboard-header,
  .panel-toolbar {
    display: grid;
  }

  .header-actions {
    justify-content: start;
  }

  .detail-grid,
  .mapping-panel,
  .upload-panel {
    grid-template-columns: 1fr;
  }

  .chart-wrap {
    min-height: 330px;
    padding-left: 42px;
    overflow-x: hidden;
  }

  .chart-grid {
    right: 0;
    width: 100%;
    left: 42px;
  }

  .chart-grid::before {
    left: -28px;
  }

  .y-axis-title {
    left: -11px;
  }
}
