/*
 * styles.css
 * Premium dark UI. One accent color, consistent components across every view.
 * The accent is injected from config at runtime onto :root as --accent, so the
 * whole theme re-skins from a single value.
 */

:root {
  --accent: #6d5efc;
  --accent-soft: rgba(109, 94, 252, 0.14);
  --accent-ink: #ffffff;

  --bg: #0a0c12;
  --bg-1: #0f121b;
  --panel: #141824;
  --panel-2: #191e2c;
  --panel-hover: #1e2434;
  --border: #232a3b;
  --border-soft: #1a1f2d;

  --text: #eef1f8;
  --text-dim: #a3abbf;
  --text-faint: #6b7488;

  --green: #33c98a;
  --amber: #f0a83c;
  --red: #e2596b;
  --blue: #3ca9f0;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.28);

  --sidebar-w: 244px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 80% -10%, rgba(109, 94, 252, 0.08), transparent 60%), var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--accent); color: #fff; }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a3143; border-radius: 20px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #37405a; background-clip: padding-box; }

/* ===========================================================================
 * AUTH / LOGIN
 * ========================================================================= */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.auth-card h1 { font-size: 20px; font-weight: 650; letter-spacing: -0.2px; }
.auth-card p.sub { color: var(--text-dim); margin-top: 4px; margin-bottom: 26px; font-size: 13px; }
.auth-card .field { margin-bottom: 16px; }
.auth-note {
  margin-top: 18px; font-size: 12px; color: var(--text-faint); text-align: center; line-height: 1.6;
}
.auth-error {
  background: rgba(226, 89, 107, 0.12);
  border: 1px solid rgba(226, 89, 107, 0.3);
  color: #f2a6b0;
  padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px;
}

/* Logo badge */
.logo-badge {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--accent), #a45ffc);
  color: #fff; font-weight: 750; font-size: 18px;
  box-shadow: 0 8px 20px var(--accent-soft);
}
.logo-badge.sm { width: 32px; height: 32px; font-size: 15px; border-radius: 10px; }

/* ===========================================================================
 * APP SHELL
 * ========================================================================= */
.app { display: none; min-height: 100vh; }
.app.active { display: block; }

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--bg-1);
  border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column;
  padding: 18px 14px;
  z-index: 40;
  transform: translateX(0);
  transition: transform 0.22s cubic-bezier(0.4,0,0.2,1);
}
/* The hamburger toggles this at any screen width, not just mobile. JS sets
   the initial state (open on desktop, closed on mobile) on boot. */
.sidebar.hidden { transform: translateX(-100%); }
.sidebar .brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 20px; }
.sidebar .brand .name { font-weight: 650; font-size: 15px; letter-spacing: -0.2px; }
.sidebar .brand .name small { display: block; color: var(--text-faint); font-weight: 500; font-size: 11px; }

.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-weight: 500; font-size: 13.5px;
  border: none; background: none; text-align: left; width: 100%;
  transition: background 0.14s, color 0.14s;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: #fff; }
.nav-item.active svg { color: var(--accent); }
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item .badge {
  margin-left: auto; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 650; padding: 1px 7px; border-radius: 20px;
}

.sidebar-foot { border-top: 1px solid var(--border-soft); padding-top: 12px; margin-top: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); }
.user-chip .avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: var(--panel-2); display: grid; place-items: center;
  font-weight: 650; font-size: 12px; color: var(--accent);
  border: 1px solid var(--border);
}
.user-chip .who { font-size: 12.5px; font-weight: 550; line-height: 1.3; overflow: hidden; }
.user-chip .who small { display: block; color: var(--text-faint); font-weight: 500; font-size: 11px; }

