:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --accent-soft: #eff6ff;
  --success: #0f766e;
  --success-soft: #ecfdf5;
  --warning: #a16207;
  --warning-soft: #fffbeb;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --shadow: 0 12px 30px rgba(17, 24, 39, .07);
  --radius: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.text-sm { font-size: 14px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 22px; }
.text-2xl { font-size: 30px; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.15fr .85fr;
}
.login-brand {
  background: #111827;
  color: white;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
  position: relative;
  overflow: hidden;
}
.login-brand::after {
  content: "";
  position: absolute;
  width: 520px;
  height: 520px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 50%;
  right: -180px;
  bottom: -180px;
  box-shadow: 0 0 0 70px rgba(255,255,255,.025), 0 0 0 140px rgba(255,255,255,.02);
}
.brand-lockup { position: relative; z-index: 1; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: white;
  color: #111827;
  font-weight: 800;
  margin-bottom: 18px;
}
.login-brand h1 { font-size: clamp(36px, 5vw, 62px); line-height: 1.02; margin: 0; letter-spacing: -2px; max-width: 760px; }
.login-brand p { color: #cbd5e1; max-width: 680px; line-height: 1.6; font-size: 17px; }
.login-feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; position: relative; z-index: 1; }
.login-feature {
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.04);
  padding: 16px;
  border-radius: 14px;
}
.login-feature strong { display: block; margin-bottom: 5px; }
.login-feature span { color: #9ca3af; font-size: 13px; line-height: 1.4; }
.login-panel { background: var(--surface); display: grid; place-items: center; padding: 32px; }
.login-card { width: min(440px, 100%); }
.login-card h2 { margin: 0 0 8px; font-size: 30px; letter-spacing: -.6px; }
.login-card > p { margin: 0 0 28px; color: var(--muted); }
.demo-credentials { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-top: 18px; }
.demo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.demo-login { text-align: left; border: 1px solid var(--line); background: white; border-radius: 12px; padding: 11px; color: var(--text); }
.demo-login:hover { border-color: var(--accent); background: var(--accent-soft); }

.form-group { display: grid; gap: 7px; margin-bottom: 14px; }
.form-group label { font-size: 13px; font-weight: 600; color: #374151; }
.input, .select, .textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: white;
  color: var(--text);
  border-radius: 11px;
  padding: 11px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.11); }
.textarea { resize: vertical; min-height: 105px; }

.btn {
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  transition: transform .1s, background .15s, border-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-2); }
.btn-secondary { background: white; border-color: var(--line-strong); color: var(--text); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: white; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 7px 10px; font-size: 13px; border-radius: 9px; }

