:root {
  --sidebar-bg: #0f1b2d;
  --sidebar-width: 258px;
  --accent: #0e7c66;
  --accent-soft: rgba(14, 124, 102, 0.12);
  --content-bg: #f4f6f9;
  --card-border: #e7ebf0;
  --text-muted-2: #8b96a5;
}

html, body {
  height: 100%;
}

body {
  background: var(--content-bg);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 0.925rem;
  color: #24303f;
}

/* ── Shell ─────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: #cdd6e0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: margin-left 0.2s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1.1rem 1.25rem;
  color: #fff;
  text-decoration: none;
  font-size: 1.15rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 1.05rem;
}

.brand-text strong {
  font-weight: 700;
}

.side-nav {
  padding: 0.75rem 0.75rem 2rem;
}

.nav-section {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #64748e;
  padding: 1.05rem 0.6rem 0.35rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.52rem 0.65rem;
  margin-bottom: 2px;
  border-radius: 8px;
  color: #cdd6e0;
  text-decoration: none;
  font-size: 0.9rem;
}

.nav-item i {
  font-size: 1rem;
  width: 1.15rem;
  text-align: center;
  color: #7f8da1;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.nav-item.active {
  background: var(--accent);
  color: #fff;
}

.nav-item.active i {
  color: #fff;
}

.nav-item.disabled {
  color: #5c6b81;
  cursor: default;
}

.nav-item.disabled:hover {
  background: none;
}

.soon {
  margin-left: auto;
  font-size: 0.62rem;
  background: rgba(255, 255, 255, 0.08);
  color: #8b98ab;
  border-radius: 20px;
  padding: 0.1rem 0.5rem;
}

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

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 1.4rem;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.topbar-title {
  font-weight: 600;
  font-size: 1.02rem;
}

.sidebar-toggle {
  color: #44505f;
  font-size: 1.3rem;
  padding: 0 0.25rem;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid var(--card-border);
  border-radius: 40px;
  padding: 0.25rem 0.8rem 0.25rem 0.3rem;
  background: #fff;
  font-size: 0.88rem;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
}

.content {
  padding: 1.5rem 1.6rem 3rem;
  max-width: 1500px;
  width: 100%;
}

/* ── Components ────────────────────────────────────── */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.15rem;
}

.page-header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0;
}

.page-header .subtitle {
  color: var(--text-muted-2);
  font-size: 0.85rem;
  margin-top: 0.15rem;
}

.card {
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--card-border);
  font-weight: 600;
}

.kpi-card {
  display: flex;
  align-items: center;
  gap: 0.95rem;
  padding: 1.05rem 1.15rem;
}

.kpi-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 11px;
  font-size: 1.25rem;
}

.kpi-value {
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.1;
}

.kpi-label {
  color: var(--text-muted-2);
  font-size: 0.8rem;
}

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-accent:hover {
  background: #0b6653;
  border-color: #0b6653;
  color: #fff;
}

.table thead th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted-2);
  border-bottom-width: 1px;
  white-space: nowrap;
}

.table td {
  vertical-align: middle;
}

.badge-status {
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.72rem;
  padding: 0.32rem 0.65rem;
}

.badge-active {
  background: #e7f6ef;
  color: #14804a;
}

.badge-inactive {
  background: #fdeceb;
  color: #b42318;
}

.badge-neutral {
  background: #eef2f6;
  color: #475467;
}

.module-card .form-check {
  margin-bottom: 0.3rem;
}

pre.json-view {
  background: #0f1b2d;
  color: #d3e0ee;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.78rem;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Login ─────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f1b2d 0%, #10382f 100%);
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px;
  padding: 2.3rem 2.2rem;
  box-shadow: 0 20px 60px rgba(4, 12, 24, 0.45);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 1.6rem;
  font-size: 1.3rem;
  color: #101828;
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 991.98px) {
  .sidebar {
    position: fixed;
    z-index: 1040;
    margin-left: calc(var(--sidebar-width) * -1);
    box-shadow: none;
  }

  .sidebar.open {
    margin-left: 0;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.35);
  }
}

