/* WeChat CRM Bridge — Design system v3 (brand refresh)
   Tokens here are the source of truth; DomainFactory pages mirror them
   via docs/brand-kit.md.
*/

:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #475569;
  --text-faint: #94a3b8;

  /* Brand palette --- distinctive, trustworthy, slightly warm.
     Primary indigo communicates premium SaaS; coral accent nods to the
     China-EU bridge without being kitschy; teal trust signals reliability. */
  --primary: #4338ca;
  --primary-hover: #3730a3;
  --primary-soft: #eef2ff;
  --accent: #fb7185;
  --accent-hover: #f43f5e;
  --accent-soft: #ffe4e6;
  --trust: #0d9488;
  --trust-soft: #ccfbf1;

  --success: #15803d;
  --success-soft: #dcfce7;
  --warning: #b45309;
  --warning-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --info: #0369a1;
  --info-soft: #e0f2fe;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --sidebar-w: 244px;
  --topbar-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sidebar {
  background: #0f172a;
  color: #e2e8f0;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 18px 8px;
  border-bottom: 1px solid #1e293b;
  margin-bottom: 12px;
}
.sidebar-brand .logo-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(67, 56, 202, 0.18), rgba(251, 113, 133, 0.18));
  border: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}
.sidebar-brand .logo-mark svg { width: 100%; height: 100%; display: block; }
.sidebar-brand .name { font-weight: 700; font-size: 14px; color: #f8fafc; letter-spacing: -0.005em; }
.sidebar-brand .sub  { font-size: 11px; color: #94a3b8; margin-top: 2px; }

.brand-footer {
  margin-top: auto;
  padding: 14px 8px 4px 8px;
  border-top: 1px solid #1e293b;
  font-size: 11px;
  line-height: 1.55;
  color: #64748b;
}
.brand-footer .trust {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-right: 8px;
  color: #cbd5e1;
}
.brand-footer .trust::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--trust);
  display: inline-block;
}

.nav-section { margin-top: 6px; }
.nav-section .title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 10px 8px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: #cbd5e1;
  cursor: pointer;
  font-size: 13px;
  user-select: none;
}
.nav-item:hover { background: #1e293b; color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #475569;
}
.nav-item.active .dot { background: #fff; }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 10;
}
.topbar .search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 7px 12px;
  width: 320px;
  max-width: 40vw;
}
.topbar .search input {
  border: 0;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 13px;
  color: var(--text);
}
.topbar .actions { display: flex; align-items: center; gap: 10px; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px 4px 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 12px;
  color: var(--text-muted);
}
.user-chip .avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #22d3ee);
  color: white; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
}

