@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  --ink: #0B2B26;
  --primary: #0F7B58;
  --primary-dark: #0A5940;
  --primary-light: #E6F5EE;
  --accent: #FF8A5B;
  --accent-light: #FFEDE3;
  --info: #3B82C4;
  --info-light: #E8F1FA;
  --bg: #F5F8F6;
  --surface: #FFFFFF;
  --border: #E3E9E6;
  --text: #12211D;
  --text-2: #5E6F69;
  --text-3: #93A19B;

  /* Legacy variable aliases for full backwards compatibility */
  --navy: #0B2B26;
  --navy2: #0E3830;
  --primary2: #0F7B58;
  --heading: #0B2B26;
  --muted: #93A19B;
  --white: #FFFFFF;
  --success: #0F7B58;
  --danger: #C4472B;
  --warning: #FF8A5B;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --radius: 14px;

  --shadow-sm: 0 1px 2px rgba(11,43,38,.05);
  --shadow-md: 0 6px 20px -6px rgba(11,43,38,.12);
  --shadow: 0 6px 20px -6px rgba(11,43,38,.12);

  --sidebar-w: 268px;
  --sidebar-w-collapsed: 84px;
  --topbar-h: 74px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; width: 100%; min-height: 100vh; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Space Grotesk', sans-serif;
  margin: 0;
  color: var(--ink);
}

.mono {
  font-family: 'IBM Plex Mono', monospace;
}

a { text-decoration: none; color: inherit; }
button, input, select, textarea { font-family: inherit; }
button { cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- Layout Shell ---------- */
.shell, .app { display: flex; min-height: 100vh; width: 100%; background: var(--bg); position: relative; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(190deg, var(--ink) 0%, #0E3830 100%);
  color: #DCEAE5;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width .25s ease, transform .25s ease;
  z-index: 1000;
  box-shadow: 8px 0 28px rgba(11,43,38,.15);
}

/* Desktop Collapsed Sidebar */
body.collapsed .sidebar,
body.sidebar-collapsed .sidebar {
  width: var(--sidebar-w-collapsed);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  min-height: var(--topbar-h);
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), #FF6B3D);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(255,138,91,.35);
}
.brand-mark svg { width: 20px; height: 20px; }

.brand-word {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  overflow: hidden;
  white-space: nowrap;
}
.brand-word b { font-family: 'Space Grotesk', sans-serif; font-size: 17px; font-weight: 700; color: #fff; }
.brand-word span { font-size: 10.5px; letter-spacing: .11em; color: #8FB6AB; text-transform: uppercase; margin-top: 2px; }

/* Legacy img support inside brand */
.brand img { width: 174px; max-height: 48px; object-fit: contain; object-position: left center; }
body.collapsed .brand-word,
body.sidebar-collapsed .brand-word,
body.sidebar-collapsed .brand span:not(.brand-mark),
body.sidebar-collapsed .brand img { display: none; }

.brand .close, .close-side {
  margin-left: auto;
  background: rgba(255,255,255,.1);
  border: 0;
  color: #fff;
  font-size: 18px;
  display: none;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  place-items: center;
}

.side-scroll, .menu {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px;
}
.side-scroll::-webkit-scrollbar, .menu::-webkit-scrollbar { width: 5px; }
.side-scroll::-webkit-scrollbar-thumb, .menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

.nav-label, .label {
  font-size: 10.5px;
  letter-spacing: .14em;
  color: #5F8B7E;
  text-transform: uppercase;
  font-weight: 600;
  padding: 10px 12px 8px;
}
body.collapsed .nav-label,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .label { opacity: 0; display: none; }

.nav-item, .item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 11px 12px;
  margin-bottom: 3px;
  border-radius: var(--radius-sm);
  color: #B9D3CB;
  font-size: 14.5px;
  font-weight: 500;
  position: relative;
  transition: background .15s ease, color .15s ease, transform .15s ease;
  white-space: nowrap;
  overflow: hidden;
  min-height: 42px;
}
.nav-item i.ic, .item i { font-size: 17px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item .lbl, .item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .chev, .nav-arrow { font-size: 11px; opacity: .5; flex-shrink: 0; margin-left: auto; }

.nav-item:hover, .item:hover {
  background: rgba(255,255,255,.06);
  color: #fff;
}
.nav-item.active, .item.active {
  background: rgba(255,255,255,.1);
  color: #fff;
  font-weight: 600;
}
.nav-item.active::before, .item.active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 8px;
  bottom: 8px;
  width: 4px;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
}

body.collapsed .nav-item .lbl, body.collapsed .nav-item .chev,
body.sidebar-collapsed .nav-item .lbl, body.sidebar-collapsed .nav-item .chev,
body.sidebar-collapsed .item span, body.sidebar-collapsed .nav-arrow { display: none !important; }

body.collapsed .nav-item, body.sidebar-collapsed .nav-item,
body.sidebar-collapsed .item { justify-content: center; padding: 0; gap: 0; }

.side-foot {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), #0D6B4C);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 13px;
}
.side-foot .who, .side-foot div:not(.avatar) { overflow: hidden; white-space: nowrap; line-height: 1.25; }
.side-foot .who b, .side-foot b { display: block; font-size: 13.5px; color: #fff; font-weight: 600; }
.side-foot .who span, .side-foot span { font-size: 11.5px; color: #8FB6AB; }

body.collapsed .side-foot .who,
body.sidebar-collapsed .side-foot .who,
body.sidebar-collapsed .side-foot > div:not(.avatar) { display: none !important; }
body.collapsed .side-foot, body.sidebar-collapsed .side-foot { justify-content: center; padding: 14px 8px; }

/* ---------- Main & Topbar ---------- */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
}

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 900;
  gap: 20px;
}
.topbar .left, .topbar .right { display: flex; align-items: center; }
.topbar .left { gap: 16px; min-width: 0; }

.icon-btn, .sidebar-toggle, .topbar .icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: grid;
  place-items: center;
  color: var(--text-2);
  font-size: 16px;
  flex-shrink: 0;
  transition: background .15s, border-color .15s, color .15s;
}
.icon-btn:hover, .sidebar-toggle:hover, .topbar .icon:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}
.hamb { display: none; }
body.sidebar-collapsed .toggle-icon { transform: rotate(180deg); }

