/* ════════════════════════════════════════════════════════════════
   xmetrics — app.css
   Design inspired by Claude's interface — warm dark neutrals,
   minimal borders, spacious typography, monochrome palette.
   ════════════════════════════════════════════════════════════════ */

/* ── TOKENS ────────────────────────────────────────────────────── */
:root {
  /* Warm dark palette — matched to Claude UI */
  --bg-sidebar:    #1a1613;
  --bg-content:    #1a1613;
  --border:        rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.09);
  --bg-hover:      rgba(255, 255, 255, 0.045);
  --bg-active:     rgba(255, 255, 255, 0.075);

  /* Typography — monochrome only */
  --text:          #f5f3ef;
  --text-2:        rgba(245, 243, 239, 0.82);
  --text-muted:    rgba(245, 243, 239, 0.52);
  --text-dim:      rgba(245, 243, 239, 0.32);
  --text-faint:    rgba(245, 243, 239, 0.18);

  /* Fonts — modern sans */
  --font:          'Geist', 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono:     'Geist Mono', 'JetBrains Mono', 'SF Mono', Menlo, monospace;

  --sidebar-w:     260px;
  --radius:        8px;
  --radius-lg:     12px;
  --transition:    160ms cubic-bezier(0.4, 0, 0.2, 1);

  --scrollbar-w:   4px;
}

/* ── RESET ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg-content);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  font-weight: 400;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  text-rendering: optimizeLegibility;
}

/* ── LAYOUT ────────────────────────────────────────────────────── */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── SIDEBAR ───────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  z-index: 50;
  position: relative;
}

/* ── LOGO ──────────────────────────────────────────────────────── */
.sidebar-logo {
  padding: 24px 20px 28px;
  flex-shrink: 0;
  text-decoration: none;
  display: block;
}
.sidebar-logo-inner {
  display: flex;
  align-items: center;
  gap: 11px;
}
.sidebar-logo-img {
  width: 27px;
  height: 27px;
  border-radius: 7px;
  overflow: hidden;
  flex-shrink: 0;
  
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-logo-img img,
.sidebar-logo-img svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.sidebar-logo-text {
  font-family: var(--font);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1;
}

/* ── NAV ───────────────────────────────────────────────────────── */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 10px 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: var(--scrollbar-w); }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.08);
  border-radius: 99px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  margin: 1px 0;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-2);
  font-size: 14.5px;
  font-weight: 400;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  user-select: none;
  white-space: nowrap;
  position: relative;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.nav-item.active {
  background: var(--bg-active);
  color: var(--text);
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color var(--transition);
}
.nav-item:hover .nav-icon,
.nav-item.active .nav-icon { color: var(--text); }
.nav-icon svg {
  width: 100%;
  height: 100%;
  display: block;
  stroke-width: 1.5;
}

/* ── SIDEBAR FOOTER (user) ─────────────────────────────────────── */
.sidebar-footer {
  flex-shrink: 0;
  padding: 14px 10px;
  border-top: 1px solid var(--border);
}

.user-block {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: var(--radius);
  transition: background var(--transition);
  text-decoration: none;
  color: inherit;
}
.user-block:hover { background: var(--bg-hover); }

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3a2f28 0%, #6b5a4e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.user-info {
  flex: 1;
  min-width: 0;
  line-height: 1.25;
}
.user-name {
  font-size: 13.5px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-logout {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--text-dim);
  transition: color var(--transition), background var(--transition);
  cursor: pointer;
  flex-shrink: 0;
  text-decoration: none;
  border: none;
  background: none;
}
.user-logout:hover {
  color: var(--text);
  background: var(--bg-hover);
}
.user-logout svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.5;
}

/* ── CONTENT ───────────────────────────────────────────────────── */
.content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-content);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.content::-webkit-scrollbar { width: var(--scrollbar-w); }
.content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 99px; }

.content-inner {
  max-width: 820px;
  margin: 0 auto;
  padding: 72px 60px 100px;
}

.page { display: none; animation: fadeIn 200ms ease; }
.page.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── TYPOGRAPHY ────────────────────────────────────────────────── */
.page-eyebrow {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 14px;
  font-weight: 400;
}

.page-title {
  font-family: var(--font);
  font-size: 27px;
  font-weight: 400;
  color: var(--text);
  line-height: 1.1;
  margin-bottom: 16px;
  letter-spacing: -0.025em;
}

.page-lead {
  font-size: 16px;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 44px;
  max-width: 640px;
  font-weight: 400;
}

.section-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin: 44px 0 18px;
  letter-spacing: 0;
}

/* ── MARKDOWN ──────────────────────────────────────────────────── */
.md-body { color: var(--text-2); line-height: 1.75; font-size: 15.5px; }

.md-body h1 {
  font-family: var(--font);
  font-size: 29px;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 40px 0 18px;
  line-height: 1.15;
}
.md-body h2 {
  font-family: var(--font);
  font-size: 26px;
  font-weight: 400;
  letter-spacing: -0.018em;
  color: var(--text);
  margin: 44px 0 16px;
  line-height: 1.2;
}
.md-body h3 {
  font-size: 17px;
  color: var(--text);
  font-weight: 600;
  margin: 32px 0 12px;
  letter-spacing: -0.005em;
}

.md-body p { margin-bottom: 18px; color: var(--text-2); }
.md-body strong { color: var(--text); font-weight: 600; }
.md-body em { color: var(--text-2); font-style: italic; }
.md-body ul, .md-body ol { padding-left: 22px; margin-bottom: 18px; color: var(--text-2); }
.md-body li { margin-bottom: 6px; }

