:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --sidebar: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --border: #d2d2d7;
  --blue: #007aff;
  --blue-hover: #0051d5;
  --green: #34c759;
  --orange: #ff9500;
  --red: #ff3b30;
  --gray: #8e8e93;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 260px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #25d366, #128c7e);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
}

.brand h1 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.2px;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s ease;
}

.nav-item:hover { background: rgba(0, 0, 0, 0.04); }
.nav-item.active { background: rgba(0, 122, 255, 0.1); color: var(--blue); }

.nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
}
.nav-item.active .nav-dot { background: var(--blue); }

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: 72px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(245, 245, 247, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.topbar h2 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.5px;
  margin: 0;
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
}

.page { display: none; animation: fade 0.2s ease; }
.page.active { display: block; }

@keyframes fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 20px;
}

.card.centered { max-width: 480px; margin: 40px auto; text-align: center; }

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
}

.card-body { padding: 24px; }

.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.kv { display: flex; flex-direction: column; gap: 4px; }
.kv-key { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px; }
.kv-value { font-size: 15px; font-weight: 500; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #e5e5ea;
  color: var(--text);
}
.status-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.tooltip-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: help;
}

.tooltip-icon .tooltip-text {
  visibility: hidden;
  opacity: 0;
  width: 320px;
  background: #1c1c1e;
  color: #f5f5f7;
  text-align: left;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.5;
  font-weight: 400;
  position: absolute;
  z-index: 100;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  box-shadow: var(--shadow-lg);
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.tooltip-icon .tooltip-text::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -6px;
  border-width: 6px;
  border-style: solid;
  border-color: #1c1c1e transparent transparent transparent;
}

.tooltip-icon:hover .tooltip-text,
.tooltip-icon:focus .tooltip-text {
  visibility: visible;
  opacity: 1;
}

.tooltip-icon code {
  background: rgba(255,255,255,0.15);
  padding: 1px 4px;
  border-radius: 4px;
  font-family: "SF Mono", Menlo, Monaco, Consolas, monospace;
}

  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-top: 16px;
  font-size: 13px;
}
.alert-error { background: rgba(255, 59, 48, 0.08); color: #c41e14; }
.hidden { display: none !important; }

.qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.qr-placeholder {
  width: 300px;
  height: 300px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 2px dashed var(--border);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
}
.qr-image {
  width: 300px;
  height: 300px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
}

.muted { color: var(--muted); font-size: 14px; margin: 0; }

.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  background: #fafafa;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
}
.input.code { font-family: "SF Mono", Menlo, Monaco, Consolas, monospace; }

.btn {
  border: none;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.05s, background 0.15s;
  font-family: inherit;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { background: var(--blue-hover); }
.btn-secondary { background: #e5e5ea; color: var(--text); }
.btn-secondary:hover { background: #d1d1d6; }

.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-item {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: #fafafa;
  border: 1px solid var(--border);
}

.list-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 140px;
}
.list-phone { font-weight: 600; font-size: 13px; }
.list-time { font-size: 12px; color: var(--muted); }
.list-body { flex: 1; font-size: 14px; word-break: break-word; }
.list-badge {
  align-self: flex-start;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(0, 122, 255, 0.1);
  color: var(--blue);
  text-transform: uppercase;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.media-item {
  border-radius: var(--radius-sm);
  background: #fafafa;
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.media-thumb {
  height: 140px;
  display: grid;
  place-items: center;
  background: #f0f0f2;
}
.media-thumb img { max-width: 100%; max-height: 100%; object-fit: cover; }
.media-info { padding: 10px; font-size: 12px; }
.media-info a { color: var(--blue); text-decoration: none; }

.log-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}
.log-row {
  padding: 8px 10px;
  border-radius: 8px;
  background: #fafafa;
  border-left: 3px solid var(--border);
}
.log-row.info { border-left-color: var(--blue); }
.log-row.warn { border-left-color: var(--orange); }
.log-row.error { border-left-color: var(--red); }
.log-time { color: var(--muted); margin-right: 8px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}
@media (max-width: 900px) { .grid-3 { grid-template-columns: 1fr; } }

.label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin: 16px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

textarea.input { width: 100%; resize: vertical; }

.code-block {
  background: #1c1c1e;
  color: #f5f5f7;
  padding: 16px;
  border-radius: var(--radius-sm);
  overflow: auto;
  font-family: "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  min-height: 280px;
  max-height: 60vh;
  white-space: pre-wrap;
  word-break: break-word;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 18px;
  border-radius: 12px;
  background: rgba(29, 29, 31, 0.92);
  color: white;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateY(0); }

.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--muted);
  font-size: 14px;
}
/* WhatsApp Web-style messages screen */

.whatsapp-layout {
  display: flex;
  height: calc(100vh - 72px); /* below topbar */
  background: #dddbd1;
  overflow: hidden;
  border-radius: 0;
  box-shadow: none;
  border: none;
  margin: -24px -32px; /* counter .content padding */
}

.whatsapp-sidebar {
  width: 30%;
  min-width: 300px;
  max-width: 420px;
  background: #fff;
  border-right: 1px solid #d1d7db;
  display: flex;
  flex-direction: column;
}

.whatsapp-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #efeae2;
  position: relative;
}

