:root {
  color-scheme: dark;
  --bg: #16161a;
  --surface: #232429;
  --surface-soft: #2c2d33;
  --text: #e8ebf5;
  --muted: #9aa3b2;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .14);
  --blue: #1683f7;
  --green: #2ccd50;
  --green-soft: rgba(44, 205, 80, .18);
  --cyan: #37d4e8;
  --cyan-soft: rgba(55, 212, 232, .18);
  --lime: #9bd45f;
  --lime-soft: rgba(155, 212, 95, .18);
  --amber: #ff9914;
  --amber-soft: rgba(255, 153, 20, .18);
  --red: #ff6b57;
  --red-soft: rgba(255, 107, 87, .18);
  --empty: rgba(255, 255, 255, .07);
  --shadow: 0 16px 34px rgba(0, 0, 0, .28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-soft: #f7f8fb;
  --text: #17202a;
  --muted: #667386;
  --line: rgba(22, 32, 42, .09);
  --line-strong: rgba(22, 32, 42, .16);
  --green-soft: rgba(44, 205, 80, .14);
  --cyan-soft: rgba(55, 212, 232, .16);
  --lime-soft: rgba(155, 212, 95, .16);
  --amber-soft: rgba(255, 153, 20, .16);
  --red-soft: rgba(255, 107, 87, .16);
  --empty: rgba(22, 32, 42, .08);
  --shadow: 0 14px 30px rgba(26, 38, 54, .1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  transition: background-color .2s ease, color .2s ease;
}

.shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 40px;
}

.topbar,
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.25;
}

h2 {
  font-size: 15px;
  line-height: 1.3;
}

p,
.section-head span,
td,
th {
  color: var(--muted);
}

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

.cache-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .06);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 700;
}

.icon-button {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .06);
  color: var(--text);
  cursor: pointer;
  font-size: 17px;
  transition: transform .16s ease, border-color .16s ease, background-color .16s ease;
}

.icon-button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, .1);
}

.summary-section,
.pool-section,
.status-section {
  margin-top: 22px;
}

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

.metrics article {
  position: relative;
  min-width: 0;
  min-height: 132px;
  overflow: hidden;
  padding: 24px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  animation: fade-up .36s ease both;
}

.metrics article::before,
.metrics article::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
}

.metrics article::before {
  width: 112px;
  height: 112px;
  top: -28px;
  right: -16px;
}

.metrics article::after {
  width: 94px;
  height: 94px;
  right: 28px;
  bottom: -40px;
}

.metrics article:nth-child(1) {
  background: var(--blue);
  animation-delay: .02s;
}

.metrics article:nth-child(2),
.metrics article:nth-child(4),
.metrics article:nth-child(5) {
  background: var(--green);
  animation-delay: .06s;
}

.metrics article:nth-child(3) {
  background: var(--amber);
  animation-delay: .1s;
}

.metrics span,
.metrics strong {
  position: relative;
  z-index: 1;
}

.metrics span {
  display: block;
  color: rgba(255, 255, 255, .82);
  font-size: 13px;
  margin-bottom: 22px;
}

.metrics strong {
  display: block;
  overflow: hidden;
  color: #ffffff;
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.02;
  font-weight: 780;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pool-section,
.status-section {
  background: rgba(35, 36, 41, .84);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 16px;
  animation: fade-up .38s ease both;
}

:root[data-theme="light"] .pool-section,
:root[data-theme="light"] .status-section {
  background: rgba(255, 255, 255, .88);
}

.table-wrap {
  overflow: auto;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

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

thead {
  background: rgba(255, 255, 255, .04);
}

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

tbody tr:last-child td {
  border-bottom: 0;
}

td strong {
  color: var(--text);
}

.status-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, .03);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  color: var(--muted);
  font-size: 12px;
}

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

.dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  display: inline-block;
}

.dot.excellent {
  background: var(--cyan);
}

.dot.good {
  background: var(--green);
}

.dot.normal {
  background: var(--lime);
}

.dot.poor {
  background: var(--amber);
}

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

.dot.empty {
  background: var(--empty);
  border: 1px solid var(--line-strong);
}

#model-filter {
  width: min(260px, 100%);
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, .06);
  color: var(--text);
  outline: none;
  padding: 0 12px;
}

#model-filter::placeholder {
  color: rgba(154, 163, 178, .72);
}

.status-scroll {
  overflow-x: auto;
  margin-top: 12px;
  padding-bottom: 2px;
}

.hour-head {
  display: grid;
  grid-template-columns: minmax(260px, 360px) repeat(var(--hours), minmax(22px, 1fr));
  gap: 6px;
  align-items: end;
  min-width: calc(260px + var(--hours) * 28px);
  padding: 0 10px 6px;
}

.hour-label {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  min-height: 14px;
  white-space: nowrap;
}

.model-grid {
  margin-top: 2px;
  padding-bottom: 2px;
}

.model-row {
  display: grid;
  grid-template-columns: minmax(260px, 360px) repeat(var(--hours), minmax(22px, 1fr));
  gap: 6px;
  align-items: center;
  min-width: calc(260px + var(--hours) * 28px);
  min-height: 44px;
  margin-top: 8px;
  padding: 12px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, .035);
  animation: row-in .24s ease both;
}