.content {
  padding: 22px 24px 64px;
  max-width: 1320px;
  width: 100%;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title h1 {
  margin: 0 0 4px 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.page-title p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}
.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.page-actions .btn-sm {
  font-size: 12px;
  padding: 6px 12px;
}

/* ===== Cards & sections ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px;
}
.card + .card { margin-top: 16px; }
.card h3 { margin: 0 0 12px 0; font-size: 14px; font-weight: 600; }
.card .subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin: -6px 0 12px 0;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px)  { .grid-2, .grid-4 { grid-template-columns: 1fr; } }

/* ===== KPI cards ===== */
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.kpi .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.kpi .value {
  font-size: 24px;
  font-weight: 700;
  margin: 6px 0 4px;
  letter-spacing: -0.01em;
}
.kpi .delta {
  font-size: 11px;
  color: var(--success);
}
.kpi .delta.neg { color: var(--danger); }
.kpi .delta.neutral { color: var(--text-muted); }

/* ===== Skeleton loaders ===== */
@keyframes wcb-skeleton-shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}
.skeleton {
  display: inline-block;
  background: linear-gradient(90deg, #eef2f7 0%, #f8fafc 50%, #eef2f7 100%);
  background-size: 200px 100%;
  background-repeat: no-repeat;
  border-radius: 6px;
  color: transparent;
  animation: wcb-skeleton-shimmer 1.25s ease-in-out infinite;
  user-select: none;
  pointer-events: none;
}
.skeleton.h-kpi { width: 64px; height: 28px; }
.skeleton.h-line { display: block; width: 100%; height: 12px; margin: 4px 0; border-radius: 4px; }
.skeleton.h-pill { width: 84px; height: 18px; border-radius: 999px; }
.skeleton.h-btn { width: 100px; height: 28px; border-radius: 8px; }
tr.skeleton-row td { padding-top: 12px; padding-bottom: 12px; }
tr.skeleton-row .skeleton { width: 60%; }

/* ===== Onboarding sidebar widget ===== */
.onboarding {
  margin: 14px 8px 0;
  padding: 12px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  color: #cbd5e1;
}
.onboarding__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.onboarding__title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  font-weight: 700;
}
.onboarding__progress {
  font-size: 11px;
  color: #4338ca;
  background: #eef2ff;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
}
.onboarding__bar {
  height: 4px;
  background: #0f172a;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 10px;
}
.onboarding__bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #4338ca, #fb7185);
  transition: width 0.3s ease;
}
.onboarding__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.onboarding__item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  line-height: 1.3;
}
.onboarding__check {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #0f172a;
  border: 1px solid #475569;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: transparent;
}
.onboarding__item.done .onboarding__check {
  background: #4338ca;
  border-color: #4338ca;
  color: #fff;
}
.onboarding__item.skipped .onboarding__check {
  background: #334155;
  border-color: #475569;
  color: #94a3b8;
}
.onboarding__item.done .onboarding__label,
.onboarding__item.skipped .onboarding__label {
  text-decoration: line-through;
  color: #64748b;
}
.onboarding__label {
  flex: 1;
  color: #e2e8f0;
}
.onboarding__action {
  font-size: 10.5px;
  color: #94a3b8;
  background: transparent;
  border: 0;
  padding: 2px 4px;
  cursor: pointer;
  text-decoration: underline;
}
.onboarding__action:hover { color: #cbd5e1; }
.onboarding__hint {
  margin-top: 10px;
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.4;
}

/* ===== Welcome empty-state (rich) ===== */
.welcome-empty {
  text-align: center;
  padding: 36px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-top: 12px;
}
.welcome-empty .mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  display: block;
}
.welcome-empty h2 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.welcome-empty p {
  margin: 0 auto 18px;
  max-width: 520px;
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.55;
}
.welcome-empty .btn-row {
  justify-content: center;
  flex-wrap: wrap;
}

/* ===== Forms ===== */
.form-row { margin-bottom: 10px; }
label.field-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
input, textarea, select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--primary);
  color: white;
  transition: background-color 0.15s, transform 0.05s;
  font-family: inherit;
}
button:hover, .btn:hover { background: var(--primary-hover); }
button:active, .btn:active { transform: translateY(1px); }
button[disabled] { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--surface-2); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
table.data th, table.data td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
table.data thead th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.muted { color: var(--text-muted); }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}
.badge.ok      { background: var(--success-soft); color: #166534; border-color: #bbf7d0; }
.badge.warn    { background: var(--warning-soft); color: #92400e; border-color: #fde68a; }
.badge.err     { background: var(--danger-soft);  color: #991b1b; border-color: #fecaca; }
.badge.off     { background: #eef2f7; color: #64748b; border-color: #e2e8f0; }
.badge.info    { background: var(--info-soft);    color: #075985; border-color: #bae6fd; }
.badge.primary { background: var(--primary-soft); color: #3730a3; border-color: #c7d2fe; }

/* ===== Filter bar ===== */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.filter-bar input,
.filter-bar select {
  width: auto;
  min-width: 140px;
}

/* ===== Empty state ===== */
.empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
}
.empty h4 { margin: 8px 0 4px; color: var(--text); font-weight: 600; }
.empty p  { margin: 0; font-size: 13px; }
.empty .emoji { font-size: 28px; }

/* ===== Toasts ===== */
.toast-host {
  position: fixed;
  right: 22px;
  bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 260px;
  max-width: 380px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: toast-in 0.18s ease-out;
}
.toast .icon { font-size: 16px; line-height: 1.1; }
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--info); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Tier 2: status pill + activity + lead drawer ===== */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
  box-shadow: 0 0 0 0 currentColor;
}
.status-pill.ok {
  background: var(--success-soft);
  color: #166534;
  border-color: #bbf7d0;
}
.status-pill.ok::before {
  background: #16a34a;
  animation: status-pulse 2.4s ease-out infinite;
}
.status-pill.warn {
  background: var(--warning-soft);
  color: #92400e;
  border-color: #fde68a;
}
.status-pill.warn::before {
  background: #d97706;
}
@keyframes status-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.55); }
  70%  { box-shadow: 0 0 0 6px rgba(22, 163, 74, 0);    }
  100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0);      }
}

