/* ═══════════════════════════════════════════════════════════════
   Kasaloma BOS — Phase 2 Experience Layer
   Premium SaaS components + safe responsive helpers.
   No business logic, database logic, or AJAX endpoints changed.
   Version: 2.6.9.22
   ═══════════════════════════════════════════════════════════════ */

body.kcrm-frontend-body {
  --kbos-p2-ink: #0f172a;
  --kbos-p2-muted: #64748b;
  --kbos-p2-soft: #f8fafc;
  --kbos-p2-line: rgba(226,232,240,.86);
  --kbos-p2-panel: rgba(255,255,255,.96);
  --kbos-p2-navy: #071a33;
  --kbos-p2-blue: #2563eb;
  --kbos-p2-cyan: #0891b2;
  --kbos-p2-green: #10b981;
  --kbos-p2-amber: #f59e0b;
  --kbos-p2-red: #ef4444;
  --kbos-p2-violet: #7c3aed;
  --kbos-p2-shadow: 0 18px 46px rgba(15,23,42,.075);
  --kbos-p2-shadow-sm: 0 8px 20px rgba(15,23,42,.055);
}

/* Global page rhythm */
body.kcrm-frontend-body .kbos-module-content,
body.kcrm-frontend-body .kcrm-main-content-area {
  scroll-behavior: smooth;
}
body.kcrm-frontend-body .kcrm-page,
body.kcrm-frontend-body .kwmc-wrap,
body.kcrm-frontend-body .ktc-wrap,
body.kcrm-frontend-body .ksales-page,
body.kcrm-frontend-body .kce-wrap,
body.kcrm-frontend-body .kpw-wrap,
body.kcrm-frontend-body .kads-wrap,
body.kcrm-frontend-body .kinstagram-wrap {
  animation: kbosP2PageIn .18s ease-out both;
}
@keyframes kbosP2PageIn {
  from { opacity: .72; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Enterprise module/page headers */
body.kcrm-frontend-body .ktc-card-toolbar,
body.kcrm-frontend-body .kwmc-card-toolbar,
body.kcrm-frontend-body .ksales-page-head,
body.kcrm-frontend-body .kcrm-contacts-toolbar,
body.kcrm-frontend-body .kcrm-section-head,
body.kcrm-frontend-body .kaib-title,
body.kcrm-frontend-body .kapp-page-head {
  background: linear-gradient(135deg, rgba(255,255,255,.96), rgba(248,250,252,.92)) !important;
  border: 1px solid var(--kbos-p2-line) !important;
  border-radius: 18px !important;
  padding: 14px 16px !important;
  box-shadow: var(--kbos-p2-shadow-sm) !important;
}
body.kcrm-frontend-body .ktc-card-toolbar h3,
body.kcrm-frontend-body .kwmc-card-toolbar h3,
body.kcrm-frontend-body .ksales-page-head h1,
body.kcrm-frontend-body .kcrm-section-head h3,
body.kcrm-frontend-body .kaib-title h2 {
  letter-spacing: -.035em !important;
}
body.kcrm-frontend-body .ktc-card-toolbar p,
body.kcrm-frontend-body .kwmc-card-toolbar p,
body.kcrm-frontend-body .ksales-page-head p,
body.kcrm-frontend-body .kcrm-section-head p {
  color: var(--kbos-p2-muted) !important;
}

/* Dashboard command strip */
body.kcrm-frontend-body .kbos-p2-command-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin: 16px 0 12px;
}
body.kcrm-frontend-body .kbos-p2-command-card {
  position: relative;
  overflow: hidden;
  padding: 15px 15px 14px;
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(226,232,240,.82);
  border-radius: 18px;
  box-shadow: var(--kbos-p2-shadow-sm);
}
body.kcrm-frontend-body .kbos-p2-command-card:before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--tone, var(--kbos-p2-blue));
}
body.kcrm-frontend-body .kbos-p2-command-card:after {
  content: "";
  position: absolute;
  width: 110px;
  height: 110px;
  right: -48px;
  top: -52px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tone, var(--kbos-p2-blue)) 12%, transparent);
}
body.kcrm-frontend-body .kbos-p2-command-label {
  position: relative;
  z-index: 1;
  color: var(--kbos-p2-muted);
  font-size: 10px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .08em;
}
body.kcrm-frontend-body .kbos-p2-command-value {
  position: relative;
  z-index: 1;
  margin-top: 5px;
  color: var(--kbos-p2-ink);
  font-size: clamp(22px, 2vw, 30px);
  line-height: 1;
  font-weight: 950;
  letter-spacing: -.05em;
}
body.kcrm-frontend-body .kbos-p2-command-note {
  position: relative;
  z-index: 1;
  margin-top: 7px;
  color: #475569;
  font-size: 12px;
  line-height: 1.35;
}
body.kcrm-frontend-body .kbos-p2-command-card.urgent {
  background: linear-gradient(135deg, #fff, #fff7ed);
}
body.kcrm-frontend-body .kbos-p2-command-card.success {
  background: linear-gradient(135deg, #fff, #ecfdf5);
}
body.kcrm-frontend-body .kbos-p2-command-card.info {
  background: linear-gradient(135deg, #fff, #eff6ff);
}
body.kcrm-frontend-body .kbos-p2-command-card.warning {
  background: linear-gradient(135deg, #fff, #fffbeb);
}

/* Campaign control center */
body.kcrm-frontend-body .kwmc-campaign-detail .kwmc-summary-grid,
body.kcrm-frontend-body .kwmc-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  gap: 10px;
  margin: 14px 0 16px;
}
body.kcrm-frontend-body .kwmc-summary-card {
  position: relative;
  overflow: hidden;
  background: rgba(255,255,255,.96) !important;
  border: 1px solid rgba(226,232,240,.86) !important;
  border-radius: 16px !important;
  padding: 12px 13px !important;
  box-shadow: 0 8px 20px rgba(15,23,42,.045) !important;
}
body.kcrm-frontend-body .kwmc-summary-card:before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--tone, #94a3b8);
}
body.kcrm-frontend-body .kwmc-summary-card small,
body.kcrm-frontend-body .kwmc-summary-label {
  display: block;
  color: #64748b;
  font-size: 10px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .08em;
}
body.kcrm-frontend-body .kwmc-summary-card strong,
body.kcrm-frontend-body .kwmc-summary-value {
  display: block;
  margin-top: 4px;
  color: #0f172a;
  font-size: 22px;
  line-height: 1;
  font-weight: 950;
  letter-spacing: -.045em;
}
body.kcrm-frontend-body .kwmc-progress-shell,
body.kcrm-frontend-body .kbos-p2-progress-shell {
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  height: 9px;
  box-shadow: inset 0 1px 2px rgba(15,23,42,.08);
}
body.kcrm-frontend-body .kwmc-progress-fill,
body.kcrm-frontend-body .kbos-p2-progress-fill {
  height: 100%;
  width: var(--pct, 0%);
  background: linear-gradient(90deg, #2563eb, #10b981);
  border-radius: inherit;
  transition: width .25s ease;
}
body.kcrm-frontend-body .kwmc-progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 7px;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
}
body.kcrm-frontend-body .kwmc-log-tools,
body.kcrm-frontend-body .kbos-p2-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid rgba(226,232,240,.86);
  border-radius: 16px;
  background: rgba(248,250,252,.72);
}
body.kcrm-frontend-body .kwmc-log-filter-group {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
body.kcrm-frontend-body .kwmc-log-search,
body.kcrm-frontend-body .kwmc-log-filter {
  height: 38px;
  border-radius: 12px !important;
  border: 1px solid #dbe5ef !important;
  background: #fff !important;
  padding: 0 12px !important;
  font-size: 12px !important;
}
body.kcrm-frontend-body .kwmc-log-search { min-width: min(320px, 72vw); }
body.kcrm-frontend-body .kwmc-row-hidden { display: none !important; }
body.kcrm-frontend-body .kwmc-log-table-wrap,
body.kcrm-frontend-body .kbos-p2-table-wrap {
  border: 1px solid rgba(226,232,240,.88) !important;
  border-radius: 18px !important;
  overflow: auto !important;
  background: #fff !important;
  box-shadow: var(--kbos-p2-shadow-sm) !important;
}
body.kcrm-frontend-body .kwmc-log-table,
body.kcrm-frontend-body .kbos-p2-data-table,
body.kcrm-frontend-body .kbos-p2-table-wrap table {
  width: 100%;
  border-collapse: separate !important;
  border-spacing: 0 !important;
}
body.kcrm-frontend-body .kwmc-log-table thead th,
body.kcrm-frontend-body .kbos-p2-data-table thead th,
body.kcrm-frontend-body .kbos-p2-table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc !important;
}
body.kcrm-frontend-body .kwmc-status-chip,
body.kcrm-frontend-body .kbos-p2-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 10px;
  line-height: 1.3;
  font-weight: 900;
  white-space: nowrap;
  border: 1px solid rgba(148,163,184,.22);
}
body.kcrm-frontend-body .kwmc-status-chip[data-status="read"] { background:#dcfce7; color:#166534; }
body.kcrm-frontend-body .kwmc-status-chip[data-status="delivered"] { background:#eff6ff; color:#075985; }
body.kcrm-frontend-body .kwmc-status-chip[data-status="sent"] { background:#f1f5f9; color:#1e3a8a; }
body.kcrm-frontend-body .kwmc-status-chip[data-status="queued"] { background:#fff7ed; color:#92400e; }
body.kcrm-frontend-body .kwmc-status-chip[data-status="failed"] { background:#fee2e2; color:#991b1b; }

/* Campaign list rows */
body.kcrm-frontend-body .kwmc-campaign-row td:first-child a {
  font-size: 13px;
  letter-spacing: -.015em;
}
body.kcrm-frontend-body .kwmc-campaign-mini-progress {
  margin-top: 8px;
  max-width: 220px;
}
body.kcrm-frontend-body .kwmc-campaign-mini-progress .kwmc-progress-shell {
  height: 6px;
}
body.kcrm-frontend-body .kwmc-campaign-mini-progress .kwmc-progress-meta {
  font-size: 10px;
  margin-top: 4px;
}

/* Settings and forms: clean SaaS sections */
body.kcrm-frontend-body .kcrm-settings-section {
  background: rgba(255,255,255,.96) !important;
  border: 1px solid rgba(226,232,240,.86) !important;
  border-radius: 20px !important;
  padding: 20px !important;
  box-shadow: var(--kbos-p2-shadow-sm) !important;
  margin-bottom: 18px !important;
}
body.kcrm-frontend-body .kcrm-settings-section > h3:first-child,
body.kcrm-frontend-body .kcrm-settings-section .kcrm-section-head h3 {
  font-size: 18px !important;
  font-weight: 950 !important;
  letter-spacing: -.035em !important;
}
body.kcrm-frontend-body .kcrm-settings-desc {
  max-width: 780px;
  color: #64748b !important;
  line-height: 1.55 !important;
}
body.kcrm-frontend-body .kcrm-form-grid,
body.kcrm-frontend-body .ksales-form-grid,
body.kcrm-frontend-body .ktc-form-grid,
body.kcrm-frontend-body .kwmc-form-grid {
  gap: 14px !important;
}
body.kcrm-frontend-body .kcrm-field,
body.kcrm-frontend-body .ksales-field,
body.kcrm-frontend-body .ktc-field,
body.kcrm-frontend-body .kwmc-field,
body.kcrm-frontend-body .kce-field,
body.kcrm-frontend-body .kpw-field {
  min-width: 0;
}
body.kcrm-frontend-body .kcrm-field small,
body.kcrm-frontend-body .ksales-field small,
body.kcrm-frontend-body .ktc-field small,
body.kcrm-frontend-body .kwmc-field small {
  color: #64748b !important;
  line-height: 1.45 !important;
}

/* AI Inbox: premium visual pass without changing sizing logic */
body.kcrm-frontend-body .kaa-inbox-layout,
body.kcrm-frontend-body .kaa-sidebar,
body.kcrm-frontend-body .kaa-chat-panel,
body.kcrm-frontend-body .kaa-detail-panel {
  border-color: rgba(226,232,240,.82) !important;
}
body.kcrm-frontend-body .kaa-sidebar,
body.kcrm-frontend-body .kaa-chat-panel,
body.kcrm-frontend-body .kaa-detail-panel {
  box-shadow: 0 10px 28px rgba(15,23,42,.045) !important;
}
body.kcrm-frontend-body .kaa-conv-item,
body.kcrm-frontend-body .kaa-message-bubble,
body.kcrm-frontend-body .kaa-reply-quote,
body.kcrm-frontend-body .kaa-media-preview,
body.kcrm-frontend-body .kaa-recording-bar {
  border-radius: 16px !important;
}
body.kcrm-frontend-body .kaa-conv-item:hover {
  transform: translateY(-1px);
}
body.kcrm-frontend-body .kaa-conv-item.active {
  box-shadow: inset 3px 0 0 #2563eb, 0 8px 20px rgba(37,99,235,.08) !important;
}
body.kcrm-frontend-body .kaa-send-btn {
  box-shadow: 0 12px 22px rgba(37,99,235,.18) !important;
}

/* Better empty states */
body.kcrm-frontend-body .ktc-empty-state,
body.kcrm-frontend-body .kcrm-empty-state,
body.kcrm-frontend-body .ksales-empty,
body.kcrm-frontend-body .kdash-empty,
body.kcrm-frontend-body .kaa-phase2-empty {
  background: linear-gradient(135deg, #fff, #f8fafc) !important;
  border: 1px dashed rgba(148,163,184,.55) !important;
  border-radius: 18px !important;
}
body.kcrm-frontend-body .ktc-empty-icon,
body.kcrm-frontend-body .ksales-empty-icon {
  filter: drop-shadow(0 10px 20px rgba(15,23,42,.08));
}

/* Safer mobile behavior: turn common data tables into readable cards */
@media (max-width: 900px) {
  body.kcrm-frontend-body .kbos-p2-command-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  body.kcrm-frontend-body .kwmc-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  body.kcrm-frontend-body .ktc-card-toolbar,
  body.kcrm-frontend-body .kwmc-card-toolbar,
  body.kcrm-frontend-body .ksales-page-head,
  body.kcrm-frontend-body .kcrm-contacts-toolbar,
  body.kcrm-frontend-body .kcrm-section-head {
    align-items: stretch !important;
  }
}
@media (max-width: 640px) {
  body.kcrm-frontend-body .kbos-p2-command-strip {
    grid-template-columns: 1fr;
  }
  body.kcrm-frontend-body .kwmc-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  body.kcrm-frontend-body .kwmc-log-tools,
  body.kcrm-frontend-body .kbos-p2-toolbar {
    align-items: stretch;
  }
  body.kcrm-frontend-body .kwmc-log-filter-group,
  body.kcrm-frontend-body .kwmc-log-search,
  body.kcrm-frontend-body .kwmc-log-filter {
    width: 100% !important;
  }
  body.kcrm-frontend-body .kbos-p2-mobile-cards {
    border: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    overflow: visible !important;
  }
  body.kcrm-frontend-body .kbos-p2-mobile-cards table,
  body.kcrm-frontend-body table.kbos-p2-mobile-table,
  body.kcrm-frontend-body table.kbos-p2-mobile-table thead,
  body.kcrm-frontend-body table.kbos-p2-mobile-table tbody,
  body.kcrm-frontend-body table.kbos-p2-mobile-table th,
  body.kcrm-frontend-body table.kbos-p2-mobile-table td,
  body.kcrm-frontend-body table.kbos-p2-mobile-table tr {
    display: block !important;
  }
  body.kcrm-frontend-body table.kbos-p2-mobile-table thead {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  body.kcrm-frontend-body table.kbos-p2-mobile-table tbody tr {
    background: #fff;
    border: 1px solid rgba(226,232,240,.86) !important;
    border-radius: 16px;
    box-shadow: 0 8px 22px rgba(15,23,42,.055);
    margin: 0 0 12px;
    overflow: hidden;
  }
  body.kcrm-frontend-body table.kbos-p2-mobile-table tbody td {
    display: grid !important;
    grid-template-columns: minmax(94px, 34%) 1fr;
    align-items: start;
    gap: 10px;
    border-bottom: 1px solid rgba(226,232,240,.74) !important;
    padding: 10px 12px !important;
    text-align: left !important;
    word-break: break-word;
  }
  body.kcrm-frontend-body table.kbos-p2-mobile-table tbody td:last-child {
    border-bottom: 0 !important;
  }
  body.kcrm-frontend-body table.kbos-p2-mobile-table tbody td:before {
    content: attr(data-label);
    color: #64748b;
    font-size: 10px;
    font-weight: 950;
    text-transform: uppercase;
    letter-spacing: .08em;
  }
  body.kcrm-frontend-body table.kbos-p2-mobile-table tbody td[data-label=""]:before,
  body.kcrm-frontend-body table.kbos-p2-mobile-table tbody td:not([data-label]):before {
    content: "";
  }
}

@media (prefers-reduced-motion: reduce) {
  body.kcrm-frontend-body .kcrm-page,
  body.kcrm-frontend-body .kwmc-wrap,
  body.kcrm-frontend-body .ktc-wrap,
  body.kcrm-frontend-body .ksales-page,
  body.kcrm-frontend-body .kce-wrap,
  body.kcrm-frontend-body .kpw-wrap,
  body.kcrm-frontend-body .kads-wrap,
  body.kcrm-frontend-body .kinstagram-wrap {
    animation: none !important;
  }
  body.kcrm-frontend-body * {
    transition-duration: .01ms !important;
  }
}
