/* ============================================================
   Queen City AI — AI Growth Engine
   Design tokens + base styles. Dense B2B SaaS console.
   ============================================================ */

:root {
  /* Accent (user-selected blue) */
  --accent: #2563eb;
  --accent-600: #2563eb;
  --accent-700: #1d4ed8;
  --accent-50: #eff6ff;
  --accent-100: #dbeafe;
  --accent-200: #bfdbfe;

  /* Neutrals — slate scale */
  --ink: #0f172a;
  --ink-2: #1e293b;
  --gray-700: #334155;
  --gray-600: #475569;
  --gray-500: #64748b;
  --gray-400: #94a3b8;
  --gray-300: #cbd5e1;
  --gray-200: #e2e8f0;
  --gray-150: #eef2f6;
  --gray-100: #f1f5f9;
  --gray-50: #f8fafc;
  --white: #ffffff;

  /* Semantic status */
  --green: #16a34a;
  --green-bg: #ecfdf3;
  --green-bd: #bbf7d0;
  --amber: #d97706;
  --amber-bg: #fffbeb;
  --amber-bd: #fde68a;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --red-bd: #fecaca;
  --violet: #7c3aed;
  --violet-bg: #f5f3ff;
  --violet-bd: #ddd6fe;

  /* Surfaces */
  --bg: var(--gray-100);
  --surface: var(--white);
  --border: var(--gray-200);
  --border-strong: var(--gray-300);

  /* Type */
  --font: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", monospace;

  /* Radius */
  --r-sm: 5px;
  --r-md: 7px;
  --r-lg: 10px;
  --r-xl: 14px;

  /* Shadow */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.10), 0 2px 4px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.16), 0 4px 8px rgba(15, 23, 42, 0.06);

  /* Density (driven by tweak) */
  --row-h: 44px;
  --cell-py: 10px;
  --pad: 24px;
}

[data-density="compact"] {
  --row-h: 36px;
  --cell-py: 6px;
  --pad: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#root { height: 100%; }

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

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 8px;
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  height: 100%;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  background: var(--ink);
  color: var(--gray-300);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.brand-logo { height: 30px; width: auto; display: block; }
.brand-product {
  font-size: 11px; font-weight: 600; letter-spacing: 0.03em;
  color: #2dd4bf;
}
.brand-mark {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: var(--accent);
  display: grid; place-items: center;
  color: #fff; font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.25);
}
.brand-name { color: #fff; font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--gray-500); margin-top: 1px; }

.ws-switch {
  margin: 12px 12px 4px;
  padding: 9px 11px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--r-md);
  display: flex; align-items: center; gap: 9px;
  cursor: pointer;
  transition: background .12s;
}
.ws-switch:hover { background: rgba(255,255,255,0.09); }
.ws-logo {
  width: 24px; height: 24px; border-radius: 6px;
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 700;
  flex-shrink: 0;
}
.ws-name { color: #fff; font-size: 13px; font-weight: 600; line-height: 1.1; }
.ws-plan { color: var(--gray-500); font-size: 11px; }

.nav { padding: 8px 10px; overflow-y: auto; flex: 1; }
.nav-group-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--gray-600); padding: 14px 10px 6px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-md);
  color: var(--gray-300); font-size: 13.5px; font-weight: 500;
  cursor: pointer; border: none; background: none; width: 100%; text-align: left;
  transition: background .1s, color .1s;
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item.active:hover { background: var(--accent-700); }
.nav-item svg { flex-shrink: 0; }
.nav-badge {
  margin-left: auto; background: rgba(255,255,255,0.14);
  color: #fff; font-size: 11px; font-weight: 600;
  padding: 1px 7px; border-radius: 20px;
}
.nav-item.active .nav-badge { background: rgba(255,255,255,0.25); }

/* Main */
.main { display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }

