:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --border-light: #edf2f7;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --teal: #0d9488;
  --sky: #0284c7;
  --orange: #f97316;
  --purple: #8b5cf6;
  --emerald: #10b981;
  --cyan: #06b6d4;
  --danger: #ef4444;
  --warn: #f59e0b;
  --ok: #10b981;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-hover: 0 10px 25px -5px rgba(16, 24, 40, 0.08), 0 8px 10px -6px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

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

button, input, select, textarea { font: inherit; color: inherit; }

.hidden { display: none !important; }

/* ------------------------------ Layout ------------------------------ */

.app {
  display: block;
  min-height: 100vh;
  position: relative;
  background: var(--bg);
}

.main {
  width: 100%;
  max-width: 100%;
  overflow-y: auto;
  padding: 20px 32px 60px;
  box-sizing: border-box;
}

/* Off-Canvas Sidebar Drawer (SmartKonek Style) */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 250px;
  background: #ffffff;
  z-index: 1050;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 16px;
  border-right: 1px solid #e2e8f0;
  box-shadow: 4px 0 25px rgba(0, 0, 0, 0.12);
  transform: translateX(-100%);
  transition: transform 0.24s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}

.sidebar.open {
  transform: translateX(0);
}

/* Dim Backdrop when sidebar drawer is open */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1040;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  backdrop-filter: blur(2px);
}

.sidebar-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-close-btn {
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 22px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1;
}

.sidebar-close-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 17px;
  color: #ffffff;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.brand-name { font-weight: 700; font-size: 16px; color: #0f172a; letter-spacing: -0.2px; }
.brand-sub { font-size: 10.5px; color: #64748b; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; }

.nav { display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #334155;
  cursor: pointer;
  text-align: left;
  font-weight: 500;
  font-size: 13.5px;
  transition: all 0.15s ease;
}

.nav-item svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }

.nav-item:hover { color: #0f172a; background: #f8fafc; }

.nav-item.active {
  color: #ffffff;
  background: #2563eb;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.nav-item.active svg {
  stroke: #ffffff;
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  font-weight: 500;
  color: #475569;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
}

.dot { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; flex: none; }
.dot.live { background: var(--ok); box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2); animation: pulse 1.8s infinite; }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.2); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.main {
  overflow-y: auto;
  padding: 20px 32px 60px;
}

/* ----------------------------- Top Header ----------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sk-hamburger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.sk-hamburger-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #cbd5e1;
}

.sk-hamburger-btn:active {
  transform: scale(0.96);
}

.topbar-left h1 { margin: 0; font-size: 22px; font-weight: 700; color: #0f172a; letter-spacing: -0.3px; }
.topbar-left p { margin: 3px 0 0; font-size: 13px; color: var(--muted); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sk-balance-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  color: #166534;
}

.sk-pill-btn {
  background: #2563eb;
  color: #ffffff;
  border: none;
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.sk-pill-btn:hover { background: #1d4ed8; }

.sk-icon-action {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.sk-icon-action:hover { background: #f1f5f9; color: #0f172a; }

.sk-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e2e8f0;
  border: 2px solid #ffffff;
  color: #1e293b;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  position: relative;
}

.sk-avatar-dot {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid #ffffff;
}

/* ----------------------- SmartKonek Channel Sub-Bar ----------------------- */

.sk-channel-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 16px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
}

.sk-bar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.sk-channel-badge {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sk-label {
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sk-channel-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
}

.sk-wa-icon {
  width: 18px;
  height: 18px;
  color: #25d366;
  flex-shrink: 0;
}

.sk-channel-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  padding: 3px;
  border-radius: 10px;
}

.sk-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sk-tab-btn.active {
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.3);
}

.sk-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sk-date-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 500;
  color: #334155;
  cursor: pointer;
}

.section-heading {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 16px 0;
  letter-spacing: -0.2px;
}

