:root {
  color-scheme: light;
  --background: #f7f8f5;
  --surface: rgba(255, 255, 253, 0.9);
  --surface-strong: #ffffff;
  --surface-muted: #f1f3ef;
  --ink: #181b19;
  --muted: #606861;
  --faint: #89918b;
  --line: rgba(36, 44, 38, 0.14);
  --line-strong: rgba(36, 44, 38, 0.25);
  --green: #16764a;
  --green-soft: #e6f4eb;
  --amber: #a35b06;
  --amber-soft: #fff1d8;
  --red: #b23b35;
  --red-soft: #fde9e7;
  --gray-soft: #ebeeeb;
  --shadow: 0 18px 58px rgba(31, 42, 34, 0.12);
  --shadow-soft: 0 8px 26px rgba(31, 42, 34, 0.08);
  --display: Georgia, "Times New Roman", "Noto Serif SC", serif;
  --body: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--background);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: transparent;
  font-family: var(--body);
  letter-spacing: 0;
}

button {
  color: inherit;
  font: inherit;
  letter-spacing: 0;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

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

.page-backdrop {
  position: fixed;
  z-index: 0;
  inset: 0;
  overflow: hidden;
  background-image:
    linear-gradient(to bottom, rgba(250, 251, 248, 0.88) 0%, rgba(247, 249, 246, 0.82) 40%, rgba(247, 248, 245, 0.94) 100%),
    url("/assets/control-room.jpg");
  background-position: center;
  background-size: cover;
}

.topbar,
.shell {
  position: relative;
  z-index: 1;
}

.topbar {
  width: min(1280px, calc(100% - 40px));
  min-height: 68px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
}

.brand {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  font-family: var(--display);
  font-size: 27px;
  line-height: 1;
}

.live-mark {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.live-mark i,
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(22, 118, 74, 0.1);
}

.pool-tabs {
  justify-self: center;
  min-width: 0;
  padding: 4px;
  display: flex;
  align-items: center;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 253, 0.72);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
}