.main { margin-left: var(--sidebar-w); min-height: 100vh; transition: margin-left 0.22s cubic-bezier(0.4,0,0.2,1); }
.main.full { margin-left: 0; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 16px 28px;
  background: rgba(10, 12, 18, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.topbar h2 { font-size: 18px; font-weight: 650; letter-spacing: -0.3px; }
.topbar .sub { color: var(--text-faint); font-size: 12.5px; margin-top: 1px; }
.topbar .spacer { flex: 1; }
.hamburger {
  display: grid; place-items: center; width: 36px; height: 36px; flex-shrink: 0;
  background: none; border: none; color: var(--text); border-radius: var(--radius-sm);
}
.hamburger:hover { background: var(--panel); }

.view { padding: 24px 28px 80px; }

/* ===========================================================================
 * BUTTONS
 * ========================================================================= */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 9px 15px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; border: 1px solid transparent;
  background: var(--panel-2); color: var(--text);
  transition: transform 0.06s, background 0.14s, border-color 0.14s;
}
.btn:hover { background: var(--panel-hover); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 8px 20px var(--accent-soft); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text-dim); }
.btn.ghost:hover { color: var(--text); border-color: #333c52; }
.btn.danger { background: rgba(226, 89, 107, 0.14); color: #f2a6b0; }
.btn.danger:hover { background: rgba(226, 89, 107, 0.22); }
.btn.sm { padding: 6px 11px; font-size: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.icon-btn {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  display: grid; place-items: center; background: var(--panel-2);
  border: 1px solid var(--border); color: var(--text-dim);
}
.icon-btn:hover { color: var(--text); background: var(--panel-hover); }
.icon-btn svg { width: 17px; height: 17px; }

/* ===========================================================================
 * FORMS
 * ========================================================================= */
label.lbl { display: block; font-size: 12px; font-weight: 550; color: var(--text-dim); margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px;
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 13.5px;
  transition: border-color 0.14s, box-shadow 0.14s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { resize: vertical; min-height: 84px; }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ===========================================================================
 * CARDS / PANELS
 * ========================================================================= */
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.card.pad-lg { padding: 22px; }
.section-title { font-size: 14px; font-weight: 650; letter-spacing: -0.2px; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.grid { display: grid; gap: 16px; }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; position: relative; overflow: hidden;
}
.kpi::after {
  content: ''; position: absolute; right: -20px; top: -20px;
  width: 90px; height: 90px; border-radius: 50%;
  background: var(--accent-soft); opacity: 0.5;
}
.kpi .k-label { color: var(--text-dim); font-size: 12.5px; font-weight: 550; display: flex; align-items: center; gap: 7px; }
.kpi .k-label svg { width: 15px; height: 15px; color: var(--accent); }
.kpi .k-value { font-size: 28px; font-weight: 720; letter-spacing: -0.6px; margin-top: 10px; }
.kpi .k-sub { font-size: 12px; color: var(--text-faint); margin-top: 4px; }
.kpi .k-sub.up { color: var(--green); }
.kpi .k-sub.down { color: var(--red); }

/* ===========================================================================
 * BADGES / PILLS
 * ========================================================================= */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600;
  background: var(--panel-2); color: var(--text-dim); border: 1px solid var(--border);
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; }
.stage-pill { padding: 4px 11px; border-radius: 20px; font-size: 11.5px; font-weight: 650; }
.src-icon {
  width: 22px; height: 22px; border-radius: 6px; display: inline-grid; place-items: center; flex: none;
}
.src-icon svg { width: 13px; height: 13px; }

.status-tag { padding: 2px 9px; border-radius: 6px; font-size: 11px; font-weight: 650; text-transform: capitalize; }
.status-draft { background: rgba(139,147,167,0.16); color: #aeb6c7; }
.status-sent { background: rgba(60,169,240,0.16); color: #7cc4f5; }
.status-paid { background: rgba(51,201,138,0.16); color: #6fdcae; }
.status-overdue { background: rgba(226,89,107,0.16); color: #f2a6b0; }
.status-won { background: rgba(51,201,138,0.16); color: #6fdcae; }
.status-lost { background: rgba(226,89,107,0.16); color: #f2a6b0; }
.status-active, .status-open { background: var(--accent-soft); color: #b9b1ff; }

/* ===========================================================================
 * TABLES
 * ========================================================================= */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table.data { width: 100%; border-collapse: collapse; min-width: 720px; }
table.data th {
  text-align: left; font-size: 11.5px; font-weight: 600; color: var(--text-faint);
  padding: 12px 16px; background: var(--bg-1); border-bottom: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: 0.4px; white-space: nowrap;
}
table.data td { padding: 13px 16px; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr { background: var(--panel); transition: background 0.12s; cursor: pointer; }
table.data tbody tr:hover { background: var(--panel-hover); }
.lead-name-cell { display: flex; align-items: center; gap: 11px; }
.lead-name-cell .who b { font-weight: 600; font-size: 13px; }
.lead-name-cell .who small { display: block; color: var(--text-faint); font-size: 11.5px; }

/* Toolbar (filters/search) */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.search {
  position: relative; flex: 1; min-width: 200px; max-width: 340px;
}
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-faint); }
.search input { padding-left: 34px; }

/* ===========================================================================
 * KANBAN  (Module 4)
 * ========================================================================= */
.kanban-summary {
  display: flex; gap: 12px; overflow-x: auto; padding-bottom: 14px; margin-bottom: 4px;
}
.pipe-total {
  background: linear-gradient(135deg, var(--accent), #a45ffc);
  color: #fff; border-radius: var(--radius); padding: 16px 20px; flex: none; min-width: 200px;
}
.pipe-total .lbl { font-size: 12px; opacity: 0.9; font-weight: 550; }
.pipe-total .val { font-size: 24px; font-weight: 720; margin-top: 4px; letter-spacing: -0.5px; }
/* Secondary stat next to the primary total: same shape, quieter color so it
   reads as supporting context rather than competing for attention. */
.pipe-total.weighted { background: var(--panel); color: var(--text); border: 1px solid var(--border); }
.pipe-total.weighted .lbl { color: var(--text-faint); opacity: 1; }

.kanban {
  display: flex; gap: 14px; overflow-x: auto; padding-bottom: 20px;
  scroll-snap-type: x proximity;
}
.kanban-col {
  flex: none; width: 288px; background: var(--bg-1);
  border: 1px solid var(--border-soft); border-radius: var(--radius);
  display: flex; flex-direction: column; max-height: calc(100vh - 260px);
}
.kanban-col.drop-target { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.kanban-col-head {
  display: flex; align-items: center; gap: 8px; padding: 13px 14px 11px;
  border-bottom: 1px solid var(--border-soft); position: sticky; top: 0;
}
.kanban-col-head .stage-dot { width: 9px; height: 9px; border-radius: 50%; }
.kanban-col-head .title { font-size: 13px; font-weight: 650; }
.kanban-col-head .count { margin-left: auto; font-size: 12px; color: var(--text-faint); background: var(--panel-2); padding: 1px 8px; border-radius: 12px; }
.kanban-col-head .sum { flex-basis: 100%; font-size: 11.5px; color: var(--text-faint); }
.kanban-cards { padding: 10px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; flex: 1; }

.kcard {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px; cursor: grab;
  transition: border-color 0.14s, transform 0.06s, box-shadow 0.14s;
}
.kcard:hover { border-color: #333c52; box-shadow: var(--shadow-soft); }
.kcard.dragging { opacity: 0.5; cursor: grabbing; }
.kcard.stale { border-left: 3px solid var(--amber); }
.kcard .top { display: flex; align-items: flex-start; gap: 8px; }
.kcard .name { font-weight: 600; font-size: 13.5px; }
.kcard .co { color: var(--text-faint); font-size: 12px; margin-top: 1px; }
.kcard .meta { display: flex; align-items: center; gap: 8px; margin-top: 11px; flex-wrap: wrap; }
.kcard .value { font-weight: 650; color: var(--green); font-size: 13px; }
.kcard .days { font-size: 11px; color: var(--text-faint); margin-left: auto; }
.kcard .stale-tag { color: var(--amber); font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }

/* ===========================================================================
 * MODAL / DRAWER
 * ========================================================================= */
.overlay {
  position: fixed; inset: 0; background: rgba(4, 6, 10, 0.62);
  backdrop-filter: blur(3px); z-index: 90; display: none;
  opacity: 0; transition: opacity 0.16s;
}
.overlay.open { display: block; opacity: 1; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 560px; max-width: 94vw;
  background: var(--bg-1); border-left: 1px solid var(--border); z-index: 100;
  transform: translateX(100%); transition: transform 0.22s cubic-bezier(0.4,0,0.2,1);
  display: flex; flex-direction: column; box-shadow: -20px 0 60px rgba(0,0,0,0.4);
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 20px 22px; border-bottom: 1px solid var(--border-soft); }
.drawer-body { padding: 22px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 16px 22px; border-top: 1px solid var(--border-soft); display: flex; gap: 10px; }

.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -46%);
  width: 520px; max-width: 94vw; max-height: 90vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg);
  z-index: 100; display: none; box-shadow: var(--shadow); opacity: 0;
  transition: opacity 0.16s, transform 0.16s;
}
.modal.open { display: block; opacity: 1; transform: translate(-50%, -50%); }
.modal.wide { width: 720px; }
.modal-head { display: flex; align-items: center; padding: 20px 22px; border-bottom: 1px solid var(--border-soft); }
.modal-head h3 { font-size: 16px; font-weight: 650; }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border-soft); display: flex; gap: 10px; justify-content: flex-end; }

/* Lead detail */
.lead-header { display: flex; align-items: flex-start; gap: 14px; }
.lead-avatar {
  width: 48px; height: 48px; border-radius: 14px; flex: none; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 18px;
}
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 20px; margin: 18px 0; }
.detail-item .dl { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600; }
.detail-item .dv { font-size: 13.5px; margin-top: 3px; font-weight: 500; }

.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 20px; }

/* Timeline */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 20px; }
.tl-item::before {
  content: ''; position: absolute; left: -22px; top: 3px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--panel); border: 2px solid var(--accent);
}
.tl-item.system::before { border-color: var(--text-faint); }
.tl-item.message::before { border-color: var(--green); }
.tl-item.status::before { border-color: var(--blue); }
.tl-item .tl-head { display: flex; align-items: center; gap: 8px; }
.tl-item .tl-type { font-size: 12.5px; font-weight: 600; }
.tl-item .tl-time { font-size: 11px; color: var(--text-faint); margin-left: auto; }
.tl-item .tl-body { font-size: 13px; color: var(--text-dim); margin-top: 4px; }

/* ===========================================================================
 * CHAT (Bot simulator + message history)
 * ========================================================================= */
.chat {
  display: flex; flex-direction: column; gap: 10px; padding: 8px 2px;
}
.bubble {
  max-width: 78%; padding: 10px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.45;
  animation: pop 0.18s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.bubble.in { align-self: flex-start; background: var(--panel-2); border-bottom-left-radius: 4px; }
.bubble.out { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.bubble .t { font-size: 10px; opacity: 0.6; margin-top: 4px; }
.chat-choices { display: flex; flex-wrap: wrap; gap: 8px; align-self: flex-start; max-width: 90%; }
.chip-btn {
  padding: 8px 13px; border-radius: 20px; font-size: 12.5px; font-weight: 550;
  background: transparent; border: 1px solid var(--accent); color: var(--accent);
  transition: background 0.12s;
}
.chip-btn:hover { background: var(--accent-soft); }
.chat-input-row { display: flex; gap: 8px; margin-top: 12px; }

/* Module-selection chips (Proposals). Deliberately not accent-colored by
   default, unlike .chip-btn, so the selected state (solid, vibrant fill) is
   the only thing that reads as "colored" and the difference is obvious. */
.mod-chip {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text-dim);
}
.mod-chip:hover { border-color: var(--text-faint); color: var(--text); }
.mod-chip.active {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 650;
}
.mod-chip.active:hover { background: var(--accent); filter: brightness(1.08); }

.phone-frame {
  max-width: 380px; margin: 0 auto; background: var(--bg-1);
  border: 1px solid var(--border); border-radius: 26px; overflow: hidden;
  box-shadow: var(--shadow);
}
.phone-top {
  background: #075e54; color: #fff; padding: 14px 16px; display: flex; align-items: center; gap: 11px;
}
.phone-top .pa { width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,0.2); display: grid; place-items: center; font-weight: 650; }
.phone-body { padding: 14px; height: 460px; overflow-y: auto; background: linear-gradient(180deg, #0c1016, #0a0c12); }
.phone-foot { padding: 10px 12px; border-top: 1px solid var(--border-soft); }

/* ===========================================================================
 * ACTIVITY FEED / LISTS
 * ========================================================================= */
.feed-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border-soft); }
.feed-item:last-child { border-bottom: none; }
.feed-ic { width: 34px; height: 34px; border-radius: 10px; flex: none; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.feed-ic svg { width: 16px; height: 16px; }
.feed-item .ft { font-size: 13px; }
.feed-item .ft b { font-weight: 600; }
.feed-item .fm { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }

/* Checklist (projects) */
.checklist { display: flex; flex-direction: column; gap: 2px; }
.check-item { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 8px; }
.check-item:hover { background: var(--panel-2); }
.check-box {
  width: 19px; height: 19px; border-radius: 6px; border: 1.5px solid var(--border);
  display: grid; place-items: center; flex: none; cursor: pointer; transition: all 0.12s;
}
.check-box.done { background: var(--accent); border-color: var(--accent); }
.check-box.done svg { color: #fff; width: 12px; height: 12px; }
.check-item.done .label { color: var(--text-faint); text-decoration: line-through; }
.check-item .label { font-size: 13px; }

.phase-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.phase-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.progress { height: 6px; background: var(--panel-2); border-radius: 20px; overflow: hidden; flex: 1; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 20px; transition: width 0.3s; }

/* Invoice preview */
.inv-doc {
  background: #fff; color: #1a1d26; border-radius: 12px; padding: 40px; max-width: 640px; margin: 0 auto;
}
.inv-doc h1 { font-size: 26px; letter-spacing: 2px; color: #6d5efc; }

/* Charts */
.chart-wrap { position: relative; height: 240px; }

/* Empty state */
.empty { text-align: center; padding: 60px 20px; color: var(--text-faint); }
.empty svg { width: 40px; height: 40px; margin-bottom: 12px; opacity: 0.5; }

/* Toast */
.toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 12px 16px; font-size: 13px; box-shadow: var(--shadow);
  min-width: 240px; animation: slideIn 0.2s ease;
}
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--panel-2); border: 1px solid var(--border); border-radius: 20px; transition: 0.2s; }
.switch .slider::before { content: ''; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px; background: var(--text-dim); border-radius: 50%; transition: 0.2s; }
.switch input:checked + .slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); background: #fff; }

.two-col { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; }
.three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

.spinner { width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===========================================================================
 * CRM REDESIGN: attention bar, compact metrics, next action, filter chips,
 * saved views, inline stage select, drawer tabs, global search.
 * ========================================================================= */

/* "Needs your attention" always renders first, above metrics. */
.attention-bar {
  display: flex; gap: 12px; align-items: flex-start;
  border: 1px solid rgba(240, 168, 60, 0.3); background: rgba(240, 168, 60, 0.06);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px;
}
.attention-bar .ic { color: var(--amber); flex: none; margin-top: 1px; }
.attention-bar .title { font-weight: 650; font-size: 13.5px; margin-bottom: 6px; }
.attention-bar .item {
  font-size: 13px; color: var(--text-dim); padding: 4px 0; cursor: pointer;
}
.attention-bar .item:hover { color: var(--text); }

/* Compact metrics row: a handful of numbers, not a wall of cards. */
.metrics-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px;
  background: var(--border); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 18px;
}
.metric-cell { background: var(--panel); padding: 16px 18px; }
.metric-cell .m-label { font-size: 11.5px; color: var(--text-faint); font-weight: 550; text-transform: uppercase; letter-spacing: 0.4px; }
.metric-cell .m-value { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; margin-top: 6px; }

/* Secondary insight (trend chart, source breakdown) collapsed by default. */
.insight-toggle {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600;
  color: var(--text-dim); background: none; border: none; padding: 6px 0; margin-bottom: 12px;
}
.insight-toggle:hover { color: var(--text); }
.insight-toggle svg { width: 14px; height: 14px; transition: transform 0.15s; }
.insight-toggle.open svg { transform: rotate(90deg); }
.insight-body { display: none; }
.insight-body.open { display: grid; }

/* Next action: a chip on cards, a full editable bar in the drawer. */
.next-chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 20px; background: var(--accent-soft); color: var(--accent);
  max-width: 100%;
}
.next-chip.overdue { background: rgba(226, 89, 107, 0.14); color: var(--red); }
.next-chip span.txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.next-action-bar {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--panel-2); border: 1px solid var(--border); margin-bottom: 16px;
}
.next-action-bar .ic { color: var(--accent); flex: none; }
.next-action-bar input[type="text"] {
  flex: 1; background: none; border: none; color: var(--text); font-size: 13.5px; font-weight: 550;
}
.next-action-bar input[type="text"]:focus { outline: none; }
.next-action-bar input[type="date"] {
  background: var(--bg-1); border: 1px solid var(--border); border-radius: 8px; color: var(--text-dim);
  font-size: 12px; padding: 5px 8px;
}
.next-action-bar .done-btn {
  flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: none; border: 1px solid var(--border); color: var(--text-faint);
}
.next-action-bar .done-btn:hover { background: var(--green); border-color: var(--green); color: #fff; }

.done-btn {
  flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: none; border: 1px solid var(--border); color: var(--text-faint); cursor: pointer;
}
.done-btn:hover { background: var(--green); border-color: var(--green); color: #fff; }

/* ===========================================================================
 * TASKS  (Module: Tasks)
 * ========================================================================= */
.task-group { margin-bottom: 22px; }
.task-group-head {
  display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 650;
  margin-bottom: 10px; color: var(--text-dim);
}
.task-group-head .count {
  font-size: 11px; font-weight: 650; padding: 1px 8px; border-radius: 20px;
  background: var(--panel-2); color: var(--text-faint);
}
.task-group-head.overdue { color: var(--red); }
.task-group-head.overdue .count { background: rgba(226, 89, 107, 0.14); color: var(--red); }
.task-group-head.today { color: var(--amber); }
.task-group-head.today .count { background: rgba(240, 168, 60, 0.14); color: var(--amber); }
.task-rows {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.task-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft); cursor: pointer; transition: background 0.12s;
}
.task-row:last-child { border-bottom: none; }
.task-row:hover { background: var(--panel-hover); }
.task-num {
  flex: none; width: 22px; text-align: center; font-size: 11.5px; font-weight: 650;
  color: var(--text-faint);
}
.task-row .lead-name-cell { flex: 1 1 200px; min-width: 0; }
.task-action {
  flex: 1.4 1 220px; min-width: 0; display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--text-dim);
}
.task-action svg { flex: none; width: 14px; height: 14px; color: var(--accent); }
.task-action span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-date { flex: none; font-size: 11.5px; font-weight: 650; min-width: 78px; text-align: right; }
.task-date.overdue { color: var(--red); }
.task-date.today { color: var(--amber); }
.task-date.upcoming { color: var(--text-faint); font-weight: 550; }
.task-date.faint { color: var(--text-faint); font-weight: 550; }

