/* ─── Design tokens ─────────────────────────────────────── */
:root {
  /* Surfaces — zinc-ish, warm neutral */
  --bg:          oklch(0.17 0.004 260);
  --bg-elev:     oklch(0.195 0.005 260);
  --surface:     oklch(0.215 0.006 260);
  --surface-2:   oklch(0.245 0.007 260);
  --border:      oklch(0.28 0.008 260);
  --border-soft: oklch(0.245 0.006 260);
  --border-hi:   oklch(0.36 0.01 260);

  /* Text */
  --text:        oklch(0.96 0.005 260);
  --text-muted:  oklch(0.70 0.012 260);
  --text-dim:    oklch(0.54 0.012 260);
  --text-soft:   oklch(0.82 0.008 260);

  /* Accent — emerald maduro */
  --accent:       oklch(0.72 0.14 160);
  --accent-hi:    oklch(0.80 0.14 160);
  --accent-soft:  oklch(0.72 0.14 160 / 0.12);
  --accent-tint:  oklch(0.72 0.14 160 / 0.06);

  /* Semantic */
  --info:    oklch(0.74 0.13 240);
  --info-soft: oklch(0.74 0.13 240 / 0.12);
  --warn:    oklch(0.80 0.14 75);
  --warn-soft: oklch(0.80 0.14 75 / 0.12);
  --danger:  oklch(0.70 0.17 25);
  --danger-soft: oklch(0.70 0.17 25 / 0.12);
  --purple:  oklch(0.72 0.14 295);
  --purple-soft: oklch(0.72 0.14 295 / 0.12);
  --pink:    oklch(0.75 0.14 350);
  --pink-soft: oklch(0.75 0.14 350 / 0.12);

  /* Radii */
  --r-sm: 6px;
  --r:    8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;

  /* Shadows */
  --sh-1: 0 1px 0 oklch(1 0 0 / 0.03) inset, 0 1px 2px oklch(0 0 0 / 0.25);
  --sh-2: 0 4px 16px oklch(0 0 0 / 0.25), 0 1px 0 oklch(1 0 0 / 0.04) inset;
  --sh-pop: 0 20px 60px -20px oklch(0 0 0 / 0.6), 0 0 0 1px var(--border);

  /* Density */
  --row-py: 9px;

  --font: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv11";
}
.mono { font-family: var(--mono); font-feature-settings: "zero"; }

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

::selection { background: var(--accent-soft); color: var(--accent-hi); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--border-hi); }

/* ─── App shell ─────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 244px 1fr;
  min-height: 100vh;
}

/* ─── Sidebar ───────────────────────────────────────────── */
.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border-soft);
  padding: 14px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 4px 4px;
}
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), oklch(0.55 0.14 160));
  display: grid; place-items: center;
  color: oklch(0.1 0 0);
  box-shadow: var(--sh-1);
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-name { font-size: 14px; font-weight: 600; letter-spacing: -0.2px; }
.brand-sub { font-size: 11px; color: var(--text-dim); margin-top: -1px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-label {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 14px 8px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6.5px 9px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--text-soft);
  cursor: pointer;
  transition: all 0.12s ease;
  user-select: none;
  position: relative;
}
.nav-item svg { width: 15px; height: 15px; opacity: 0.8; flex-shrink: 0; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
}
.nav-item.active svg { color: var(--accent); opacity: 1; }
.nav-tag {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  padding: 1px 6px;
  border-radius: 20px;
}

.sidebar-foot { display: flex; flex-direction: column; gap: 10px; }
.plan-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 10px 12px;
}
.plan-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.plan-name { font-size: 12.5px; font-weight: 500; }
.plan-badge {
  font-size: 9.5px; font-weight: 600;
  padding: 2px 7px; border-radius: 20px;
  background: var(--accent-soft); color: var(--accent-hi);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.plan-meter {
  height: 4px; background: var(--border);
  border-radius: 4px; overflow: hidden; margin-bottom: 6px;
}
.plan-meter-bar {
  height: 100%; background: linear-gradient(90deg, var(--accent) 0%, var(--accent-hi) 100%);
  border-radius: 4px;
  transition: width 0.5s cubic-bezier(.2,.8,.2,1);
}
.plan-stats { font-size: 11px; color: var(--text-dim); font-family: var(--mono); }

.agent-row {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
}
.agent-pulse {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent);
  animation: pulse 2s cubic-bezier(.4,0,.6,1) infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 oklch(0.72 0.14 160 / 0.4); }
  50% { box-shadow: 0 0 0 6px oklch(0.72 0.14 160 / 0); }
}
.agent-label { font-size: 11.5px; font-weight: 500; }
.agent-sub { font-size: 10.5px; color: var(--text-dim); font-family: var(--mono); margin-top: 1px; }