.activity-wrap { position: relative; }
.activity-btn { font-size: 16px; line-height: 1; padding: 6px 8px; }
.activity-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  width: min(360px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 900;
  max-height: 320px;
  display: flex;
  flex-direction: column;
}
.activity-popover.hidden { display: none !important; }
.activity-popover__head {
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.activity-popover__body {
  overflow-y: auto;
  padding: 6px 0;
}
.activity-item {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}
.activity-item:last-child { border-bottom: 0; }
.activity-item .t { font-weight: 600; color: var(--text); margin-bottom: 2px; }
.activity-item .s { color: var(--text-muted); line-height: 1.35; }
.activity-item .d { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

#lead_rows tr.lead-row { cursor: pointer; }
#lead_rows tr.lead-row:hover { background: var(--surface-2); }

.lead-drawer {
  position: fixed;
  inset: 0;
  z-index: 950;
  pointer-events: none;
}
.lead-drawer:not(.hidden) { pointer-events: auto; }
.lead-drawer.hidden { display: none !important; }
.lead-drawer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.lead-drawer:not(.hidden) .lead-drawer__backdrop { opacity: 1; }
.lead-drawer__panel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(440px, 100%);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 40px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.22s ease;
}
.lead-drawer:not(.hidden) .lead-drawer__panel { transform: translateX(0); }
.lead-drawer__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.lead-drawer__head h2 { margin: 0; font-size: 17px; font-weight: 700; }
.lead-drawer__sub { margin-top: 4px; }
.lead-drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px 18px;
  font-size: 13px;
}
.lead-drawer__foot {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.lead-timeline { list-style: none; margin: 0; padding: 0; }
.lead-timeline li {
  position: relative;
  padding-left: 18px;
  padding-bottom: 14px;
  border-left: 2px solid var(--border);
  margin-left: 6px;
}
.lead-timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.lead-timeline li::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface);
}
.lead-timeline .ev-title { font-weight: 600; color: var(--text); }
.lead-timeline .ev-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.lead-timeline .ev-detail { font-size: 12px; color: var(--text-muted); margin-top: 4px; line-height: 1.45; }