.titles, .topbar .left > div { min-width: 0; }
.titles h1, .topbar h1 { font-size: 19px; font-weight: 700; font-family: 'Space Grotesk', sans-serif; color: var(--ink); margin: 0; }
.crumb { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.crumb b { color: var(--text-2); font-weight: 600; }

.search-box, .searchbar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0 14px;
    height: 40px;
    width: 320px;
    flex-shrink: 1;
    margin-bottom: 10px;
}
.search-box i, .searchbar i { color: var(--text-3); font-size: 14px; }
.search-box input, .searchbar input {
  border: 0;
  background: transparent;
  outline: 0;
  font-size: 13.5px;
  width: 100%;
  color: var(--text);
  font-family: inherit;
}
.search-box input::placeholder, .searchbar input::placeholder { color: var(--text-3); }

.topbar .right { gap: 12px; flex-shrink: 0; }
.wa-btn, .whatsapp-launcher {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 18px;
  border: 1px solid var(--border);
  transition: transform .15s, background .15s;
  text-decoration: none;
}
.wa-btn:hover, .whatsapp-launcher:hover {
  transform: translateY(-1px);
  background: var(--primary);
  color: #fff;
}

.bell-wrap { position: relative; }
.dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  border: 1.5px solid var(--surface);
}

.vr, .divider { width: 1px; height: 26px; background: var(--border); }
.user-pill, .user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 6px 5px 5px;
  border-radius: 12px;
  cursor: pointer;
}
.user-pill:hover, .user:hover { background: var(--bg); }
.user-pill .who, .user-text { line-height: 1.2; }
.user-pill .who b, .user-text b { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.user-pill .who span, .user-text span { font-size: 11.5px; color: var(--text-3); }
.user-pill i, .user i { color: var(--text-3); font-size: 12px; }

/* ---------- Main Content Area ---------- */
.content {
  padding: 28px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .18s ease, transform .18s ease;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px 0;
  gap: 12px;
}
.card-head h2 { font-size: 16.5px; font-weight: 700; font-family: 'Space Grotesk', sans-serif; color: var(--ink); }
.card-head p { font-size: 12.5px; color: var(--text-3); margin-top: 3px; }
.card-body { padding: 20px 24px 24px; }

/* ---------- Hero Banner ---------- */
.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(120deg, var(--primary-dark) 0%, var(--primary) 60%, #128F67 100%);
  border-radius: var(--radius-lg);
  padding: 38px 40px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}
.hero-pattern { position: absolute; inset: 0; opacity: .16; pointer-events: none; }
.hero-text { position: relative; max-width: 560px; }
.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  font-weight: 600;
  background: rgba(255,255,255,.14);
  padding: 6px 12px;
  border-radius: 20px;
  margin-bottom: 14px;
}
.hero-eyebrow .pulse { width: 6px; height: 6px; border-radius: 50%; background: #5EEAB0; animation: pulse 1.8s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.hero h2 { font-size: 28px; color: #fff; font-weight: 700; letter-spacing: -.01em; }
.hero p { font-size: 14.5px; color: rgba(255,255,255,.82); margin-top: 9px; line-height: 1.55; }
.hero-actions { display: flex; gap: 12px; margin-top: 22px; position: relative; }

.hero-side { position: relative; flex-shrink: 0; display: flex; gap: 22px; }
.hero-metric { text-align: center; }
.hero-metric .n { font-family: 'IBM Plex Mono', monospace; font-size: 26px; font-weight: 600; }
.hero-metric .l { font-size: 11px; color: rgba(255,255,255,.7); margin-top: 4px; letter-spacing: .02em; }
.hero-metric + .hero-metric { border-left: 1px solid rgba(255,255,255,.22); padding-left: 22px; }

/* ---------- Buttons ---------- */
.btn, .btn-theme, .btn-accent, .btn-outline, .btn-ghost, .btn-danger {
  border: 0;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
  cursor: pointer;
}
.btn:hover, .btn-theme:hover, .btn-accent:hover, .btn-outline:hover, .btn-danger:hover {
  transform: translateY(-1px);
}
.btn-accent {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 20px -6px rgba(255,138,91,.6);
}
.btn-theme, .btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 18px -4px rgba(15,123,88,.4);
}
.btn-theme:hover, .btn-primary:hover {
  background: var(--primary-dark);
  color: #fff;
}
.btn-outline {
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-outline:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}
.btn-ghost {
  background: rgba(255,255,255,.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,.3);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-sm {
  padding: 7px 12px;
  font-size: 12px;
  border-radius: 8px;
}

/* ---------- Stats Cards ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 22px;
}
.stat-card, .stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease;
}
.stat-card:hover, .stat:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.stat-top { display: flex; align-items: flex-start; justify-content: space-between; }
.stat-icon, .stat .iconbox {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 17px;
  background: var(--primary-light);
  color: var(--primary-dark);
}
.stat-icon.p { background: var(--primary-light); color: var(--primary-dark); }
.stat-icon.a { background: var(--accent-light); color: #D9642E; }
.stat-icon.i { background: var(--info-light); color: var(--info); }
.delta {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 20px;
}
.delta.up { color: #0D8A57; background: #E4F7ED; }
.delta.down { color: #C4472B; background: #FCEAE6; }
.stat-num, .stat strong {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 27px;
  font-weight: 600;
  color: var(--ink);
  margin-top: 14px;
  letter-spacing: -.01em;
  display: block;
}
.stat-label, .stat span { font-size: 13px; color: var(--text-2); margin-top: 3px; display: block; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 24px; margin-top: 14px; }
.spark i { flex: 1; background: var(--primary-light); border-radius: 2px; transition: background .15s; }
.stat-card:hover .spark i, .stat:hover .spark i { background: var(--primary); }

/* ---------- Quick actions ---------- */
.quick-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}
.quick-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 13px;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.quick-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.quick-ic {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
}
.quick-card:nth-child(2) .quick-ic { background: var(--accent); }
.quick-card:nth-child(3) .quick-ic { background: var(--info); }
.quick-card:nth-child(4) .quick-ic { background: var(--ink); }
.quick-txt b { display: block; font-size: 13.5px; font-weight: 600; color: var(--text); }
.quick-txt span { font-size: 11.5px; color: var(--text-3); }

