:root {
  --background: #fafaf9;
  --foreground: #0f172a;
  --muted-foreground: #64748b;
  --card: rgba(255, 255, 255, 0.94);
  --card-strong: #ffffff;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.12);
  --primary: #111827;
  --primary-foreground: #f8fafc;
  --secondary: #f8fafc;
  --secondary-foreground: #0f172a;
  --muted: #f8fafc;
  --accent: #eef2ff;
  --accent-foreground: #3730a3;
  --success: #059669;
  --success-soft: rgba(5, 150, 105, 0.1);
  --sky: #0284c7;
  --sky-soft: rgba(2, 132, 199, 0.1);
  --violet: #7c3aed;
  --violet-soft: rgba(124, 58, 237, 0.1);
  --amber: #d97706;
  --amber-soft: rgba(217, 119, 6, 0.12);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.12);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.05);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", "Noto Sans SC", sans-serif;
  color: var(--foreground);
  background:
    radial-gradient(circle at top left, rgba(148, 163, 184, 0.14), transparent 28%),
    radial-gradient(circle at bottom right, rgba(59, 130, 246, 0.08), transparent 26%),
    linear-gradient(180deg, #ffffff 0%, #fafaf9 48%, #f5f7fb 100%);
}

.shell {
  position: relative;
  min-height: 100vh;
  display: flex;
}

body.auth-mode .shell {
  display: block;
}

body.auth-mode .app-sidebar {
  display: none;
}

body.auth-mode .layout {
  width: 100%;
  max-width: none;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

body.auth-mode .login-card {
  width: min(520px, calc(100vw - 32px));
  max-width: 520px;
}

.shell-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.08) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.7), transparent 92%);
  pointer-events: none;
}

.layout {
  position: relative;
  z-index: 1;
  flex: 1;
  width: calc(100vw - 272px);
  max-width: 1680px;
  margin: 0 auto;
  padding: 28px 34px 72px;
  overflow: hidden;
}

.app-sidebar {
  position: sticky;
  top: 0;
  z-index: 2;
  width: 272px;
  height: 100vh;
  flex: 0 0 272px;
  border-right: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(20px);
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 24px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.sidebar-logo {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 14px;
  background: #2563eb;
  color: #ffffff;
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.18);
}

.sidebar-brand h1,
.sidebar-user p {
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.sidebar-brand h1 {
  font-size: 18px;
}

.sidebar-brand p,
.sidebar-user span {
  margin: 3px 0 0;
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 700;
}

.sidebar-nav {
  display: grid;
  gap: 8px;
  margin-top: 20px;
}

.sidebar-token-card {
  display: grid;
  gap: 7px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(239, 246, 255, 0.92), rgba(255, 255, 255, 0.9)),
    #ffffff;
}

.sidebar-token-card span,
.sidebar-token-card small {
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 800;
}

.sidebar-token-card strong {
  color: var(--foreground);
  font-size: 20px;
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--muted-foreground);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.sidebar-link:hover {
  background: rgba(15, 23, 42, 0.05);
  color: var(--foreground);
  transform: translateX(2px);
}

.sidebar-link.active {
  background: rgba(37, 99, 235, 0.1);
  color: #2563eb;
}

.sidebar-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.06);
  font-size: 12px;
  font-weight: 900;
}

.sidebar-link.active .sidebar-icon {
  background: #2563eb;
  color: #ffffff;
}

.sidebar-footer {
  display: grid;
  gap: 14px;
  margin-top: auto;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.sidebar-avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 13px;
  font-weight: 900;
}

.sidebar-footer .button {
  width: 100%;
}

.hero,
.card {
  backdrop-filter: blur(16px);
}

.hero {
  margin-bottom: 20px;
  padding: 24px;
  border-radius: calc(var(--radius-xl) + 4px);
  border: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.82)),
    var(--card);
  box-shadow: var(--shadow-md);
}

.hero-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.brand-badge,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand-badge {
  background: var(--foreground);
  color: var(--primary-foreground);
}

.brand-text {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted-foreground);
}

.hero-copy {
  max-width: 900px;
  margin: 36px auto 8px;
  text-align: center;
}

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

.hero h1,
.section-head h2,
.section-head h3,
.token-title-row h2 {
  margin: 0;
}

.hero h1 {
  font-size: clamp(1.5rem, 2.3vw, 2rem);
  line-height: 1.03;
  letter-spacing: -0.04em;
}

.hero-description {
  max-width: 900px;
  margin: 14px auto 0;
  color: var(--muted-foreground);
  font-size: 15px;
  line-height: 1.75;
}

.card {
  padding: 24px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.dashboard {
  display: grid;
  gap: 20px;
  min-width: 0;
}

.dashboard-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.dashboard-toolbar .view-switch {
  margin: 0 auto;
}

.view-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-sm);
}