/* ─── Topbar ────────────────────────────────────────────── */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 52px;
  display: flex; align-items: center;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-soft);
  gap: 18px;
  background: var(--bg);
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(8px);
  background: oklch(0.17 0.004 260 / 0.8);
}
.crumbs { display: flex; align-items: center; gap: 7px; font-size: 12.5px; }
.crumb-muted { color: var(--text-dim); }
.crumb-sep { color: var(--text-dim); opacity: 0.4; }
.crumb-current { color: var(--text); font-weight: 500; }

.topbar-search {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r);
  padding: 0 10px;
  width: 320px;
  transition: all 0.15s;
}
.topbar-search:focus-within { border-color: var(--border-hi); background: var(--surface-2); }
.topbar-search svg { color: var(--text-dim); flex-shrink: 0; }
.topbar-search input {
  flex: 1;
  border: none; background: none; outline: none;
  padding: 7px 0;
  font-size: 12.5px;
  color: var(--text);
}
.topbar-search input::placeholder { color: var(--text-dim); }
kbd {
  font-family: var(--mono);
  font-size: 10px;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  background: var(--bg);
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: var(--r);
  color: var(--text-muted);
  transition: all 0.12s;
  position: relative;
}
.icon-btn:hover { background: var(--surface); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn .dot {
  position: absolute; top: 8px; right: 8px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--bg);
}

.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  margin-left: 4px;
  cursor: pointer;
  transition: all 0.12s;
}
.user-chip:hover { border-color: var(--border-hi); background: var(--surface); }
.avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--info));
  color: oklch(0.1 0 0);
  display: grid; place-items: center;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.02em;
}
.user-name { font-size: 12px; font-weight: 500; }
.user-sub { font-size: 10px; color: var(--text-dim); margin-top: -1px; }

/* ─── Content ───────────────────────────────────────────── */
.content { padding: 24px 24px 40px; max-width: 1560px; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 20px;
  gap: 24px;
}
.page-title { font-size: 22px; font-weight: 600; letter-spacing: -0.4px; }
.page-sub { font-size: 12.5px; color: var(--text-dim); margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px;
  font-size: 12.5px; font-weight: 500;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: all 0.12s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-hi); }
.btn svg { width: 14px; height: 14px; }
.btn-primary {
  background: var(--text);
  color: oklch(0.15 0 0);
  border-color: var(--text);
  font-weight: 600;
}
.btn-primary:hover { background: oklch(0.88 0 0); border-color: oklch(0.88 0 0); }
.btn-accent {
  background: var(--accent);
  color: oklch(0.13 0.01 160);
  border-color: var(--accent);
  font-weight: 600;
}
.btn-accent:hover { background: var(--accent-hi); border-color: var(--accent-hi); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface); border-color: var(--border-soft); }

/* ─── Metric cards ──────────────────────────────────────── */
.metrics {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 1px;
  background: var(--border-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 20px;
}
.metric {
  padding: 18px 20px;
  background: var(--bg-elev);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 130px;
}
.metric-head { display: flex; align-items: center; gap: 8px; }
.metric-ico {
  width: 26px; height: 26px;
  border-radius: 7px;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--border-soft);
}
.metric-ico svg { width: 14px; height: 14px; color: var(--text-muted); }
.metric-ico.ac { background: var(--accent-soft); border-color: transparent; }
.metric-ico.ac svg { color: var(--accent-hi); }
.metric-ico.in { background: var(--info-soft); border-color: transparent; }
.metric-ico.in svg { color: var(--info); }
.metric-ico.wa { background: var(--warn-soft); border-color: transparent; }
.metric-ico.wa svg { color: var(--warn); }
.metric-ico.pu { background: var(--purple-soft); border-color: transparent; }
.metric-ico.pu svg { color: var(--purple); }