.topbar {
  height: 56px; flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 22px; gap: 16px;
}
.topbar h1 { font-family: "Space Grotesk", var(--font); font-size: 16px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.topbar .crumb { color: var(--gray-400); font-size: 13px; }
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--gray-100); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 7px 11px; width: 280px;
  color: var(--gray-400); font-size: 13px;
}
.search input { border: none; background: none; outline: none; flex: 1; color: var(--ink); font-size: 13px; }
.spacer { flex: 1; }

.role-switch {
  display: flex; background: var(--gray-100); border-radius: var(--r-md);
  padding: 3px; gap: 2px; border: 1px solid var(--border);
}
.role-btn {
  border: none; background: none; padding: 5px 11px; border-radius: 5px;
  font-size: 12.5px; font-weight: 500; color: var(--gray-500);
}
.role-btn.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-xs); font-weight: 600; }

.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
}

.content { flex: 1; overflow-y: auto; }
.page { padding: var(--pad) 28px 48px; max-width: 1320px; margin: 0 auto; }
.page-wide { max-width: 100%; }

.page-head { margin-bottom: 20px; }
.page-head h2 { font-family: "Space Grotesk", var(--font); font-size: 22px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.02em; }
.page-head p { color: var(--gray-500); font-size: 13.5px; margin: 0; max-width: 640px; }

/* ---------- Primitives ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-xs);
}
.card-pad { padding: 18px; }
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 14px; font-weight: 600; margin: 0; }
.card-head .sub { font-size: 12px; color: var(--gray-500); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: var(--r-md); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--gray-700);
  padding: 7px 13px; font-size: 13px; font-weight: 500;
  transition: background .1s, border-color .1s, box-shadow .1s;
  white-space: nowrap;
}
.btn:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: var(--shadow-xs); }
.btn-primary:hover { background: var(--accent-700); border-color: var(--accent-700); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-danger { color: var(--red); border-color: var(--red-bd); background: var(--red-bg); }
.btn-danger:hover { background: #fee2e2; }
.btn:disabled { opacity: .5; pointer-events: none; }

/* Badge / pill */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600; padding: 2px 9px;
  border-radius: 20px; border: 1px solid transparent; white-space: nowrap;
}
.dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

.b-new    { background: var(--accent-50); color: var(--accent-700); border-color: var(--accent-200); }
.b-reviewed { background: var(--violet-bg); color: var(--violet); border-color: var(--violet-bd); }
.b-approved { background: var(--green-bg); color: var(--green); border-color: var(--green-bd); }
.b-rejected { background: var(--red-bg); color: var(--red); border-color: var(--red-bd); }
.b-exported { background: var(--gray-100); color: var(--gray-600); border-color: var(--gray-300); }
.b-synced  { background: #ecfeff; color: #0e7490; border-color: #a5f3fc; }
.b-gray    { background: var(--gray-100); color: var(--gray-600); border-color: var(--gray-200); }

/* Table */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--gray-500); padding: 9px 14px;
  border-bottom: 1px solid var(--border); background: var(--gray-50);
  position: sticky; top: 0; z-index: 1; white-space: nowrap;
}
table.tbl td {
  padding: var(--cell-py) 14px; border-bottom: 1px solid var(--gray-150);
  vertical-align: middle; height: var(--row-h);
}
table.tbl tbody tr { transition: background .08s; cursor: pointer; }
table.tbl tbody tr:hover { background: var(--accent-50); }
table.tbl tbody tr.selected { background: var(--accent-50); }
table.tbl tbody tr:last-child td { border-bottom: none; }

.cell-co { display: flex; align-items: center; gap: 11px; }
.co-logo {
  width: 30px; height: 30px; border-radius: 7px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff;
}
.co-name { font-weight: 600; color: var(--ink); line-height: 1.15; }
.co-url { font-size: 11.5px; color: var(--gray-400); }
.muted { color: var(--gray-500); }
.mono { font-family: var(--mono); font-size: 12px; }