.md-body code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--text);
}
.md-body pre {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  overflow-x: auto;
  margin-bottom: 22px;
  line-height: 1.6;
}
.md-body pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-muted);
  font-size: 13px;
  white-space: pre;
}

.md-body blockquote {
  border-left: 2px solid var(--border-strong);
  padding-left: 20px;
  margin: 22px 0;
  color: var(--text-muted);
  font-style: italic;
}

.md-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  font-size: 14px;
}
.md-body th {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-strong);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
}
.md-body td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
}
.md-body tr:hover td { background: var(--bg-hover); }
.md-body hr { border: none; border-top: 1px solid var(--border); margin: 36px 0; }
.md-body a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--text-dim);
  transition: border-color var(--transition);
}
.md-body a:hover { border-color: var(--text); }

/* ── DATASET TABLE ─────────────────────────────────────────────── */
.dataset-table-wrap { overflow-x: auto; margin-bottom: 28px; }
.dataset-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 13px;
}
.dataset-table th {
  text-align: left;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-strong);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  background: transparent;
  position: sticky;
  top: 0;
}
.dataset-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}
.dataset-table td.metric-name { color: var(--text); }
.dataset-table td.val-d0 { color: var(--text); }
.dataset-table tr:hover td { background: var(--bg-hover); }

/* ── HERO / KPI ROW ────────────────────────────────────────────── */
.hero-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 1px;
  margin-top: 36px;
  /* background: var(--border); */
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.hero-kpi {
  background: var(--bg-content);
  padding: 20px 22px;
  transition: background var(--transition);
}
.hero-kpi:hover { background: rgba(255,255,255,0.02); }
.hero-kpi-label {
  font-size: 12.5px;
  color: var(--text-dim);
  font-weight: 400;
  margin-bottom: 8px;
}
.hero-kpi-val {
  font-size: 26px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.hero-kpi-val.small { font-size: 18px; letter-spacing: 0; }

/* ── AGENT GRID ────────────────────────────────────────────────── */
.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 44px;
}
.agent-card {
  background: var(--bg-content);
  padding: 22px 24px;
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
}
.agent-card:hover { background: rgba(255,255,255,0.02); }
.agent-card-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
.agent-card-role {
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 16px;
}
.agent-card-score {
  font-size: 30px;
  font-weight: 400;
  color: var(--text);
  font-family: var(--font);
  letter-spacing: -0.02em;
  line-height: 1;
}
.agent-card-score-sub {
  font-size: 13px;
  color: var(--text-dim);
  font-family: var(--font);
  margin-left: 4px;
}

/* ── REPORT META ───────────────────────────────────────────────── */
.report-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 24px 0 40px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.meta-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  padding: 4px 11px;
  border-radius: 99px;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-weight: 400;
}

/* ── INFO BOX ──────────────────────────────────────────────────── */
.info-box {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  color: var(--text-muted);
  font-size: 14.5px;
  margin-bottom: 24px;
  line-height: 1.7;
}
.info-box code {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  padding: 1px 6px;
  border-radius: 4px;
}

/* ── HISTORY TABLE ─────────────────────────────────────────────── */
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.history-table th {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-strong);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
}
.history-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: middle;
}
.history-table tr.row-clickable { cursor: pointer; transition: background var(--transition); }
.history-table tr.row-clickable:hover td { background: var(--bg-hover); }
.history-table td.td-date { color: var(--text); font-family: var(--font-mono); font-size: 13px; }
.history-table td.td-score { color: var(--text); font-family: var(--font-mono); font-size: 13px; }
.history-table td.td-muted { color: var(--text-dim); font-family: var(--font-mono); font-size: 12.5px; }
.history-table td.td-action { color: var(--text-muted); font-size: 13px; }

.dataset-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 24px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  background: transparent;
}
.dataset-btn:hover {
  border-color: var(--text);
  color: var(--text);
  background: var(--bg-hover);
}

/* ── LOADING ───────────────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-dim);
  font-size: 14px;
  padding: 60px 0;
}
.loading-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: pulse 1.2s ease-in-out infinite;
}
.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse {
  0%, 100% { opacity: 0.2; transform: scale(0.8); }
  50%      { opacity: 1;   transform: scale(1); }
}

/* ── HAMBURGER ─────────────────────────────────────────────────── */
.hamburger {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  width: 38px;
  height: 38px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  padding: 10px;
}
.hamburger span {
  display: block;
  width: 16px;
  height: 1.5px;
  background: var(--text-muted);
  border-radius: 99px;
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 40;
  backdrop-filter: blur(3px);
}

/* ── RESPONSIVE ────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .hamburger { display: flex; }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform 240ms cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
  }
  .sidebar.open { transform: translateX(0); }
  .overlay.visible { display: block; }

  .content-inner { padding: 64px 28px 80px; }
  .page-title { font-size: 29px; }
  .md-body h1 { font-size: 28px; }
  .md-body h2 { font-size: 22px; }
}

@media (max-width: 480px) {
  .content-inner { padding: 64px 20px 80px; }
  .page-title { font-size: 29px; }
  .hero-kpi-row { grid-template-columns: repeat(2, 1fr); }
  .agent-grid { grid-template-columns: 1fr; }
  .history-table th:nth-child(3),
  .history-table td:nth-child(3) { display: none; }
}
