/*
 * AI Growth System dashboards — Notion-inspired application shell
 * Design source: DESIGN-notion.md
 * Vanilla CSS only; no external font or UI dependencies.
 */
:root {
  color-scheme: light;

  /* Notion-derived core palette */
  --primary: #0075de;
  --primary-active: #005bab;
  --canvas: #ffffff;
  --canvas-soft: #f6f5f4;
  --surface: #ffffff;
  --ink: #000000;
  --ink-secondary: #31302e;
  --muted: #615d59;
  --faint: #a39e98;
  --hairline: #e6e6e6;

  /* Semantic colors stay quiet and are not structural accents. */
  --danger: #9b2c2c;
  --danger-soft: #fff0ee;
  --success: #1b6b34;
  --success-soft: #edf7ee;
  --warning: #785c11;
  --warning-soft: #faf3dc;

  --sidebar-w: 252px;
  --radius-xs: 4px;
  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-soft: 0 0.2px 1px rgba(0,0,0,.01), 0 1px 3px rgba(0,0,0,.025), 0 4px 12px rgba(0,0,0,.035);
  --shadow-elevated: 0 4px 12px rgba(0,0,0,.05), 0 18px 42px rgba(0,0,0,.06);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas-soft); }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink-secondary);
  background: var(--canvas-soft);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
::selection { background: rgba(0,117,222,.16); }
[hidden] { display: none !important; }

/* ---------- app shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--canvas-soft);
  border-right: 1px solid var(--hairline);
  color: var(--ink-secondary);
  z-index: 20;
}

.sidebar .logo {
  position: relative;
  min-height: 64px;
  padding: 12px 14px 12px 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-bottom: 1px solid transparent;
}
.sidebar .logo::before {
  content: "A";
  position: absolute;
  left: 14px;
  top: 16px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -.02em;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.15);
}
.sidebar .logo b {
  display: block;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.25;
  font-weight: 650;
  letter-spacing: -.012em;
}
.sidebar .logo span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.25;
}

.nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  padding: 8px 8px 12px;
  scrollbar-width: thin;
  scrollbar-color: #d8d6d3 transparent;
}
.nav::before {
  content: "Workspace";
  padding: 8px 8px 5px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: .015em;
}
.nav button {
  position: relative;
  width: 100%;
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #45433f;
  text-align: left;
  font-size: 14px;
  line-height: 1.35;
  font-weight: 450;
  cursor: pointer;
  transition: background-color .12s ease, color .12s ease;
}
.nav button::before {
  content: "·";
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  color: #78746f;
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
}
.nav button[data-section="overview"]::before { content: "⌂"; }
.nav button[data-section="employees"]::before,
.nav button[data-section="deployments"]::before { content: "✦"; font-size: 13px; }
.nav button[data-section="conversations"]::before { content: "◌"; }
.nav button[data-section="leads"]::before { content: "◎"; }
.nav button[data-section="brain"]::before { content: "◇"; }
.nav button[data-section="channels"]::before { content: "↗"; }
.nav button[data-section="usage"]::before { content: "▥"; }
.nav button[data-section="tenants"]::before { content: "▦"; }
.nav button:hover { background: rgba(55,53,47,.055); color: var(--ink); }
.nav button.active {
  background: rgba(55,53,47,.085);
  color: var(--ink);
  font-weight: 550;
  box-shadow: inset 2px 0 0 var(--primary);
}
.nav button.active::before { color: var(--primary); }
.nav button:focus-visible {
  outline: 2px solid rgba(0,117,222,.28);
  outline-offset: 1px;
}
.nav .tag {
  margin-left: auto;
  padding: 1px 5px;
  border: 1px solid #dedbd7;
  border-radius: 999px;
  background: rgba(255,255,255,.65);
  color: #8a8681;
  font-size: 9.5px;
  font-weight: 650;
  line-height: 1.45;
  letter-spacing: .03em;
}
.sidebar .foot {
  margin: 6px 8px 8px;
  padding: 9px 10px;
  border-top: 1px solid var(--hairline);
  color: var(--faint);
  font-size: 11px;
  line-height: 1.35;
}

/* ---------- main / header ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 28px;
  background: rgba(246,245,244,.94);
  border-bottom: 1px solid rgba(230,230,230,.9);
  backdrop-filter: blur(12px);
}
.topbar > div:first-child { min-width: 180px; }
.topbar h1 {
  margin: 0;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.35;
  font-weight: 650;
  letter-spacing: -.18px;
}
.topbar .sub {
  margin-top: 1px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}
.topbar .right { display: flex; align-items: center; gap: 6px; }

.auth-bar {
  max-width: 620px;
  padding: 5px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: rgba(255,255,255,.86);
  box-shadow: 0 1px 2px rgba(0,0,0,.02);
}
.auth-bar input {
  width: 190px;
  max-width: 260px;
  min-height: 32px;
  padding: 5px 9px;
  border-color: transparent;
  background: transparent;
}
.auth-bar input + input { border-left: 1px solid var(--hairline); border-radius: 0; }
.auth-bar input:focus { background: #fff; }

.content {
  width: 100%;
  max-width: 1320px;
  padding: 28px 30px 72px;
}
.section { display: none; }
.section.active { display: block; animation: notionFade .16s ease-out; }
@keyframes notionFade {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- layout ---------- */
.grid.two,
.grid.three { display: grid; align-items: start; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.kpi {
  min-height: 112px;
  padding: 17px 18px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: 0 .5px 1.5px rgba(0,0,0,.018);
}
.kpi .label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: .045em;
  text-transform: uppercase;
}
.kpi .value {
  margin-top: 7px;
  color: var(--ink);
  font-size: 30px;
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}
.kpi .hint { margin-top: 7px; color: var(--faint); font-size: 11.5px; line-height: 1.35; }