.metric-lbl { font-size: 11.5px; color: var(--text-muted); font-weight: 500; }
.metric-val {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  display: flex; align-items: baseline; gap: 8px;
}
.metric-val .unit { font-size: 13px; color: var(--text-dim); font-weight: 500; letter-spacing: 0; }
@keyframes metric-countup {
  from { transform: translateY(6px); opacity: 0; color: #6ee7b7; }
  60%  { color: #6ee7b7; }
  to   { transform: translateY(0);   opacity: 1; color: inherit; }
}
.metric-val-updated { animation: metric-countup 0.5s ease-out; }
.metric-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: auto;
  font-size: 11px;
  color: var(--text-dim);
}
.delta {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 500;
  font-family: var(--mono);
}
.delta.up { color: var(--accent-hi); }
.delta.down { color: var(--danger); }
.delta svg { width: 10px; height: 10px; }
.spark { width: 100%; height: 30px; display: block; }

/* ─── Panels / cards ────────────────────────────────────── */
.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  gap: 12px;
}
.panel-title { font-size: 13px; font-weight: 600; }
.panel-sub { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }

/* ─── Dashboard grid ────────────────────────────────────── */
.dash-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

/* Activity / chart */
.chart-panel { padding: 18px; height: 320px; display: flex; flex-direction: column; }
.chart-legend {
  display: flex; gap: 16px;
  margin-bottom: 14px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.leg-sw { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 6px; vertical-align: middle; }
.leg-ac { background: var(--accent); }
.leg-in { background: var(--info); }
.chart-body { flex: 1; position: relative; }
.chart-body svg { width: 100%; height: 100%; display: block; }

.chart-tip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-2);
  border: 1px solid var(--border-hi);
  border-radius: var(--r);
  padding: 8px 11px;
  font-size: 11.5px;
  box-shadow: var(--sh-pop);
  opacity: 0; transform: translateY(-4px);
  transition: opacity 0.12s, transform 0.12s;
  z-index: 5;
  min-width: 140px;
}
.chart-tip.show { opacity: 1; transform: translateY(-8px); }
.tip-lbl { color: var(--text-dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.tip-row { display: flex; justify-content: space-between; gap: 12px; font-family: var(--mono); }

/* Insights */
.insights { padding: 14px; display: flex; flex-direction: column; gap: 2px; height: 320px; overflow-y: auto; }
.insight {
  padding: 11px 12px;
  border-radius: var(--r-md);
  display: flex; gap: 11px;
  transition: background 0.12s;
  cursor: pointer;
}
.insight:hover { background: var(--surface); }
.insight-ico {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.insight-ico svg { width: 14px; height: 14px; }
.insight-ico.ac { background: var(--accent-soft); color: var(--accent-hi); }
.insight-ico.in { background: var(--info-soft); color: var(--info); }
.insight-ico.wa { background: var(--warn-soft); color: var(--warn); }
.insight-ico.pu { background: var(--purple-soft); color: var(--purple); }
.insight-ico.pk { background: var(--pink-soft); color: var(--pink); }
.insight-txt { flex: 1; min-width: 0; }
.insight-title { font-size: 12.5px; font-weight: 500; margin-bottom: 2px; }
.insight-sub { font-size: 11.5px; color: var(--text-dim); line-height: 1.4; }
.insight-time { font-size: 10.5px; color: var(--text-dim); font-family: var(--mono); margin-top: 3px; }

/* Distribution / breakdown */
.breakdown { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.break-card { padding: 18px; }
.break-title { font-size: 13px; font-weight: 600; margin-bottom: 14px; }
.bar-row {
  display: grid;
  grid-template-columns: 90px 1fr 60px;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  font-size: 12px;
}
.bar-label { color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 6px; background: var(--surface); border-radius: 4px; overflow: hidden; position: relative; }
.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transform-origin: left;
  animation: barGrow 0.8s cubic-bezier(.2,.8,.2,1);
}
@keyframes barGrow { from { transform: scaleX(0); } }
.bar-fill.in { background: var(--info); }
.bar-fill.wa { background: var(--warn); }
.bar-fill.pu { background: var(--purple); }
.bar-fill.pk { background: var(--pink); }
.bar-val { font-family: var(--mono); font-size: 11.5px; color: var(--text-muted); text-align: right; }

/* Map card */
.map-card { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.map-ranks { display: flex; flex-direction: column; gap: 6px; }
.rank-row {
  display: grid;
  grid-template-columns: 18px 1fr 70px 60px;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
  font-size: 12px;
}
.rank-num { font-family: var(--mono); font-size: 11px; color: var(--text-dim); }
.rank-name { font-weight: 500; }
.rank-bar { position: relative; height: 4px; background: var(--surface); border-radius: 4px; overflow: hidden; }
.rank-bar-fill { height: 100%; background: var(--accent); border-radius: 4px; animation: barGrow 0.8s cubic-bezier(.2,.8,.2,1); }
.rank-val { font-family: var(--mono); font-size: 11.5px; color: var(--text-muted); text-align: right; }

/* ─── Filter bar (chip style) ───────────────────────────── */
.filter-bar {
  display: flex; flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  margin-bottom: 14px;
}
.filter-search {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 0 10px;
  flex: 1; min-width: 220px;
  transition: all 0.15s;
}
.filter-search:focus-within { border-color: var(--accent); }
.filter-search svg { color: var(--text-dim); width: 14px; height: 14px; }
.filter-search input {
  flex: 1; border: none; background: none; outline: none;
  font-size: 12.5px; padding: 7px 0;
}

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 11px;
  font-size: 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  transition: all 0.12s;
  white-space: nowrap;
  user-select: none;
}
.chip:hover { border-color: var(--border-hi); color: var(--text); }
.chip svg { width: 12px; height: 12px; }
.chip.on { background: var(--accent-soft); border-color: oklch(0.72 0.14 160 / 0.4); color: var(--accent-hi); }
.chip.on.in { background: var(--info-soft); border-color: oklch(0.74 0.13 240 / 0.4); color: var(--info); }
.chip.on.wa { background: var(--warn-soft); border-color: oklch(0.80 0.14 75 / 0.4); color: var(--warn); }
.chip.on.pu { background: var(--purple-soft); border-color: oklch(0.72 0.14 295 / 0.4); color: var(--purple); }
.chip.select {
  padding: 4px 4px 4px 11px;
  gap: 8px;
}
.chip.select select {
  border: none; background: transparent; color: inherit;
  font-size: 12px;
  padding: 2px 22px 2px 0;
  min-width: 80px;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 6px center;
  cursor: pointer;
}
.chip.select select:focus { outline: none; }
.chip.select select option { background: #1c1c26; color: #f4f4f5; }

.chip-sep { width: 1px; height: 20px; background: var(--border); margin: 0 2px; }

/* ─── Table ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}
table.data thead th {
  position: sticky; top: 0;
  background: var(--bg-elev);
  padding: 8px 12px;
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  font-weight: 500;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
  user-select: none;
}
table.data thead th.sortable { cursor: pointer; }
table.data thead th.sortable:hover { color: var(--text); }
table.data thead th .th-inner { display: inline-flex; align-items: center; gap: 5px; }
table.data thead th .sort-ico {
  display: inline-flex;
  flex-direction: column;
  color: var(--text-dim);
  opacity: 0.45;
}
table.data thead th.sort-asc .sort-ico,
table.data thead th.sort-desc .sort-ico { opacity: 1; color: var(--accent); }
table.data thead th .sort-ico svg { width: 7px; height: 7px; display: block; }
table.data thead th.sort-asc .sort-ico svg:last-child,
table.data thead th.sort-desc .sort-ico svg:first-child { opacity: 0.3; }

table.data tbody td {
  padding: var(--row-py) 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
  color: var(--text-soft);
}
table.data tbody tr { transition: background 0.1s; }
table.data tbody tr:hover td { background: oklch(1 0 0 / 0.02); }
table.data tbody tr.selected td { background: oklch(0.72 0.14 160 / 0.05); }
table.data tbody tr.expanded td { background: oklch(1 0 0 / 0.025); border-bottom-color: transparent; }

.density-comfort { --row-py: 12px; }
.density-normal  { --row-py: 9px; }
.density-compact { --row-py: 5px; font-size: 12px; }

.co-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.co-avatar {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  display: grid; place-items: center;
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.co-main { min-width: 0; }
.co-name { font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; font-size: 12.5px;}
.co-cnae { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; margin-top: 1px; }

.mono-cell { font-family: var(--mono); font-size: 11.5px; color: var(--text-muted); }
.city-cell .c-name { color: var(--text-soft); }
.city-cell .c-uf { color: var(--text-dim); font-size: 11px; margin-left: 4px; }

.badge {
  display: inline-flex; align-items: center;
  font-size: 10px; font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  font-family: var(--mono);
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}
.badge.mei { background: var(--info-soft); color: var(--info); border-color: oklch(0.74 0.13 240 / 0.2); }
.badge.me  { background: var(--pink-soft); color: var(--pink); border-color: oklch(0.75 0.14 350 / 0.2); }
.badge.epp { background: var(--purple-soft); color: var(--purple); border-color: oklch(0.72 0.14 295 / 0.2); }
.badge.de  { background: var(--warn-soft); color: var(--warn); border-color: oklch(0.80 0.14 75 / 0.2); }

.contact-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px;
  padding: 2px 7px 2px 5px;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  color: var(--text-soft);
  font-family: var(--mono);
}
.contact-pill svg { width: 11px; height: 11px; color: var(--text-dim); }
.contact-pill.ac svg { color: var(--accent); }
.contact-pill.in svg { color: var(--info); }
.contact-em { color: var(--text-dim); font-style: italic; font-size: 11px; }

/* lock / mask for free plan */
.locked {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--mono);
  cursor: pointer;
}
.locked:hover { color: var(--warn); }
.locked svg { width: 10px; height: 10px; }
.masked { filter: blur(4px); user-select: none; }
.mask-text { font-family: var(--mono); color: var(--text-dim); }

/* Checkbox */
.checkbox {
  appearance: none;
  width: 14px; height: 14px;
  border-radius: 4px;
  border: 1.5px solid var(--border-hi);
  background: var(--surface);
  cursor: pointer;
  position: relative;
  transition: all 0.1s;
  flex-shrink: 0;
}
.checkbox:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.checkbox:checked::after {
  content: '';
  position: absolute;
  left: 3px; top: 0px;
  width: 4px; height: 8px;
  border: solid oklch(0.15 0.01 160);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.checkbox.indet { background: var(--accent); border-color: var(--accent); }
.checkbox.indet::after {
  content: '';
  position: absolute;
  left: 2px; top: 5px;
  width: 8px; height: 2px;
  background: oklch(0.15 0.01 160);
  border: none;
  transform: none;
}

.row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.row-btn {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 6px;
  color: var(--text-dim);
  transition: all 0.12s;
}
.row-btn:hover { background: var(--surface-2); color: var(--text); }
.row-btn svg { width: 14px; height: 14px; }
.row-btn.expand svg { transition: transform 0.2s; }
tr.expanded .row-btn.expand svg { transform: rotate(90deg); color: var(--accent); }

/* Inline expansion */
tr.detail-row td {
  padding: 0 !important;
  background: oklch(0 0 0 / 0.25) !important;
  border-bottom: 1px solid var(--border-soft);
}
.detail-inner {
  padding: 18px 20px 20px 52px;
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  gap: 24px;
}
.detail-col h4 {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.detail-field { margin-bottom: 10px; }
.detail-field .k { font-size: 10.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 2px; }
.detail-field .v { font-size: 12.5px; color: var(--text); }
.detail-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }
.detail-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border-radius: var(--r);
  margin-bottom: 14px;
  font-size: 11.5px;
}
.detail-bar .kv { color: var(--text-dim); }
.detail-bar .kv strong { color: var(--text); font-weight: 500; margin-left: 4px; }
.detail-bar .sep { width: 1px; height: 12px; background: var(--border); }
.detail-loading { padding: 24px; text-align: center; color: var(--text-dim); font-size: 12px; }

/* Pagination */
.pager {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 16px;
  border-top: 1px solid var(--border-soft);
  font-size: 12px; color: var(--text-dim);
}
.pager-btns { display: flex; gap: 2px; align-items: center; }
.page-btn {
  min-width: 28px; height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--mono);
  transition: all 0.1s;
  display: grid; place-items: center;
}
.page-btn:hover { background: var(--surface); color: var(--text); }
.page-btn.active { background: var(--text); color: oklch(0.15 0 0); font-weight: 600; }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.page-ellipsis { color: var(--text-dim); padding: 0 4px; }

/* Bulk bar */
.bulk-bar {
  position: sticky;
  top: 52px;
  z-index: 4;
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-pop);
  animation: slideIn 0.2s cubic-bezier(.2,.8,.2,1);
}
.bulk-bar.show { display: flex; }
@keyframes slideIn {
  from { transform: translateY(-6px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.bulk-count {
  font-size: 12.5px;
  font-weight: 500;
}
.bulk-count strong { color: var(--accent-hi); font-variant-numeric: tabular-nums; }
.bulk-actions { display: flex; gap: 6px; margin-left: auto; }

/* Radius tweak */
.radius-sharp { --r-sm: 2px; --r: 3px; --r-md: 4px; --r-lg: 5px; --r-xl: 6px; }
.radius-round { --r-sm: 10px; --r: 14px; --r-md: 16px; --r-lg: 20px; --r-xl: 24px; }

/* Tweaks panel */
.tweaks-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 280px;
  background: var(--bg-elev);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-pop);
  z-index: 100;
  transform: translateY(20px) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s cubic-bezier(.2,.8,.2,1);
}
.tweaks-panel.open { transform: none; opacity: 1; pointer-events: auto; }
.tweaks-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 12.5px;
  font-weight: 600;
}
.tweaks-close { color: var(--text-dim); font-size: 18px; line-height: 1; cursor: pointer; }
.tweaks-close:hover { color: var(--text); }
.tweaks-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 14px; }
.tweak-group label {
  display: block;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.tweak-segments {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r);
  padding: 2px;
  gap: 2px;
}
.tweak-segments button {
  font-size: 11px;
  padding: 5px 6px;
  border-radius: 5px;
  color: var(--text-muted);
  transition: all 0.12s;
}
.tweak-segments button:hover { color: var(--text); }
.tweak-segments button.on { background: var(--bg-elev); color: var(--text); box-shadow: var(--sh-1); }