/* Active filter chips, shown so current filter state is never hidden. */
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 14px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 550;
  padding: 5px 8px 5px 12px; border-radius: 20px; background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text-dim);
}
.filter-chip button { display: grid; place-items: center; color: var(--text-faint); }
.filter-chip button:hover { color: var(--red); }
.filter-chip button svg { width: 13px; height: 13px; }

/* Saved view presets. */
.view-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.view-tab {
  font-size: 12.5px; font-weight: 600; padding: 7px 13px; border-radius: 9px;
  background: none; border: 1px solid var(--border); color: var(--text-dim);
}
.view-tab:hover { color: var(--text); }
.view-tab.active { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* Inline stage select, styled to sit inline like a pill but act as a real dropdown. */
select.stage-select {
  appearance: none; -webkit-appearance: none; border: none; border-radius: 20px;
  font-size: 12px; font-weight: 650; padding: 5px 24px 5px 12px; cursor: pointer;
  background-repeat: no-repeat; background-position: right 8px center; background-size: 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7488' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}
select.stage-select:focus { outline: 2px solid var(--accent-soft); }

/* Sticky kanban column headers. */
.kanban-col-head.sticky { position: sticky; top: 0; z-index: 2; }
.lost-toggle {
  font-size: 12px; color: var(--text-faint); background: none; border: 1px dashed var(--border);
  border-radius: var(--radius-sm); padding: 10px; text-align: center; cursor: pointer; flex: none;
  width: 240px;
}
.lost-toggle:hover { color: var(--text-dim); border-color: var(--text-faint); }

/* Quick inline stage-move control on a kanban card, alternative to drag. */
.kcard .move-btn {
  flex: none; width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center;
  color: var(--text-faint); background: none; border: none;
}
.kcard .move-btn:hover { color: var(--accent); background: var(--accent-soft); }
.kcard select.stage-select-invisible {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}

/* Drawer section tabs: overview / activity / messages / deal. */
.drawer-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-soft); margin: 4px 0 18px; }
.drawer-tab {
  font-size: 12.5px; font-weight: 600; color: var(--text-faint); background: none; border: none;
  padding: 9px 4px; margin-right: 18px; border-bottom: 2px solid transparent; position: relative; top: 1px;
}
.drawer-tab:hover { color: var(--text-dim); }
.drawer-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.unread-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--red); margin-left: 2px; }
.drawer-pane { display: none; }
.drawer-pane.active { display: block; }

