/* Vexara CRM — design tokens (inherited from vexaraai.cloud / vexara-2026 theme)
   Dense, tabular variant for an internal sales tool. */
@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700&family=Geist+Mono:wght@400;500&display=swap');

:root {
  --bg:        oklch(99% 0.003 240);
  --bg-elev:   oklch(100% 0 0);
  --bg-subtle: oklch(97% 0.005 240);
  --bg-hover:  oklch(95% 0.007 240);
  --ink:       oklch(15% 0.02 250);
  --ink-muted: oklch(45% 0.015 250);
  --ink-faint: oklch(65% 0.012 250);
  --line:      oklch(15% 0.02 250 / 0.09);
  --line-strong: oklch(15% 0.02 250 / 0.16);
  --accent:    oklch(58% 0.20 255);
  --accent-ink: oklch(98% 0.005 240);
  --accent-soft: oklch(58% 0.20 255 / 0.10);
  --success:   oklch(62% 0.16 155);
  --warn:      oklch(72% 0.16 60);
  --danger:    oklch(58% 0.22 25);

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;

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

  --shadow-sm: 0 1px 2px oklch(15% 0.02 250 / 0.04);
  --shadow:    0 4px 24px oklch(15% 0.02 250 / 0.06), 0 1px 2px oklch(15% 0.02 250 / 0.04);

  --sidebar-w: 220px;
}

[data-theme="dark"] {
  --bg:        oklch(12% 0.015 250);
  --bg-elev:   oklch(16% 0.018 250);
  --bg-subtle: oklch(19% 0.018 250);
  --bg-hover:  oklch(22% 0.018 250);
  --ink:       oklch(98% 0.005 240);
  --ink-muted: oklch(78% 0.012 250);
  --ink-faint: oklch(62% 0.015 250);
  --line:      oklch(97% 0.005 240 / 0.10);
  --line-strong: oklch(97% 0.005 240 / 0.20);
  --accent:    oklch(78% 0.16 255);
  --accent-ink: oklch(12% 0.015 250);
  --accent-soft: oklch(78% 0.16 255 / 0.18);
  --shadow-sm: 0 1px 2px oklch(0% 0 0 / 0.4);
  --shadow:    0 8px 32px oklch(0% 0 0 / 0.4), 0 2px 4px oklch(0% 0 0 / 0.3);
}

/* ─── Reset ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; padding: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--font-mono); font-size: 13px; }

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

.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600;
  font-size: 15px;
  padding: 6px 8px 16px;
  letter-spacing: -0.01em;
}
.sidebar .brand .mark {
  width: 18px; height: 18px;
  background: var(--accent);
  border-radius: 4px;
  display: inline-block;
  position: relative;
}
.sidebar .brand .mark::after {
  content: ""; position: absolute;
  inset: 4px;
  background: var(--accent-ink);
  border-radius: 2px;
  opacity: 0.25;
}
.sidebar nav a {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
}
.sidebar nav a:hover { background: var(--bg-hover); color: var(--ink); text-decoration: none; }
.sidebar nav a.active { background: var(--accent-soft); color: var(--accent); }
.sidebar nav .section {
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-faint);
  padding: 14px 10px 4px;
  letter-spacing: 0.04em;
}
.sidebar .footer {
  margin-top: auto;
  padding: 10px;
  font-size: 12px;
  color: var(--ink-faint);
}

main { padding: 24px 32px; max-width: 1280px; }
.page-header {
  display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap;
  margin-bottom: 20px;
  gap: 12px;
}
.page-header h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.page-header .crumbs { font-size: 13px; color: var(--ink-faint); margin-bottom: 4px; }
.page-header .crumbs a { color: var(--ink-muted); }

/* ─── Cards / panels ──────────────────────────────────────────────────── */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px;
}
.card h3 { margin: 0 0 12px; font-size: 13px; font-weight: 600; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.04em; }

.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: 2fr 1fr; }

/* ─── Stat cards ──────────────────────────────────────────────────────── */
.stat {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat .label { font-size: 12px; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 500; }
.stat .value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin-top: 4px; font-family: var(--font-mono); }
.stat .delta { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }

/* ─── Tables ──────────────────────────────────────────────────────────── */
table.t {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
table.t th, table.t td { text-align: left; padding: 10px 14px; }
table.t th {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  border-bottom: 1px solid var(--line);
  background: var(--bg-subtle);
}
table.t td { border-bottom: 1px solid var(--line); font-size: 13px; }
table.t tr:last-child td { border-bottom: none; }
table.t tr:hover td { background: var(--bg-subtle); cursor: pointer; }
table.t .num, table.t td.mono { font-family: var(--font-mono); font-size: 12px; }

/* ─── Badges / chips ──────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  background: var(--bg-subtle);
  color: var(--ink-muted);
}
.badge.lifecycle-new        { background: oklch(85% 0.04 250 / 0.5); color: oklch(35% 0.05 250); }
.badge.lifecycle-engaged    { background: oklch(85% 0.10 220 / 0.4); color: oklch(35% 0.15 220); }
.badge.lifecycle-qualified  { background: oklch(85% 0.13 80  / 0.4); color: oklch(35% 0.15 80); }
.badge.lifecycle-opportunity{ background: oklch(85% 0.13 145 / 0.4); color: oklch(35% 0.15 145); }
.badge.lifecycle-customer   { background: oklch(80% 0.20 145 / 0.4); color: oklch(30% 0.20 145); }
.badge.lifecycle-lost       { background: oklch(85% 0.10 25  / 0.4); color: oklch(40% 0.18 25); }
.badge.lifecycle-do_not_contact { background: oklch(80% 0 0 / 0.5); color: oklch(35% 0 0); }

[data-theme="dark"] .badge.lifecycle-new        { background: oklch(35% 0.04 250 / 0.5); color: oklch(85% 0.05 250); }
[data-theme="dark"] .badge.lifecycle-engaged    { background: oklch(35% 0.15 220 / 0.4); color: oklch(85% 0.15 220); }
[data-theme="dark"] .badge.lifecycle-qualified  { background: oklch(35% 0.15 80 / 0.4);  color: oklch(85% 0.15 80); }
[data-theme="dark"] .badge.lifecycle-opportunity{ background: oklch(35% 0.15 145 / 0.4); color: oklch(85% 0.15 145); }
[data-theme="dark"] .badge.lifecycle-customer   { background: oklch(30% 0.20 145 / 0.4); color: oklch(85% 0.20 145); }
[data-theme="dark"] .badge.lifecycle-lost       { background: oklch(35% 0.18 25 / 0.4);  color: oklch(85% 0.10 25); }
[data-theme="dark"] .badge.lifecycle-do_not_contact { background: oklch(30% 0 0 / 0.5);  color: oklch(80% 0 0); }

/* ─── Kanban (deals) ──────────────────────────────────────────────────── */
.kanban {
  display: grid;
  grid-template-columns: repeat(7, minmax(220px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 12px;
}
.kanban .col {
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 10px;
  min-height: 200px;
}
.kanban .col h4 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  display: flex; justify-content: space-between; align-items: baseline;
}
.kanban .col h4 .count { color: var(--ink-faint); font-family: var(--font-mono); font-weight: 500; }
.kanban .deal-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
}
.kanban .deal-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.kanban .deal-card .title { font-weight: 500; font-size: 13px; line-height: 1.3; margin-bottom: 6px; }
.kanban .deal-card .meta { font-size: 11px; color: var(--ink-faint); display: flex; justify-content: space-between; }
.kanban .deal-card .value { font-family: var(--font-mono); color: var(--ink-muted); }

/* ─── Timeline (activities) ───────────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; gap: 8px; }
.timeline .item {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
}
.timeline .item .icon {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  font-size: 13px;
  background: var(--bg-subtle);
  border-radius: 50%;
  color: var(--ink-muted);
}
.timeline .item .body { display: flex; flex-direction: column; gap: 2px; }
.timeline .item .subject { font-weight: 500; }
.timeline .item .summary { color: var(--ink-muted); font-size: 13px; }
.timeline .item .when { color: var(--ink-faint); font-size: 11px; font-family: var(--font-mono); }

/* ─── Tabs ────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); }

/* ─── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--bg-elev);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.btn:hover { background: var(--bg-subtle); }
.btn.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.btn-primary:hover { filter: brightness(1.05); }

/* ─── Misc ────────────────────────────────────────────────────────────── */
.muted { color: var(--ink-muted); }
.faint { color: var(--ink-faint); }
.empty { padding: 40px; text-align: center; color: var(--ink-faint); border: 1px dashed var(--line-strong); border-radius: var(--radius); }

.theme-toggle {
  background: none; border: none; cursor: pointer;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
}
.theme-toggle:hover { background: var(--bg-hover); color: var(--ink); }

/* HTMX swap-indicator */
.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator { opacity: 1; }

/* Filters bar */
.filters { display: flex; gap: 8px; margin-bottom: 14px; }
.filters select, .filters input[type="search"] {
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--ink);
}
.filters input[type="search"] { flex: 1; min-width: 0; }

/* ─── Forms ───────────────────────────────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: 14px; max-width: 720px; }
.form .row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form .row.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
}
.form label.full { grid-column: 1 / -1; }
.form label .req { color: var(--danger); margin-left: 2px; }
.form input,
.form select,
.form textarea {
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--ink);
  font-size: 13px;
  font-weight: 400;
}
.form input:focus,
.form select:focus,
.form textarea:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}
.form textarea { resize: vertical; min-height: 80px; font-family: var(--font-sans); }
.form .errors {
  background: oklch(95% 0.06 25 / 0.6);
  border: 1px solid oklch(70% 0.18 25 / 0.4);
  color: oklch(35% 0.18 25);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
[data-theme="dark"] .form .errors {
  background: oklch(35% 0.18 25 / 0.3);
  color: oklch(85% 0.10 25);
}
.form .err { color: var(--danger); font-size: 11px; margin-top: 2px; }
.form .actions { display: flex; gap: 8px; margin-top: 8px; }
.form .help { color: var(--ink-faint); font-size: 11px; font-weight: 400; }

.btn.btn-danger {
  background: oklch(95% 0.06 25 / 0.6);
  color: oklch(35% 0.18 25);
  border-color: oklch(70% 0.18 25 / 0.4);
}
[data-theme="dark"] .btn.btn-danger {
  background: oklch(35% 0.18 25 / 0.3);
  color: oklch(85% 0.10 25);
  border-color: oklch(50% 0.18 25 / 0.4);
}
.btn.btn-danger:hover { filter: brightness(1.05); }
.btn.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-muted); }
.btn.btn-ghost:hover { background: var(--bg-hover); color: var(--ink); }
.btn.btn-sm { padding: 4px 8px; font-size: 12px; }

/* "+ New" header action */
.page-header .actions { display: flex; gap: 8px; }

/* Inline forms (HTMX swap-target) */
.inline-form {
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.inline-form textarea { min-height: 60px; }

/* Kanban — drag affordances */
.kanban .deal-card { transition: transform 0.1s, box-shadow 0.1s; }
.kanban .deal-card.sortable-ghost { opacity: 0.4; }
.kanban .deal-card.sortable-chosen { box-shadow: var(--shadow); }
.kanban .col.sortable-drag-over { background: var(--bg-hover); }