.whatsapp-chat::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(#d1d7db 1.5px, transparent 1.5px);
  background-size: 24px 24px;
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
}

.whatsapp-header {
  height: 59px;
  background: #f0f2f5;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid #d1d7db;
  z-index: 1;
}

.sidebar-header {
  gap: 12px;
}

.whatsapp-sidebar-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

.whatsapp-new-chat {
  padding: 10px 12px;
  background: #f0f2f5;
  border-bottom: 1px solid #e9edef;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.whatsapp-new-chat-actions {
  display: flex;
  gap: 8px;
}

.whatsapp-new-chat .input {
  background: #fff;
}

.whatsapp-title {
  font-size: 16px;
  font-weight: 600;
  color: #111b21;
}

.whatsapp-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #dfe5e7;
  color: #54656f;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.whatsapp-search {
  height: 49px;
  background: #f0f2f5;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #e9edef;
}

.whatsapp-search input {
  flex: 1;
  border: none;
  border-radius: 8px;
  background: #fff;
  padding: 8px 12px 8px 34px;
  font-size: 14px;
  color: #111b21;
  outline: none;
}

.whatsapp-search .search-icon {
  position: absolute;
  left: 22px;
  font-size: 13px;
  opacity: 0.5;
}

.whatsapp-contacts {
  flex: 1;
  overflow-y: auto;
  background: #fff;
}

.wa-contact {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f0f2f5;
  transition: background 0.15s;
}

.wa-contact:hover { background: #f5f6f6; }
.wa-contact.active { background: #e9edef; }

.wa-contact-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wa-contact-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.wa-contact-name {
  font-size: 15px;
  font-weight: 500;
  color: #111b21;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wa-contact-time {
  font-size: 11px;
  color: #667781;
  flex-shrink: 0;
}

.wa-contact-preview {
  font-size: 13px;
  color: #667781;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wa-account-label {
  font-size: 11px;
  color: var(--blue);
  font-weight: 500;
  margin-right: 2px;
}

.chat-header {
  padding-left: 16px;
  gap: 12px;
}

.chat-header-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.chat-header-name {
  font-size: 15px;
  font-weight: 500;
  color: #111b21;
}

.chat-header-status {
  font-size: 12px;
  color: #667781;
}

.whatsapp-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 8%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 1;
}

.wa-empty-chat {
  margin: auto;
  color: #667781;
  font-size: 14px;
  background: rgba(255,255,255,0.7);
  padding: 12px 20px;
  border-radius: 8px;
}

.wa-message-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
}

.wa-message {
  max-width: 65%;
  padding: 6px 8px 4px 9px;
  border-radius: 7.5px;
  font-size: 14px;
  line-height: 1.4;
  color: #111b21;
  position: relative;
  word-wrap: break-word;
  box-shadow: 0 1px 0.5px rgba(11,20,26,.13);
  align-self: flex-start;
}