.pool-tab {
  min-width: 112px;
  height: 36px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  transition: color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.pool-tab:hover {
  color: var(--ink);
  background: var(--surface-muted);
}

.pool-tab[aria-selected="true"] {
  color: #fff;
  background: var(--ink);
  box-shadow: 0 6px 18px rgba(24, 27, 25, 0.18);
}

.pool-tab-count {
  min-width: 21px;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(96, 104, 97, 0.12);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.pool-tab[aria-selected="true"] .pool-tab-count {
  background: rgba(255, 255, 255, 0.16);
}

.icon-button {
  justify-self: end;
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  transition: transform 160ms ease, opacity 160ms ease;
}

.icon-button:hover {
  transform: rotate(24deg);
}

.icon-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.icon-button.loading span {
  animation: spin 700ms linear infinite;
}

.shell {
  width: min(1280px, calc(100% - 40px));
  margin: 0 auto;
  padding: 0 0 28px;
}

.hero {
  min-height: 196px;
  padding: 32px 0 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.eyebrow,
.section-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.eyebrow {
  margin-bottom: 12px;
}

.hero h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 58px;
  font-weight: 400;
  line-height: 1;
}

.hero h1 em {
  color: var(--muted);
  font-style: italic;
  font-weight: 400;
}

.hero-meta {
  margin: 17px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  color: var(--muted);
  font-size: 12px;
}

.hero-meta span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.summary {
  display: grid;
  grid-template-columns: 1.18fr repeat(5, minmax(0, 0.82fr));
  gap: 10px;
  margin-bottom: 10px;
}

.metric {
  min-width: 0;
  min-height: 92px;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.metric.primary {
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.metric-label {
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.metric-value {
  overflow: hidden;
  color: var(--ink);
  font-family: var(--display);
  font-size: 34px;
  line-height: 0.95;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.metric-sub {
  margin-top: 9px;
  overflow: hidden;
  color: var(--faint);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric.available .metric-value {
  color: var(--green);
}

.metric.limited .metric-value {
  color: var(--amber);
}

.metric.cost .metric-value {
  color: #1b5f70;
}

.metric.problem .metric-value {
  color: var(--red);
}

.metric.reset .metric-value {
  font-size: 27px;
}

.workspace {
  min-height: 430px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.workspace-head {
  min-height: 76px;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 253, 0.84);
}

.workspace-head h2 {
  margin: 4px 0 0;
  font-size: 18px;
  line-height: 1.1;
}

.status-filters {
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-filter {
  height: 34px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-filter:hover {
  color: var(--ink);
  background: var(--surface-muted);
}

.status-filter.active {
  border-color: var(--line);
  background: var(--surface-muted);
  color: var(--ink);
}

.table-wrap {
  position: relative;
  min-height: 306px;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 1050px;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 13px 15px;
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 1px solid var(--line-strong);
  background: #f3f5f2;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

th:nth-child(1) { width: 92px; }
th:nth-child(2) { width: 210px; }
th:nth-child(3) { width: 90px; }
th:nth-child(4) { width: 150px; }
th:nth-child(5),
th:nth-child(6) { width: 254px; }

.channel-table {
  min-width: 1180px;
}

.channel-table th:nth-child(2) { width: 190px; }
.channel-table th:nth-child(4) { width: 135px; }
.channel-table th:nth-child(5) { width: 120px; }
.channel-table th:nth-child(6),
.channel-table th:nth-child(7) { width: 220px; }

td {
  height: 62px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
}

tbody tr {
  transition: background 150ms ease;
}

tbody tr:hover {
  background: #f8faf7;
}

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

.status-pill {
  min-width: 58px;
  height: 25px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.ok,
.status-pill.operational {
  border-color: rgba(22, 118, 74, 0.18);
  background: var(--green-soft);
  color: var(--green);
}

.status-pill.limited,
.status-pill.degraded {
  border-color: rgba(163, 91, 6, 0.2);
  background: var(--amber-soft);
  color: var(--amber);
}

.status-pill.expired,
.status-pill.query_failed,
.status-pill.failed,
.status-pill.error {
  border-color: rgba(178, 59, 53, 0.18);
  background: var(--red-soft);
  color: var(--red);
}

.status-pill.disabled,
.status-pill.unknown {
  border-color: var(--line);
  background: var(--gray-soft);
  color: var(--muted);
}

.account-cell {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.account-cell strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-cell span,
.snapshot-cell span {
  color: var(--faint);
  font-size: 11px;
}

.plan-label,
.provider-label {
  font-weight: 750;
}

.latency-value {
  font-variant-numeric: tabular-nums;
}

.snapshot-cell {
  display: grid;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}

.quota {
  display: grid;
  gap: 6px;
}

.quota-top,
.quota-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-variant-numeric: tabular-nums;
}

.quota-top span,
.quota-meta {
  color: var(--faint);
  font-size: 11px;
}

.quota-top strong {
  font-size: 15px;
}

.quota-progress {
  width: 100%;
  height: 6px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: #e3e7e3;
  color: var(--green);
  appearance: none;
}

.quota-progress::-webkit-progress-bar {
  border-radius: 999px;
  background: #e3e7e3;
}

.quota-progress::-webkit-progress-value {
  min-width: 2px;
  border-radius: 999px;
  background: currentColor;
}

.quota-progress::-moz-progress-bar {
  min-width: 2px;
  border-radius: 999px;
  background: currentColor;
}

.quota.warn .quota-progress {
  color: var(--amber);
}

.quota.danger .quota-progress {
  color: var(--red);
}

.quota.missing {
  min-height: 38px;
  align-content: center;
  color: var(--faint);
  font-size: 12px;
}

.empty-state {
  min-height: 250px;
  padding: 28px;
  display: grid;
  place-content: center;
  gap: 7px;
  text-align: center;
}

.empty-state strong {
  font-size: 15px;
}

.empty-state span {
  color: var(--muted);
  font-size: 12px;
}

.pagination {
  min-height: 52px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  border-top: 1px solid var(--line);
  background: #f3f5f2;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.page-button {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-strong);
  color: var(--ink);
  cursor: pointer;
  font-size: 17px;
}

.page-button:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--surface-muted);
}

.page-button:disabled {
  cursor: default;
  opacity: 0.38;
}

.error-banner {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(390px, calc(100% - 36px));
  padding: 13px 15px;
  display: grid;
  gap: 4px;
  border: 1px solid rgba(178, 59, 53, 0.22);
  border-radius: 7px;
  background: var(--red-soft);
  box-shadow: var(--shadow);
  color: var(--red);
}

.error-banner span {
  font-size: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 1040px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
  }

  .pool-tabs {
    max-width: 100%;
    overflow-x: auto;
    justify-self: stretch;
  }

  .pool-tab {
    min-width: 104px;
    flex: 1 0 auto;
  }

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

  .metric.primary {
    grid-column: span 1;
  }
}

@media (max-width: 720px) {
  .page-backdrop {
    background-position: 42% center;
  }

  .topbar {
    width: min(100% - 24px, 1280px);
    padding: 12px 0 8px;
    grid-template-columns: 1fr auto;
    gap: 10px;
  }

  .brand-mark {
    font-size: 23px;
  }

  .pool-tabs {
    grid-column: 1 / -1;
    grid-row: 2;
    order: 3;
  }

  .icon-button {
    grid-column: 2;
    grid-row: 1;
  }

  .shell {
    width: min(100% - 24px, 1280px);
  }

  .hero {
    min-height: 174px;
    padding: 30px 0 24px;
  }

  .hero h1 {
    font-size: 43px;
  }

  .hero-meta {
    gap: 12px;
    flex-wrap: wrap;
  }

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

  .metric {
    min-height: 86px;
  }

  .workspace-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .status-filters {
    width: 100%;
    overflow-x: auto;
  }

  .status-filter {
    flex: 0 0 auto;
  }

  .table-wrap {
    overflow-x: hidden;
  }

  table,
  .channel-table {
    min-width: 0;
    display: block;
  }

  thead {
    display: none;
  }

  tbody {
    display: block;
  }

  tbody tr {
    padding: 15px;
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr) 58px;
    gap: 13px 10px;
    border-bottom: 1px solid var(--line);
  }

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

  tbody td {
    width: auto;
    height: auto;
    padding: 0;
    border: 0;
  }

  tbody td:nth-child(1),
  tbody td:nth-child(2),
  tbody td:nth-child(3) {
    align-self: center;
  }

  tbody td:nth-child(4),
  tbody td:nth-child(5),
  tbody td:nth-child(6),
  tbody td:nth-child(7) {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
  }

  tbody td:nth-child(4) {
    padding-top: 12px;
    border-top: 1px solid var(--line);
  }

  tbody td:nth-child(4)::before,
  tbody td:nth-child(5)::before,
  tbody td:nth-child(6)::before,
  tbody td:nth-child(7)::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 750;
  }

  .pagination {
    position: sticky;
    bottom: 0;
    z-index: 2;
  }
}

@media (max-width: 420px) {
  .live-mark {
    display: none;
  }

  .pool-tabs {
    gap: 1px;
    padding: 3px;
  }

  .pool-tab {
    min-width: 0;
    padding-inline: 4px;
    flex: 1 1 0;
    gap: 4px;
    font-size: 12px;
  }

  .pool-tab-count {
    min-width: 18px;
    padding-inline: 3px;
  }

  .hero h1 {
    font-size: 38px;
  }

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

  .metric-value {
    font-size: 31px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
