/* Procura — design tokens & base styles */
:root {
  --bg: #f7f5f0;
  --bg-warm: #faf8f3;
  --surface: #ffffff;
  --surface-2: #fafaf7;
  --border: #e8e4d9;
  --border-strong: #d8d2c2;
  --ink: #1a1a17;
  --ink-2: #4a4a44;
  --muted: #8a857a;
  --muted-2: #b5b0a3;
  --ok: #1a7f4f;
  --ok-bg: #e3f1e8;
  --warn: #b8590e;
  --warn-bg: #fbeed7;
  --crit: #b3261e;
  --crit-bg: #fbe4e2;
  --accent: #1f1f1c;
  --hover: #f1ede3;
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 0 rgba(20, 18, 12, 0.04);
  --shadow: 0 1px 2px rgba(20, 18, 12, 0.06), 0 0 0 1px rgba(20, 18, 12, 0.04);
  --shadow-lg: 0 16px 40px -16px rgba(20, 18, 12, 0.22), 0 2px 8px rgba(20, 18, 12, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Onest", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.005em;
}

.serif { font-family: "Onest", system-ui, sans-serif; font-weight: 600; letter-spacing: -0.02em; }
.mono { font-family: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace; }

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* App shell */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--ink); color: #fff;
  display: grid; place-items: center;
  font-family: "Onest", sans-serif;
  font-weight: 700;
  font-size: 14px; line-height: 1;
  letter-spacing: -0.02em;
}
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.brand-sub { font-size: 10px; color: var(--muted); letter-spacing: 0.12em; text-transform: uppercase; margin-top: 1px; }

.nav { display: flex; gap: 4px; margin-left: 18px; }
.nav button {
  background: none; border: none; padding: 6px 12px;
  border-radius: 6px; font-size: 13px; color: var(--ink-2);
  font-weight: 500;
}
.nav button:hover { background: var(--hover); color: var(--ink); }
.nav button.active { background: var(--ink); color: #fff; }

.topbar-spacer { flex: 1; }

.topbar-search {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  min-width: 280px;
  color: var(--muted);
}
.topbar-search input { background: none; border: none; outline: none; flex: 1; font-size: 13px; color: var(--ink); }
.kbd { font-family: "Geist Mono", monospace; font-size: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px; color: var(--muted); }

.topbar-action { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 6px; cursor: pointer; color: var(--ink-2); }
.topbar-action:hover { background: var(--hover); color: var(--ink); }

.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #2a6f5b, #0f3d33);
  color: #fff; display: grid; place-items: center;
  font-size: 11px; font-weight: 600;
}