/* ===== Tier 3: Kanban / pipeline ===== */
.kanban {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  gap: 12px;
  overflow-x: auto;
}
@media (max-width: 1100px) {
  .kanban { grid-template-columns: repeat(5, 240px); }
}
.kanban__col {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-height: 320px;
  display: flex;
  flex-direction: column;
}
.kanban__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.kanban__count {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
}
.kanban__body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.kanban__empty {
  padding: 20px 6px;
  text-align: center;
}
.kanban__card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.05s ease;
}
.kanban__card:hover { box-shadow: var(--shadow-sm); }
.kanban__card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.kanban__card-title { font-weight: 600; font-size: 13px; }
.kanban__stage {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.kanban__card-sub { margin-top: 2px; }
.kanban__card-msg {
  font-size: 12px;
  color: var(--text-muted);
  margin: 6px 0 4px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.kanban__card-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.kanban__card-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.kanban__handle {
  flex: 0 0 auto;
  cursor: grab;
  user-select: none;
  font-size: 12px;
  line-height: 1.2;
  letter-spacing: -1px;
  color: var(--text-muted);
  padding: 4px 2px;
  border-radius: 6px;
  border: 1px solid transparent;
}
.kanban__handle:hover {
  color: var(--text);
  border-color: var(--border);
  background: var(--surface-2);
}
.kanban__handle:active {
  cursor: grabbing;
}
.kanban__card-main {
  flex: 1;
  min-width: 0;
}
.kanban__card--dragging {
  opacity: 0.55;
}
.kanban__body--drop-hover {
  box-shadow: inset 0 0 0 2px var(--primary);
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
}

/* ===== Reporting (KPI page) ===== */
.reporting-root .kpi {
  min-height: 88px;
}
.reporting-overview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.report-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.report-bar-track {
  flex: 1;
  height: 10px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.report-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--trust));
  border-radius: 999px;
  transition: width 0.25s ease;
  min-width: 0;
}
.report-daily-chart {
  display: flex;
  align-items: flex-end;
  justify-content: stretch;
  gap: 4px;
  min-height: 120px;
  padding: 8px 0 4px;
  border-bottom: 1px solid var(--border);
}
.report-daily-cell {
  flex: 1;
  min-width: 0;
  max-width: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 120px;
}
.report-daily-bar {
  width: 100%;
  min-height: 2px;
  background: var(--primary);
  border-radius: 4px 4px 0 0;
  opacity: 0.85;
}
.report-daily-label {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 4px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ===== Tier 4: Investor mode, help drawer, status, print ===== */
body.investor-mode #investorModeBtn {
  background: var(--warning-soft);
  color: #92400e;
  border: 1px solid #fde68a;
}
body.investor-mode .ai-actions button,
body.investor-mode [data-act="sync"],
body.investor-mode #createLeadBtn,
body.investor-mode #createFollowupBtn,
body.investor-mode #csvCommitBtn {
  opacity: 0.55;
  pointer-events: none;
}
.investor-banner {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 980;
  background: var(--warning-soft);
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 999px;
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-md);
  font-size: 12.5px;
  font-weight: 600;
}
.investor-banner.hidden { display: none !important; }

.help-fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  z-index: 940;
}
.help-fab:hover { background: var(--primary-hover); }

.help-drawer {
  position: fixed;
  inset: 0;
  z-index: 960;
  pointer-events: none;
}
.help-drawer:not(.hidden) { pointer-events: auto; }
.help-drawer.hidden { display: none !important; }
.help-drawer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
}
.help-drawer__panel {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: min(420px, 100%);
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 40px rgba(15, 23, 42, 0.12);
}
.help-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.help-drawer__head h2 { margin: 0; font-size: 16px; }
.help-drawer__body {
  padding: 14px 18px;
  overflow-y: auto;
}
.help-video {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  margin: 12px 0;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.help-video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.help-video p { padding: 16px; }
.help-links {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}
.help-links a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  text-decoration: none;
  color: var(--text);
}
.help-links a:hover { background: var(--primary-soft); border-color: #c7d2fe; }

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.status-overall .status-pill { font-size: 13px; }

@media print {
  body.print-reporting .sidebar,
  body.print-reporting .topbar,
  body.print-reporting #investorBanner,
  body.print-reporting #helpFab,
  body.print-reporting #activityPopover,
  body.print-reporting .toast-host,
  body.print-reporting #onboardingWidget,
  body.print-reporting .page-header .btn-row,
  body.print-reporting .nav-item,
  body.print-reporting .lead-drawer,
  body.print-reporting .help-drawer {
    display: none !important;
  }
  body.print-reporting .app { grid-template-columns: 1fr !important; }
  body.print-reporting .main { width: 100% !important; }
  body.print-reporting .page { display: none !important; }
  body.print-reporting .page[data-page="reporting"] { display: block !important; }
  body.print-reporting .reporting-root .card { break-inside: avoid; box-shadow: none; }
  body.print-reporting .report-daily-cell { height: 80px; }
  body.print-reporting { background: #fff !important; }
}

/* ===== Small utilities ===== */
.small { font-size: 12px; color: var(--text-muted); }
.mono  { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.flex  { display: flex; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.between { justify-content: space-between; }
.align-center { align-items: center; }
.hidden { display: none !important; }
.page { display: none; }
.page.active { display: block; }

/* ===== Sidebar on small screens ===== */
@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 100;
  }
  .sidebar.open { transform: translateX(0); }
  .topbar .menu-btn { display: inline-flex !important; }
}
.topbar .menu-btn { display: none; }