.alert { padding: 12px 14px; border-radius: 11px; font-size: 14px; border: 1px solid; margin-bottom: 14px; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.alert-info { background: var(--accent-soft); color: #1e40af; border-color: #bfdbfe; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: #a7f3d0; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar {
  background: #111827;
  color: #f9fafb;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 20;
}
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 22px; border-bottom: 1px solid rgba(255,255,255,.09); margin-bottom: 14px; }
.sidebar-brand .brand-mark { margin: 0; width: 36px; height: 36px; border-radius: 10px; }
.sidebar-brand strong { display: block; font-size: 15px; }
.sidebar-brand span { display: block; font-size: 11px; color: #9ca3af; margin-top: 2px; }
.nav-section { font-size: 10px; text-transform: uppercase; letter-spacing: 1.2px; color: #6b7280; padding: 13px 10px 8px; }
.nav-button {
  width: 100%;
  border: 0;
  color: #cbd5e1;
  background: transparent;
  text-align: left;
  border-radius: 10px;
  padding: 10px 11px;
  margin: 2px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-button:hover { background: rgba(255,255,255,.06); color: white; }
.nav-button.active { background: rgba(37,99,235,.24); color: white; }
.nav-icon { width: 22px; text-align: center; font-size: 12px; color: #9ca3af; }
.nav-button.active .nav-icon { color: #93c5fd; }
.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255,255,255,.09); padding-top: 13px; }
.account-mini { padding: 8px; margin-bottom: 6px; }
.account-mini strong { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-mini span { display: block; color: #9ca3af; font-size: 11px; margin-top: 3px; }

.main-shell { min-width: 0; }
.topbar {
  height: 72px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-title strong { display: block; font-size: 16px; }
.topbar-title span { font-size: 12px; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.credit-chip { border: 1px solid var(--line); border-radius: 999px; padding: 7px 11px; background: white; font-size: 12px; white-space: nowrap; }
.credit-chip strong { margin-left: 3px; }
.mobile-menu { display: none; }
.main-content { padding: 28px; max-width: 1600px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.page-head h1 { margin: 0 0 5px; font-size: 27px; letter-spacing: -.5px; }
.page-head p { margin: 0; color: var(--muted); font-size: 14px; }
.page-actions { display: flex; gap: 9px; flex-wrap: wrap; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(17,24,39,.02); }
.card-pad { padding: 20px; }
.card-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.card-title h2, .card-title h3 { margin: 0; font-size: 16px; }
.card-title p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.stat-card { padding: 18px; }
.stat-label { color: var(--muted); font-size: 12px; margin-bottom: 9px; }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -1px; }
.stat-foot { color: var(--muted); font-size: 11px; margin-top: 7px; }
.stat-positive { color: var(--success); }

.progress { height: 8px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; min-width: 2px; }
.progress.success > span { background: var(--success); }
.usage-line { display: grid; gap: 7px; margin-top: 15px; }
.usage-line:first-child { margin-top: 0; }
.usage-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-neutral { background: #f3f4f6; color: #4b5563; }
.badge-blue { background: var(--accent-soft); color: #1d4ed8; }
.badge-green { background: var(--success-soft); color: var(--success); }
.badge-yellow { background: var(--warning-soft); color: var(--warning); }
.badge-red { background: var(--danger-soft); color: var(--danger); }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 13px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 760px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); background: var(--surface-2); padding: 11px 12px; position: sticky; top: 0; }
td { border-top: 1px solid var(--line); padding: 12px; vertical-align: middle; }
tbody tr:hover { background: #fafcff; }
.table-company strong { display: block; }
.table-company span { color: var(--muted); font-size: 11px; }
.table-actions { display: flex; gap: 6px; }
.check { width: 17px; height: 17px; accent-color: var(--accent); }

.filters { display: grid; grid-template-columns: 1.4fr 1fr 1fr auto; gap: 10px; align-items: end; }
.search-form { display: grid; grid-template-columns: 1.35fr 1.35fr .7fr .9fr; gap: 14px; }
.search-form .span-all { grid-column: 1 / -1; }
.form-note { font-size: 12px; color: var(--muted); line-height: 1.45; }

.funnel-list { display: grid; gap: 13px; }
.funnel-row { display: grid; grid-template-columns: 125px minmax(0,1fr) 36px; gap: 12px; align-items: center; font-size: 12px; }
.activity-list { display: grid; gap: 2px; }
.activity-item { display: grid; grid-template-columns: 8px minmax(0,1fr) auto; gap: 11px; align-items: start; padding: 10px 0; border-top: 1px solid var(--line); }
.activity-item:first-child { border-top: 0; padding-top: 0; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 5px; }
.activity-item strong { display: block; font-size: 13px; }
.activity-item span { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.activity-time { color: var(--muted); font-size: 11px; white-space: nowrap; }

.lead-cards { display: none; gap: 10px; }
.lead-card { padding: 15px; }
.lead-card-head { display: flex; justify-content: space-between; gap: 12px; }
.lead-card-meta { display: grid; gap: 5px; margin: 12px 0; font-size: 12px; color: #4b5563; }
.lead-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.pipeline { display: grid; grid-template-columns: repeat(6, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.pipeline-column { background: #eef1f5; border-radius: 14px; min-height: 520px; padding: 10px; }
.pipeline-column.drag-over { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--accent-soft); }
.pipeline-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 3px 10px; }
.pipeline-head strong { font-size: 12px; }
.pipeline-head span { background: rgba(255,255,255,.9); border-radius: 999px; padding: 3px 7px; color: var(--muted); font-size: 10px; }
.pipeline-cards { display: grid; gap: 8px; min-height: 450px; }
.pipeline-card { background: white; border: 1px solid #dde2e8; border-radius: 11px; padding: 12px; box-shadow: 0 2px 5px rgba(17,24,39,.03); cursor: grab; }
.pipeline-card:active { cursor: grabbing; }
.pipeline-card strong { display: block; font-size: 12px; }
.pipeline-card .meta { color: var(--muted); font-size: 10px; margin-top: 4px; }
.pipeline-card .score { margin-top: 10px; font-size: 10px; color: var(--accent); font-weight: 700; }

.campaign-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(330px, .9fr); gap: 16px; }
.preview-box { background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: 16px; min-height: 180px; white-space: pre-wrap; line-height: 1.55; font-size: 13px; }
.campaign-item { padding: 14px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px; align-items: center; }
.campaign-item:first-child { border-top: 0; padding-top: 0; }
.campaign-item strong { display: block; font-size: 13px; }
.campaign-item span { color: var(--muted); font-size: 11px; }

.inbox { display: grid; grid-template-columns: 320px minmax(0,1fr); min-height: 640px; overflow: hidden; }
.inbox-list { border-right: 1px solid var(--line); background: #fbfcfe; }
.inbox-search { padding: 13px; border-bottom: 1px solid var(--line); }
.conversation-item { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; padding: 14px; }
.conversation-item:hover, .conversation-item.active { background: white; }
.conversation-item.active { box-shadow: inset 3px 0 var(--accent); }
.conversation-item strong { display: block; font-size: 13px; }
.conversation-item .snippet { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conversation-line { display: flex; justify-content: space-between; gap: 10px; }
.conversation-time { color: var(--muted); font-size: 10px; }
.chat { display: grid; grid-template-rows: auto minmax(0,1fr) auto; min-width: 0; }
.chat-head { border-bottom: 1px solid var(--line); padding: 16px 18px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.chat-head strong { display: block; }
.chat-head span { color: var(--muted); font-size: 11px; }
.messages { padding: 20px; overflow-y: auto; background: #f8fafc; display: flex; flex-direction: column; gap: 11px; }
.message { max-width: min(620px, 82%); border: 1px solid var(--line); background: white; border-radius: 13px 13px 13px 3px; padding: 11px 13px; line-height: 1.5; font-size: 13px; box-shadow: 0 1px 2px rgba(17,24,39,.03); }
.message.me { align-self: flex-end; background: var(--accent); color: white; border-color: var(--accent); border-radius: 13px 13px 3px 13px; }
.message-time { display: block; opacity: .65; font-size: 9px; margin-top: 5px; }
.chat-compose { border-top: 1px solid var(--line); padding: 13px; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px; }

.plan-card { padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: white; }
.plan-card.current { border-color: #93c5fd; box-shadow: 0 0 0 3px var(--accent-soft); }
.plan-price { font-size: 30px; font-weight: 700; margin: 13px 0 3px; }
.plan-price span { font-size: 12px; color: var(--muted); font-weight: 400; }
.plan-list { display: grid; gap: 8px; padding: 0; margin: 17px 0; list-style: none; font-size: 12px; color: #4b5563; }

.admin-customer { display: flex; align-items: center; gap: 9px; }
.avatar { width: 32px; height: 32px; border-radius: 9px; background: #e5e7eb; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #374151; flex: 0 0 auto; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(17,24,39,.45); display: grid; place-items: center; padding: 20px; z-index: 100; }
.modal { width: min(700px, 100%); max-height: min(840px, 92vh); overflow: auto; background: white; border-radius: 18px; box-shadow: 0 30px 80px rgba(17,24,39,.25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding: 16px 20px; position: sticky; top: 0; background: white; z-index: 2; }
.modal-head h2 { font-size: 17px; margin: 0; }
.modal-body { padding: 20px; }
.modal-foot { border-top: 1px solid var(--line); padding: 14px 20px; display: flex; justify-content: flex-end; gap: 9px; position: sticky; bottom: 0; background: white; }
.modal-close { border: 0; background: transparent; font-size: 20px; color: var(--muted); }

.toast-stack { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: grid; gap: 8px; }
.toast { width: min(380px, calc(100vw - 36px)); background: #111827; color: white; border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); font-size: 13px; animation: toastIn .18s ease-out; }
.toast.success { background: #065f46; }
.toast.error { background: #991b1b; }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty strong { display: block; color: var(--text); margin-bottom: 6px; }
.separator { height: 1px; background: var(--line); margin: 18px 0; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-10 { gap: 10px; }
.gap-12 { gap: 12px; }
.wrap { flex-wrap: wrap; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.w-full { width: 100%; }

@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .search-form { grid-template-columns: 1fr 1fr; }
  .campaign-layout { grid-template-columns: 1fr; }
}

@media (max-width: 920px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { min-height: auto; padding: 34px 24px; }
  .login-brand h1 { font-size: 38px; }
  .login-feature-grid { grid-template-columns: 1fr; }
  .login-panel { padding: 34px 20px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -270px; width: 248px; transition: left .2s; box-shadow: var(--shadow); }
  .sidebar.open { left: 0; }
  .mobile-menu { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .main-content { padding: 20px 16px; }
  .inbox { grid-template-columns: 260px minmax(0,1fr); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 700px) {
  .page-head { align-items: flex-start; flex-direction: column; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .search-form, .filters { grid-template-columns: 1fr; }
  .search-form .span-all { grid-column: auto; }
  .table-wrap.desktop-leads { display: none; }
  .lead-cards { display: grid; }
  .inbox { grid-template-columns: 1fr; }
  .inbox-list { border-right: 0; border-bottom: 1px solid var(--line); max-height: 250px; overflow: auto; }
  .chat { min-height: 520px; }
  .credit-chip:nth-child(2) { display: none; }
  .topbar-title span { display: none; }
  .demo-grid { grid-template-columns: 1fr; }
  .funnel-row { grid-template-columns: 90px minmax(0,1fr) 30px; }
}
