:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --line: #dfe3ea;
  --text: #17202e;
  --muted: #667085;
  --blue: #2563eb;
  --green: #07855f;
  --red: #c2413a;
  --amber: #b7791f;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #101828;
  color: #eef2f7;
  padding: 24px 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: #2f80ed;
  font-weight: 800;
}

.brand-title {
  font-size: 18px;
  font-weight: 800;
}

.brand-subtitle {
  color: #98a2b3;
  font-size: 13px;
  margin-top: 2px;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tab {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #d0d5dd;
  cursor: pointer;
  padding: 11px 12px;
  text-align: left;
}

.nav-tab.active,
.nav-tab:hover {
  background: #1d2939;
  border-color: #344054;
  color: #ffffff;
}

.provider-panel {
  margin-top: 28px;
  border-top: 1px solid #344054;
  padding-top: 18px;
  color: #d0d5dd;
  font-size: 13px;
}

.provider-panel h2 {
  margin: 0 0 10px;
  font-size: 13px;
  color: #ffffff;
}

.provider-state {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
}

.provider-state strong {
  color: #ffffff;
  font-weight: 650;
}

.provider-state span {
  color: #98a2b3;
}

.content {
  min-width: 0;
  padding: 28px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-header h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

.page-header p {
  margin: 7px 0 0;
  color: var(--muted);
}

.ghost-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  min-width: 82px;
  padding: 10px 14px;
}

.ghost-button:hover {
  border-color: #98a2b3;
}

.filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.filters label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.filters span {
  color: var(--muted);
  font-size: 13px;
}

.filters input,
.filters select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 8px 10px;
}

.wide-field {
  grid-column: span 2;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
  box-shadow: var(--shadow);
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin-top: 9px;
  font-size: 25px;
  line-height: 1.1;
}

.metric-card.positive strong {
  color: var(--green);
}

.metric-card.negative strong {
  color: var(--red);
}

.table-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.table-toolbar h2 {
  margin: 0;
  font-size: 17px;
}

.table-toolbar span {
  color: var(--muted);
  font-size: 13px;
}

.fetch-progress {
  height: 3px;
  background: rgba(37, 99, 235, 0.08);
  overflow: hidden;
  opacity: 0;
  transition: opacity 160ms ease;
}

.fetch-progress.active {
  opacity: 1;
}

.fetch-progress-bar {
  width: 36%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2563eb 0%, #60a5fa 100%);
  transform: translateX(-120%);
}

.fetch-progress.active .fetch-progress-bar {
  animation: fetch-progress-slide 1s ease-in-out infinite;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 300px);
}

table {
  width: 100%;
  min-width: 1680px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: right;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #475467;
  font-weight: 700;
}

th:first-child,
td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  text-align: left;
}

td:first-child {
  background: var(--surface);
}

th:first-child {
  z-index: 3;
  background: #f8fafc;
}

tr:nth-child(even) td {
  background: #fbfcfe;
}

tr:nth-child(even) td:first-child {
  background: #fbfcfe;
}

.number-negative {
  color: var(--red);
}

.number-positive {
  color: var(--green);
}

.loading,
.empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

@keyframes fetch-progress-slide {
  0% {
    transform: translateX(-120%);
  }

  100% {
    transform: translateX(420%);
  }
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: var(--bg);
}

.login-form {
  display: grid;
  gap: 16px;
  width: 340px;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.login-title {
  font-size: 22px;
  font-weight: 800;
}

.login-error {
  color: var(--red);
  font-size: 13px;
  min-height: 20px;
}

.login-form label {
  display: grid;
  gap: 6px;
}

.login-form label span {
  color: var(--muted);
  font-size: 13px;
}

.login-form input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
}

.login-form button {
  min-height: 42px;
  border: none;
  border-radius: 8px;
  background: var(--blue);
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.login-form button:hover {
  opacity: 0.9;
}

/* hidden state */
.login-overlay.hidden {
  display: none;
}

@media (max-width: 1060px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    padding: 16px;
  }

  .brand {
    margin: 0;
  }

  .nav-tabs {
    grid-auto-flow: column;
  }

  .provider-panel {
    display: none;
  }

  .filters,
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .wide-field {
    grid-column: span 2;
  }
}

@media (max-width: 640px) {
  .content {
    padding: 18px;
  }

  .sidebar {
    grid-template-columns: 1fr;
  }

  .nav-tabs {
    grid-auto-flow: row;
  }

  .page-header {
    display: grid;
  }

  .filters,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .wide-field {
    grid-column: span 1;
  }
}