/* ------------------------- SmartKonek Card Grid -------------------------- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.sk-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
  position: relative;
}

.sk-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: #cbd5e1;
}

.sk-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.sk-card-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sk-icon-box {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.sk-icon-box svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.sk-icon-blue { background: #2563eb; }
.sk-icon-orange { background: #f97316; }
.sk-icon-purple { background: #8b5cf6; }
.sk-icon-green { background: #10b981; }
.sk-icon-cyan { background: #06b6d4; }
.sk-icon-violet { background: #6366f1; }

.sk-card-title-group {
  display: flex;
  flex-direction: column;
}

.sk-card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: #475569;
}

.sk-card-value {
  font-size: 26px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.1;
  margin-top: 2px;
}

.sk-arrow-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #ffffff;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sk-arrow-btn:hover {
  background: #eff6ff;
  border-color: #2563eb;
  color: #2563eb;
  transform: translate(2px, -2px);
}

.sk-divider {
  border: none;
  border-top: 1px dashed #e2e8f0;
  margin: 14px 0 12px;
}

.sk-submetrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px 12px;
  font-size: 12px;
}

.sk-sub-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #64748b;
  white-space: nowrap;
}

.sk-bullet {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  flex-shrink: 0;
}

.sk-sub-val {
  font-weight: 700;
  color: #0f172a;
  margin-left: auto;
}

/* -------------------- Message Analytics (SmartKonek) -------------------- */

.sk-msg-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.sk-msg-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.sk-msg-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.sk-msg-title {
  font-size: 13.5px;
  font-weight: 600;
  color: #475569;
}

.sk-msg-value-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
}

.sk-msg-val {
  font-size: 26px;
  font-weight: 700;
  color: #0f172a;
}

.sk-trend-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
}
.sk-trend-down { background: #fee2e2; color: #b91c1c; }
.sk-trend-neutral { background: #f1f5f9; color: #475569; }

.sk-msg-cat-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  border-top: 1px dashed #e2e8f0;
  padding-top: 12px;
  margin-top: auto;
}

.sk-msg-cat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #64748b;
}

.sk-msg-cat-row b {
  color: #0f172a;
  font-weight: 600;
}

/* -------------------- Live Agent Activity Table -------------------- */

.sk-agent-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.sk-agent-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.sk-agent-desc {
  font-size: 12.5px;
  color: #64748b;
  margin: 4px 0 0;
  max-width: 680px;
  line-height: 1.5;
}

.sk-agent-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.sk-agent-table th {
  background: #f8fafc;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.sk-agent-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.sk-agent-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sk-agent-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #eff6ff;
  color: #2563eb;
  font-weight: 700;
  font-size: 12.5px;
  display: grid;
  place-items: center;
  border: 1px solid #bfdbfe;
  flex-shrink: 0;
}

.sk-agent-name {
  font-weight: 600;
  color: #0f172a;
}

.sk-agent-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.sk-status-dot-green {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
}

/* ------------------------------ Cards ------------------------------- */

.card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.2px;
}

.grid-2 { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 20px; align-items: start; }

@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .sk-msg-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: 1fr; }
  .sk-msg-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .app { grid-template-columns: 76px minmax(0, 1fr); }
  .brand-text, .nav-item span, .sidebar-foot span:not(.dot) { display: none; }
  .nav-item { justify-content: center; }
  .sidebar-foot { justify-content: center; padding: 8px 0; border-color: transparent; background: transparent; }
  .dot { width: 10px; height: 10px; }
}

/* ------------------------------ Forms ------------------------------- */

.stack { display: grid; gap: 14px; }

.field { display: grid; gap: 6px; }

.field label {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}

input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%;
  padding: 10px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: #0f172a;
  outline: none;
  font-size: 13.5px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder, textarea::placeholder { color: #94a3b8; }

textarea { resize: vertical; min-height: 96px; line-height: 1.55; }

input:focus, select:focus, textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #64748b 50%), linear-gradient(135deg, #64748b 50%, transparent 50%);
  background-position: calc(100% - 18px) 18px, calc(100% - 13px) 18px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

.hint { font-size: 12px; color: #64748b; }

/* ----------------------------- Buttons ------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid #2563eb;
  background: #2563eb;
  color: #ffffff;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:hover { background: #1d4ed8; border-color: #1d4ed8; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn.ghost {
  background: #ffffff;
  border-color: var(--border);
  color: #334155;
  font-weight: 500;
}

.btn.ghost:hover { background: #f8fafc; border-color: #cbd5e1; color: #0f172a; }

.btn.danger {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}
.btn.danger:hover { background: #fecaca; }

.btn.sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }

.icon-btn {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 9px;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn:hover { color: var(--danger); border-color: #fca5a5; background: #fff5f5; }

/* ------------------------------ Table ------------------------------- */

.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); background: #ffffff; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th {
  text-align: left;
  padding: 11px 14px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #64748b;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td { padding: 12px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; color: #1e293b; }

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

.mono { font-family: "JetBrains Mono", "Cascadia Code", ui-monospace, monospace; font-size: 12.5px; }

.chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  border: 1px solid transparent;
}