.view-button {
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  background: transparent;
  color: var(--muted-foreground);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.view-button.active {
  background: var(--foreground);
  color: var(--primary-foreground);
}

.view-panel {
  display: grid;
  gap: 20px;
  min-width: 0;
}

.section-head,
.token-header,
.token-title-row,
.stat-head,
.chart-summary,
.rank-topline,
.rank-meta,
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.login-card {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 40px 36px;
  display: grid;
  justify-items: center;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.95)),
    var(--card);
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.08);
}

.login-card .section-head {
  width: 100%;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  text-align: center;
}

.login-card .section-head > div {
  text-align: center;
}

.login-card .badge-outline {
  margin: 0 auto;
}

.badge-outline {
  border-color: var(--border-strong);
  background: #fff;
  color: var(--muted-foreground);
}

.badge-muted {
  background: #f8fafc;
  border-color: var(--border);
  color: var(--muted-foreground);
}

.badge-status {
  background: var(--success-soft);
  color: var(--success);
}

.badge-status.inactive {
  background: var(--danger-soft);
  color: var(--danger);
}

.login-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-top: 24px;
  width: 100%;
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
}

.field {
  display: grid;
  gap: 10px;
  text-align: center;
}

.field span {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted-foreground);
}

.field input,
.field select {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: #ffffff;
  color: var(--foreground);
  font: inherit;
  text-align: center;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.field input:focus,
.field select:focus {
  border-color: rgba(15, 23, 42, 0.24);
  box-shadow: 0 0 0 4px rgba(15, 23, 42, 0.06);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease, background 0.18s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

.button-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: var(--shadow-sm);
}

.button-secondary {
  background: #ffffff;
  color: var(--secondary-foreground);
  border-color: var(--border-strong);
}

.login-form .button {
  width: 100%;
  max-width: 240px;
  margin: 4px auto 0;
}

.status-message {
  min-height: 20px;
  margin: 16px 0 0;
  color: var(--muted-foreground);
  font-size: 14px;
  text-align: center;
}

.login-test-link {
  justify-self: end;
  margin-top: 8px;
  color: var(--muted-foreground);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.login-test-link:hover {
  color: #2563eb;
  text-decoration: underline;
}

.status-message.error {
  color: var(--danger);
}

.token-card {
  padding: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 1), rgba(248, 250, 252, 0.92)),
    var(--card-strong);
}

.token-header {
  align-items: flex-start;
}

.token-title-row {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-top: 8px;
}

.token-title-row h2 {
  font-size: clamp(1.15rem, 1.7vw, 1.45rem);
  line-height: 1;
  letter-spacing: -0.04em;
}

.token-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
}

.meta-item {
  min-width: 0;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(248, 250, 252, 0.88);
}

.meta-item span,
.metric-label,
.stat-card span,
.stat-card small,
.rank-meta,
.empty-text,
.empty-cell,
.chart-summary span,
th,
.pagination-text {
  color: var(--muted-foreground);
}

.stat-card > span,
.stat-card > small {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fbfcfd;
}

.stat-card > span span,
.stat-card > small span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.stat-card > span b,
.stat-card > small b {
  font-weight: 800;
}

.stat-card > span em,
.stat-card > small em {
  color: var(--foreground);
  font-style: normal;
  font-weight: 900;
  text-align: right;
  white-space: nowrap;
}

.meta-item span,
.metric-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
}

.meta-item strong,
.stat-card strong,
.chart-summary strong {
  display: block;
  margin-top: 6px;
  font-size: 1.4rem;
  line-height: 1.2;
}

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

.spotlight-card {
  padding: 20px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
}

.spotlight-card-strong {
  background:
    linear-gradient(180deg, rgba(238, 242, 255, 0.92), rgba(255, 255, 255, 1)),
    #ffffff;
  border-color: rgba(99, 102, 241, 0.16);
}