.model-row.status-excellent {
  border-color: rgba(55, 212, 232, .38);
  background: linear-gradient(90deg, rgba(55, 212, 232, .08), rgba(255, 255, 255, .032) 36%);
}

.model-row.status-good {
  border-color: rgba(44, 205, 80, .32);
  background: linear-gradient(90deg, rgba(44, 205, 80, .075), rgba(255, 255, 255, .032) 36%);
}

.model-row.status-normal {
  border-color: rgba(155, 212, 95, .3);
  background: linear-gradient(90deg, rgba(155, 212, 95, .075), rgba(255, 255, 255, .032) 36%);
}

.model-row.status-poor {
  border-color: rgba(255, 153, 20, .34);
  background: linear-gradient(90deg, rgba(255, 153, 20, .085), rgba(255, 255, 255, .032) 36%);
}

.model-row.status-bad {
  border-color: rgba(255, 107, 87, .36);
  background: linear-gradient(90deg, rgba(255, 107, 87, .09), rgba(255, 255, 255, .032) 36%);
}

.model-row[hidden] {
  display: none;
}

.model-name {
  position: relative;
  overflow: hidden;
  min-height: 44px;
  padding: 2px 10px 2px 14px;
}

.model-name::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 5px;
  border-radius: 999px;
  background: var(--empty);
}

.model-name.status-excellent::before {
  background: var(--cyan);
  box-shadow: 0 0 18px rgba(55, 212, 232, .45);
}

.model-name.status-good::before {
  background: var(--green);
  box-shadow: 0 0 18px rgba(44, 205, 80, .36);
}

.model-name.status-normal::before {
  background: var(--lime);
  box-shadow: 0 0 18px rgba(155, 212, 95, .34);
}

.model-name.status-poor::before {
  background: var(--amber);
  box-shadow: 0 0 18px rgba(255, 153, 20, .34);
}

.model-name.status-bad::before {
  background: var(--red);
  box-shadow: 0 0 18px rgba(255, 107, 87, .36);
}

.model-name strong,
.model-name .model-meta {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.model-name strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.model-name.status-excellent strong {
  color: var(--cyan);
}

.model-name.status-good strong {
  color: var(--green);
}

.model-name.status-normal strong {
  color: var(--lime);
}

.model-name.status-poor strong {
  color: var(--amber);
}

.model-name.status-bad strong {
  color: var(--red);
}

.model-meta {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  margin-top: 6px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  max-width: 96px;
  min-height: 22px;
  overflow: hidden;
  border-radius: 7px;
  padding: 2px 7px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-excellent .meta-chip.rate {
  background: var(--cyan-soft);
  color: var(--cyan);
}

.status-good .meta-chip.rate {
  background: var(--green-soft);
  color: var(--green);
}

.status-normal .meta-chip.rate {
  background: var(--lime-soft);
  color: var(--lime);
}

.status-poor .meta-chip.rate {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-bad .meta-chip.rate {
  background: var(--red-soft);
  color: var(--red);
}

.meta-chip.token,
.meta-chip.request {
  background: rgba(255, 255, 255, .055);
  color: var(--muted);
  font-weight: 650;
}

:root[data-theme="light"] .meta-chip.token,
:root[data-theme="light"] .meta-chip.request {
  background: rgba(22, 32, 42, .06);
}

.cell {
  width: 100%;
  max-width: 34px;
  aspect-ratio: 1 / 1;
  height: auto;
  justify-self: center;
  align-self: center;
  border-radius: 8px;
  border: 2px solid transparent;
  background: var(--empty);
  transition: transform .12s ease, box-shadow .12s ease;
}

.cell:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, .28);
}

.cell.empty {
  border-color: transparent;
}

.cell.excellent {
  background: var(--cyan-soft);
  border-color: var(--cyan);
}

.cell.good {
  background: var(--green-soft);
  border-color: var(--green);
}

.cell.normal {
  background: var(--lime-soft);
  border-color: var(--lime);
}

.cell.poor {
  background: var(--amber-soft);
  border-color: var(--amber);
}

.cell.bad {
  background: var(--red-soft);
  border-color: var(--red);
}

.cell.busy {
  box-shadow: inset 0 -5px 0 rgba(255, 255, 255, .12);
}

.cell-tooltip {
  position: fixed;
  z-index: 50;
  left: 0;
  top: 0;
  min-width: 190px;
  max-width: 280px;
  pointer-events: none;
  white-space: pre-line;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(22, 22, 26, .96);
  color: var(--text);
  box-shadow: 0 16px 36px rgba(0, 0, 0, .34);
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.65;
  backdrop-filter: blur(10px);
}

:root[data-theme="light"] .cell-tooltip {
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 16px 36px rgba(26, 38, 54, .18);
}

.cell-tooltip[hidden] {
  display: none;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes row-in {
  from {
    opacity: 0;
    transform: translateX(-6px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (max-width: 980px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .metrics article:last-child {
    grid-column: span 2;
  }

  .status-tools {
    align-items: stretch;
    flex-direction: column;
  }

  #model-filter {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100vw - 20px, 1480px);
    padding-top: 16px;
  }

  .topbar,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }

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

  .metrics article:last-child {
    grid-column: auto;
  }

  .meta-chip.request {
    display: none;
  }

  .cell {
    border-radius: 7px;
  }
}
