:root {
  --black: #171717;
  --canvas: #fafafa;
  --gray-50: #fafafa;
  --gray-100: #ebebeb;
  --gray-400: #808080;
  --gray-500: #666666;
  --gray-600: #4d4d4d;
  --blue: #0072f5;
  --on-accent: #ffffff;
  --focus: hsl(212, 100%, 48%);
  --surface-1: #ffffff;
  --surface-2: #fafafa;
  --surface-3: #f5f5f5;
  --hairline: #ebebeb;
  --hairline-strong: rgba(0, 0, 0, 0.08);
  --ink-muted: #4d4d4d;
  --ink-subtle: #666666;
  --success: #047857;
  --danger: #b91c1c;
  --ring: rgba(0, 0, 0, 0.08) 0 0 0 1px;
  --ring-light: inset 0 0 0 1px var(--hairline);
  --card: rgba(0, 0, 0, 0.08) 0 0 0 1px, rgba(0, 0, 0, 0.04) 0 2px 2px, rgb(250, 250, 250) 0 0 0 1px;
  --font-sans: "Geist", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-family: var(--font-sans);
  color: var(--black);
  background: var(--canvas);
  font-feature-settings: "liga" 1;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--canvas);
  color-scheme: light;
}

button,
select {
  font: inherit;
}

button:focus-visible,
select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  min-width: 0;
  padding: 14px 12px;
  box-shadow: var(--ring-light);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 32px;
  margin-bottom: 18px;
  font-size: 13px;
  font-weight: 600;
}

.triangle {
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 15px solid var(--black);
}

.nav,
.app-row,
.primary,
.secondary,
.empty button {
  border: 0;
  cursor: pointer;
}

.nav {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border-radius: 6px;
  background: var(--black);
  color: var(--on-accent);
  text-align: left;
  font-size: 14px;
  font-weight: 500;
}

.app-list {
  display: grid;
  gap: 3px;
  margin-top: 12px;
}

.app-row {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 40px;
  padding: 6px;
  border-radius: 6px;
  background: transparent;
  color: var(--black);
  text-align: left;
}

.app-row:hover,
.app-row.selected {
  background: var(--surface-2);
  box-shadow: var(--ring-light);
}

.app-row strong {
  display: block;
  overflow: hidden;
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-row small,
td small,
.detail small,
.muted {
  display: block;
  color: var(--gray-500);
  font-size: 12px;
}

.status i {
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: var(--blue);
}

.app-row i {
  display: none;
}

.app-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--black);
  color: var(--on-accent);
  box-shadow: var(--ring-light);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
}

.app-icon.large {
  width: 44px;
  height: 44px;
}

.workspace {
  min-width: 0;
  overflow: hidden;
  padding: 14px 22px 24px;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  margin: -14px -22px 12px;
  padding: 8px 22px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  box-shadow: var(--ring-light);
}

select,
.primary,
.secondary,
.status {
  height: 32px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
}

select {
  min-width: 132px;
  border: 0;
  background: var(--surface-1);
  color: var(--black);
  padding: 0 9px;
  box-shadow: var(--ring-light);
}

.primary {
  padding: 0 14px;
  background: var(--black);
  color: var(--on-accent);
}

.primary:hover {
  background: #2b3340;
}

.secondary {
  padding: 0 12px;
  background: var(--surface-1);
  color: var(--black);
  box-shadow: var(--ring-light);
}

.secondary:hover {
  box-shadow: var(--ring);
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 0 10px;
  background: var(--surface-2);
  color: var(--ink-muted);
  font-size: 12px;
  white-space: nowrap;
}

.muted {
  white-space: nowrap;
}

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

.hero h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: -0.96px;
}

.hero p {
  margin: 6px 0 0;
  color: var(--ink-subtle);
  font-size: 13px;
}