.wa-message.in {
  background: #fff;
  border-top-left-radius: 0;
}

.wa-message.out {
  background: #d9fdd3;
  border-top-right-radius: 0;
  align-self: flex-end;
}

.wa-message-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.wa-message-time {
  font-size: 10px;
  color: #667781;
}

.wa-message-type {
  font-size: 10px;
  color: #8696a0;
  text-transform: uppercase;
}

.trace-ai-btn {
  padding: 2px 8px;
  font-size: 11px;
  line-height: 1.2;
}

.wa-message-media {
  max-width: 100%;
  border-radius: 6px;
  margin-bottom: 4px;
  display: block;
}

.wa-message-media video,
.wa-message-media img {
  max-width: 100%;
  border-radius: 6px;
}

.wa-message-audio {
  width: 100%;
  max-width: 260px;
  height: 36px;
  margin-bottom: 4px;
  display: block;
}

.wa-message-author {
  font-size: 11px;
  font-weight: 600;
  color: #00a884;
  margin-bottom: 2px;
}

.wa-message-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,0.04);
  padding: 8px 10px;
  border-radius: 6px;
  color: #111b21;
  text-decoration: none;
  font-size: 13px;
  margin-bottom: 4px;
}

.wa-message-location {
  background: rgba(0,0,0,0.04);
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 4px;
}

.wa-message-location-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #008069;
  font-weight: 500;
  text-decoration: none;
}

.wa-message-location-link:hover {
  text-decoration: underline;
}

.wa-message-location-desc {
  font-size: 13px;
  color: #111b21;
  margin-top: 4px;
}

.wa-message-location-thumb {
  max-width: 240px;
  border: 1px solid rgba(0,0,0,0.08);
}

.whatsapp-input-area {
  height: 62px;
  background: #f0f2f5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  z-index: 1;
}

.whatsapp-input-area input {
  flex: 1;
  border: none;
  border-radius: 8px;
  background: #fff;
  padding: 10px 14px;
  font-size: 15px;
  color: #111b21;
  outline: none;
}

.whatsapp-input-area input:disabled {
  background: #e9edef;
  color: #8696a0;
}

.wa-send-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: #00a884;
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}