/* Global search, topbar. */
.gsearch { position: relative; width: 320px; max-width: 40vw; }
.gsearch input {
  width: 100%; background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px 9px 36px; color: var(--text); font-size: 13px;
}
.gsearch input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.gsearch svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-faint); }
.gsearch-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow);
  max-height: 340px; overflow-y: auto; z-index: 60; display: none;
}
.gsearch-results.open { display: block; }
.gsearch-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; }
.gsearch-row:hover { background: var(--panel-hover); }
.gsearch-row .who b { display: block; font-size: 13px; }
.gsearch-row .who small { color: var(--text-faint); font-size: 11.5px; }
.gsearch-empty { padding: 16px 12px; color: var(--text-faint); font-size: 12.5px; text-align: center; }

/* Sortable table headers. */
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--text); }
table.data th.sortable .sort-ic { display: inline-block; margin-left: 4px; opacity: 0.5; }
table.data th.sortable.active .sort-ic { opacity: 1; color: var(--accent); }

/* ===========================================================================
 * RESPONSIVE
 * ========================================================================= */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .three-col { grid-template-columns: 1fr; }
  .metrics-row { grid-template-columns: repeat(2, 1fr); }
  .gsearch { width: 220px; }
}
@media (max-width: 820px) {
  .sidebar { width: 260px; box-shadow: var(--shadow); }
  .view { padding: 18px 16px 80px; }
  .topbar { padding: 14px 16px; }
  .detail-grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .drawer { width: 100%; }
  .kpi .k-value { font-size: 24px; }
  /* Hidden, not shrunk: at this width the search box was compressing the
     hamburger's clickable area down until taps missed it. The hamburger is
     more important than the search box at phone/landscape widths. */
  .gsearch { display: none; }
  .lost-toggle { width: 100%; }
  .task-row { flex-wrap: wrap; row-gap: 8px; }
  .task-row .lead-name-cell { flex-basis: 100%; }
  .task-date { text-align: left; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .kpi { padding: 14px; }
  .metrics-row { grid-template-columns: 1fr 1fr; }
}

/* Scrim behind mobile sidebar */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 39; display: none; }
.scrim.open { display: block; }
@media (min-width: 821px) { .scrim { display: none !important; } }
