:root {
  --sidebar-w: 260px;
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --surface: #ffffff;
  --canvas: #f1f5f9;
  --accent: #0f766e;
  --accent-soft: #ccfbf1;
  --accent-hover: #0d9488;
  --danger: #b91c1c;
  --warning: #b45309;
  --success: #15803d;
  --info: #1d4ed8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 8px 24px rgba(15, 23, 42, 0.04);
  --font: "Plus Jakarta Sans", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #0b1220 0%, #111827 100%);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  border-right: 1px solid rgba(255,255,255,0.06);
}
.sidebar-brand {
  padding: 1.35rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-brand .mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  font-size: .9rem;
  margin-right: .75rem;
}
.sidebar-brand strong { display: block; font-size: 1rem; color: #fff; letter-spacing: -.01em; }
.sidebar-brand span { font-size: .75rem; color: #94a3b8; }

.sidebar-nav { padding: 1rem .75rem; overflow-y: auto; flex: 1; }
.nav-section {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #64748b;
  margin: .85rem .65rem .4rem;
  font-weight: 600;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .65rem .75rem;
  border-radius: 10px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: .9rem;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav-link.active { background: rgba(13, 148, 136, 0.18); color: #5eead4; }
.nav-link svg { width: 18px; height: 18px; opacity: .9; flex-shrink: 0; }

.sidebar-footer {
  padding: 1rem 1.1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #1e293b;
  color: #5eead4;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: .85rem;
}
.user-chip .meta { min-width: 0; }
.user-chip .meta strong { display: block; font-size: .85rem; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .meta span { font-size: .72rem; color: #94a3b8; text-transform: capitalize; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: .85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-title { font-size: 1.05rem; font-weight: 700; letter-spacing: -.02em; }
.topbar-sub { color: var(--muted); font-size: .82rem; }
.content { padding: 1.5rem; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.page-header h1 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: -.03em;
  font-weight: 750;
}
.page-header p { margin: .25rem 0 0; color: var(--muted); font-size: .92rem; }
.page-actions { display: flex; gap: .6rem; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: .55rem 1rem;
  font-weight: 600;
  font-size: .875rem;
  text-decoration: none;
  cursor: pointer;
  transition: .15s ease;
  font-family: inherit;
  line-height: 1.2;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-secondary:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-danger { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; border-radius: 8px; }
.btn-block { width: 100%; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow);
}
.stat-card .label { color: var(--muted); font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-card .value { font-size: 1.75rem; font-weight: 750; letter-spacing: -.03em; margin-top: .35rem; }
.stat-card .hint { color: var(--muted); font-size: .78rem; margin-top: .35rem; }
.stat-card.accent { background: linear-gradient(135deg, #0f766e, #134e4a); color: #fff; border: none; }
.stat-card.accent .label, .stat-card.accent .hint { color: rgba(255,255,255,.75); }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--line);
}
.panel-header h2 { margin: 0; font-size: 1rem; font-weight: 700; }
.panel-body { padding: 1.15rem; }
.panel-body.flush { padding: 0; }

.filter-bar {
  display: grid;
  grid-template-columns: 1.4fr repeat(4, minmax(0, 1fr)) auto;
  gap: .65rem;
  padding: 1rem 1.15rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}
.filter-bar.compact { grid-template-columns: 1.6fr repeat(3, minmax(0, 1fr)) auto; }

.form-label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: .35rem;
}
.form-control, .form-select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .55rem .75rem;
  font: inherit;
  font-size: .875rem;
  background: #fff;
  color: var(--ink);
}
.form-control:focus, .form-select:focus {
  outline: none;
  border-color: #5eead4;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.form-stack > * + * { margin-top: .85rem; }

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
table.data th {
  text-align: left;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  font-weight: 700;
  padding: .85rem 1.15rem;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  white-space: nowrap;
}
table.data td {
  padding: .95rem 1.15rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #f8fafc; }
.lead-cell strong { display: block; font-weight: 650; }
.lead-cell span { color: var(--muted); font-size: .78rem; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: .2rem .55rem;
  font-size: .72rem;
  font-weight: 700;
  background: #e2e8f0;
  color: #334155;
  white-space: nowrap;
}
.badge-new, .badge-assigned { background: #e0f2fe; color: #075985; }
.badge-contacted, .badge-responded { background: #ede9fe; color: #5b21b6; }
.badge-interested, .badge-qualified, .badge-converted { background: #dcfce7; color: #166534; }
.badge-follow-up { background: #ffedd5; color: #9a3412; }
.badge-not-interested, .badge-lost, .badge-closed, .badge-no-response { background: #fee2e2; color: #991b1b; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #ffedd5; color: #9a3412; }
.badge-muted { background: #e2e8f0; color: #475569; }

.alert {
  border-radius: 12px;
  padding: .85rem 1rem;
  margin-bottom: 1rem;
  font-size: .9rem;
  border: 1px solid transparent;
}
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-danger { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

.empty {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--muted);
}
.empty strong { display: block; color: var(--ink); margin-bottom: .35rem; }

.grid-2 { display: grid; grid-template-columns: 1.7fr 1fr; gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.stack > * + * { margin-top: 1rem; }

.timeline { position: relative; padding-left: 1.25rem; }
.timeline::before {
  content: "";
  position: absolute;
  left: .35rem;
  top: .2rem;
  bottom: .2rem;
  width: 2px;
  background: var(--line);
}
.timeline-item { position: relative; padding-bottom: 1.1rem; }
.timeline-item::before {
  content: "";
  position: absolute;
  left: -1.05rem;
  top: .35rem;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--accent);
}
.timeline-item .when { color: var(--muted); font-size: .75rem; }
.timeline-item .what { font-weight: 650; margin-top: .15rem; }
.timeline-item .who { color: var(--muted); font-size: .8rem; margin-top: .15rem; }

.kv { display: grid; grid-template-columns: 120px 1fr; gap: .35rem .75rem; font-size: .875rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 550; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.18), transparent 28%),
    linear-gradient(160deg, #0b1220 0%, #102a2a 45%, #0f172a 100%);
  padding: 1.5rem;
}
.login-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 18px;
  padding: 2rem;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.login-card h1 { margin: 0 0 .35rem; font-size: 1.55rem; letter-spacing: -.03em; }
.login-card p { color: var(--muted); margin: 0 0 1.5rem; }

.pagination { display: flex; gap: .35rem; flex-wrap: wrap; padding: 1rem 1.15rem; }
.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 .6rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  text-decoration: none;
  font-size: .82rem;
  color: var(--ink-soft);
}
.pagination .active span { background: var(--accent); color: #fff; border-color: var(--accent); }

.contact-actions { display: flex; gap: .45rem; flex-wrap: wrap; margin-top: .85rem; }
.pill-link {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .4rem .7rem;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: .8rem;
  font-weight: 600;
}
.pill-link:hover { background: var(--accent-soft); color: var(--accent); }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-bar, .filter-bar.compact { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { display: none; }
  .content { padding: 1rem; }
  .stat-grid, .form-row, .grid-3 { grid-template-columns: 1fr; }
}

/* Bootstrap-compatible pagination used by Laravel */
.pagination { display: flex; gap: .35rem; flex-wrap: wrap; padding: 1rem 1.15rem; list-style: none; margin: 0; }
.page-item .page-link,
.pagination .page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 .65rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  text-decoration: none;
  font-size: .82rem;
  color: var(--ink-soft);
}
.page-item.active .page-link,
.pagination .active > .page-link {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.page-item.disabled .page-link { opacity: .5; pointer-events: none; }

/* Settings tabs */
.settings-shell { display: flex; flex-direction: column; gap: 1rem; }
.settings-tabs {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  padding: .35rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.settings-tab {
  display: inline-flex;
  align-items: center;
  padding: .7rem 1rem;
  border-radius: 10px;
  text-decoration: none;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 600;
  transition: background .15s ease, color .15s ease;
}
.settings-tab:hover { color: var(--ink); background: #f8fafc; }
.settings-tab.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.settings-inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 1.15rem;
  border-bottom: 1px solid var(--line);
}
.settings-inline-form .form-control { flex: 1; min-width: 220px; }
.check-inline {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-size: .85rem;
  color: var(--ink-soft);
}
.settings-list { display: flex; flex-direction: column; }
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .8rem 0;
  border-bottom: 1px solid var(--line);
}
.settings-row:last-child { border-bottom: none; }
.settings-row-meta { color: var(--muted); font-size: .78rem; margin-top: .2rem; }
.settings-help {
  margin: 0 0 1.1rem;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.5;
}
.webhook-box {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
}
.webhook-url {
  display: block;
  margin-top: .35rem;
  padding: .7rem .8rem;
  background: #0b1220;
  color: #99f6e4;
  border-radius: 8px;
  font-size: .8rem;
  word-break: break-all;
}
.chip-row { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .4rem; }
.chip {
  display: inline-flex;
  padding: .25rem .55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .72rem;
  font-weight: 600;
}
.setup-steps {
  margin: 1.15rem 0 0;
  padding-left: 1.15rem;
  color: var(--ink-soft);
  font-size: .86rem;
  line-height: 1.55;
}
.setup-steps li { margin-bottom: .45rem; }
.checklist { display: flex; flex-direction: column; gap: .55rem; }
.check-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  font-size: .88rem;
  color: var(--muted);
}
.check-item span {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--line);
  display: inline-block;
  flex-shrink: 0;
}
.check-item.ok { color: var(--success); font-weight: 600; }
.check-item.ok span {
  border-color: var(--success);
  background: var(--success);
  box-shadow: inset 0 0 0 2px #fff;
}
.input-with-action { display: flex; gap: .5rem; }

.btn-meta {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  padding: .8rem 1.15rem;
  border: none;
  border-radius: 10px;
  background: #1877f2;
  color: #fff !important;
  font-weight: 700;
  font-size: .92rem;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(24, 119, 242, 0.28);
}
.btn-meta:hover { background: #166fe5; color: #fff; }
.btn-meta:disabled,
.btn-meta[disabled] {
  opacity: .55;
  cursor: not-allowed;
  box-shadow: none;
}
.meta-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  color: #1877f2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: .95rem;
  line-height: 1;
}
.meta-connected-card {
  display: flex;
  gap: .85rem;
  align-items: center;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(135deg, #eff6ff, #f8fafc);
}
.meta-connected-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #1877f2;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.page-picker {
  margin-top: 1.25rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--line);
}
.page-picker h3 {
  margin: 0 0 .35rem;
  font-size: 1rem;
}
.alert-warning {
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  padding: .75rem 1rem;
  font-size: .88rem;
}

.alert-info {
  background: #eff6ff;
  color: #1e3a8a;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: .85rem 1rem;
  font-size: .88rem;
  line-height: 1.45;
}
.method-compare {
  display: flex;
  flex-direction: column;
  gap: .85rem;
}
.method-compare > div {
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--line);
}
.method-compare > div:last-child { border-bottom: none; padding-bottom: 0; }