.wa-send-btn:hover { background: #008f72; }
.wa-send-btn:disabled { background: #a0a0a0; cursor: not-allowed; }

.wa-attach-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #54656f;
  font-size: 18px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}

.wa-attach-btn:hover { background: #e9edef; }
.wa-attach-btn:disabled { color: #a0a0a0; cursor: not-allowed; }

@media (max-width: 900px) {
  .whatsapp-sidebar { min-width: 240px; }
  .whatsapp-messages { padding: 16px 4%; }
  .whatsapp-info { display: none; }
}

.whatsapp-info {
  width: 25%;
  min-width: 260px;
  max-width: 320px;
  background: #fff;
  border-left: 1px solid #d1d7db;
  display: flex;
  flex-direction: column;
  z-index: 1;
  overflow-y: auto;
}

.whatsapp-info-header {
  height: 59px;
  background: #f0f2f5;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  border-bottom: 1px solid #d1d7db;
}

.whatsapp-info-section {
  padding: 16px;
  border-bottom: 1px solid #f0f2f5;
}

.whatsapp-info-section h4 {
  margin: 0 0 8px 0;
  font-size: 13px;
  font-weight: 600;
  color: #667781;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.whatsapp-info-section .muted {
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}

.info-context-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.info-context-item {
  background: #f0f2f5;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
}

.info-context-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #667781;
  margin-bottom: 4px;
}

.info-context-body {
  color: #111b21;
  word-break: break-word;
  line-height: 1.4;
}

.whatsapp-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  background: #fff;
  border-bottom: 1px solid #f0f2f5;
}

.wa-filter {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f0f2f5;
  font-size: 12px;
  color: #54656f;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.wa-filter:hover { background: #e9edef; }

.wa-filter input {
  width: 14px;
  height: 14px;
  accent-color: #00a884;
  cursor: pointer;
}

/* Broadcast page */
#bc-recipients {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  background: var(--surface);
  margin-bottom: 12px;
}

.bc-contact {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.bc-contact:hover { background: rgba(0, 0, 0, 0.03); }

.bc-contact-name {
  font-weight: 500;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bc-contact-phone {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bc-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.bc-toolbar button {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13px;
  cursor: pointer;
}

.bc-toolbar button:hover { background: #f2f2f7; }

.bc-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.bc-variants {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0 12px;
  font-size: 13px;
  color: #6e6e73;
}

.bc-variant-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  background: #f5f5f7;
  border-radius: 8px;
}

.bc-variant-num {
  flex-shrink: 0;
  min-width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  background: #007aff;
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.bc-variant-text {
  flex: 1;
  white-space: pre-wrap;
  word-break: break-word;
  color: #1d1d1f;
}

.bc-variant-item .btn {
  flex-shrink: 0;
}

.bc-item {
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

.bc-item:last-child { border-bottom: none; }

.bc-item-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.bc-item-meta {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.bc-item-actions {
  display: flex;
  gap: 8px;
}

.bc-item-status {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 20px;
}

.bc-scheduled { background: #e5e5ea; color: #555; }
.bc-sending { background: #fff3cd; color: #856404; }
.bc-paused { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.bc-completed { background: #d4edda; color: #155724; }
.bc-failed { background: #f8d7da; color: #721c24; }
.bc-cancelled { background: #e2e3e5; color: #383d41; }
.bc-posted { background: #d1ecf1; color: #0c5460; }

/* Instagram campaigns */
.insta-stats { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.insta-stats .stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  min-width: 90px;
  text-align: center;
}
.insta-stats .stat-value { font-size: 20px; font-weight: 700; color: var(--blue); }
.insta-stats .stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

.insta-campaign-card { cursor: default; }
.insta-campaign-card .insta-card-caption {
  color: var(--text);
  font-size: 13px;
  margin: 6px 0;
  line-height: 1.4;
}
.insta-thumbs { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.insta-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.insta-comment {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  background: var(--bg);
}
.insta-comment-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 4px;
}
.insta-comment-text { font-size: 14px; margin-bottom: 6px; }
.insta-comment-reply {
  font-size: 13px;
  color: #155724;
  background: #d4edda;
  padding: 6px 10px;
  border-radius: 8px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* Collections page */
.collection-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  height: calc(100vh - 140px);
}

.collection-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.collection-sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.collection-sidebar-header h3 { margin: 0; font-size: 16px; }

.collection-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.collection-item {
  padding: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease;
}

.collection-item:hover { background: rgba(0, 0, 0, 0.04); }
.collection-item.active { background: rgba(0, 122, 255, 0.1); }

.collection-item-name { font-weight: 600; font-size: 14px; }
.collection-item-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }

.collection-main { overflow-y: auto; }

.collection-empty {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
}

.collection-meta { display: flex; gap: 8px; margin-top: 8px; }

.badge {
  background: rgba(0, 0, 0, 0.04);
  color: var(--muted);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
}

.badge.success { background: #d1fae5; color: #065f46; }
.badge.warning { background: #fef3c7; color: #92400e; }
.badge.error { background: #fee2e2; color: #991b1b; }

.collection-upload-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-top: 8px;
}

.collection-upload-row > div { flex: 1; }

.collection-documents {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.collection-doc {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.02);
}

.collection-doc-name { font-weight: 600; font-size: 14px; }
.collection-doc-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.collection-doc-actions { display: flex; gap: 8px; }

.status-pending { color: var(--orange); }
.status-indexing { color: var(--blue); }
.status-indexed { color: var(--green); }
.status-failed { color: var(--red); }

/* Agent auto-response indicator */
.agent-auto {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.agent-auto-responded {
  background: #d4edda;
  color: #155724;
}

.agent-auto-not-required {
  background: #fff3cd;
  color: #856404;
}

/* Product Promotions page */
.promotion-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  height: calc(100vh - 140px);
}

.promotion-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.promotion-sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.promotion-sidebar-header h3 { margin: 0; font-size: 16px; }

.promotion-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.promotion-item {
  padding: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease;
}

.promotion-item:hover { background: rgba(0, 0, 0, 0.04); }
.promotion-item.active { background: rgba(0, 122, 255, 0.1); }

.promotion-item-name { font-weight: 600; font-size: 14px; }
.promotion-item-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }

.promotion-main { overflow-y: auto; }

.promotion-empty {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
}

.promotion-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.promotion-buckets {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.promotion-bucket {
  flex: 1;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}

.promotion-bucket-count { font-size: 20px; font-weight: 700; }
.promotion-bucket-label { font-size: 12px; color: var(--muted); text-transform: capitalize; }

.promotion-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.promotion-tab {
  padding: 10px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

.promotion-tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.promotion-tab-pane { display: none; }
.promotion-tab-pane.active { display: block; }

.promotion-toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.promotion-toolbar .input { max-width: 300px; }

.promotion-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 400px;
  overflow-y: auto;
}

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

.promotion-table th,
.promotion-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.promotion-table th {
  background: rgba(0, 0, 0, 0.03);
  font-weight: 600;
  position: sticky;
  top: 0;
}

.promotion-table tbody tr:hover { background: rgba(0, 0, 0, 0.02); }

.promotion-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  font-size: 13px;
}

.promotion-selected {
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 13px;
  min-height: 60px;
  max-height: 120px;
  overflow-y: auto;
}

/* CRM pages */
.crm-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  height: calc(100vh - 140px);
}

.crm-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.crm-sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.crm-sidebar-header h3 { margin: 0; font-size: 16px; }

.crm-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.crm-list-item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease;
  background: rgba(0,0,0,0.02);
}

.crm-list-item:hover { background: rgba(0,0,0,0.04); }
.crm-list-item.active { background: rgba(0,122,255,0.1); border-color: var(--blue); }

.crm-list-item-title { font-weight: 600; font-size: 14px; }
.crm-list-item-meta { color: var(--muted); font-size: 12px; margin-top: 4px; }

.ad-responder-item-body {
  font-size: 13px;
  color: var(--text);
  margin-top: 6px;
  line-height: 1.4;
}

.badge-new { background: #e0f2fe; color: #0369a1; }
.badge-reviewed { background: #f3f4f6; color: #4b5563; }
.badge-contacted { background: #fef3c7; color: #92400e; }
.badge-converted { background: #d1fae5; color: #065f46; }
.badge-dropped { background: #fee2e2; color: #991b1b; }

.crm-main { overflow-y: auto; }

.crm-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.crm-tab {
  padding: 10px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

.crm-tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.crm-kanban {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.crm-card {
  background: rgba(0,0,0,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.crm-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.crm-card-title { font-weight: 600; font-size: 14px; }
.crm-card-meta { color: var(--muted); font-size: 12px; }
.crm-card-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

.crm-priority-high { color: var(--red); }
.crm-priority-medium { color: var(--orange); }
.crm-priority-low { color: var(--green); }

.crm-visits-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.crm-visit-day {
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
}

.crm-visit-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.crm-visit-time {
  min-width: 60px;
  font-size: 13px;
  font-weight: 600;
  color: var(--blue);
}

.crm-visit-body { flex: 1; }
.crm-visit-title { font-weight: 600; font-size: 14px; }
.crm-visit-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }

.crm-section {
  margin-bottom: 16px;
}

.crm-section h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin: 0 0 8px;
}

.crm-section ul {
  margin: 0;
  padding-left: 18px;
  font-size: 14px;
  line-height: 1.5;
}

.crm-section li { margin-bottom: 4px; }

.crm-empty { padding: 40px; text-align: center; color: var(--muted); font-size: 14px; }

.crm-customer-profile {
  background: rgba(0,0,0,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 13px;
  white-space: pre-wrap;
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal.hidden { display: none; }

.modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

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

.modal-header h3 { margin: 0; font-size: 16px; }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.input-sm {
  padding: 6px 10px;
  font-size: 13px;
}

/* Postings page */
.postings-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  height: calc(100vh - 140px);
}
.postings-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.postings-sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.postings-sidebar-header h3 { margin: 0; font-size: 16px; }
.postings-product-list {
  flex: 1;
  overflow: auto;
  padding: 8px;
}
.postings-product-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 4px;
}
.postings-product-item:hover { background: rgba(0,0,0,0.04); }
.postings-product-item.active { background: rgba(0,122,255,0.1); color: var(--blue); }
.postings-product-item .muted { font-size: 12px; }
.postings-empty {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
}
.postings-product-info {
  background: var(--bg);
  padding: 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}
.postings-creatives {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.postings-creative-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: pointer;
  background: var(--surface);
}
.postings-creative-card:hover { border-color: var(--blue); }
.postings-creative-card img,
.postings-creative-card video {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 8px;
}
.postings-creative-media {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.postings-creative-media img,
.postings-creative-media video {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.postings-platform-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.postings-platform-tab {
  padding: 8px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
}
.postings-platform-tab.active {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}
.postings-platform-preview {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  background: var(--bg);
  min-height: 120px;
}
.postings-platform-preview img,
.postings-platform-preview video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  display: block;
}
.postings-format-frame {
  background: #f5f5f7;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 280px;
  margin-bottom: 8px;
}
.postings-platform-accounts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.postings-account-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.postings-account-row input[type="checkbox"] { margin-right: 6px; }
.postings-accounts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow: auto;
}
.postings-form-factor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.postings-form-factor-tile {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  background: var(--surface);
  transition: border-color .15s, background .15s;
}
.postings-form-factor-tile:hover { border-color: var(--blue); }
.postings-form-factor-tile.active {
  border-color: var(--blue);
  background: rgba(0,122,255,0.08);
}
.postings-form-factor-tile .ff-icon { font-size: 24px; display: block; margin-bottom: 4px; }
.postings-form-factor-tile .ff-label { font-size: 12px; font-weight: 500; }
.postings-form-factor-tile .ff-desc { font-size: 10px; color: var(--muted); margin-top: 2px; line-height: 1.2; }
.postings-format-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.postings-format-tile {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 6px;
  text-align: center;
  cursor: pointer;
  background: var(--surface);
  transition: border-color .15s, background .15s;
}
.postings-format-tile:hover { border-color: var(--blue); }
.postings-format-tile.active {
  border-color: var(--blue);
  background: rgba(0,122,255,0.08);
}
.postings-format-tile .fmt-icon { font-size: 20px; display: block; margin-bottom: 3px; }
.postings-format-tile .fmt-label { font-size: 11px; font-weight: 500; }
.postings-format-tile .fmt-dim { font-size: 9px; color: var(--muted); margin-top: 2px; }
.postings-post-type-btns {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.postings-post-type-btn {
  padding: 4px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 11px;
}
.postings-post-type-btn.active {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}

.audience-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  background: #6366f1;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.progress-bar {
  width: 100%;
  height: 12px;
  background: var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--blue);
  transition: width 0.3s ease;
}

/* Marketplace */
.marketplace-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.marketplace-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

.marketplace-card:hover {
  box-shadow: var(--shadow);
}

.marketplace-card-media {
  aspect-ratio: 1;
  background: var(--bg);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.marketplace-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.marketplace-card-noimg {
  color: var(--muted);
  font-size: 13px;
}

.marketplace-card-body {
  padding: 12px;
}

.marketplace-card-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}

.marketplace-card-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.marketplace-card-price {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  margin-bottom: 4px;
}

.marketplace-card-stock {
  font-size: 12px;
  color: var(--green);
  margin-bottom: 4px;
}

.marketplace-card-tags {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

@media (max-width: 900px) {
  .postings-layout { grid-template-columns: 1fr; height: auto; }
  .postings-sidebar { max-height: 300px; }
  .crm-layout { grid-template-columns: 1fr; height: auto; }
  .crm-sidebar { max-height: 300px; }
}