.chip.teal { background: #ccfbf1; color: #0f766e; border-color: #99f6e4; }
.chip.grey { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }
.chip.amber { background: #fef3c7; color: #b45309; border-color: #fde68a; }
.chip.green { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.chip.red { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }

/* ---------------------------- Progress ------------------------------ */

.progress { height: 8px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }

.progress > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #2563eb, #38bdf8);
  transition: width 0.5s ease;
}

.progress.small { height: 6px; }

.campaign-row {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
}

.campaign-row + .campaign-row { margin-top: 10px; }

.campaign-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.campaign-name { font-weight: 600; color: #0f172a; }
.campaign-meta { font-size: 12px; color: #64748b; display: flex; gap: 12px; flex-wrap: wrap; }
.campaign-actions { display: flex; gap: 6px; align-items: center; }

/* ----------------------------- Template ----------------------------- */

.tpl-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  background: #ffffff;
}

.tpl-card + .tpl-card { margin-top: 12px; }
.tpl-body {
  margin: 10px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: #f8fafc;
  border-left: 3px solid #2563eb;
  font-size: 13px;
  white-space: pre-wrap;
  color: #1e293b;
}

.var-pill {
  display: inline-block;
  padding: 1px 7px;
  margin: 0 2px;
  border-radius: 6px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 600;
  font-family: ui-monospace, monospace;
}

/* ------------------------------ Toast ------------------------------- */

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 380px;
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0f172a;
  color: #ffffff;
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.25);
  font-size: 13.5px;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: 0.25s ease;
  z-index: 80;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.ok { border-color: #10b981; }
.toast.err { border-color: #ef4444; }

/* ------------------------------ Modal ------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 90;
}

.modal { width: min(440px, 100%); }

/* ------------------------------ Login ------------------------------- */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

.login-card {
  width: min(390px, 100%);
  display: grid;
  gap: 18px;
  padding: 32px 28px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

.login-card .brand { justify-content: center; margin-bottom: 6px; }

.empty {
  padding: 32px;
  text-align: center;
  color: #64748b;
  font-size: 13px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: #f8fafc;
}

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar .grow { flex: 1 1 180px; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
.kv:last-child { border-bottom: none; }
.kv b { font-weight: 600; color: #0f172a; }

/* ---------------------------- Live Chat UI ---------------------------- */

.chat-container {
  display: grid;
  grid-template-columns: 360px 1fr;
  height: calc(100vh - 130px);
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.chat-sidebar {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: #ffffff;
}

.chat-sidebar-header {
  padding: 8px 12px 6px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.chat-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.chat-top-row .sk-icon-action {
  width: 28px;
  height: 28px;
  border-radius: 7px;
}

.chat-channel-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #eff6ff;
  border: 1px solid #dbeafe;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: #2563eb;
}

.chat-select-sm {
  padding: 3px 8px;
  font-size: 11.5px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: #0f172a;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.chat-select-sm:focus {
  border-color: #2563eb;
}

.chat-tabs-wrap {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #f1f5f9;
  background: #ffffff;
  padding: 0;
}

.chat-tabs {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 1px 0;
  overflow-x: auto;
  flex: 1;
}

.chat-tab-arrow {
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 6px;
  cursor: pointer;
}
.chat-tab-arrow:hover {
  color: #2563eb;
}

.chat-tab-btn {
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.chat-tab-btn.active {
  color: #2563eb;
  border-bottom: 2px solid #2563eb;
  border-radius: 0;
  background: transparent;
}

.chat-tab-search-btn {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #64748b;
  padding: 2px 8px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  font-size: 11px;
  font-weight: 500;
  margin-left: 4px;
  transition: all 0.15s ease;
}

.chat-tab-search-btn:hover {
  background: #f8fafc;
  color: #0f172a;
  border-color: #94a3b8;
}

.chat-tab-search-btn.active {
  background: #eff6ff;
  color: #2563eb;
  border-color: #3b82f6;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.08);
}

/* Row 2: Sub-tabs (Interest & Followup Ulang) */
.chat-subtabs-wrap {
  display: flex;
  align-items: center;
  padding: 1px 0;
  background: transparent;
}

.chat-subtabs {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  width: 100%;
}

.chat-subtab-btn {
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  height: 22px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.chat-subtab-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #cbd5e1;
}

.chat-subtab-btn.active {
  background: #eff6ff;
  color: #2563eb;
  border-color: #93c5fd;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.08);
}

.subtab-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.subtab-dot.dot-interest {
  background: #f59e0b;
}

.subtab-dot.dot-followup {
  background: #8b5cf6;
}

.subtab-count {
  font-size: 10px;
  opacity: 0.85;
}

/* Search input collapsible */
.chat-search-expand-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 2px 8px;
  height: 26px;
  box-sizing: border-box;
  margin-top: 1px;
}

.chat-search-expand-wrap.hidden {
  display: none !important;
}

.chat-search-input-compact {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 11.5px;
  color: #0f172a;
  outline: none;
  padding: 0;
  font-family: inherit;
}

.chat-search-input-compact::placeholder {
  color: #94a3b8;
}

.chat-search-clear-btn {
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-search-clear-btn:hover {
  color: #ef4444;
}

/* Status Chips on Chat Items */
.chat-lead-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1.5px 7px;
  border-radius: 12px;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.chat-lead-chip.interest {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.chat-lead-chip.followup {
  background: #f3e8ff;
  color: #7e22ce;
  border: 1px solid #e9d5ff;
}

.chat-pin-badge {
  display: inline-flex;
  align-items: center;
  color: #2563eb;
  margin-left: 4px;
}

.chat-item.pinned {
  background: #fbfdff;
  border-left: 3px solid #2563eb;
}

.chat-item.pinned:hover {
  background: #f1f7fe;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
}

.chat-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background 0.15s ease;
  position: relative;
}

.chat-item:hover { background: #f8fafc; }
.chat-item.active { background: #eff6ff; }

.chat-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #cbd5e1;
  color: #1e293b;
  font-weight: 700;
  font-size: 15px;
  display: grid;
  place-items: center;
}

.chat-wa-icon-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 17px;
  height: 17px;
  background: #25d366;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #ffffff;
  border: 2px solid #ffffff;
}

.chat-wa-icon-badge svg {
  width: 10px;
  height: 10px;
  fill: currentColor;
}

.chat-avatar-unread {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 18px;
  height: 18px;
  background: #2563eb;
  border-radius: 50%;
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.chat-start-btn {
  background: #2563eb;
  color: #ffffff;
  border: none;
  padding: 10px 22px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
  margin-top: 6px;
}
.chat-start-btn:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.chat-item-main {
  flex: 1;
  min-width: 0;
}

.chat-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px;
}

.chat-name {
  font-weight: 700;
  font-size: 13px;
  color: #0f172a;
  letter-spacing: -0.1px;
}

.chat-time {
  font-size: 11px;
  color: #94a3b8;
}

.chat-item-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chat-snippet {
  font-size: 12px;
  color: #64748b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-unread-badge {
  background: #2563eb;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  flex-shrink: 0;
}

/* Chat Thread (Right Pane) */
.chat-main {
  display: flex;
  flex-direction: column;
  background: #f8fafc;
}

.chat-main-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-contact-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-image: radial-gradient(rgba(148, 163, 184, 0.15) 1px, transparent 1px);
  background-size: 20px 20px;
}

.chat-bubble {
  max-width: 65%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.45;
  position: relative;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.chat-bubble.inbound {
  align-self: flex-start;
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-top-left-radius: 4px;
}

.chat-bubble.outbound {
  align-self: flex-end;
  background: #dcf8c6;
  color: #0f172a;
  border: 1px solid #c8e6b8;
  border-top-right-radius: 4px;
}

.chat-bubble-time {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 4px;
  text-align: right;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.chat-composer {
  padding: 14px 20px;
  background: #ffffff;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  border: 1px solid var(--border);
  outline: none;
}
.chat-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.chat-empty-state {
  margin: auto;
  text-align: center;
  color: #64748b;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* Context Menu & 3-dots actions */
.chat-context-menu {
  position: fixed;
  z-index: 1000;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  min-width: 200px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: fadeIn 0.12s ease-out;
}

.chat-context-menu.hidden {
  display: none !important;
}

.chat-cm-header {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  padding: 6px 10px 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #f1f5f9;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-cm-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  font-size: 12.5px;
  font-weight: 500;
  color: #1e293b;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s ease;
  user-select: none;
}

.chat-cm-item:hover {
  background: #f1f5f9;
}

/* Context Menu Submenu (Status -> Interest / Followup) */
.chat-cm-item.has-submenu {
  position: relative;
}

.chat-cm-submenu {
  display: none;
  position: absolute;
  left: 100%;
  top: -4px;
  margin-left: 6px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
  min-width: 150px;
  padding: 5px;
  z-index: 1010;
}

.chat-cm-item.has-submenu:hover .chat-cm-submenu,
.chat-cm-item.has-submenu.open .chat-cm-submenu {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-cm-subitem {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 500;
  color: #1e293b;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s ease;
  white-space: nowrap;
}

.chat-cm-subitem:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.chat-cm-subitem.active {
  background: #eff6ff;
  color: #2563eb;
  font-weight: 700;
}

.chat-cm-subitem.muted-sub {
  color: #94a3b8;
  font-size: 11px;
  border-top: 1px solid #f1f5f9;
  margin-top: 2px;
  padding-top: 6px;
}

.chat-cm-subitem.muted-sub:hover {
  color: #ef4444;
  background: #fef2f2;
}

.chat-cm-item.danger {
  color: #ef4444;
}

.chat-cm-item.danger:hover {
  background: #fef2f2;
}

.chat-cm-divider {
  border: none;
  border-top: 1px solid #f1f5f9;
  margin: 4px 0;
}

.chat-item-actions {
  opacity: 0;
  transition: opacity 0.15s ease;
  border: none;
  background: transparent;
  color: #94a3b8;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  margin-left: 4px;
}

.chat-item:hover .chat-item-actions {
  opacity: 1;
}

.chat-item-actions:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.chat-status-chip {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}
.chat-status-chip.closed {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}
.chat-status-chip.open {
  background: #ecfdf5;
  color: #059669;
}

.chat-list-empty {
  padding: 40px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.chat-empty-icon {
  font-size: 32px;
  opacity: 0.6;
}

.chat-template-preview-box {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
  color: #1e293b;
  min-height: 60px;
  max-height: 140px;
  overflow-y: auto;
  white-space: pre-wrap;
  background-image: radial-gradient(rgba(148, 163, 184, 0.12) 1px, transparent 1px);
  background-size: 16px 16px;
}

/* ----------------- SmartKonek Import Contacts By File Modal ----------------- */

.sk-import-modal {
  max-width: 520px;
  width: 100%;
}

.sk-import-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px 14px;
  margin-bottom: 8px;
}

.sk-link-sample {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #4f46e5;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s ease;
}
.sk-link-sample:hover {
  color: #3730a3;
  text-decoration: underline;
}

.sk-floating-field {
  position: relative;
  margin-top: 4px;
}

.sk-floating-label {
  position: absolute;
  top: -8px;
  left: 12px;
  background: #ffffff;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  z-index: 2;
  border-radius: 4px;
}

.sk-select-wa-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.sk-wa-icon-sm {
  position: absolute;
  left: 12px;
  pointer-events: none;
  z-index: 2;
}

.sk-field-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: #0f172a;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.sk-field-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.sk-radio-group {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 4px;
}

.sk-radio-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #334155;
  cursor: pointer;
}

.sk-radio-label input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: #4f46e5;
  cursor: pointer;
}

/* Dashed Dropzone */
.sk-dropzone {
  border: 2px dashed #0f172a;
  border-radius: 12px;
  padding: 24px 20px;
  text-align: center;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 6px;
}

.sk-dropzone:hover {
  background: #f8fafc;
  border-color: #2563eb;
}

.sk-dropzone.dragover {
  border-color: #2563eb;
  background: #eff6ff;
  border-style: solid;
}

.sk-dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.sk-dropzone-icon {
  margin-bottom: 8px;
}

.sk-dropzone-text {
  font-size: 13px;
  font-weight: 500;
  color: #334155;
  line-height: 1.4;
}

.sk-dropzone-file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 10px 14px;
  color: #1e40af;
  font-size: 13px;
  font-weight: 600;
}