/* Empty */
.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}
.empty-state .big {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r-sm);
  display: inline-block;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ─── Toast notifications ────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  padding: 10px 16px;
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-hi);
  box-shadow: var(--sh-pop);
  z-index: 600;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  max-width: 360px;
}
.toast.toast-show { opacity: 1; transform: translateY(0); }
.toast-info    { border-color: var(--info);   background: oklch(0.74 0.13 240 / 0.12); }
.toast-success { border-color: var(--accent); background: oklch(0.72 0.14 160 / 0.12); }
.toast-warning { border-color: var(--warn);   background: oklch(0.80 0.14 75  / 0.12); }
.toast-error   { border-color: var(--danger); background: oklch(0.70 0.17 25  / 0.12); }

/* ─── Row context menu dropdown ──────────────────────────────── */
.row-dropdown {
  background: var(--bg-elev);
  border: 1px solid var(--border-hi);
  border-radius: var(--r);
  box-shadow: var(--sh-pop);
  min-width: 150px;
  overflow: hidden;
}
.row-dropdown button {
  display: block; width: 100%;
  text-align: left;
  padding: 9px 14px;
  font-size: 12.5px;
  color: var(--text-muted);
  transition: background 0.1s, color 0.1s;
  background: none; border: none; cursor: pointer;
}
.row-dropdown button:hover { background: var(--surface-2); color: var(--text); }
.row-dropdown button svg { width: 13px; height: 13px; vertical-align: middle; margin-right: 6px; flex-shrink: 0; }