/* ---------- Segmented Control & Timeline ---------- */
.seg { display: flex; background: var(--bg); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; font-size: 12px; font-weight: 600; color: var(--text-2);
  padding: 6px 12px; border-radius: 7px;
}
.seg button.active { background: var(--surface); color: var(--primary-dark); box-shadow: var(--shadow-sm); }

.legend { display: flex; gap: 16px; margin-top: 2px; }
.legend span { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

.chart { display: flex; align-items: flex-end; gap: 14px; height: 220px; margin-top: 22px; padding: 0 4px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bars { display: flex; align-items: flex-end; gap: 5px; height: 100%; }
.bar { width: 15px; border-radius: 5px 5px 2px 2px; transition: height 1s cubic-bezier(.2,.8,.2,1); }
.bar.sent { background: var(--primary-light); }
.bar.engaged { background: linear-gradient(180deg,#17B26A,var(--primary-dark)); }
.chart-col .m { font-size: 11.5px; color: var(--text-3); font-weight: 500; }

.timeline { display: flex; flex-direction: column; }
.t-item { display: flex; gap: 14px; position: relative; padding-bottom: 22px; }
.t-item:last-child { padding-bottom: 0; }
.t-item::before {
  content: ""; position: absolute; left: 15px; top: 32px; bottom: 0; width: 1.5px; background: var(--border);
}
.t-item:last-child::before { display: none; }
.t-ic {
  width: 31px; height: 31px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; font-size: 13px; z-index: 1;
}
.t-ic.ok { background: var(--primary-light); color: var(--primary-dark); }
.t-ic.send { background: var(--accent-light); color: #D9642E; }
.t-ic.imp { background: var(--info-light); color: var(--info); }
.t-body b { display: block; font-size: 13.5px; font-weight: 600; color: var(--text); }
.t-body p { font-size: 12.5px; color: var(--text-2); margin: 3px 0 0; line-height: 1.5; }
.t-body time { font-size: 11px; color: var(--text-3); display: block; margin-top: 5px; }

.view-all {
  display: block; text-align: center; font-size: 12.5px; font-weight: 600; color: var(--primary-dark);
  padding: 12px; margin: 6px -24px -24px; border-top: 1px solid var(--border);
}
.view-all:hover { background: var(--primary-light); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; margin-top: 12px; }
.table { width: 100%; border-collapse: collapse; text-align: left; }
.table th {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-3);
  background: var(--bg);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
}
.table td strong { color: var(--ink); font-weight: 600; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: var(--primary-light); }

/* ---------- Status Badges ---------- */
.status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}
.status.active { background: var(--primary-light); color: var(--primary-dark); }
.status.pending { background: var(--accent-light); color: #D9642E; }
.status.draft { background: var(--info-light); color: var(--info); }
.status.rejected { background: #FCEAE6; color: #C4472B; }

/* ---------- Forms & Inputs ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.full { grid-column: 1 / -1; }
.field label {
  display: block;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--ink);
  margin-bottom: 7px;
}
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  outline: 0;
  background: var(--surface);
  color: var(--text);
  font-size: 14.5px;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { min-height: 110px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15,123,88,.12);
}

/* ---------- Grid Layouts ---------- */
.grid-2 { display: grid; grid-template-columns: 1.65fr 1fr; gap: 20px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }

/* ==========================================================
   AUTO FLOW / WORKFLOW BUILDER (workflow-builder.html)
   ========================================================== */
.flow-canvas { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 10px 4px 24px; }
.flow-row { display: flex; align-items: center; gap: 0; min-width: max-content; }
.flow-node {
  width: 150px; min-width: 150px; border-radius: 12px; padding: 12px 14px;
  text-align: center; cursor: pointer; border: 1.5px solid var(--border);
  background: var(--surface); transition: .15s; position: relative;
}
.flow-node:hover { border-color: var(--primary); transform: translateY(-2px); }
.flow-node.selected { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,123,88,.14); }
.flow-node .fn-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; margin: 0 auto 8px; font-size: 14px; }
.flow-node .fn-title { font-size: 11px; font-weight: 700; color: var(--ink); font-family: 'Space Grotesk', sans-serif; }
.flow-node .fn-sub { font-size: 9.5px; color: var(--text-3); margin-top: 2px; }
.flow-node.start .fn-ico { background: var(--primary-light); color: var(--primary-dark); }
.flow-node.step .fn-ico { background: var(--info-light); color: var(--info); }
.flow-node.menu .fn-ico { background: var(--accent-light); color: #D9642E; }
.flow-node.end .fn-ico { background: var(--bg); color: var(--text-2); }
.flow-arrow { width: 34px; min-width: 34px; height: 2px; background: var(--border); position: relative; }
.flow-arrow:after { content: ""; position: absolute; right: 0; top: -4px; border: 5px solid transparent; border-left-color: var(--border); }

.menu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; }
.menu-opt {
  border: 1.5px solid var(--border); border-radius: 11px; padding: 12px;
  cursor: pointer; background: var(--surface); transition: .15s; display: flex; gap: 10px; align-items: flex-start;
}
.menu-opt:hover { border-color: var(--primary); }
.menu-opt.selected { border-color: var(--primary); background: var(--primary-light); box-shadow: 0 0 0 3px rgba(15,123,88,.1); }
.menu-opt .mo-num { width: 22px; height: 22px; min-width: 22px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.menu-opt .mo-body b { display: block; font-size: 12px; color: var(--ink); font-family: 'Space Grotesk', sans-serif; }
.menu-opt .mo-body span { font-size: 10.5px; color: var(--text-3); }

.wf-split { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; align-items: start; }
.wf-editor { border: 1px solid var(--border); border-radius: 12px; padding: 16px; background: var(--bg); }
.wf-editor h4 { margin: 0 0 12px; font-size: 12px; color: var(--ink); font-family: 'Space Grotesk', sans-serif; }
.wf-editor .empty { color: var(--text-3); font-size: 11px; text-align: center; padding: 30px 10px; }

/* Chat preview simulator */
.chat-sim { border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: #e9edf1; }
.chat-sim-head { background: var(--ink); color: #fff; padding: 12px 16px; display: flex; align-items: center; gap: 10px; font-size: 12px; }
.chat-sim-head .csa { width: 28px; height: 28px; border-radius: 50%; background: var(--primary); display: grid; place-items: center; font-size: 13px; color: #fff; }
.chat-sim-body { height: 360px; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.chat-bubble { max-width: 82%; padding: 9px 12px; border-radius: 12px; font-size: 11.5px; line-height: 1.55; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.06); align-self: flex-start; border-bottom-left-radius: 3px; color: var(--text); }
.chat-bubble.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 3px; border-bottom-left-radius: 12px; }
.chat-bubble b { display: block; margin-bottom: 3px; }
.chat-quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.chat-quick button { border: 1px solid var(--primary); background: #fff; color: var(--primary-dark); border-radius: 20px; padding: 6px 12px; font-size: 10.5px; font-weight: 600; cursor: pointer; }
.chat-quick button:hover { background: var(--primary); color: #fff; }
.chat-sim-foot { padding: 10px 14px; background: #fff; border-top: 1px solid var(--border); display: flex; justify-content: center; }

/* ==========================================================
   CAMPAIGN CREATION WIZARD (create-campaign.html)
   ========================================================== */
.wizard-steps { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 26px; position: relative; }
.wizard-steps:before { content: ""; position: absolute; top: 16px; left: 5%; right: 5%; height: 2px; background: var(--border); z-index: 0; }
.wizard-step { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 1; text-align: center; cursor: pointer; }
.wizard-step .num { width: 32px; height: 32px; border-radius: 50%; background: #fff; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: var(--text-3); transition: .2s; }
.wizard-step .lbl { font-size: 11px; color: var(--text-3); font-weight: 600; }
.wizard-step.done .num { background: var(--primary); border-color: var(--primary); color: #fff; }
.wizard-step.done .lbl { color: var(--primary-dark); }
.wizard-step.active .num { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 0 0 4px rgba(15,123,88,.14); }
.wizard-step.active .lbl { color: var(--primary-dark); font-weight: 700; }

.step-panel { display: none; }
.step-panel.active { display: block; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.radio-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.radio-card { border: 1.5px solid var(--border); border-radius: 12px; padding: 16px; cursor: pointer; transition: .15s; position: relative; background: #fff; }
.radio-card:hover { border-color: var(--primary); }
.radio-card.selected { border-color: var(--primary); background: var(--primary-light); box-shadow: 0 0 0 3px rgba(15,123,88,.08); }
.radio-card i { font-size: 20px; color: var(--primary); margin-bottom: 8px; display: block; }
.radio-card h4 { margin: 0 0 4px; font-size: 13px; color: var(--ink); font-family: 'Space Grotesk', sans-serif; }
.radio-card p { margin: 0; font-size: 11px; color: var(--text-2); }
.radio-card .check { position: absolute; top: 12px; right: 12px; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--border); display: grid; place-items: center; }
.radio-card.selected .check { background: var(--primary); border-color: var(--primary); }
.radio-card.selected .check:after { content: "✓"; color: #fff; font-size: 10px; font-weight: 700; }

.content-type-row { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.content-type-btn { display: flex; align-items: center; gap: 8px; border: 1.5px solid var(--border); border-radius: 10px; padding: 10px 16px; cursor: pointer; background: #fff; color: var(--text); font-weight: 600; font-size: 12px; }
.content-type-btn i { font-size: 15px; }
.content-type-btn.selected { border-color: var(--primary); background: var(--primary); color: #fff; }

.wizard-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
.preview-panel { border: 1px solid var(--border); border-radius: 12px; padding: 16px; background: var(--bg); height: fit-content; }
.preview-panel h4 { margin: 0 0 12px; font-size: 12px; color: var(--ink); display: flex; align-items: center; gap: 6px; font-family: 'Space Grotesk', sans-serif; }
.preview-body { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 14px; min-height: 180px; }
.preview-body .ph-title { font-weight: 700; color: var(--ink); font-size: 13px; margin-bottom: 6px; font-family: 'Space Grotesk', sans-serif; }
.preview-body .ph-text { font-size: 11px; color: var(--text); line-height: 1.6; }
.preview-body .ph-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 150px; color: var(--text-3); gap: 8px; }
.preview-body .ph-empty i { font-size: 28px; }

.schedule-options { display: flex; gap: 14px; margin-bottom: 16px; }
.schedule-opt { flex: 1; border: 1.5px solid var(--border); border-radius: 10px; padding: 14px; cursor: pointer; display: flex; align-items: center; gap: 10px; }
.schedule-opt.selected { border-color: var(--primary); background: var(--primary-light); }
.schedule-opt input { accent-color: var(--primary); }

.review-box { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.review-sec { padding: 16px 18px; border-bottom: 1px solid var(--border); }
.review-sec:last-child { border-bottom: 0; }
.review-sec .rh { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.review-sec .rh b { font-size: 12px; color: var(--ink); font-family: 'Space Grotesk', sans-serif; }
.review-sec .rh a { font-size: 11px; color: var(--primary-dark); font-weight: 600; cursor: pointer; }
.review-row { display: flex; justify-content: space-between; font-size: 12px; padding: 4px 0; color: var(--text-2); }
.review-row span:last-child { color: var(--ink); font-weight: 600; }

.wizard-nav { display: flex; justify-content: space-between; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.success-box { text-align: center; padding: 50px 20px; }
.success-box i { font-size: 56px; color: var(--primary); margin-bottom: 16px; display: block; }
.success-box h2 { margin: 0 0 8px; color: var(--ink); font-family: 'Space Grotesk', sans-serif; }
.success-box p { color: var(--text-2); margin: 0 0 22px; }

/* ==========================================================
   BRAND MANAGEMENT & CARDS (brand-management.html)
   ========================================================== */
.brand-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.brand-card { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); overflow: hidden; transition: .2s; }
.brand-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.brand-logo-box { height: 150px; background: var(--bg); display: flex; align-items: center; justify-content: center; border-bottom: 1px solid var(--border); }
.brand-logo-box img { max-width: 150px; max-height: 100px; object-fit: contain; }
.brand-card-content { padding: 17px 18px; }
.brand-card-content h3 { margin: 0 0 7px; color: var(--ink); font-size: 17px; font-family: 'Space Grotesk', sans-serif; }
.brand-card-content p { margin: 0 0 12px; color: var(--text-3); font-size: 12px; }
.brand-card-content p i { color: var(--primary); margin-right: 5px; }
.brand-card-actions { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; }

/* ==========================================================
   USER MANAGEMENT MODAL & PASSWORDS (user-management.html)
   ========================================================== */
.add-user-overlay { display: none; position: fixed; inset: 0; z-index: 9999; background: rgba(11,43,38,.5); align-items: center; justify-content: center; padding: 20px; }
.add-user-overlay.show { display: flex; }
.add-user-modal { width: 100%; max-width: 720px; max-height: 92vh; overflow: auto; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-md); border: 1px solid var(--border); }
.add-user-header { display: flex; justify-content: space-between; padding: 22px 24px; border-bottom: 1px solid var(--border); }
.add-user-header h2 { margin: 0; color: var(--ink); font-size: 21px; font-family: 'Space Grotesk', sans-serif; }
.add-user-header p { margin: 5px 0 0; color: var(--text-3); font-size: 12px; }
.modal-close { border: 0; width: 34px; height: 34px; border-radius: 8px; cursor: pointer; background: var(--bg); color: var(--text-2); display: grid; place-items: center; }
.add-user-modal form { padding: 24px; }
.password-box { position: relative; }
.password-box input { padding-right: 45px; }
.password-box button { position: absolute; right: 5px; top: 5px; width: 34px; height: 34px; border: 0; background: transparent; cursor: pointer; color: var(--text-3); display: grid; place-items: center; }
.add-user-footer { margin: 22px -24px -24px; padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ==========================================================
   CONTENT LIBRARY & ASSET GRIDS (content-library.html)
   ========================================================== */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tab { padding: 10px 14px; color: var(--text-3); font-size: 12px; border-bottom: 2px solid transparent; cursor: pointer; font-weight: 500; }
.tab.active { color: var(--primary); border-color: var(--primary); font-weight: 700; }
.image-box { height: 180px; border-radius: 12px; overflow: hidden; background: linear-gradient(135deg,#e8f6f0,#dce9ee); display: grid; place-items: center; color: var(--primary); font-size: 40px; }
.image-box img { width: 100%; height: 100%; object-fit: cover; }
.mini-card { padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.mini-card h3 { font-size: 14px; color: var(--ink); margin: 0 0 8px; font-family: 'Space Grotesk', sans-serif; }
.mini-card p { font-size: 12px; color: var(--text-2); margin: 0; line-height: 1.6; }

/* ---------- Switch control ---------- */
.switch { width: 40px; height: 22px; border-radius: 20px; background: #cbd5e1; display: inline-block; padding: 3px; cursor: pointer; transition: .2s; }
.switch i { display: block; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: margin-left .2s; }
.switch.on { background: var(--primary); }
.switch.on i { margin-left: 18px; }

/* ---------- Mobile Overlay ---------- */
.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11,43,38,.5);
  z-index: 9500;
}
.mobile-overlay.show { display: block; }

/* ==========================================================
   COMPREHENSIVE RESPONSIVE BREAKPOINTS (4K to 320px Mobile)
   ========================================================== */

@media (max-width: 1400px) {
  .content { padding: 24px; }
}

@media (max-width: 1200px) {
  .grid-2, .wf-split, .wizard-grid { grid-template-columns: 1fr; }
  .stats, .quick-row { grid-template-columns: repeat(2, 1fr); }
  .brand-grid, .menu-grid { grid-template-columns: repeat(2, 1fr); }
  .hero { padding: 32px 30px; }
}

@media (max-width: 992px) {
  .search-box, .searchbar:not(.card-head .searchbar) { display: none; }
  .hero-side { display: none; }
  .radio-cards { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .shell, .app { flex-direction: column; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w) !important;
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.2,.8,.2,1);
    z-index: 10000;
    box-shadow: 0 0 50px rgba(0,0,0,.4);
  }
  .sidebar.open { transform: translateX(0); }
  
  body.collapsed .sidebar,
  body.sidebar-collapsed .sidebar {
    width: var(--sidebar-w) !important;
    transform: translateX(-100%);
  }
  body.collapsed .sidebar.open,
  body.sidebar-collapsed .sidebar.open {
    transform: translateX(0);
  }
  body.collapsed .brand-word,
  body.sidebar-collapsed .brand-word,
  body.sidebar-collapsed .brand img,
  body.sidebar-collapsed .nav-label,
  body.sidebar-collapsed .label,
  body.sidebar-collapsed .item span,
  body.sidebar-collapsed .side-foot > div:not(.avatar) {
    display: revert !important;
  }
  body.collapsed .nav-item,
  body.sidebar-collapsed .nav-item,
  body.sidebar-collapsed .item {
    justify-content: flex-start;
    padding: 11px 12px;
  }
  
  .hamb { display: grid !important; }
  .toggle-btn, .sidebar-toggle { display: none !important; }
  .close-side, .brand .close { display: grid !important; }
  
  .topbar { height: 64px; padding: 0 16px; }
  .topbar h1 { font-size: 17px; }
  .crumb { display: none; }
  .content { padding: 16px; }
  
  .hero { flex-direction: column; align-items: flex-start; padding: 24px; }
  .hero h2 { font-size: 22px; }
  .hero p { font-size: 13.5px; }
  .hero-actions { width: 100%; flex-wrap: wrap; }
  .hero-actions .btn { flex: 1; min-width: 140px; justify-content: center; }

  .card-head { flex-direction: column; align-items: flex-start; gap: 14px; }
  .card-head > div:last-child { width: 100%; justify-content: flex-start; flex-wrap: wrap; }

  .pc-toast-wrap { left: 14px; right: 14px; bottom: 14px; }
  .pc-toast { min-width: 0; max-width: none; }
}

@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr; }
  .quick-row { grid-template-columns: 1fr; }
  .brand-grid, .menu-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  
  .user-pill .who, .user-text { display: none; }
  .user-pill, .user { padding: 4px; }
  
  .wizard-step .lbl { display: none; }
  .wizard-steps:before { left: 10%; right: 10%; }
  
  .schedule-options { flex-direction: column; }
  
  .pc-modal { width: 95vw; margin: 10px; max-height: 92vh; }
  .pc-modal-head, .pc-modal-body, .pc-modal-foot { padding: 14px 16px; }
  
  .table th, .table td { padding: 10px 10px; font-size: 12px; }
}

@media (max-width: 420px) {
  .topbar { padding: 0 12px; }
  .content { padding: 12px; }
  .card-body { padding: 16px; }
  .stat-card, .stat { padding: 16px; }
  .stat-num, .stat strong { font-size: 22px; }
}

/* ==========================================================
   TOAST & MODAL DIALOG POLISH
   ========================================================== */
.pc-toast-wrap {
  position: fixed; right: 22px; bottom: 22px; z-index: 12000;
  display: flex; flex-direction: column; gap: 10px;
}
.pc-toast {
  min-width: 260px; max-width: 390px; padding: 12px 15px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-md); display: flex; align-items: center; gap: 10px;
  color: var(--text); font-size: 13px; transform: translateY(14px); opacity: 0; transition: .25s;
}
.pc-toast.show { transform: translateY(0); opacity: 1; }
.pc-toast i { font-size: 17px; color: var(--primary); }
.pc-toast.error i { color: var(--danger); }

.pc-modal-overlay {
  position: fixed; inset: 0; z-index: 11000; background: rgba(11,43,38,.5);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; visibility: hidden; transition: .18s;
}
.pc-modal-overlay.show { opacity: 1; visibility: visible; }
.pc-modal {
  width: min(680px, 100%); max-height: 90vh; overflow: auto; background: var(--surface);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md); border: 1px solid var(--border);
  transform: translateY(12px); transition: .2s;
}
.pc-modal-overlay.show .pc-modal { transform: translateY(0); }
.pc-modal-head {
  padding: 20px 24px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; gap: 15px;
}
.pc-modal-head h3 { margin: 0; color: var(--ink); font-size: 18px; font-family: 'Space Grotesk', sans-serif; }
.pc-modal-head p { margin: 4px 0 0; color: var(--text-3); font-size: 12px; }
.pc-modal-close {
  border: 0; background: var(--bg); color: var(--text-2);
  border-radius: 8px; width: 34px; height: 34px; font-size: 21px; cursor: pointer;
}
.pc-modal-body { padding: 22px 24px; }
.pc-modal-foot {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}
.pc-detail-row {
  display: flex; justify-content: space-between; gap: 15px; padding: 11px 0; border-bottom: 1px solid var(--border);
}
.pc-detail-row span { color: var(--text-3); font-size: 12px; }
.pc-detail-row b { color: var(--ink); font-size: 13px; text-align: right; }

/* ===== Header User Menu (Profile / Logout) ===== */
.user-menu{position:relative}
.user-menu-dropdown{
  position:absolute; top:calc(100% + 10px); right:0; min-width:190px;
  background:var(--surface,#fff); border:1px solid var(--border,#E7E9EE);
  border-radius:12px; box-shadow:0 12px 30px rgba(20,25,40,.14);
  padding:8px; opacity:0; visibility:hidden; transform:translateY(8px);
  transition:.16s ease; z-index:200;
}
.user-menu-dropdown.open{opacity:1; visibility:visible; transform:translateY(0)}
.user-menu-item{
  display:flex; align-items:center; gap:10px; padding:10px 12px; border-radius:8px;
  color:var(--ink,#1B2430); font-size:13.5px; font-weight:500; text-decoration:none;
  transition:.12s;
}
.user-menu-item i{font-size:15px; color:var(--text-3,#8A93A6); width:16px; text-align:center}
.user-menu-item:hover{background:var(--bg,#F5F6F9)}
.user-menu-item.user-menu-logout{color:#E5484D}
.user-menu-item.user-menu-logout i{color:#E5484D}


/* Global dropdown viewport safety - no page scrollbar caused by opening a dropdown */
html, body { max-width:100%; overflow-x:hidden; }
.pc-select2 { min-width:0; position:relative; }
.pc-select2-dropdown { max-width:min(100%,420px); }
.pc-select2-options { max-height:min(230px,38vh); overflow-y:auto; overflow-x:hidden; scrollbar-width:thin; }
.pc-select2-option { min-width:0; white-space:normal; overflow-wrap:anywhere; }
.pc-select2.drop-up .pc-select2-dropdown { top:auto; bottom:calc(100% + 5px); }


/* Division selector in the top navigation */
.division-switcher{position:relative;margin-right:4px}
.division-switcher-btn{height:38px;display:flex;align-items:center;gap:7px;padding:0 11px;border:1px solid var(--border,#dfe8e4);background:#fff;border-radius:9px;color:var(--ink,#15251f);font:600 11px Inter,Arial,sans-serif;cursor:pointer;white-space:nowrap}
.division-switcher-btn i:first-child{color:var(--primary,#008f62);font-size:13px}.division-switcher-btn i:last-child{color:var(--text-3,#8a93a6);font-size:10px}
.division-switcher-btn:hover{background:var(--bg,#f5f6f9);border-color:#cfe0da}
.division-dropdown{position:absolute;right:0;top:44px;width:190px;padding:6px;background:#fff;border:1px solid #e3ebe7;border-radius:10px;box-shadow:0 16px 35px rgba(24,42,35,.14);opacity:0;visibility:hidden;transform:translateY(-4px);transition:.15s ease;z-index:1100}
.division-dropdown.open{opacity:1;visibility:visible;transform:translateY(0)}
.division-dropdown button{width:100%;display:flex;align-items:center;gap:8px;border:0;background:#fff;padding:9px 10px;border-radius:7px;color:var(--ink,#15251f);font:500 11px Inter,Arial,sans-serif;text-align:left;cursor:pointer}
.division-dropdown button:hover{background:var(--bg,#f5f6f9);color:var(--primary,#008f62)}
.division-dropdown button i{font-size:7px;color:var(--primary,#008f62)}
@media(max-width:760px){.division-switcher-btn span{display:none}.division-switcher-btn{padding:0 9px}.division-dropdown{right:-35px}}