@media (min-width: 992px) {
  .sidebar-toggle {
    display: none;
  }
}

/* ===================== Phase 2 — Customer 360 & Leads ===================== */

/* Profile header */
.profile-avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 56px; height: 56px; border-radius: 16px;
    background: linear-gradient(135deg, var(--brand, #0f766e), #134e4a);
    color: #fff; font-weight: 700; font-size: 1.25rem; text-transform: uppercase;
    flex-shrink: 0;
}
.profile-avatar.sm { width: 40px; height: 40px; font-size: .95rem; border-radius: 12px; }
.profile-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; }
.profile-tabs .nav-link { white-space: nowrap; }

/* Info lists */
.info-list dt { color: #64748b; font-weight: 500; }
.info-list dd { margin-bottom: .5rem; }
.text-pre-wrap { white-space: pre-wrap; }
.contact-list li { padding: .35rem 0; border-bottom: 1px dashed #e2e8f0; }
.contact-list li:last-child { border-bottom: 0; }
.contact-list li i { width: 1.4rem; display: inline-block; }

/* Timeline */
.timeline { position: relative; padding-left: .25rem; }
.timeline-item {
    position: relative; display: flex; gap: .85rem;
    padding: .65rem 0 .65rem 0;
}
.timeline-item:not(:last-child)::before {
    content: ""; position: absolute; left: 15px; top: 42px; bottom: -10px;
    width: 2px; background: #e2e8f0;
}
.timeline-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 50%;
    background: #f1f5f9; color: #475569; flex-shrink: 0; z-index: 1;
    border: 1px solid #e2e8f0;
}
.timeline-item.important .timeline-icon { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.timeline-title { font-weight: 600; font-size: .9rem; }
.timeline-detail { font-size: .85rem; color: #475569; white-space: pre-wrap; margin-top: .1rem; }
.timeline-meta { font-size: .75rem; color: #94a3b8; margin-top: .15rem; }

/* Tags */
.tag-chip {
    display: inline-flex; align-items: center;
    padding: .2rem .6rem; border-radius: 999px;
    font-size: .75rem; font-weight: 600;
    color: var(--tag-color, #64748b);
    background: color-mix(in srgb, var(--tag-color, #64748b) 12%, #fff);
    border: 1px solid color-mix(in srgb, var(--tag-color, #64748b) 35%, #fff);
}
.tag-checkbox { cursor: pointer; }
.tag-checkbox input { display: none; }
.tag-checkbox input:not(:checked) + .tag-chip { opacity: .4; filter: grayscale(.6); }

/* Lead status chips */
.status-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.status-chip {
    border: 1px solid #e2e8f0; background: #fff; border-radius: 999px;
    padding: .25rem .75rem; font-size: .8rem; font-weight: 500; color: #475569;
    transition: all .15s ease;
}
.status-chip span { color: #94a3b8; margin-left: .25rem; font-weight: 600; }
.status-chip:hover { border-color: var(--brand, #0f766e); color: var(--brand, #0f766e); }
.status-chip.active {
    background: var(--brand, #0f766e); border-color: var(--brand, #0f766e); color: #fff;
}
.status-chip.active span { color: rgba(255, 255, 255, .8); }

/* Empty states */
.empty-state {
    text-align: center; padding: 2.5rem 1rem; color: #64748b;
}
.empty-state i { font-size: 2.2rem; color: #cbd5e1; display: block; margin-bottom: .5rem; }
.empty-state p { margin-bottom: .75rem; }

/* Relation cards */
.relation-card { border: 1px solid #e2e8f0; box-shadow: none; }
.relation-card:hover { border-color: var(--brand, #0f766e); }

/* Merge table */
.merge-table th, .merge-table td { vertical-align: top; }

/* Global search (topbar) */
.global-search { position: relative; width: 320px; max-width: 40vw; }
.global-search > i {
    position: absolute; left: .65rem; top: 50%; transform: translateY(-50%);
    color: #94a3b8; pointer-events: none; font-size: .85rem;
}
.global-search input { padding-left: 2rem; border-radius: 999px; background: #f8fafc; }
.global-search input:focus { background: #fff; }
.global-search-results {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 1050;
    background: #fff; border: 1px solid #e2e8f0; border-radius: .75rem;
    box-shadow: 0 12px 32px rgba(15, 23, 42, .12);
    max-height: 420px; overflow-y: auto; padding: .35rem;
}
.gs-section {
    font-size: .7rem; text-transform: uppercase; letter-spacing: .04em;
    color: #94a3b8; font-weight: 700; padding: .45rem .6rem .2rem;
}
.gs-item {
    display: flex; align-items: center; gap: .6rem;
    padding: .45rem .6rem; border-radius: .5rem; text-decoration: none; color: inherit;
}
.gs-item:hover, .gs-item.focus { background: #f1f5f9; }
.gs-item .gs-title { font-weight: 600; font-size: .85rem; }
.gs-item .gs-sub { font-size: .75rem; color: #94a3b8; }
.gs-empty { padding: .75rem; text-align: center; color: #94a3b8; font-size: .85rem; }

@media (max-width: 575.98px) {
    .global-search { display: none; }
}

/* ===================== Phase 3 — Kanban, follow-ups, notifications ===================== */

/* Kanban board */
.kanban-board {
    display: flex; gap: .75rem; overflow-x: auto; padding-bottom: 1rem;
    align-items: flex-start; scrollbar-width: thin;
}
.kanban-column {
    flex: 0 0 280px; max-width: 280px;
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: .75rem;
}
.kanban-col-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: .6rem .75rem; border-bottom: 3px solid var(--stage-color, #cbd5e1);
}
.kanban-col-title { font-weight: 700; font-size: .85rem; }
.kanban-col-meta { font-size: .72rem; color: #94a3b8; }
.kanban-cards { min-height: 60px; padding: .5rem; display: flex; flex-direction: column; gap: .5rem; max-height: calc(100vh - 320px); overflow-y: auto; }
.kanban-card {
    background: #fff; border: 1px solid #e2e8f0; border-radius: .6rem;
    padding: .55rem .65rem; cursor: grab; box-shadow: 0 1px 2px rgba(15, 23, 42, .05);
}
.kanban-card:active { cursor: grabbing; }
.kanban-card:hover { border-color: var(--brand, #0f766e); }
.kanban-card-customer { font-size: .85rem; font-weight: 600; margin-top: .1rem; }
.kanban-card-assignee { font-size: .72rem; color: #94a3b8; margin-top: .25rem; }
.kanban-ghost { opacity: .4; border-style: dashed; }

/* Bell */
.bell-btn { color: #475569; padding: .35rem .5rem; }
.bell-btn:hover { color: var(--brand, #0f766e); }
.bell-badge {
    position: absolute; top: 0; right: 0;
    background: #dc2626; color: #fff; border-radius: 999px;
    font-size: .62rem; font-weight: 700; padding: .1rem .32rem; line-height: 1;
}
.notif-dropdown { width: 360px; max-width: 90vw; }
.notif-items { max-height: 380px; overflow-y: auto; }
.notif-item {
    display: flex; gap: .6rem; padding: .55rem .75rem;
    border-bottom: 1px solid #f1f5f9; text-decoration: none; color: inherit;
}
.notif-item:hover { background: #f8fafc; }
.notif-item .notif-title { font-size: .82rem; font-weight: 600; }
.notif-item .notif-body { font-size: .75rem; color: #64748b; }
.notif-item .notif-time { font-size: .7rem; color: #94a3b8; }
.notif-unread { background: #f0fdfa; }
.notif-item.unread { background: #f0fdfa; }

/* Toasts */
.toast-stack { position: fixed; bottom: 1rem; right: 1rem; z-index: 1080; display: flex; flex-direction: column; gap: .5rem; }