/* ─── Danger button ──────────────────────────────────────────── */
.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover { background: oklch(0.70 0.17 25 / 0.22); }

/* ─── Shake animation ────────────────────────────────────────── */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}
.shake { animation: shake 0.5s ease; }

/* Admin form */
.admin-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: flex-end;
}
.field-group { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 10.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.field-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 8px 11px;
  font-size: 12.5px;
  color: var(--text);
  transition: border-color 0.15s;
}
.field-input:focus { outline: none; border-color: var(--accent); }
.field-input::placeholder { color: var(--text-dim); }

/* Token row */
.token-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 12.5px;
}
.token-row:last-child { border-bottom: none; }
.token-val { font-family: var(--mono); font-size: 11.5px; color: var(--text-muted); }

/* ─── Limit reached UI ────────────────────────────────────────── */
.limit-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: oklch(0.22 0.04 55);
  border: 1px solid oklch(0.55 0.14 55);
  border-radius: var(--r);
  margin-bottom: 18px;
  font-size: 13px;
  color: oklch(0.90 0.08 60);
  flex-wrap: wrap;
}
.limit-banner-icon { flex-shrink: 0; display: flex; align-items: center; color: var(--warn); }
.limit-banner-icon svg { width: 16px; height: 16px; }
.limit-banner-text { flex: 1; line-height: 1.5; }
.limit-banner-cta {
  color: var(--warn);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  padding: 4px 10px;
  border: 1px solid var(--warn);
  border-radius: 6px;
  font-size: 12px;
  transition: background 0.15s;
}
.limit-banner-cta:hover { background: oklch(0.55 0.14 55 / 0.25); }

