:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --ink: #1f2933;
  --muted: #697586;
  --line: #dfe5eb;
  --line-soft: #eef2f6;
  --red: #e14658;
  --red-dark: #bf2d42;
  --blue: #2f80ed;
  --green: #20a66a;
  --shadow: 0 8px 24px rgba(31, 41, 51, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
}

button {
  font: inherit;
}

select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
  height: 100vh;
  padding: 20px 14px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
}

.workspace {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 52px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 0 8px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 8px;
}

.brand-mark {
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--red);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

.brand-mark.missing::before {
  content: "";
  width: 18px;
  height: 18px;
  border: 2px solid #fff;
  border-radius: 5px;
  opacity: 0.85;
}

.brand-mark.missing img {
  display: none;
}

.brand-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.15;
}

.brand strong {
  display: block;
  font-size: 0.98rem;
  line-height: 1.15;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 0 10px;
  color: #4b5968;
  font-size: 0.92rem;
  font-weight: 650;
  text-decoration: none;
  border-radius: 8px;
}

.nav-item.active {
  color: var(--red-dark);
  background: #fff0f2;
}

.nav-icon {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-radius: 5px;
  opacity: 0.8;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 1.35rem;
  line-height: 1.15;
}

h2 {
  font-size: 1rem;
  line-height: 1.25;
}

h3 {
  font-size: 1rem;
  line-height: 1.25;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 68px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.toolbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.status {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
}

.module {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dashboard-panel {
  min-height: 360px;
  padding: 14px;
}

.panel-quarter {
  grid-column: span 3;
}

.panel-half {
  grid-column: span 6;
}

.module-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.range-select-label {
  display: grid;
  gap: 4px;
  min-width: 104px;
}

.range-select-label span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

.range-select-label select {
  min-height: 32px;
  padding: 0 30px 0 10px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 0.86rem;
  font-weight: 650;
}

.module-label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

.chart-module {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 12px;
}

.chart-wrap {
  position: relative;
  justify-self: center;
  width: min(180px, 100%);
  aspect-ratio: 1;
}

#entryChart {
  width: 100%;
  height: 100%;
}

.chart-center {
  position: absolute;
  inset: 50% auto auto 50%;
  display: grid;
  place-items: center;
  width: 44%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
}

.chart-center strong {
  font-size: 1.25rem;
  line-height: 1;
}

.chart-center span {
  margin-top: -10px;
  color: var(--muted);
  font-size: 0.72rem;
}

.legend-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 64px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-soft);
}

.metric-swatch {
  width: 8px;
  height: 32px;
  flex: 0 0 8px;
  border-radius: 8px;
}

.success .metric-swatch {
  background: var(--green);
}

.failed .metric-swatch {
  background: var(--red);
}

.legend-item p {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.legend-item strong {
  font-size: 1.28rem;
  line-height: 1;
}

.period-meta {
  display: grid;
  gap: 3px;
  margin: 12px 0 0;
  padding-top: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  border-top: 1px solid var(--line-soft);
}

.top-users-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.top-users-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 32px;
  padding: 7px 9px;
  color: var(--ink);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--surface-soft);
  font-size: 0.84rem;
}

.top-users-list span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-users-list strong {
  color: var(--red-dark);
  font-size: 0.88rem;
}

.top-users-list .top-user-empty {
  justify-content: center;
  color: var(--muted);
}

.hourly-chart {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 8px;
  min-height: 254px;
  padding: 8px 0 0;
}

.hourly-axis {
  position: relative;
  height: 234px;
  margin-bottom: 20px;
}

.hourly-axis span {
  position: absolute;
  right: 0;
  transform: translateY(50%);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
}

.hourly-plot {
  display: grid;
  grid-template-columns: repeat(24, minmax(0, 1fr));
  align-items: end;
  gap: 5px;
  min-width: 0;
  background:
    repeating-linear-gradient(
      to top,
      var(--line-soft) 0,
      var(--line-soft) 1px,
      transparent 1px,
      transparent calc((100% - 20px) / var(--axis-steps, 2))
    );
}

.hourly-bar {
  display: grid;
  grid-template-rows: 1fr 20px;
  align-items: end;
  min-width: 0;
  height: 254px;
}

.hourly-track {
  display: flex;
  align-items: end;
  width: 100%;
  height: 100%;
  border-radius: 5px;
  background: var(--surface-soft);
  box-shadow: inset 0 0 0 1px var(--line-soft);
}

.hourly-track span {
  display: block;
  width: 100%;
  border-radius: 5px 5px 2px 2px;
  background: linear-gradient(180deg, var(--red) 0%, var(--red-dark) 100%);
}

.hourly-bar em {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.66rem;
  font-style: normal;
  text-align: center;
  white-space: nowrap;
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .sidebar {
    padding-inline: 10px;
  }

  .brand {
    justify-content: center;
    padding: 0;
  }

  .brand div:last-child,
  .nav-item {
    font-size: 0;
  }

  .nav-item {
    justify-content: center;
    padding: 0;
  }

  .panel-quarter {
    grid-column: span 6;
  }

  .panel-half {
    grid-column: span 12;
  }
}

@media (max-width: 780px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-list {
    grid-template-columns: 1fr;
  }

  .nav-item {
    font-size: 0;
  }

  .workspace {
    padding: 14px;
  }

  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-quarter,
  .panel-half {
    grid-column: span 12;
  }

  .status {
    white-space: normal;
  }
}