/* Checkbox */
.cbx {
  width: 16px; height: 16px; border-radius: 4px; border: 1.5px solid var(--gray-300);
  background: var(--surface); display: grid; place-items: center; flex-shrink: 0;
  transition: background .1s, border-color .1s;
}
.cbx.on { background: var(--accent); border-color: var(--accent); }
.cbx svg { opacity: 0; }
.cbx.on svg { opacity: 1; }

/* Score meter */
.score { display: flex; align-items: center; gap: 8px; }
.score-num { font-weight: 700; font-size: 13px; width: 26px; }
.score-bar { width: 54px; height: 6px; border-radius: 4px; background: var(--gray-200); overflow: hidden; }
.score-fill { height: 100%; border-radius: 4px; }
.s-high .score-fill { background: var(--green); }
.s-high .score-num { color: var(--green); }
.s-mid .score-fill  { background: var(--amber); }
.s-mid .score-num  { color: var(--amber); }
.s-low .score-fill  { background: var(--gray-400); }
.s-low .score-num  { color: var(--gray-500); }

/* Stat card */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 16px 18px; box-shadow: var(--shadow-xs);
}
.stat-label { font-size: 12px; color: var(--gray-500); font-weight: 500; display: flex; align-items: center; gap: 7px; }
.stat-val { font-size: 27px; font-weight: 700; letter-spacing: -0.02em; margin-top: 8px; line-height: 1; }
.stat-delta { font-size: 12px; margin-top: 7px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.delta-up { color: var(--green); }
.delta-down { color: var(--red); }
.delta-flat { color: var(--gray-400); }

/* Filter bar */
.filterbar {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 12px 0; 
}
.fpill {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); padding: 6px 11px; font-size: 12.5px; font-weight: 500;
  color: var(--gray-600);
}
.fpill:hover { border-color: var(--gray-400); background: var(--gray-50); }
.fpill.on { background: var(--accent-50); border-color: var(--accent-200); color: var(--accent-700); }
.fpill select { border: none; background: none; outline: none; font-weight: 500; color: inherit; font-size: 12.5px; }

/* Bulk action bar */
.bulkbar {
  display: flex; align-items: center; gap: 12px;
  background: var(--ink); color: #fff;
  padding: 9px 16px; border-radius: var(--r-md);
  box-shadow: var(--shadow-md); font-size: 13px;
}
.bulkbar .btn { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.18); color: #fff; }
.bulkbar .btn:hover { background: rgba(255,255,255,0.18); }
.bulkbar .btn-primary { background: var(--accent); border-color: var(--accent); }

/* Drawer */
.drawer-scrim {
  position: absolute; inset: 0; background: rgba(15,23,42,0.32);
  z-index: 40; animation: fade .15s ease;
}
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: 620px; max-width: 92%;
  background: var(--surface); z-index: 41; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; animation: slidein .22s cubic-bezier(.2,.7,.3,1);
}
@keyframes slidein { from { transform: translateX(30px); opacity: .6; } to { transform: translateX(0); opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.drawer-head { padding: 18px 22px; border-bottom: 1px solid var(--border); }
.drawer-body { flex: 1; overflow-y: auto; padding: 22px; }
.drawer-foot {
  padding: 14px 22px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; align-items: center; background: var(--gray-50);
}

/* Misc layout helpers */
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }
.gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }

.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--gray-500); font-weight: 600; margin: 0 0 10px; }
.kv { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--gray-150); font-size: 13px; }
.kv:last-child { border: none; }
.kv .k { color: var(--gray-500); }
.kv .v { font-weight: 500; color: var(--ink); text-align: right; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--gray-400); font-weight: 400; margin-top: 4px; }
.input, .textarea, .select {
  width: 100%; border: 1px solid var(--border-strong); border-radius: var(--r-md);
  padding: 9px 11px; font-size: 13.5px; color: var(--ink); background: var(--surface);
  outline: none; transition: border-color .1s, box-shadow .1s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-100); }