.plan-upgrade-link {
  display: inline-block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--warn);
  text-decoration: none;
  font-weight: 500;
}
.plan-upgrade-link:hover { text-decoration: underline; }

.limit-reached-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 32px 24px;
  text-align: center;
}
.limit-reached-icon { color: var(--warn); opacity: 0.7; }
.limit-reached-icon svg { width: 28px; height: 28px; }
.limit-reached-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-hi);
}
.limit-reached-sub {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 480px;
  line-height: 1.6;
}
.limit-reached-btn {
  margin-top: 6px;
  background: oklch(0.22 0.04 55);
  border-color: var(--warn) !important;
  color: var(--warn) !important;
}
.limit-reached-btn:hover { background: oklch(0.28 0.06 55); }

/* ─── P2 additions ───────────────────────────────────────────── */
.agent-stopped { background: var(--text-dim) !important; animation: none !important; }
.export-limit-note { font-size: 11.5px; color: var(--text-dim); margin-top: 10px; }
.filter-clear {
  background: none; border: none; cursor: pointer;
  color: var(--text-dim); font-size: 13px; line-height: 1;
  padding: 0 2px; margin-left: -4px;
  transition: color 0.12s;
}
.filter-clear:hover { color: var(--danger); }

/* ─── Token login overlay ─────────────────────────────────────── */
.token-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
}
.token-box {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-xl);
  padding: 40px 48px;
  width: min(420px, 90vw);
  box-shadow: var(--sh-pop);
}
.token-logo { color: var(--accent); }
.token-brand { font-size: 16px; font-weight: 700; color: var(--text); }
.token-title { font-size: 22px; font-weight: 600; color: var(--text); text-align: center; margin: 0; }
.token-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text);
  font-family: var(--mono);
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.token-input:focus { outline: none; border-color: var(--accent); }
.token-btn { width: 100%; justify-content: center; padding: 10px; font-size: 14px; }