.spotlight-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.65rem, 2.4vw, 2.2rem);
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.spotlight-card small {
  display: block;
  margin-top: 10px;
  color: var(--muted-foreground);
  font-size: 12px;
  line-height: 1.5;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.stat-card {
  min-height: 188px;
  background: rgba(255, 255, 255, 0.96);
}

.stat-head {
  align-items: flex-start;
  margin-bottom: 18px;
}

.stat-card h3 {
  font-size: 16px;
  line-height: 1.2;
}

.stat-card strong {
  font-size: clamp(1.8rem, 2.4vw, 2.4rem);
  letter-spacing: -0.04em;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.dot-emerald {
  background: var(--success);
  box-shadow: 0 0 0 6px var(--success-soft);
}

.dot-sky {
  background: var(--sky);
  box-shadow: 0 0 0 6px var(--sky-soft);
}

.dot-violet {
  background: var(--violet);
  box-shadow: 0 0 0 6px var(--violet-soft);
}

.dot-amber {
  background: var(--amber);
  box-shadow: 0 0 0 6px var(--amber-soft);
}

.chart-grid,
.content-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

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

.chart-card,
.panel-card,
.models-card,
.table-card,
.log-filter-card {
  background: rgba(255, 255, 255, 0.96);
}

.chart-host {
  margin-top: 24px;
}

.chart-summary {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fbfcfd;
}

.chart-svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-grid-line {
  stroke: rgba(148, 163, 184, 0.22);
  stroke-width: 1;
}

.chart-line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-area {
  opacity: 0.9;
}

.chart-dot {
  stroke: #ffffff;
  stroke-width: 2;
}

.chart-label {
  fill: var(--muted-foreground);
  font-size: 12px;
}

.list-stack {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.rank-item {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #ffffff;
}

.rank-topline strong {
  font-size: 15px;
  line-height: 1.4;
}

.rank-meta {
  font-size: 12px;
}

.rank-track {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: #eef2f7;
}

.rank-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0f172a, #475569);
}

.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.model-pill {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #ffffff;
  font-size: 13px;
  font-weight: 700;
}

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

.filter-actions {
  display: grid;
  align-content: end;
  gap: 10px;
}

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

.log-summary-card {
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: #ffffff;
}

.log-summary-card span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted-foreground);
}

.log-summary-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.5rem;
  line-height: 1.2;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  margin-top: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.logs-table-wrap {
  margin-top: 22px;
}

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

.logs-table {
  min-width: 1160px;
}

.logs-table-card,
.log-filter-card {
  min-width: 0;
}

.logs-table tbody tr {
  transition: background 0.18s ease, box-shadow 0.18s ease;
}

.logs-table tbody tr:hover {
  background: rgba(248, 250, 252, 0.9);
}

.logs-table tbody tr.cache-hit-row {
  background:
    linear-gradient(90deg, rgba(5, 150, 105, 0.1), transparent 34%),
    rgba(240, 253, 244, 0.72);
}

.duration-pill,
.cache-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.duration-pill.fast {
  background: var(--success-soft);
  color: var(--success);
}

.duration-pill.medium {
  background: var(--amber-soft);
  color: var(--amber);
}

.duration-pill.slow {
  background: var(--danger-soft);
  color: var(--danger);
}

.duration-pill.neutral,
.cache-pill.empty {
  background: #f8fafc;
  color: var(--muted-foreground);
}

.cache-pill.hit {
  background: rgba(5, 150, 105, 0.14);
  color: var(--success);
  box-shadow: inset 0 0 0 1px rgba(5, 150, 105, 0.18);
}

th,
td {
  padding: 12px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

.mono-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status-chip.ok {
  background: var(--success-soft);
  color: var(--success);
}

.status-chip.bad {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-chip.neutral {
  background: #f8fafc;
  color: var(--muted-foreground);
}

.pagination-bar {
  margin-top: 20px;
}

.pagination-text {
  font-size: 14px;
  text-align: center;
}

.empty-text,
.empty-cell {
  font-size: 14px;
}

.hidden {
  display: none !important;
}

@media (max-width: 1100px) {
  .spotlight-grid,
  .overview-grid,
  .log-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 820px) {
  .shell {
    display: block;
  }

  .app-sidebar {
    position: relative;
    width: min(100vw - 20px, 1240px);
    height: auto;
    margin: 10px auto 0;
    border: 1px solid var(--border);
    border-radius: 24px;
  }

  .sidebar-inner {
    padding: 16px;
  }

  .sidebar-brand {
    margin-bottom: 16px;
  }

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

  .sidebar-footer {
    margin-top: 18px;
    grid-template-columns: 1fr;
  }

  .layout {
    width: min(100vw - 20px, 1240px);
    padding: 16px 0 56px;
  }

  .hero-topbar,
  .dashboard-toolbar,
  .token-header,
  .section-head,
  .stat-head,
  .chart-summary,
  .pagination-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .dashboard-toolbar {
    align-items: center;
  }

  .login-form,
  .spotlight-grid,
  .overview-grid,
  .chart-grid,
  .content-grid,
  .content-grid-triple,
  .token-meta,
  .model-grid,
  .filters-grid,
  .log-summary-grid {
    grid-template-columns: 1fr;
  }

  .hero-copy {
    margin-top: 24px;
  }

  .hero h1 {
    font-size: 1.5rem;
  }

  .login-card {
    padding: 28px 18px 24px;
  }

  .filter-actions,
  .login-form .button {
    max-width: none;
    width: 100%;
  }

  table,
  .logs-table {
    min-width: 980px;
  }
}