.card {
  position: relative;
  margin-bottom: 16px;
  padding: 21px 22px;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: 0 .5px 1.5px rgba(0,0,0,.018);
}
.card h2 {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.35;
  font-weight: 650;
  letter-spacing: -.18px;
}
.card h3 {
  color: var(--ink-secondary);
  font-size: 14px;
  line-height: 1.4;
  font-weight: 650;
}
.card .desc {
  max-width: 760px;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* ---------- tables ---------- */
table.data {
  width: 100%;
  min-width: 560px;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--ink-secondary);
  font-size: 13px;
  line-height: 1.45;
}
table.data thead th {
  background: #faf9f8;
}
table.data th {
  padding: 8px 10px;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  color: #797570;
  text-align: left;
  white-space: nowrap;
  font-size: 10.5px;
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: .055em;
  text-transform: uppercase;
}
table.data th:first-child { border-left: 1px solid var(--hairline); border-radius: 6px 0 0 6px; }
table.data th:last-child { border-right: 1px solid var(--hairline); border-radius: 0 6px 6px 0; }
table.data td {
  padding: 10px;
  border-bottom: 1px solid #efeeec;
  vertical-align: middle;
}
table.data tbody tr { transition: background-color .1s ease; }
table.data tbody tr:hover:not(.section-head) { background: #faf9f8; }
table.data tbody tr[data-id],
table.data tbody tr[data-tenant] { cursor: pointer; }
table.data tr:last-child td { border-bottom-color: transparent; }
tr.section-head td {
  padding-top: 17px;
  padding-bottom: 6px;
  border-bottom: 0;
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
}
tr.dimmed td { opacity: .55; }

/* ---------- forms ---------- */
form { min-width: 0; }
label.field {
  display: block;
  margin-bottom: 12px;
  color: var(--ink-secondary);
  font-size: 13px;
  font-weight: 500;
}
label.field > span {
  display: block;
  margin-bottom: 5px;
  color: #4f4b47;
  font-size: 12px;
  font-weight: 550;
  line-height: 1.35;
}
input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid #d8d6d3;
  border-radius: var(--radius-xs);
  outline: none;
  background: var(--surface);
  color: var(--ink-secondary);
  font-size: 13px;
  line-height: 1.45;
  box-shadow: inset 0 1px 0 rgba(0,0,0,.012);
  transition: border-color .12s ease, box-shadow .12s ease, background-color .12s ease;
}
textarea { min-height: 96px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #aaa6a1; }
input:hover, select:hover, textarea:hover { border-color: #c8c5c1; }
input:focus, select:focus, textarea:focus {
  border-color: rgba(0,117,222,.72);
  box-shadow: 0 0 0 2px rgba(0,117,222,.11);
  background: #fff;
}
input[type="file"] { padding: 6px; }
input[type="file"]::file-selector-button {
  margin-right: 9px;
  padding: 5px 9px;
  border: 1px solid var(--hairline);
  border-radius: 5px;
  background: #faf9f8;
  color: var(--ink-secondary);
  font-size: 12px;
  cursor: pointer;
}

/* ---------- buttons ---------- */
button.btn {
  min-height: 36px;
  padding: 7px 14px;
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  line-height: 1.35;
  font-weight: 600;
  letter-spacing: -.01em;
  cursor: pointer;
  box-shadow: 0 1px 1px rgba(0,0,0,.04);
  transition: background-color .12s ease, border-color .12s ease, transform .08s ease, box-shadow .12s ease;
}
button.btn:hover { background: #006dcf; border-color: #006dcf; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
button.btn:active { background: var(--primary-active); border-color: var(--primary-active); transform: scale(.985); }
button.btn:focus-visible { outline: 2px solid rgba(0,117,222,.28); outline-offset: 2px; }
button.btn.secondary {
  border-color: #d8d6d3;
  background: var(--surface);
  color: var(--ink-secondary);
  box-shadow: 0 1px 2px rgba(0,0,0,.025);
}
button.btn.secondary:hover { background: #f7f6f5; border-color: #cbc8c4; }
button.btn.secondary:active { background: #f1efed; }
button.btn.small { min-height: 30px; padding: 5px 9px; border-radius: 6px; font-size: 11.5px; }
button.btn:disabled { opacity: .45; cursor: default; transform: none; }

/* ---------- badges, utilities, snippets ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 2px 7px;
  border: 1px solid #dedbd7;
  border-radius: 999px;
  background: #faf9f8;
  color: #5d5955;
  font-size: 10.5px;
  line-height: 1.45;
  font-weight: 600;
  letter-spacing: .015em;
}
.badge.gray { background: #f1f0ef; color: #66615d; border-color: #e5e3e1; }
.badge.green { background: var(--success-soft); color: var(--success); border-color: #dcecdf; }
.badge.amber { background: var(--warning-soft); color: var(--warning); border-color: #eee3bd; }
.badge.red { background: var(--danger-soft); color: var(--danger); border-color: #f0d8d4; }
.badge.blue { background: #eef6fd; color: var(--primary-active); border-color: #dcebf8; }

.empty { padding: 14px 2px; color: var(--faint); font-size: 12.5px; }
.row-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-note, .muted-text { color: var(--muted); font-size: 12px; line-height: 1.5; }
.inline-note { margin-top: -3px; }
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 11.5px;
  letter-spacing: -.01em;
}
pre.snippet {
  min-height: 46px;
  margin: 12px 0 0;
  padding: 12px 13px;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid #282725;
  border-radius: var(--radius-md);
  background: #1f1e1c;
  color: #f7f6f4;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.55;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  max-width: min(520px, calc(100vw - 40px));
  padding: 11px 14px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius-lg);
  background: #2b2927;
  color: #fff;
  box-shadow: var(--shadow-elevated);
  font-size: 12.5px;
  line-height: 1.45;
}
.toast.ok { background: var(--primary-active); }

/* ---------- setup guides ---------- */
details.guide-block {
  margin-bottom: 8px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  background: var(--surface);
}
details.guide-block summary {
  position: relative;
  padding: 11px 38px 11px 12px;
  list-style: none;
  color: var(--ink-secondary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 550;
  line-height: 1.45;
  transition: background-color .12s ease;
}
details.guide-block summary::-webkit-details-marker { display: none; }
details.guide-block summary::after {
  content: "›";
  position: absolute;
  right: 14px;
  top: 50%;
  color: var(--faint);
  font-size: 18px;
  transform: translateY(-50%) rotate(90deg);
  transition: transform .12s ease;
}
details.guide-block[open] summary::after { transform: translateY(-50%) rotate(-90deg); }
details.guide-block summary:hover { background: #faf9f8; }
details.guide-block[open] summary { border-bottom: 1px solid var(--hairline); }
details.guide-block .guide,
details.guide-block > .muted-text { margin-left: 14px; margin-right: 14px; }
ol.guide {
  display: grid;
  gap: 7px;
  margin-top: 13px;
  margin-bottom: 12px;
  padding-left: 22px;
  color: #4b4844;
  font-size: 12.5px;
  line-height: 1.55;
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  :root { --sidebar-w: 224px; }
  .content { padding-left: 22px; padding-right: 22px; }
  .grid.three { grid-template-columns: 1fr; }
  .auth-bar input { width: 160px; }
}

@media (max-width: 820px) {
  .app { display: block; }
  .sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    height: auto;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--hairline);
    box-shadow: 0 1px 8px rgba(0,0,0,.025);
  }
  .sidebar .logo {
    min-height: 49px;
    padding-top: 7px;
    padding-bottom: 7px;
  }
  .sidebar .logo::before { top: 11px; }
  .sidebar .logo span, .sidebar .foot, .nav::before { display: none; }
  .nav {
    flex-direction: row;
    gap: 2px;
    padding: 0 8px 7px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav button {
    width: auto;
    flex: 0 0 auto;
    min-height: 32px;
    padding: 5px 9px;
    white-space: nowrap;
  }
  .nav button::before { flex-basis: 18px; width: 18px; }
  .nav button.active { box-shadow: inset 0 -2px 0 var(--primary); }
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 16px;
    background: var(--canvas-soft);
  }
  .topbar .right, .auth-bar { width: 100%; max-width: none; }
  .auth-bar { display: grid !important; grid-template-columns: 1fr 1fr auto; }
  .auth-bar input { width: 100%; max-width: none; min-width: 0; }
  .content { padding: 18px 14px 54px; }
  .grid.two { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .topbar h1 { font-size: 18px; }
  .auth-bar { grid-template-columns: 1fr; padding: 6px; }
  .auth-bar input + input { border-left: 0; border-top: 1px solid var(--hairline); border-radius: 0; }
  .auth-bar button.btn { width: 100%; }
  .kpis { grid-template-columns: 1fr; }
  .kpi { min-height: 94px; }
  .card { padding: 17px 16px; border-radius: 10px; }
  table.data { min-width: 520px; }
  .row-actions > input, .row-actions > select { max-width: none !important; flex: 1 1 100%; }
  .row-actions > .btn { flex: 0 0 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* Commercial setup uses the existing dashboard palette and controls. */
.welcome-page { background: var(--canvas-soft); }
.welcome-shell { margin: 0 auto; padding: 32px 24px 72px; }
.landing-shell { max-width: 1168px; }
.signup-shell { max-width: 768px; padding-top: 56px; }
.setup-shell { max-width: 960px; }
.welcome-header { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.welcome-header a.logo { color: inherit; text-decoration: none; }
.welcome-hero { padding: 96px 0 72px; max-width: 880px; }
.welcome-hero h1 { font-size: clamp(36px, 5.1vw, 60px); line-height: 1.08; letter-spacing: -0.04em; margin: 20px 0; }
.setup-card h1, .signup-shell h1 { font-size: clamp(28px, 3.6vw, 40px); line-height: 1.16; letter-spacing: -0.03em; }
.setup-card { padding: 30px; }
.setup-steps { display: flex; gap: 12px; flex-wrap: wrap; margin: 28px 0 20px; color: var(--muted); font-size: 13px; }
.setup-steps span { padding: 8px 12px; border: 1px solid var(--hairline); border-radius: var(--radius-sm); background: var(--surface); }
.setup-steps [aria-current] { color: var(--primary-active); background: #eff7ff; border-color: #a8cfee; }
.setup-steps .done { color: var(--success); }
.setup-offer { margin-top: 18px; }
.setup-next { margin-top: 28px; }
.form-status { display: block; font-size: 13px; margin: 10px 0 0; min-height: 20px; }
.form-status[data-state="success"] { color: var(--success); }
.form-status[data-state="error"] { color: var(--danger); }
.btn:disabled { cursor: wait; opacity: .55; }
.reply-composer { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--hairline); }
@media (max-width: 620px) {
  .welcome-shell { padding: 22px 16px 48px; }
  .welcome-header { align-items: flex-start; flex-wrap: wrap; }
  .welcome-hero { padding: 56px 0 44px; }
  .setup-card { padding: 20px; }
  .setup-steps { gap: 6px; }
  .setup-steps span { padding: 6px 8px; font-size: 12px; }
}
