:root {
  color-scheme: light;
  --ink: #162033;
  --muted: #667085;
  --line: #d8dee8;
  --panel: #ffffff;
  --paper: #f4f7fb;
  --nav: #111827;
  --nav-soft: #1f2937;
  --teal: #0f9f8f;
  --blue: #2f6fed;
  --amber: #d88a12;
  --red: #d94a45;
  --green: #1f9d5a;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 24px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

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

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  background: var(--nav);
  color: #f8fafc;
}

.back-link {
  color: #b6c4d8;
  font-size: 0.84rem;
  text-decoration: none;
}

.back-link:hover {
  color: #ffffff;
}

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

.brand-mark,
.avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #f8fafc;
  color: var(--nav);
  font-weight: 800;
}

.brand strong {
  display: block;
  letter-spacing: 0;
}

.brand small {
  display: block;
  margin-top: 2px;
  color: #aab7c8;
  font-size: 0.78rem;
}

.side-nav {
  display: grid;
  gap: 8px;
}

.side-nav a {
  padding: 11px 12px;
  border-radius: 8px;
  color: #cbd5e1;
  text-decoration: none;
  transition:
    background-color 160ms ease,
    color 160ms ease;
}

.side-nav a:hover,
.side-nav .active {
  background: var(--nav-soft);
  color: #ffffff;
}

.sidebar-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #0f172a;
}

.sidebar-note span {
  display: block;
  color: #94a3b8;
  font-size: 0.78rem;
}

.sidebar-note strong {
  display: block;
  margin-top: 3px;
  color: #7dd3fc;
}

.workspace {
  width: min(100%, 1240px);
  margin: 0 auto;
  padding: 28px;
}

.kpi-grid,
.chart-grid,
.health-grid,
.panel {
  scroll-margin-top: 24px;
}

.topbar,
.toolbar,
.panel,
.health-card,
.kpi-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 40px rgba(16, 24, 40, 0.06);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.6rem, 2vw, 2.25rem);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
  letter-spacing: 0;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search {
  display: grid;
  gap: 4px;
}

.search span {
  color: var(--muted);
  font-size: 0.72rem;
}

.search input {
  width: 210px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--ink);
}

.icon-button {
  position: relative;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.bell-dot {
  position: absolute;
  top: 9px;
  right: 10px;
  width: 8px;
  height: 8px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: var(--red);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding: 14px 16px;
}

.toolbar span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.9rem;
}

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

.segmented button {
  min-width: 78px;
  padding: 8px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}

.segmented .selected {
  background: var(--nav);
  color: #ffffff;
}

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

.kpi-card {
  min-height: 138px;
  padding: 16px;
}

.kpi-card.is-hidden {
  display: none;
}

.kpi-card.skeleton {
  position: relative;
  overflow: hidden;
}

.kpi-card.skeleton::before,
.kpi-card.skeleton::after {
  content: "";
  display: block;
  border-radius: 999px;
  background: #edf2f7;
}

.kpi-card.skeleton::before {
  width: 52%;
  height: 13px;
}

.kpi-card.skeleton::after {
  width: 72%;
  height: 30px;
  margin-top: 24px;
}

.kpi-card.skeleton span {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.72), transparent);
  animation: shimmer 950ms infinite;
}

.empty-kpi {
  grid-column: 1 / -1;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@keyframes shimmer {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(100%);
  }
}

.kpi-card span {
  color: var(--muted);
  font-size: 0.86rem;
}

.kpi-card strong {
  display: block;
  margin-top: 12px;
  font-size: clamp(1.65rem, 3vw, 2.25rem);
  letter-spacing: 0;
}

.trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
}

.trend.up {
  background: #e8f8ef;
  color: var(--green);
}

.trend.down {
  background: #fff1ed;
  color: var(--red);
}

.chart-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.85fr);
  gap: 14px;
  margin-top: 14px;
}

.panel {
  min-width: 0;
  padding: 16px;
}

.line-panel {
  grid-row: span 2;
}

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

.panel-heading span {
  color: var(--muted);
  font-size: 0.84rem;
  white-space: nowrap;
}

.line-chart-wrap {
  min-height: 315px;
  overflow-x: auto;
}

.line-chart {
  width: 100%;
  min-width: 620px;
  min-height: 315px;
}

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

.axis-label {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

#revenueLine {
  fill: none;
  stroke: var(--blue);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dot {
  fill: #ffffff;
  stroke: var(--blue);
  stroke-width: 4;
  cursor: pointer;
  transition:
    r 160ms ease,
    stroke-width 160ms ease;
}

.dot:hover,
.dot:focus {
  r: 8;
  stroke-width: 5;
}

.line-label {
  fill: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.bar-chart {
  display: grid;
  gap: 14px;
  padding-top: 5px;
}

.bar-item {
  display: grid;
  grid-template-columns: 86px 1fr 82px;
  align-items: center;
  gap: 10px;
}

.bar-item span {
  color: var(--muted);
  font-size: 0.84rem;
}

.bar-track {
  position: relative;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #ecf1f7;
}

.bar-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--blue));
  transition: width 700ms cubic-bezier(0.22, 1, 0.36, 1);
}

.target-marker {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  background: var(--nav);
  opacity: 0.7;
}

.bar-value {
  display: grid;
  gap: 2px;
  justify-items: end;
  font-size: 0.78rem;
}

.bar-value strong {
  color: var(--ink);
}

.bar-value small {
  color: var(--muted);
  font-size: 0.72rem;
}

.donut-row {
  display: grid;
  grid-template-columns: 132px 1fr;
  align-items: center;
  gap: 18px;
}

.donut {
  position: relative;
  display: grid;
  place-items: center;
  width: 132px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--blue) 0 54%, var(--teal) 54% 79%, var(--amber) 79% 100%);
}

.donut::after {
  content: "";
  position: absolute;
  inset: 28px;
  border-radius: 50%;
  background: #ffffff;
}

.donut span {
  position: relative;
  z-index: 1;
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 900;
}

.legend {
  display: grid;
  gap: 9px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.legend li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 7px;
  border-radius: 50%;
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.health-card {
  padding: 14px;
}

.health-card span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.84rem;
}

.health-state {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.ok {
  background: var(--green);
}

.watch {
  background: var(--amber);
}

.bad {
  background: var(--red);
}

@media (max-width: 980px) {
  html {
    scroll-padding-top: 14px;
  }

  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 18px;
  }

  .side-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .sidebar-note {
    margin-top: 0;
  }

  .workspace {
    padding: 18px;
  }

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

  .chart-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    align-items: stretch;
  }

  .search {
    flex: 1;
  }

  .search input {
    width: 100%;
  }

  .brand small {
    display: none;
  }

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

  .kpi-grid,
  .health-grid {
    grid-template-columns: 1fr;
  }

  .bar-item {
    grid-template-columns: 74px 1fr 74px;
  }

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

  .line-chart {
    min-width: 560px;
  }
}