.hero strong {
  color: var(--black);
  font-size: 36px;
  font-weight: 600;
  line-height: 1;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(118px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.kpi {
  border: 0;
  border-radius: 8px;
  background: var(--surface-1);
  padding: 11px 12px;
  box-shadow: var(--card);
  text-align: left;
  cursor: pointer;
  min-width: 0;
}

.kpi.selected {
  background: #ffffff;
  box-shadow: rgba(0, 114, 245, 0.55) 0 0 0 1px, rgba(0, 114, 245, 0.06) 0 2px 2px;
}

.kpi:last-child {
  box-shadow: none;
}

.kpi span,
.panel-title span,
.metric-row span {
  color: var(--gray-500);
  font-size: 12px;
  font-weight: 500;
}

.kpi strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.1;
  white-space: nowrap;
}

.kpi em,
.pill {
  display: inline-flex;
  margin-top: 5px;
  font-style: normal;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.up {
  color: var(--success);
}

.down {
  color: var(--danger);
}

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

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

.panel h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
}

.panel-title,
.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
}

.trend {
  overflow: hidden;
}

.chart {
  display: block;
  width: 100%;
  height: clamp(240px, 24vw, 320px);
}

.chart line {
  stroke: var(--hairline);
}

.chart text {
  fill: var(--gray-500);
  font-family: var(--font-mono);
  font-size: 11px;
}

.chart path {
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart circle {
  opacity: 0.72;
}

.chart circle:hover {
  opacity: 1;
  stroke: var(--black);
  stroke-width: 2;
}

.chart .end-label {
  paint-order: stroke;
  stroke: var(--surface-1);
  stroke-width: 4px;
  font-weight: 600;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 0 14px 12px;
  color: var(--gray-500);
  font-size: 12px;
  max-height: 48px;
  overflow: auto;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  width: 7px;
  height: 7px;
  border-radius: 9999px;
}

.detail-head {
  justify-content: flex-start;
  box-shadow: inset 0 -1px 0 var(--hairline);
}

.detail-head h2 {
  max-width: 230px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  box-shadow: inset 0 -1px 0 var(--hairline);
}

.metric-row strong,
td {
  font-variant-numeric: tabular-nums;
}

.empty {
  margin: 16px;
  padding: 18px;
  border-radius: 12px;
  background: var(--surface-2);
  box-shadow: var(--ring-light);
  color: var(--gray-600);
}

.empty strong {
  color: var(--black);
  font-size: 14px;
  font-weight: 600;
}

.empty p {
  margin: 8px 0 14px;
  font-size: 13px;
  line-height: 1.5;
}

.empty button {
  height: 32px;
  border-radius: 8px;
  padding: 0 12px;
  background: var(--blue);
  color: var(--on-accent);
  font-size: 13px;
  font-weight: 500;
}

.table-panel {
  margin-top: 8px;
  overflow-x: auto;
}

.table-panel h2 {
  padding: 12px 14px;
  box-shadow: inset 0 -1px 0 var(--hairline);
}

table {
  width: 100%;
  min-width: 960px;
  border-collapse: collapse;
}

th,
td {
  padding: 9px 10px;
  box-shadow: inset 0 -1px 0 var(--hairline);
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  min-width: 260px;
  white-space: normal;
}

th {
  color: var(--gray-500);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
}

td strong {
  display: block;
  font-weight: 500;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #f8fbff;
}

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

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

  .brand {
    margin-bottom: 12px;
  }

  .nav {
    max-width: 180px;
  }

  .app-list {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .app-row {
    flex: 0 0 190px;
  }

  .workspace {
    padding: 14px;
  }

  .toolbar {
    position: static;
    margin: 0 0 14px;
    padding: 0;
    box-shadow: none;
    flex-wrap: wrap;
  }

  .status {
    margin-left: 0;
  }

  .hero {
    align-items: flex-start;
  }

  .hero strong {
    font-size: 34px;
  }

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

  .trend {
    overflow-x: auto;
  }
}

@media (max-width: 560px) {
  select {
    min-width: 0;
    flex: 1 1 120px;
  }
}

@media (max-width: 360px) {
  .kpis {
    grid-template-columns: 1fr;
  }
}
