:root {
  --bg-0: #09090b;
  --bg-1: #111113;
  --bg-2: #18181b;
  --bg-3: #222226;
  --bg-4: #2c2c32;
  --ink-0: #fafafa;
  --ink-1: #d4d4d8;
  --ink-2: #a1a1aa;
  --ink-3: #52525b;
  --line:  #27272a;
  --brand: #B8FF3D;
  --brand-dim: rgba(184,255,61,0.25);
  --pos:   #4ade80;
  --neg:   #f87171;
  --warn:  #fb923c;
  --blue:  #38bdf8;
  --r-sm:  6px;
  --r-md:  10px;
  --r-lg:  14px;
  --t-xs:  11px;
  --t-sm:  12px;
  --t-md:  13px;
  --t-lg:  15px;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --sidebar-w: 220px;
}

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

body {
  background: var(--bg-0);
  color: var(--ink-1);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: var(--t-md);
  line-height: 1.5;
  min-height: 100vh;
}

button { font: inherit; background: none; border: none; cursor: pointer; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ── Layout ── */
.cl-shell   { display: flex; height: 100vh; overflow: hidden; }
.cl-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-1);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 4px;
  overflow-y: auto;
}
.cl-main {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Brand ── */
.cl-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}
.cl-brand-icon {
  width: 28px; height: 28px;
  background: var(--brand);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.cl-brand-icon svg { color: #09090b; }
.cl-brand-name { font-size: var(--t-md); font-weight: 700; color: var(--ink-0); }
.cl-brand-sub  { font-size: var(--t-xs); color: var(--ink-3); font-family: var(--font-mono); }

/* ── Nav ── */
.cl-nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 10px 8px 4px;
}
.cl-nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 8px;
  border-radius: var(--r-md);
  color: var(--ink-2);
  font-size: var(--t-md);
  transition: background .1s, color .1s;
  cursor: pointer;
  width: 100%;
  text-align: left;
  position: relative;
}
.cl-nav-item:hover  { background: var(--bg-2); color: var(--ink-0); }
.cl-nav-item.active { background: var(--bg-3); color: var(--ink-0); }
.cl-nav-item.active::before {
  content: "";
  position: absolute;
  left: -12px; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--brand);
  border-radius: 0 2px 2px 0;
}
.cl-nav-icon { width: 16px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }

/* ── Header ── */
.cl-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.cl-header-left h1 { font-size: 20px; font-weight: 700; color: var(--ink-0); }
.cl-header-left p  { font-size: var(--t-sm); color: var(--ink-3); margin-top: 3px; }
.cl-period-badge {
  font-size: var(--t-xs);
  font-family: var(--font-mono);
  color: var(--ink-3);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 4px 10px;
  white-space: nowrap;
}

/* ── KPI row ── */
.cl-kpi-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}
.cl-kpi {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cl-kpi-label { font-size: var(--t-xs); color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.cl-kpi-value { font-size: 22px; font-weight: 700; color: var(--ink-0); font-family: var(--font-mono); }
.cl-kpi-sub   { font-size: var(--t-xs); color: var(--ink-3); }

/* ── Behavior signals ── */
.cl-signals {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}
.cl-signal {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px;
}
.cl-signal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.cl-signal-name { font-size: var(--t-xs); color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.cl-signal-icon { font-size: 14px; }
.cl-signal-pct  { font-size: 20px; font-weight: 700; font-family: var(--font-mono); }
.cl-signal-pct.warn { color: var(--warn); }
.cl-signal-pct.neg  { color: var(--neg);  }
.cl-signal-pct.ok   { color: var(--pos);  }
.cl-signal-pct.neutral { color: var(--ink-1); }
.cl-signal-bar-bg { height: 3px; background: var(--bg-3); border-radius: 2px; overflow: hidden; }
.cl-signal-bar    { height: 3px; border-radius: 2px; transition: width .4s; }
.cl-signal-count  { font-size: var(--t-xs); color: var(--ink-3); margin-top: 5px; font-family: var(--font-mono); }

/* ── Two-col grid ── */
.cl-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cl-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Card ── */
.cl-card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
}
.cl-card-title {
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--ink-0);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cl-card-title span.count {
  font-size: var(--t-xs);
  color: var(--ink-3);
  font-weight: 400;
  font-family: var(--font-mono);
}

/* ── Bar list ── */
.cl-bar-list { display: flex; flex-direction: column; gap: 8px; }
.cl-bar-row  { display: flex; flex-direction: column; gap: 3px; }
.cl-bar-meta { display: flex; justify-content: space-between; align-items: baseline; }
.cl-bar-name {
  font-size: var(--t-sm);
  color: var(--ink-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70%;
}
.cl-bar-val  { font-size: var(--t-xs); color: var(--ink-3); font-family: var(--font-mono); flex-shrink: 0; }
.cl-bar-track { height: 4px; background: var(--bg-3); border-radius: 2px; overflow: hidden; }
.cl-bar-fill  { height: 4px; background: var(--brand); border-radius: 2px; opacity: 0.7; }

/* ── Page table ── */
.cl-table { width: 100%; border-collapse: collapse; }
.cl-table th {
  text-align: left;
  font-size: var(--t-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-3);
  padding: 0 0 8px;
  border-bottom: 1px solid var(--line);
}
.cl-table td {
  padding: 8px 0;
  font-size: var(--t-sm);
  border-bottom: 1px solid var(--line);
  color: var(--ink-1);
}
.cl-table tr:last-child td { border-bottom: none; }
.cl-table .url {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  color: var(--ink-2);
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cl-table .num {
  font-family: var(--font-mono);
  text-align: right;
  color: var(--ink-0);
  font-weight: 600;
  padding-left: 12px;
  white-space: nowrap;
}
.cl-table .num-dim { font-weight: 400; color: var(--ink-3); }

/* ── Loading / empty ── */
.cl-loading {
  display: flex; align-items: center; justify-content: center;
  height: 200px;
  color: var(--ink-3);
  font-size: var(--t-sm);
  flex-direction: column;
  gap: 10px;
}
.cl-spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--bg-3);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.cl-error {
  padding: 16px;
  background: rgba(248,113,113,0.06);
  border: 1px solid rgba(248,113,113,0.2);
  border-radius: var(--r-md);
  color: var(--neg);
  font-size: var(--t-sm);
  font-family: var(--font-mono);
}

/* ── Collect badge ── */
.cl-collect-note {
  font-size: var(--t-xs);
  color: var(--ink-3);
  font-family: var(--font-mono);
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  line-height: 1.6;
}

/* ── Responsive ── */
@media (max-width: 1100px) {
  .cl-kpi-row, .cl-signals { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 800px) {
  .cl-kpi-row, .cl-signals { grid-template-columns: repeat(2, 1fr); }
  .cl-grid-2, .cl-grid-3   { grid-template-columns: 1fr; }
  .cl-sidebar { display: none; }
}