/* ─── Modal overlay ───────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: oklch(0 0 0 / 0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  backdrop-filter: blur(2px);
}
.modal-box {
  background: var(--bg-elev);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-pop);
  width: min(520px, 92vw);
  max-height: 85vh;
  overflow-y: auto;
  display: flex; flex-direction: column;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
}
.modal-header h3 { font-size: 14px; font-weight: 600; margin: 0; }
.modal-close {
  color: var(--text-dim); font-size: 20px; line-height: 1; cursor: pointer;
  width: 28px; height: 28px; display: grid; place-items: center; border-radius: 6px;
  transition: all 0.12s; background: none; border: none;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: 20px; flex: 1; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-soft);
  display: flex; justify-content: flex-end; gap: 8px;
}
.upgrade-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.upgrade-plan {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
}
.upgrade-plan.featured { border-color: var(--info); }
.upgrade-plan.featured-pro { border-color: var(--accent); }
.upgrade-plan-name { font-weight: 600; font-size: 14px; margin-bottom: 10px; }
.upgrade-plan-features { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-muted); }

/* ─── Hamburger + mobile sidebar drawer ──────────────────────── */
.hamburger {
  display: none;
  align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border-radius: var(--r);
  color: var(--text-muted);
  font-size: 18px;
  background: none; border: none; cursor: pointer;
  transition: all 0.12s;
}
.hamburger:hover { background: var(--surface-2); color: var(--text); }
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: oklch(0 0 0 / 0.5);
  z-index: 199;
}

/* Responsive */
@media (max-width: 1200px) {
  .dash-grid { grid-template-columns: 1fr; }
  .breakdown { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .metrics { grid-template-columns: 1fr; }
  .topbar-search { width: auto; flex: 1; }
  .user-chip .user-txt { display: none; }
  .hamburger { display: flex; }
  .app.sidebar-open .sidebar {
    display: flex;
    position: fixed;
    left: 0; top: 0;
    height: 100vh;
    z-index: 200;
    width: 240px;
    animation: slideInLeft 0.22s cubic-bezier(.2,.8,.2,1);
  }
  .app.sidebar-open .sidebar-overlay { display: block; }
}
@keyframes slideInLeft {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}