/* Industry picker */
.industry-picker { position: relative; }
.industry-btn { display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 8px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.industry-btn:hover { background: var(--hover); border-color: var(--border-strong); }
.industry-icon { width: 26px; height: 26px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; color: var(--ink); }
.industry-meta { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; }
.industry-eyebrow { font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.industry-name { font-size: 13px; font-weight: 600; color: var(--ink); margin-top: 2px; letter-spacing: -0.005em; }
.industry-menu { position: absolute; top: calc(100% + 6px); right: 0; min-width: 280px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 40; }
.industry-menu-head { padding: 8px 10px 6px; font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.industry-menu-foot { padding: 8px 10px 4px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--border); margin-top: 4px; }
.industry-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 6px; background: none; border: none; text-align: left; cursor: pointer; font-size: 13px; color: var(--ink); }
.industry-item:hover { background: var(--hover); }
.industry-item.active { background: var(--hover); font-weight: 600; }
.industry-item-icon { width: 24px; height: 24px; border-radius: 5px; display: grid; place-items: center; }
.industry-item-name { flex: 1; }

/* Main */
.main { flex: 1; padding: 28px 32px 80px; max-width: 1480px; width: 100%; margin: 0 auto; }
.main.wide { max-width: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 24px; gap: 24px; }
.page-title { font-family: "Onest", sans-serif; font-size: 30px; line-height: 1.15; letter-spacing: -0.025em; font-weight: 600; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.page-actions { display: flex; gap: 8px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 500; cursor: pointer; }
.btn:hover { background: var(--hover); border-color: var(--border-strong); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #000; }
.btn.ghost { background: none; border-color: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.danger { color: var(--crit); border-color: transparent; background: none; }
.btn.danger:hover { background: var(--crit-bg); }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.card.flat { box-shadow: none; }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.card-title { font-size: 13px; font-weight: 600; letter-spacing: -0.005em; }
.card-eyebrow { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

/* Status pills */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 500; letter-spacing: 0.01em; }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: var(--ok-bg); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.crit { color: var(--crit); background: var(--crit-bg); }
.pill.neutral { color: var(--ink-2); background: var(--hover); }
.pill.outline { background: transparent; border: 1px solid var(--border); color: var(--ink-2); }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 18px 20px; position: relative; }
.kpi-label { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.kpi-value { font-family: "Onest", sans-serif; font-size: 32px; line-height: 1.05; letter-spacing: -0.03em; margin-top: 10px; font-weight: 600; }
.kpi-value .unit { font-size: 15px; color: var(--muted); margin-left: 4px; font-weight: 500; letter-spacing: -0.01em; }
.kpi-delta { display: inline-flex; align-items: center; gap: 4px; margin-top: 8px; font-size: 12px; color: var(--ok); font-weight: 500; }
.kpi-delta.down { color: var(--crit); }
.kpi-spark { position: absolute; right: 16px; bottom: 16px; opacity: 0.7; }

/* Tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.tbl td { padding: 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: var(--surface-2); }

.cell-stack { display: flex; flex-direction: column; gap: 2px; }
.cell-strong { font-weight: 500; color: var(--ink); }
.cell-sub { font-size: 12px; color: var(--muted); }

/* Bar chart row */
.bar-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.bar-row-label { width: 200px; font-size: 12px; color: var(--ink-2); text-align: right; }
.bar-row-track { flex: 1; height: 10px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.bar-row-fill { height: 100%; background: var(--ink); border-radius: 2px; transition: width 0.4s ease; }
.bar-row-fill.muted { background: var(--muted-2); }
.bar-row-fill.accent { background: #2a6f5b; }
.bar-row-value { width: 90px; font-size: 12px; color: var(--ink-2); text-align: right; font-variant-numeric: tabular-nums; }

/* Drawer */
.drawer-overlay { position: fixed; inset: 0; background: rgba(20, 18, 12, 0.32); z-index: 50; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 92vw); background: var(--surface); z-index: 51; transform: translateX(100%); transition: transform 0.28s cubic-bezier(0.32, 0.72, 0.24, 1); display: flex; flex-direction: column; box-shadow: -24px 0 60px -20px rgba(20, 18, 12, 0.2); }
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.drawer-title { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.drawer-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.drawer-actions { display: flex; gap: 6px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 22px 24px 40px; }
.drawer-close { background: none; border: none; padding: 6px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.drawer-close:hover { background: var(--hover); color: var(--ink); }

/* Sections inside drawer */
.section { margin-bottom: 24px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.section-title { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

/* Agent cards on dashboard */
.agent-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.agent-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 20px; cursor: pointer; transition: all 0.15s; display: flex; flex-direction: column; gap: 12px; min-height: 180px; }
.agent-card:hover { border-color: var(--ink); transform: translateY(-1px); box-shadow: var(--shadow); }
.agent-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.agent-icon { width: 36px; height: 36px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; color: var(--ink-2); flex-shrink: 0; }
.agent-card h3 { font-size: 15px; font-weight: 600; margin: 0; letter-spacing: -0.005em; }
.agent-card p { color: var(--muted); font-size: 13px; margin: 0; line-height: 1.45; flex: 1; }
.agent-card-stats { display: flex; gap: 16px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 12px; }
.agent-stat .agent-stat-v { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.agent-stat .agent-stat-l { color: var(--muted); font-size: 11px; }

/* Activity feed */
.activity { display: flex; flex-direction: column; }
.activity-row { display: grid; grid-template-columns: 56px 1fr auto; gap: 14px; padding: 11px 20px; border-bottom: 1px solid var(--border); font-size: 13px; align-items: center; }
.activity-row:last-child { border-bottom: none; }
.activity-time { font-family: "Geist Mono", monospace; font-size: 11px; color: var(--muted); }
.activity-text { color: var(--ink-2); }
.activity-text strong { color: var(--ink); font-weight: 500; }
.activity-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; margin-right: 8px; vertical-align: middle; }
.activity-dot.ok { background: var(--ok); }
.activity-dot.warn { background: var(--warn); }
.activity-dot.crit { background: var(--crit); }

/* Variance/diff bar */
.diff-bar { display: flex; align-items: center; gap: 6px; padding: 12px 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.diff-bar .label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; }
.diff-bar .val { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.diff-bar .val.warn { color: var(--warn); }
.diff-bar .val.crit { color: var(--crit); }
.diff-bar .val.ok { color: var(--ok); }
.diff-bar .sep { color: var(--border-strong); margin: 0 6px; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs button { background: none; border: none; padding: 9px 14px; font-size: 13px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--ink); border-bottom-color: var(--ink); }
.tabs button .count { color: var(--muted-2); margin-left: 4px; font-variant-numeric: tabular-nums; }
.tabs button.active .count { color: var(--ink-2); }

/* Tag chips */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 4px; font-size: 11px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--border); font-weight: 500; }

/* AI bubble */
.ai-box { display: flex; gap: 12px; padding: 14px 16px; background: linear-gradient(180deg, #f9f5ed 0%, #fdfbf6 100%); border: 1px solid #e6dec5; border-radius: 8px; }
.ai-icon { width: 26px; height: 26px; border-radius: 7px; background: var(--ink); color: #f3efe1; display: grid; place-items: center; flex-shrink: 0; font-family: "Onest", sans-serif; font-weight: 700; font-size: 13px; line-height: 1; letter-spacing: -0.02em; }
.ai-body { flex: 1; font-size: 13px; line-height: 1.55; color: var(--ink-2); }
.ai-body strong { color: var(--ink); font-weight: 600; }
.ai-body .ai-label { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 4px; display: block; }

/* Two-col layouts */
.split { display: grid; grid-template-columns: 1fr 380px; gap: 16px; }
.split-3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 14px; }

/* Spend line chart */
.spend-chart { width: 100%; height: 220px; }
.spend-chart .line { fill: none; stroke: var(--ink); stroke-width: 1.5; }
.spend-chart .area { fill: url(#area-fade); opacity: 0.6; }
.spend-chart .dot { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; }
.spend-chart .grid { stroke: var(--border); stroke-dasharray: 2 4; }
.spend-chart .label { font-size: 10px; fill: var(--muted); font-family: "Geist Mono", monospace; }

/* Donut chart */
.donut-wrap { display: flex; align-items: center; gap: 24px; padding: 18px 20px; }
.donut svg { transform: rotate(-90deg); }
.donut-center { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.donut-legend { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.donut-legend-row { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.donut-legend-row .sw { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.donut-legend-row .nm { flex: 1; color: var(--ink-2); }
.donut-legend-row .vl { color: var(--muted); font-variant-numeric: tabular-nums; }

/* Supplier rows */
.supplier-row { display: grid; grid-template-columns: 1fr 70px 70px 90px; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.supplier-row:last-child { border-bottom: none; }
.supplier-bar { width: 100%; height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; margin-top: 4px; }
.supplier-bar > div { height: 100%; background: var(--ink); }

/* Pulse dot */
@keyframes pulse-dot { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.55; transform: scale(1.5); } }
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); margin-right: 6px; animation: pulse-dot 1.8s ease-in-out infinite; }

/* utility */
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.gap-sm { gap: 6px; }
.gap-md { gap: 12px; }
.gap-lg { gap: 20px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 14px; }
.mt-4 { margin-top: 20px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 14px; }
.tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.between { justify-content: space-between; }
.text-right { text-align: right; }

/* Tweaks panel visible only when activated by host */
[data-tweaks-hidden="true"] { display: none; }