.textarea { resize: vertical; min-height: 84px; line-height: 1.5; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--gray-100); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 11px; font-size: 12.5px; font-weight: 500; color: var(--gray-700);
}
.chip .x { color: var(--gray-400); cursor: pointer; display: grid; place-items: center; }
.chip .x:hover { color: var(--red); }
.chip-accent { background: var(--accent-50); border-color: var(--accent-200); color: var(--accent-700); }

/* Evidence / citation block */
.evidence {
  border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 12px 14px; background: var(--gray-50); margin-bottom: 10px;
}
.evidence .src { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--gray-500); margin-bottom: 6px; }
.evidence .quote { font-size: 13px; line-height: 1.5; color: var(--gray-700); }
.evidence a { color: var(--accent); text-decoration: none; font-weight: 500; }
.evidence a:hover { text-decoration: underline; }

/* Progress / bars for reporting */
.bar-row { display: grid; grid-template-columns: 130px 1fr 52px; align-items: center; gap: 12px; padding: 7px 0; font-size: 13px; }
.bar-track { height: 9px; background: var(--gray-150); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 6px; }
.bar-val { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Onboarding */
.onb { min-height: 100%; display: flex; flex-direction: column; background: var(--gray-100); }
.onb-topbar { display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 20px; background: var(--ink); border-bottom: 1px solid rgba(255,255,255,0.07); flex-shrink: 0; }
.onb-brand { background: none; border: none; padding: 0; cursor: pointer; display: flex; align-items: center; }
.onb-brand-logo { height: 26px; width: auto; display: block; }
.onb-brand-product { color: #2dd4bf; font-size: 11px; font-weight: 600; letter-spacing: 0.03em; }
.onb-exit { background: none; border: none; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; color: var(--gray-300); font-size: 13px; font-weight: 500; padding: 7px 10px; border-radius: var(--r-md); transition: background .12s, color .12s; }
.onb-exit:hover { background: rgba(255,255,255,0.08); color: #fff; }
.onb-body { flex: 1; display: grid; place-items: center; padding: 40px 20px; }
.onb-card { width: 720px; max-width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-md); overflow: hidden; }
.onb-steps { display: flex; border-bottom: 1px solid var(--border); }
.onb-step { flex: 1; padding: 14px 16px; display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--gray-400); border-right: 1px solid var(--border); }
.onb-step:last-child { border-right: none; }
.onb-step.active { color: var(--ink); font-weight: 600; }
.onb-step.done { color: var(--green); }
.onb-num { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid currentColor; display: grid; place-items: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.onb-step.active .onb-num { background: var(--accent); border-color: var(--accent); color: #fff; }
.onb-step.done .onb-num { background: var(--green); border-color: var(--green); color: #fff; }

/* Upload dropzone */
.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--r-lg);
  padding: 26px; text-align: center; color: var(--gray-500); background: var(--gray-50);
  transition: border-color .1s, background .1s;
}
.dropzone:hover { border-color: var(--accent); background: var(--accent-50); }

/* Toast */
.toast-wrap { position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--r-md);
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 9px; animation: slideup .2s ease;
}
@keyframes slideup { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.empty { text-align: center; padding: 60px 20px; color: var(--gray-400); }
.empty svg { margin-bottom: 12px; }

/* integration card */
.intg { display: flex; align-items: center; gap: 14px; padding: 16px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
.intg-logo { width: 42px; height: 42px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; color: #fff; flex-shrink: 0; font-size: 15px; }

/* mini sparkline / bar chart */
.chart { display: flex; align-items: flex-end; gap: 5px; height: 120px; }
.chart .bar { flex: 1; background: var(--accent-200); border-radius: 4px 4px 0 0; position: relative; transition: background .1s; min-width: 6px; }
.chart .bar:hover { background: var(--accent); }
.chart .bar .tip { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 6px; background: var(--ink); color: #fff; font-size: 11px; padding: 3px 7px; border-radius: 5px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .1s; }
.chart .bar:hover .tip { opacity: 1; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab { padding: 9px 14px; font-size: 13px; font-weight: 500; color: var(--gray-500); border: none; background: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab:hover { color: var(--ink); }
