/* ================================================================
 * FinEdu CRM Dashboard — Stylesheet
 * ================================================================ */

/* === CSS Variables / Theming === */
/* Fin Education Consultants CRM — palette sampled from the company logo:
   #0048AC royal blue (ring + wordmark), #FC301C / #FC7434 / #FCDC58
   (the hummingbird gradient, red -> orange -> gold). */
:root {
  --bg-primary: #F4F7FB;        /* cool porcelain — main canvas */
  --bg-secondary: #E7EFF9;      /* soft sky — sidebar / panels */
  --bg-card: #FFFFFF;           /* clean white cards */
  --bg-input: #F7FAFD;          /* barely-blue inputs */
  --text-primary: #0E2138;      /* deep navy ink */
  --text-secondary: #3F5872;    /* slate blue */
  --text-muted: #5F7590;        /* muted blue-gray */
  --border: #D6E2F0;            /* cool light border */
  --border-light: #E7EFF9;
  --primary: #0048AC;           /* Fin Education logo blue */
  --primary-hover: #003784;
  --primary-light: rgba(0, 72, 172, 0.08);
  --success: #137A52;           /* deep green */
  --success-light: rgba(19, 122, 82, 0.12);
  --warning: #BD5C0D;           /* darkened hummingbird orange */
  --warning-light: rgba(252, 116, 52, 0.16);
  --danger: #D42B18;            /* hummingbird red */
  --danger-light: rgba(252, 48, 28, 0.12);
  --info: #1D6FD8;              /* lighter brand blue */
  --info-light: rgba(29, 111, 216, 0.12);
  --shadow-sm: 0 1px 2px rgba(10, 35, 70, 0.05);
  --shadow: 0 1px 3px rgba(10, 35, 70, 0.08), 0 1px 2px rgba(10, 35, 70, 0.05);
  --shadow-lg: 0 8px 24px rgba(10, 35, 70, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --chat-customer: #FFE7D2;     /* warm peach — from the hummingbird */
  --chat-customer-text: #33200F;
  --chat-ai: #E6EDF6;           /* cool gray-blue — AI bubbles */
  --chat-ai-text: #0E2138;
  --chat-agent: #0048AC;        /* logo blue — agent replies */
  --chat-agent-text: #FFFFFF;
}

[data-theme="dark"] {
  /* Dark mode: deep navy drawn from the logo ring, not a neutral gray */
  --bg-primary: #0A1524;
  --bg-secondary: #0F1F33;
  --bg-card: #14283F;
  --bg-input: #1B3350;
  --text-primary: #E8F0FA;
  --text-secondary: #A8BFD6;
  --text-muted: #8299B2;
  --border: #24405F;
  --border-light: #14283F;
  --primary: #5FA0F0;           /* lifted logo blue, readable on navy */
  --primary-hover: #7DB4F7;
  --primary-light: rgba(95, 160, 240, 0.16);
  --success: #34C48A;
  --success-light: rgba(52, 196, 138, 0.20);
  --warning: #F59642;
  --warning-light: rgba(252, 116, 52, 0.22);
  --danger: #F4705C;
  --danger-light: rgba(252, 48, 28, 0.22);
  --info: #6BA8F5;
  --info-light: rgba(107, 168, 245, 0.20);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow: 0 1px 3px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.6);
  --chat-customer: #3A2A1C;
  --chat-customer-text: #F6EBE0;
  --chat-ai: #1E3550;
  --chat-ai-text: #E8F0FA;
  --chat-agent: #5FA0F0;
  --chat-agent-text: #08172A;
}

/* === Reset === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
}

a { color: var(--primary); text-decoration: none; }

/* === Login Screen === */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-secondary);
}

.login-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo i {
  font-size: 48px;
  color: var(--primary);
  margin-bottom: 12px;
}

.login-logo h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.login-logo p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]),
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input[type="checkbox"],
.form-group input[type="radio"] {
  width: auto;
  margin: 0 4px 0 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--danger-light);
  border-radius: var(--radius-sm);
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { opacity: 0.9; }

.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover:not(:disabled) { opacity: 0.9; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { opacity: 0.9; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-secondary); color: var(--text-primary); }

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

.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 16px;
}
.icon-btn:hover { background: var(--bg-secondary); color: var(--text-primary); }

/* === Layout === */
#main-app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* === Sidebar === */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s;
  z-index: 100;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: #FFFFFF;
  border: 1px solid var(--border);
  color: var(--primary);
  font-size: 22px;
  flex-shrink: 0;
  overflow: hidden;
}
.sidebar-logo img { width: 100%; height: 100%; object-fit: contain; }

.sidebar-header i {
  font-size: 24px;
  color: var(--primary);
}

.sidebar-title {
  display: flex; flex-direction: column; line-height: 1.15;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}
.sidebar-title small {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 2px;
}

.sidebar-toggle-mobile {
  display: none;
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
}

.sidebar-nav {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.18s ease;
  margin-bottom: 4px;
  position: relative;
}

.nav-item:hover {
  background: rgba(107, 66, 38, 0.06);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.nav-item.active i { color: #fff; }

.nav-item i { width: 20px; text-align: center; }

/* Collapsible nav group headers */
.nav-group-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  transition: all 0.18s ease;
}
.nav-group-header:hover {
  background: rgba(107, 66, 38, 0.06);
  color: var(--text-primary);
}
.nav-group-header > i:first-child { width: 20px; text-align: center; }
.nav-group-header span { flex: 1; }
.nav-chevron {
  font-size: 11px;
  opacity: 0.6;
  transition: transform 0.2s ease;
}
.nav-group-header.collapsed .nav-chevron { transform: rotate(-90deg); }

.nav-group {
  overflow: hidden;
  max-height: 600px;
  transition: max-height 0.25s ease;
}
.nav-group.collapsed { max-height: 0; }

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 18px;
  height: 18px;
  text-align: center;
  letter-spacing: 0.02em;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.nav-badge-group {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.nav-badge-unread {
  /* unread = primary brand brown so it reads "to-do" without alarm */
  background: var(--primary);
}
.nav-badge-human {
  /* new human mode = warning amber — needs attention NOW */
  background: var(--warning);
  animation: badge-pulse 2s ease-in-out infinite;
}
.nav-item.active .nav-badge {
  /* keep contrast when row is active (white text on brown bg) */
  background: rgba(255,255,255,0.25);
  color: #fff;
}

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

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

.sidebar-actions {
  display: flex;
  gap: 4px;
}

/* === Main Content === */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.top-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  height: var(--topbar-height);
  min-height: var(--topbar-height);
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.top-bar h2 {
  font-size: 18px;
  font-weight: 600;
  flex: 1;
}

.menu-btn { display: none; }

.connection-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
}
.connection-dot.connected { background: var(--success); }

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

/* === Stats Cards === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-icon.success { background: var(--success-light); color: var(--success); }
.stat-icon.warning { background: var(--warning-light); color: var(--warning); }
.stat-icon.info { background: var(--info-light); color: var(--info); }

.stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

/* === Charts === */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.chart-card h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chart-card canvas {
  width: 100% !important;
  max-height: 250px;
}

/* === Table === */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.table-header h3 {
  font-size: 16px;
  font-weight: 600;
  margin-right: auto;
}

.search-input {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
}

.search-input i { color: var(--text-muted); font-size: 14px; }

.search-input input {
  border: none;
  background: none;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  width: 180px;
  font-family: inherit;
}

.filter-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.filter-tab,
.filter-tabs button {
  padding: 7px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
  font-family: inherit;
  letter-spacing: 0.02em;
}

.filter-tab:hover,
.filter-tabs button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.filter-tab.active,
.filter-tabs button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 1px 2px rgba(74, 45, 23, 0.18);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px 20px;
  text-align: left;
  font-size: 13px;
  border-bottom: 1px solid var(--border-light);
}

th {
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
  background: var(--bg-secondary);
}

tr:hover td { background: var(--bg-secondary); }

.table-empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
}

.table-empty i {
  font-size: 48px;
  margin-bottom: 12px;
  display: block;
}

/* === Badges === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-ai { background: var(--info-light); color: var(--info); }
.badge-human { background: var(--warning-light); color: var(--warning); }
.badge-closed { background: var(--bg-secondary); color: var(--text-muted); }

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* === Session List Cards === */
.sessions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0;
}

.session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  gap: 12px;
  transition: all 0.16s ease;
  box-shadow: var(--shadow-sm);
}

.session-row:hover {
  background: var(--bg-card);
  border-color: var(--border);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.session-row.session-unread {
  border-left: 4px solid var(--primary);
  background: linear-gradient(90deg, rgba(107, 66, 38, 0.06) 0%, var(--bg-card) 22%);
  box-shadow: 0 0 0 1px var(--primary-light), var(--shadow-sm);
}
.session-row.session-unread .session-name { font-weight: 700; color: var(--text-primary); }
.session-row.session-unread .session-preview { color: var(--text-primary); font-weight: 500; }

.session-row.session-order-interest {
  border-left: 4px solid var(--warning);
  background: linear-gradient(90deg, rgba(193,154,82,0.10) 0%, var(--bg-card) 25%);
}
.session-row.session-order-alert {
  border-left: 4px solid #D97706;  /* deeper amber/orange = more urgent than warning */
  background: linear-gradient(90deg, rgba(217,119,6,0.14) 0%, var(--bg-card) 25%);
  box-shadow: 0 0 0 1px rgba(217,119,6,0.18), var(--shadow-sm);
}
.session-row.session-payment-alert {
  border-left: 4px solid #DC2626;  /* red = top-priority */
  background: linear-gradient(90deg, rgba(220,38,38,0.12) 0%, var(--bg-card) 25%);
  box-shadow: 0 0 0 1px rgba(220,38,38,0.20), var(--shadow-sm);
}
.session-row.session-ordered {
  border-left: 4px solid var(--success);
  background: linear-gradient(90deg, rgba(93,142,90,0.08) 0%, var(--bg-card) 25%);
}
/* Priority cascade when multiple flags overlap: payment > order_alert > ordered > order_interest > unread */
.session-row.session-unread.session-order-interest { border-left-color: var(--warning); }
.session-row.session-unread.session-order-alert { border-left-color: #D97706; }
.session-row.session-unread.session-payment-alert { border-left-color: #DC2626; }
.session-row.session-unread.session-ordered { border-left-color: var(--success); }
.session-row.session-payment-alert.session-order-alert { border-left-color: #DC2626; }
.session-row.session-payment-alert.session-ordered { border-left-color: #DC2626; }

.order-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.02em;
  margin-left: 6px; vertical-align: middle;
  white-space: nowrap;
}
.order-badge-interest {
  background: var(--warning-light); color: var(--warning);
  animation: order-pulse 2.5s ease-in-out infinite;
}
.order-badge-alert {
  background: rgba(217,119,6,0.18); color: #B45309;
  animation: order-pulse 2s ease-in-out infinite;
}
.order-badge-payment {
  background: rgba(220,38,38,0.18); color: #B91C1C;
  animation: payment-pulse 1.6s ease-in-out infinite;
  font-weight: 800;
}
.order-badge-done {
  background: var(--success-light); color: var(--success);
}
@keyframes payment-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(220,38,38,0.3); }
  50%      { transform: scale(1.08); box-shadow: 0 0 0 4px rgba(220,38,38,0); }
}

/* Per-flag toggle buttons in chat header — show outline when inactive, filled when set */
.flag-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.flag-btn:hover { border-color: var(--text-primary); color: var(--text-primary); }
.flag-btn-interest.active { background: var(--warning); color: #fff; border-color: var(--warning); }
.flag-btn-alert.active    { background: #D97706; color: #fff; border-color: #D97706; }
.flag-btn-payment.active  { background: #DC2626; color: #fff; border-color: #DC2626; }
.flag-btn-ordered.active  { background: var(--success); color: #fff; border-color: var(--success); }
.flag-btn-interest:hover  { color: var(--warning); border-color: var(--warning); }
.flag-btn-alert:hover     { color: #D97706; border-color: #D97706; }
.flag-btn-payment:hover   { color: #DC2626; border-color: #DC2626; }
.flag-btn-ordered:hover   { color: var(--success); border-color: var(--success); }
@keyframes order-pulse {
  0%, 100% { transform: scale(1); opacity: 0.95; }
  50% { transform: scale(1.06); opacity: 1; }
}

.badge-new {
  display: inline-flex; align-items: center;
  background: var(--primary); color: #fff;
  font-size: 9px; font-weight: 800;
  letter-spacing: 0.08em;
  padding: 2px 7px; border-radius: 999px;
  margin-right: 6px;
  animation: badge-pulse 2.4s ease-in-out infinite;
  vertical-align: middle;
}
@keyframes badge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(107, 66, 38, 0.45); }
  50%      { box-shadow: 0 0 0 5px rgba(107, 66, 38, 0); }
}

.unread-indicator {
  position: absolute; top: -2px; right: -2px;
  width: 12px; height: 12px;
  background: var(--primary); border-radius: 50%;
  border: 2px solid var(--bg-card);
  box-shadow: 0 0 0 2px rgba(107, 66, 38, 0.18);
}

.session-lead-row {
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
  margin-top: 4px;
}
.session-lead-name {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; color: var(--primary);
  background: var(--primary-light); padding: 2px 8px;
  border-radius: 999px;
}

.session-row-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.session-avatar {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  position: relative;
}

.status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--bg-card);
}

.dot-ai { background: var(--info); }
.dot-human { background: var(--warning); }
.dot-closed { background: var(--text-muted); }

.session-info { min-width: 0; flex: 1; }

.session-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-channel {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 6px;
}

.session-preview {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.session-row-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  min-width: 90px;
}

.session-time { font-size: 11px; color: var(--text-muted); }
.session-meta { font-size: 10px; color: var(--text-muted); }

/* === Chat Layout (Split View) === */
.chat-layout {
  display: flex;
  height: calc(100vh - var(--topbar-height) - 48px);
  gap: 0;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  flex-wrap: wrap;
}

.chat-action-btns {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.chat-sidebar {
  width: 300px;
  min-width: 300px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  overflow-y: auto;
}

.sidebar-panel-toggle {
  display: none;
}

.panel-content {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

/* Customer Info Panel */
.customer-info-panel {
  margin-bottom: 20px;
}

.customer-info-panel h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  gap: 8px;
}

.info-label {
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}

.info-value {
  color: var(--text-primary);
  font-weight: 500;
  text-align: right;
  word-break: break-all;
}

.session-id-code {
  font-size: 10px;
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
}

/* Notes Panel */
.notes-panel h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.note-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 13px;
}

.note-text {
  line-height: 1.5;
  margin-bottom: 4px;
}

.note-meta {
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.note-delete {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 10px;
  padding: 2px;
  margin-left: auto;
}

.note-input {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.note-input textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  padding: 8px 10px;
  resize: none;
  outline: none;
}

.note-input textarea:focus {
  border-color: var(--primary);
}

/* Chat Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  position: relative;
  word-break: break-word;
}

.msg-text { white-space: pre-wrap; }

.msg-customer {
  align-self: flex-start;
  background: var(--chat-customer);
  color: var(--chat-customer-text);
  border-bottom-left-radius: 4px;
}

.msg-ai {
  align-self: flex-start;
  background: var(--chat-ai);
  color: var(--chat-ai-text);
  border-bottom-left-radius: 4px;
}

.msg-agent {
  align-self: flex-end;
  background: var(--chat-agent);
  color: var(--chat-agent-text);
  border-bottom-right-radius: 4px;
}

.msg-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

.msg-agent .msg-meta { color: rgba(255,255,255,0.7); }

.msg-system {
  align-self: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  padding: 6px 16px;
  border-radius: 20px;
  text-align: center;
}

/* WhatsApp-style day separator — small centered chip injected between
   messages whenever the calendar day changes. Stretches across the
   full chat width with a hairline that fades behind the chip so the
   eye locks onto the date label. */
.msg-day-divider {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 14px 0 6px;
  position: relative;
}
.msg-day-divider::before {
  content: '';
  position: absolute;
  left: 8%;
  right: 8%;
  top: 50%;
  height: 1px;
  background: var(--border);
  opacity: 0.6;
}
.msg-day-divider span {
  position: relative;
  z-index: 1;
  background: var(--bg-main, var(--bg-card));
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.chat-input-bar textarea {
  flex: 1;
  border: none;
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  resize: none;
  min-height: 44px;
  max-height: 120px;
  outline: none;
}

/* Voice-note recording row — replaces the input row while recording */
#chat-record-bar { align-items: center; gap: 10px; }
.rec-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  background: #ef4444;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
  animation: rec-pulse 1.2s ease-out infinite;
}
@keyframes rec-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
  70%  { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* === Knowledge Base Cards === */
.kb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.kb-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: box-shadow 0.2s;
}

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

.kb-card-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.kb-category {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary);
  background: var(--primary-light);
  padding: 2px 8px;
  border-radius: 4px;
}

.kb-card h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
}

.kb-card p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kb-card-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

.kb-priority {
  font-size: 11px;
  color: var(--text-muted);
}

.kb-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
}

.kb-status.active { background: var(--success-light); color: var(--success); }
.kb-status.inactive { background: var(--danger-light); color: var(--danger); }

/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

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

.modal-header h3 { font-size: 16px; font-weight: 600; }

.modal-body { padding: 24px; }

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

/* === Toast === */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease;
  max-width: 360px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--info); }

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

/* === Pagination === */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px 20px;
  border-top: 1px solid var(--border-light);
}

.pagination button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}

.pagination button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.pagination button:disabled { opacity: 0.3; cursor: not-allowed; }

/* === Responsive === */
@media (max-width: 1024px) {
  .chat-sidebar {
    width: 260px;
    min-width: 260px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
  }

  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle-mobile { display: block; }
  .menu-btn { display: flex; }

  .page-content { padding: 12px; }
  .charts-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .table-header { flex-direction: column; align-items: stretch; }
  .kb-grid { grid-template-columns: 1fr; }
  .hide-mobile { display: none !important; }

  /* Chat mobile layout */
  .chat-layout { flex-direction: column; height: calc(100vh - var(--topbar-height) - 24px); }

  .chat-sidebar {
    width: 100%;
    min-width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: none;
    overflow: visible;
  }

  .sidebar-panel-toggle { display: flex !important; margin: 8px 16px; }
  .panel-content { display: none; }
  .panel-content.panel-open { display: block; }
  .chat-sidebar.panel-expanded { flex: 0 0 auto; }

  .msg-bubble { max-width: 85%; }

  .chat-top-actions { padding: 6px 0; }
  .chat-action-btns { margin-left: auto; }
  .chat-action-btns .btn { padding: 6px 8px; font-size: 11px; }

  .session-row { padding: 10px 12px; }
  .session-row-right { min-width: 70px; }

  /* Modal mobile */
  .modal { max-width: 95vw; margin: 12px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 22px; }
  .filter-tabs { flex-wrap: wrap; }
  .chat-action-btns { flex-wrap: wrap; }
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* === Utilities === */
/* === Dashboard Filters === */
.dash-filters {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.date-range-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.date-range-picker label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.date-range-picker input[type="date"] {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
}

.date-range-picker input[type="date"]:focus {
  outline: none;
  border-color: var(--primary);
}

.quick-filters {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.stat-icon.closed { background: var(--bg-secondary); color: var(--text-muted); }

.clickable { cursor: pointer; }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-muted { color: var(--text-muted); }
.text-small { font-size: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }

/* ================================================================
 * Settings Page
 * ================================================================ */
.settings-page {
  max-width: 900px;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.settings-header h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.settings-group {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 20px;
  overflow: hidden;
}

.settings-group-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border);
}

.settings-group-header i {
  font-size: 20px;
  color: var(--primary);
  width: 28px;
  text-align: center;
}

.settings-group-header h4 {
  margin: 0;
  font-size: 15px;
}

.settings-group-header p {
  margin: 2px 0 0;
}

.settings-items {
  padding: 4px 0;
}

.setting-item {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  align-items: start;
}

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

.setting-item.setting-empty {
  background: rgba(245, 158, 11, 0.03);
}

.setting-label {
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.setting-desc {
  margin-top: 4px;
  line-height: 1.4;
}

.setting-key {
  margin-top: 2px;
}

.setting-control {
  display: flex;
  flex-direction: column;
}

.setting-input-group {
  display: flex;
  gap: 4px;
}

.setting-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace, sans-serif;
  min-width: 0;
}

.setting-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.setting-meta {
  grid-column: 1 / -1;
  font-size: 11px;
  padding-top: 4px;
}

/* Settings Mobile */
@media (max-width: 768px) {
  .setting-item {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .settings-header {
    flex-direction: column;
  }
}

/* ================================================================
 * LEADS
 * ================================================================ */
.nav-sub { padding-left: 32px; font-size: 13px; opacity: 0.85; }

.leads-toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 16px; padding: 12px; background: var(--surface);
  border-radius: 10px; border: 1px solid var(--border);
}
.leads-search {
  flex: 1; min-width: 220px; position: relative;
}
.leads-search input {
  width: 100%; padding: 8px 12px 8px 32px;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; font-size: 14px;
}
.leads-search i {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}
.leads-filter {
  padding: 7px 10px; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; font-size: 13px; min-width: 130px;
}
.leads-count { padding: 8px 12px; color: var(--text-muted); font-size: 13px; }
.leads-table { width: 100%; border-collapse: collapse; }
.leads-table th, .leads-table td {
  padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border);
  font-size: 14px; vertical-align: middle;
}
.leads-table th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.leads-table tr:hover { background: var(--surface-hover, rgba(255,255,255,0.03)); }

.lead-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; margin: 2px 4px 2px 0;
  background: var(--primary); color: #fff;
  border-radius: 999px; font-size: 12px; font-weight: 500;
  white-space: nowrap;
}
.lead-chip .fa-times {
  cursor: pointer; opacity: 0.7; margin-left: 2px; font-size: 10px;
}
.lead-chip .fa-times:hover { opacity: 1; }
.lead-chip-list { background: #475569; }

.tag-input-wrap {
  display: flex; flex-direction: column; gap: 6px;
  padding: 6px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; min-height: 38px;
}
.tag-chips { display: flex; flex-wrap: wrap; gap: 2px; }
.tag-input-row { position: relative; }
.tag-input {
  width: 100%; padding: 6px 8px; background: transparent;
  border: none; outline: none; color: var(--text); font-size: 14px;
}
.tag-suggest-list {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; margin-top: 4px; max-height: 240px; overflow-y: auto;
  z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.tag-suggest-item {
  padding: 8px 12px; cursor: pointer; font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.tag-suggest-item:last-child { border-bottom: none; }
.tag-suggest-item:hover { background: var(--surface-hover, rgba(255,255,255,0.05)); }
.tag-suggest-create { color: var(--primary); font-weight: 500; }

.lead-form-panel {
  margin-top: 16px; padding-top: 16px;
  border-top: 1px solid var(--border);
}
.lead-form-panel h4 {
  display: flex; align-items: center; gap: 6px;
  margin: 0 0 12px; font-size: 14px; color: var(--text);
}
.lead-status-line {
  margin-top: 8px; font-size: 12px; color: var(--success, #10b981);
  display: flex; align-items: center; gap: 6px;
}
.lead-session-link {
  margin-top: 8px; padding: 8px 12px; background: var(--bg);
  border: 1px dashed var(--border); border-radius: 8px;
  font-size: 13px; color: var(--text-muted);
}
.lead-session-link a { color: var(--primary); }

.leads-settings-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}
@media (max-width: 768px) { .leads-settings-grid { grid-template-columns: 1fr; } }
.settings-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px;
}
.settings-card-head {
  display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px;
}
.settings-card-head h3 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.row-add { display: flex; gap: 6px; }
.row-add input[type="text"] {
  flex: 1; padding: 6px 10px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px; color: var(--text);
}
.row-add input[type="color"] {
  width: 36px; height: 32px; border: 1px solid var(--border);
  border-radius: 6px; background: transparent; cursor: pointer;
}
.ls-row {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.ls-row:last-child { border-bottom: none; }
.ls-row .ls-name {
  flex: 1; padding: 6px 10px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px; color: var(--text);
}
.ls-row .ls-color {
  width: 32px; height: 28px; border: 1px solid var(--border);
  border-radius: 6px; background: transparent; cursor: pointer;
}
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text-muted);
}
.empty-state i { font-size: 48px; opacity: 0.4; margin-bottom: 12px; }

/* === Product Portfolio v2 === */

/* Product card additions */
.product-card-meta {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  font-size: 11px; margin-top: 3px;
}
.product-card-num {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  padding: 1px 7px; border-radius: 4px;
  font-family: ui-monospace, monospace;
}
.product-card-stock { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 3px; }
.product-card-var {
  font-size: 11px; color: var(--text-secondary);
  margin-top: 4px;
}
.product-card-var i { margin-right: 4px; opacity: 0.6; }
.price-sale { color: var(--primary); font-weight: 700; }
.price-was { text-decoration: line-through; opacity: 0.5; font-weight: 400; font-size: 0.85em; margin-left: 4px; }

/* Stock chips */
.stock-chip {
  display: inline-block;
  padding: 1px 7px; border-radius: 4px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.02em;
  text-transform: uppercase;
}
.stock-in_stock          { background: var(--success-light); color: var(--success); }
.stock-out_of_stock      { background: var(--danger-light); color: var(--danger); }
.stock-retired           { background: var(--bg-secondary); color: var(--text-muted); }
.stock-orders_only       { background: var(--warning-light); color: var(--warning); }
.stock-bulk_orders_only  { background: var(--info-light); color: var(--info); }
.stock-upcoming          { background: var(--primary-light); color: var(--primary); }

/* Stock pill multi-select (in modal) */
.stock-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.stock-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  background: var(--bg-card);
  transition: all 0.15s ease;
  user-select: none;
}
.stock-pill input { margin: 0; accent-color: var(--primary); }
.stock-pill:has(input:checked) {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

/* Product modal — collapsible sections */
.pm-section {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  background: var(--bg-card);
  overflow: hidden;
}
.pm-section-head {
  width: 100%; padding: 10px 14px;
  background: var(--bg-secondary); border: none; border-bottom: 1px solid transparent;
  font-weight: 600; font-size: 13px; color: var(--text-primary);
  font-family: inherit; text-align: left; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
}
.pm-section-head i { transition: transform 0.2s ease; opacity: 0.6; font-size: 11px; }
.pm-section.open .pm-section-head { border-bottom-color: var(--border-light); }
.pm-section.open .pm-section-head i { transform: rotate(180deg); }
.pm-section-body { padding: 14px; display: none; }
.pm-section.open .pm-section-body { display: block; }

.pm-inline-err {
  margin-top: 6px;
  padding: 8px 10px;
  background: var(--danger-light);
  color: var(--danger);
  border-radius: 6px;
  font-size: 12px;
}

/* Smart Optimize — per-product inline button row + suggestion card */
.pm-optimize-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(16,185,129,.08), rgba(16,185,129,.02));
  border: 1px dashed rgba(16,185,129,.3);
  border-radius: var(--radius);
}
.pm-opt-card {
  margin: 8px 0 16px;
  padding: 14px;
  background: var(--bg-secondary);
  border: 1px solid rgba(16,185,129,.4);
  border-radius: var(--radius);
}
.pm-opt-head {
  font-weight: 600;
  margin-bottom: 10px;
  color: #10b981;
}
.opt-readonly {
  padding: 8px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}
.opt-readonly-long {
  max-height: 180px;
  overflow-y: auto;
}

/* Categories tree */
.cat-tree {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  overflow: hidden;
}
.cat-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.12s ease;
}
.cat-row:last-child { border-bottom: none; }
.cat-row:hover { background: var(--bg-secondary); }
.cat-name { display: flex; align-items: center; gap: 4px; font-size: 14px; }
.cat-meta { font-size: 11px; color: var(--text-muted); margin-left: 8px; }
.cat-actions { display: flex; gap: 4px; }

/* WooCommerce import log */
.woo-log {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  max-height: 220px;
  overflow-y: auto;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* === Products grid === */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  padding: 4px 0;
}
.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.16s ease;
  box-shadow: var(--shadow-sm);
}
.product-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.product-card-inactive { opacity: 0.55; }
.product-card-image {
  width: 100%; aspect-ratio: 1 / 1;
  background: var(--bg-secondary);
  position: relative; overflow: hidden;
}
.product-card-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.product-card-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); background: var(--bg-secondary);
}
.product-card-placeholder i { font-size: 32px; opacity: 0.4; }
.product-card-body { padding: 12px; }
.product-card-name {
  font-weight: 600; font-size: 14px; line-height: 1.3;
  color: var(--text-primary);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; text-overflow: ellipsis;
}
.product-card-cat {
  font-size: 10px; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text-muted);
  margin-top: 4px;
}
.product-card-price { font-size: 13px; color: var(--primary); font-weight: 600; margin-top: 4px; }
.product-card-tags { margin-top: 6px; }
.product-inactive-flag {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,0.6); color: #fff;
  padding: 2px 8px; border-radius: 4px;
  font-size: 10px; font-weight: 700;
}

/* === Social posts list === */
.social-posts-list { display: flex; flex-direction: column; gap: 12px; }
.social-post-card {
  display: flex; gap: 12px;
  background: var(--bg-card); border: 1px solid var(--border-light);
  border-radius: var(--radius); padding: 12px;
  cursor: pointer; transition: all 0.16s ease;
  box-shadow: var(--shadow-sm);
}
.social-post-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.social-post-image {
  width: 120px; height: 120px; flex-shrink: 0;
  background: var(--bg-secondary); border-radius: var(--radius-sm);
  overflow: hidden;
}
.social-post-image img, .social-post-image .product-card-placeholder { width: 100%; height: 100%; object-fit: cover; }
.social-post-body { flex: 1; min-width: 0; }
.social-post-head { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.social-post-caption { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; line-height: 1.4; }
.social-post-products { display: flex; flex-wrap: wrap; gap: 4px; }

/* === Health banner === */
.health-banner {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 13px; line-height: 1.5;
  border: 1px solid transparent;
}
.health-banner i { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.health-banner.danger {
  background: var(--danger-light); color: var(--danger);
  border-color: var(--danger);
}
.health-banner.warn {
  background: var(--warning-light); color: var(--warning);
  border-color: var(--warning);
}
.health-banner.ok {
  background: var(--success-light); color: var(--success);
  border-color: var(--success);
}
.health-banner a { color: inherit; text-decoration: underline; font-weight: 600; }
.health-banner code { background: rgba(0,0,0,0.08); padding: 1px 6px; border-radius: 4px; font-size: 12px; }

/* === Bulk product upload list === */
.bulk-products-list {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 50vh; overflow-y: auto;
  margin-top: 10px;
}
.bulk-prod-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}
.bulk-prod-row img {
  width: 56px; height: 56px; border-radius: var(--radius-sm);
  object-fit: cover; flex-shrink: 0;
  background: var(--bg-card);
}
.bulk-prod-fields {
  flex: 1; display: flex; gap: 8px; align-items: center; min-width: 0;
}
.bulk-prod-fields input[type="text"] {
  flex: 1; min-width: 0;
  padding: 8px 12px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-primary); font-family: inherit;
}
.bulk-prod-fields input[type="text"]:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.bulk-prod-name { flex: 2 !important; }
.bulk-prod-status {
  display: flex; align-items: center; gap: 4px;
  flex-shrink: 0; min-width: 32px;
  font-size: 18px;
}
@media (max-width: 600px) {
  .bulk-prod-row { flex-wrap: wrap; }
  .bulk-prod-fields { width: 100%; flex-wrap: wrap; }
  .bulk-prod-name, .bulk-prod-price { flex-basis: 100% !important; }
}

/* === Confidence bar === */
.confidence-bar {
  position: relative;
  width: 80px; height: 16px;
  background: var(--bg-secondary);
  border-radius: 999px; overflow: hidden;
}
.confidence-fill {
  height: 100%; transition: width 0.3s ease;
}
.confidence-bar span {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: var(--text-primary);
  letter-spacing: 0.02em;
}

/* === Mobile === */
@media (max-width: 768px) {
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .product-card-body { padding: 10px; }
  .product-card-name { font-size: 13px; }
  .social-post-card { flex-direction: column; }
  .social-post-image { width: 100%; height: 200px; }
}

/* === Collection autocomplete (--- trigger in chat input) === */
.collection-autocomplete {
  position: absolute;
  bottom: calc(100% + 6px); left: 0; right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 280px;
  overflow-y: auto;
  z-index: 200;
  padding: 6px;
}
.collection-autocomplete .ac-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  transition: background 0.12s ease;
}
.collection-autocomplete .ac-item:hover,
.collection-autocomplete .ac-item.ac-active {
  background: var(--primary-light);
}
.collection-autocomplete .ac-name {
  font-weight: 600;
  color: var(--primary);
  font-family: 'JetBrains Mono', 'Menlo', monospace;
  font-size: 12.5px;
  white-space: nowrap;
}
.collection-autocomplete .ac-meta {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: auto;
  white-space: nowrap;
}
.collection-autocomplete .ac-desc {
  flex-basis: 100%;
  font-size: 11px;
  color: var(--text-secondary);
  padding-left: 0;
  opacity: 0.85;
}

/* === Baseline input styling — applies to ALL inputs not inside .form-group ===
   The marketing pages use bare inputs that need the same warm look. */
.send-step-card input[type="text"],
.send-step-card input[type="email"],
.send-step-card input[type="number"],
.send-step-card select,
.send-step-card textarea,
.csv-drop-zone + textarea,
#bk-csv {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.send-step-card textarea, #bk-csv {
  resize: vertical; min-height: 80px;
}
.send-step-card input:focus,
.send-step-card select:focus,
.send-step-card textarea:focus,
#bk-csv:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* === Marketing — list pills, CSV upload, campaign UI === */
.mkt-lists-bar {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px;
  padding: 12px; background: var(--bg-card);
  border: 1px solid var(--border-light); border-radius: var(--radius);
}
.mkt-list-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; font-size: 13px; font-weight: 500;
  background: var(--bg-secondary); color: var(--text-secondary);
  border: 1px solid var(--border-light);
  border-radius: 999px; cursor: pointer; transition: all 0.16s ease;
}
.mkt-list-pill:hover { color: var(--text-primary); border-color: var(--border); }
.mkt-list-pill.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.mkt-list-pill .pill-count {
  background: rgba(255,255,255,0.25); color: inherit;
  padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 700;
}
.mkt-list-pill:not(.active) .pill-count { background: var(--bg-card); color: var(--text-muted); }
.mkt-edit-list { font-size: 11px; opacity: 0.5; margin-left: 4px; cursor: pointer; }
.mkt-edit-list:hover { opacity: 1; }

.csv-drop-zone {
  border: 2px dashed var(--border); border-radius: var(--radius-sm);
  padding: 24px; text-align: center; color: var(--text-muted);
  margin-bottom: 8px; transition: all 0.16s ease;
}
.csv-drop-zone.drag-over {
  border-color: var(--primary); background: var(--primary-light);
  color: var(--primary);
}
.csv-drop-zone i { font-size: 28px; display: block; margin-bottom: 8px; }

.bulk-result { padding: 12px; background: var(--bg-secondary); border-radius: var(--radius-sm); margin-top: 12px; }
.bulk-stat-row { display: flex; gap: 12px; flex-wrap: wrap; }
.bulk-stat { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 500; }
.bulk-stat.ok   { background: var(--success-light); color: var(--success); }
.bulk-stat.info { background: var(--info-light); color: var(--info); }
.bulk-stat.warn { background: var(--warning-light); color: var(--warning); }

.send-step-card {
  background: var(--bg-card); border: 1px solid var(--border-light);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.send-step-card h3 { display: flex; align-items: center; gap: 12px; font-size: 15px; margin-bottom: 12px; }
.send-step-card .step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 13px; font-weight: 700;
}

.template-card {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px; border: 1px solid var(--border-light); border-radius: var(--radius-sm);
  margin-bottom: 8px; cursor: pointer; transition: all 0.16s ease;
}
.template-card:hover { border-color: var(--primary); background: var(--primary-light); }
.template-card input[type="radio"] { margin-top: 2px; }
.template-card input[type="radio"]:checked + div .template-name { color: var(--primary); }
.template-card .template-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.template-card .template-lang, .template-card .template-cat {
  font-size: 10px; padding: 2px 7px; border-radius: 999px;
  font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
}
.template-card .template-lang { background: var(--info-light); color: var(--info); }
.template-card .template-cat  { background: var(--warning-light); color: var(--warning); }
.template-card .template-preview {
  font-size: 12px; color: var(--text-secondary);
  margin-top: 6px; line-height: 1.5; white-space: pre-wrap;
}

.template-card.template-disabled {
  opacity: 0.55; cursor: not-allowed;
  background: var(--bg-secondary);
}
.template-card.template-disabled:hover {
  border-color: var(--border-light); background: var(--bg-secondary);
}
.template-card.template-disabled input[type="radio"] { cursor: not-allowed; }

.template-warning {
  margin-top: 8px; padding: 8px 10px;
  background: var(--danger-light); color: var(--danger);
  border-radius: var(--radius-sm); font-size: 12px;
  display: flex; align-items: flex-start; gap: 8px; line-height: 1.45;
}
.template-warning i { margin-top: 2px; }

.var-meta {
  display: inline-block;
  font-size: 9px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-muted);
  margin-left: 6px; vertical-align: middle;
  padding: 2px 6px; border-radius: 4px;
  background: var(--bg-secondary);
}

.var-input-block {
  padding: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}
.var-input-label {
  font-weight: 600; font-size: 13px;
  color: var(--text-primary); margin-bottom: 8px;
  display: flex; align-items: center;
}
.var-mode-tabs {
  display: inline-flex; gap: 4px;
  padding: 3px; background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 999px; margin-bottom: 10px;
}
.var-mode-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; font-size: 12px; font-weight: 500;
  background: transparent; color: var(--text-muted);
  border: none; cursor: pointer; border-radius: 999px;
  transition: all 0.15s ease;
}
.var-mode-pill:hover { color: var(--text-primary); }
.var-mode-pill.active {
  background: var(--primary); color: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.var-mode-pill.var-mode-dyn.active {
  background: var(--warning); color: #fff;
}
.var-mode-input { width: 100%; }
.var-mode-input input {
  width: 100%; padding: 9px 12px;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-primary); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit;
}
.var-mode-input input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.var-dyn-readout {
  padding: 10px 12px;
  background: var(--warning-light); color: var(--warning);
  border: 1px dashed var(--warning); border-radius: var(--radius-sm);
  font-size: 13px; display: flex; align-items: center; gap: 8px;
}
.var-dyn-readout i { font-size: 14px; }

.tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.tab-btn {
  padding: 8px 14px; background: transparent; border: none;
  color: var(--text-muted); cursor: pointer; font-size: 13px; font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.recipient-list-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; margin: 4px;
  background: var(--bg-secondary); border: 1px solid var(--border-light);
  border-radius: 999px; cursor: pointer; transition: all 0.16s ease;
  user-select: none;
}
.recipient-list-pill.checked,
.recipient-list-pill:has(input:checked) {
  background: var(--primary-light); border-color: var(--primary); color: var(--primary);
}
.recipient-list-pill input { margin: 0; accent-color: var(--primary); }

.search-list { display: flex; flex-direction: column; gap: 4px; max-height: 320px; overflow-y: auto; padding: 4px; }
.search-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-radius: var(--radius-sm);
  background: var(--bg-secondary);
}
.search-item.added { background: var(--primary-light); }
.search-item.added button { background: var(--danger); color: #fff; }

.cs-summary {
  margin-top: 12px; padding: 10px 14px;
  background: var(--bg-secondary); border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-primary);
}

.campaign-header { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.campaign-status {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  background: var(--bg-secondary); margin-left: 8px; vertical-align: middle;
  font-weight: 600;
}
.campaign-progress { margin-top: 12px; }
.progress-bar {
  height: 10px; background: var(--bg-secondary);
  border-radius: 999px; overflow: hidden; margin-bottom: 8px;
}
.progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--primary), #8B5A2B);
  transition: width 0.5s ease;
}
.progress-stats { display: flex; gap: 16px; font-size: 13px; flex-wrap: wrap; }

.status-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600;
}
.status-pill.ok      { background: var(--success-light); color: var(--success); }
.status-pill.err     { background: var(--danger-light); color: var(--danger); }
.status-pill.pending { background: var(--bg-secondary); color: var(--text-muted); }
.error-text { font-size: 12px; color: var(--danger); }

/* === Login screen polish === */
.login-brand-mark {
  border-radius: 16px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  padding: 4px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.login-logo h1 {
  color: var(--text-primary);
  font-size: 26px;
  margin: 4px 0 2px;
}
.login-logo p {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 0 0 18px;
}

/* ================================================================
 * Global card, button, and mobile tuning
 * ================================================================ */

/* Smoother global type rendering */
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

/* Buttons with a touch more presence */
.btn {
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: all 0.18s ease;
}
.btn-primary {
  box-shadow: 0 1px 2px rgba(74, 45, 23, 0.18);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 2px 6px rgba(74, 45, 23, 0.25);
  transform: translateY(-1px);
}
.btn:active:not(:disabled) { transform: translateY(0); }

/* Inputs — warm focus ring */
input, textarea, select {
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* Stat cards with subtle accent */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.16s ease;
}
.stat-card:hover { box-shadow: var(--shadow); }

/* Topbar — softer with bg-secondary */
.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

/* Table headers — muted, refined */
th { font-size: 11px !important; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted) !important; }

/* Mobile tightening */
@media (max-width: 768px) {
  .session-row { padding: 12px; border-radius: var(--radius-sm); }
  .session-row-right { min-width: 60px; }
  .leads-toolbar { padding: 10px; gap: 6px; }
  .leads-search { min-width: 100%; flex-basis: 100%; }
  .leads-filter { flex: 1; min-width: 130px; }
  .stat-card { padding: 14px; }

  /* Table → vertical-stack-friendly on phones */
  .leads-table th, .leads-table td { padding: 8px 10px; font-size: 13px; }

  /* Chat bubbles tighter */
  .msg-bubble { padding: 9px 12px; font-size: 13.5px; }

  /* Sidebar header gets a bit smaller */
  .sidebar-header { padding: 16px; }
  .sidebar-logo { width: 38px; height: 38px; }
  .sidebar-title { font-size: 15px; }

  /* Buttons in header / actions */
  .btn { padding: 8px 12px; }
  .btn-sm { padding: 6px 10px; font-size: 12px; }
}

@media (max-width: 480px) {
  .session-name { font-size: 13.5px; }
  .session-preview { font-size: 11.5px; }
  .session-channel { display: none; }
  .leads-table th:nth-child(3),
  .leads-table td:nth-child(3) { display: none; } /* hide email col on phones */
}

/* ================================================================
   AI Cost Analytics page
   ================================================================ */
.ai-cost-page { display: flex; flex-direction: column; gap: 16px; }

.ai-cost-filters {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.aic-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.aic-custom { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.aic-custom input[type="date"],
.aic-custom input[type="text"],
.aic-custom select {
  padding: 6px 10px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg-card);
  color: var(--text-primary);
}
.aic-custom input[type="text"] { min-width: 200px; }

/* KPI cards */
.aic-kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.aic-kpi {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.aic-kpi-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.aic-kpi-value { font-size: 28px; font-weight: 700; color: var(--text-primary); margin-top: 4px; line-height: 1.1; }
.aic-kpi-sub { font-size: 12px; margin-top: 4px; }

.aic-filtered-strip {
  background: linear-gradient(135deg, rgba(0,72,172,.08), rgba(0,72,172,.02));
  border: 1px solid rgba(0,72,172,.25);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-primary);
}

.aic-section {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.aic-section-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  margin-bottom: 12px;
}
.aic-section-head h3 { margin: 0; font-size: 16px; font-weight: 600; }

.aic-chart-wrap { position: relative; height: 280px; }

.aic-breakdown-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.aic-bars { display: flex; flex-direction: column; gap: 8px; }
.aic-bar-row { display: grid; grid-template-columns: 130px 1fr 110px; gap: 10px; align-items: center; font-size: 13px; }
.aic-bar-label { color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aic-bar-track { background: var(--bg-secondary); height: 12px; border-radius: 6px; overflow: hidden; }
.aic-bar-fill { background: linear-gradient(90deg, #0048AC, #1D6FD8); height: 100%; }
.aic-bar-val { text-align: right; font-variant-numeric: tabular-nums; }

.aic-pager { display: flex; align-items: center; gap: 8px; padding: 10px 0 0; }
.aic-link { color: var(--accent); text-decoration: none; }
.aic-link:hover { text-decoration: underline; }

/* Per-message cost chip in Sessions UI (when toggle on) */
.msg-cost-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: 10px;
  background: rgba(0,72,172,.12);
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-left: 6px;
}
.session-cost-banner {
  background: linear-gradient(135deg, rgba(0,72,172,.08), rgba(0,72,172,.02));
  border: 1px solid rgba(0,72,172,.2);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

@media (max-width: 900px) {
  .aic-kpi-row { grid-template-columns: repeat(2, 1fr); }
  .aic-breakdown-row { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .aic-kpi-row { grid-template-columns: 1fr; }
}

/* AI Cost — markup indicator + download button */
.aic-markup-badge {
  background: linear-gradient(135deg, rgba(16,185,129,.08), rgba(16,185,129,.02));
  border: 1px solid rgba(16,185,129,.25);
  color: var(--text-primary);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.aic-markup-badge i { color: #10b981; }

/* KB Audit cards */
.kba-card { padding: 4px; }
.kba-card-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border-light);
}
.kba-class { padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.kba-reasoning {
  background: linear-gradient(135deg, rgba(139,92,246,.08), rgba(139,92,246,.02));
  border: 1px solid rgba(139,92,246,.25);
  border-radius: 6px; padding: 8px 12px; margin-top: 8px; font-size: 13px;
}
.kba-reasoning i { color: #8b5cf6; margin-right: 4px; }
.kba-pre {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 10px 12px;
  font-family: monospace;
  font-size: 11px;
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-secondary);
}
.kba-merge-target {
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 10px 12px;
  margin-top: 8px;
  background: var(--bg-secondary);
}
.kba-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--border-light);
}

/* ================================================================
   Message reply feature
   ================================================================ */

/* Message bubble needs relative positioning so the reply icon can float */
.msg-bubble { position: relative; }

/* Reply icon — bottom-right corner of every bubble (consistent across
   customer / AI / agent directions so users always find it in the same
   place). Hidden until hover; on touch devices stays at low opacity so
   it's always discoverable. */
.msg-reply-btn {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  border: none;
  background: rgba(255, 255, 255, 0.85);
  color: var(--text-secondary);
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  z-index: 2;
}
.msg-bubble:hover .msg-reply-btn { opacity: 1; }
.msg-reply-btn:hover { background: var(--accent); color: #fff; }
/* Customer / AI bubbles use a darker base so the icon reads against the
   lighter inbound bubble background. */
.msg-customer .msg-reply-btn,
.msg-ai .msg-reply-btn { background: rgba(0,0,0,0.08); color: var(--text-secondary); }
.msg-customer .msg-reply-btn:hover,
.msg-ai .msg-reply-btn:hover { background: var(--accent); color: #fff; }

/* Tap-and-hold friendly on mobile: always visible at low opacity */
@media (hover: none) {
  .msg-reply-btn { opacity: 0.55; }
}

/* Quoted-message card above a reply's body, click-to-jump-to-original */
.msg-quote {
  background: rgba(0, 0, 0, 0.06);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: background 0.12s ease;
  font-size: 12px;
  line-height: 1.35;
}
.msg-quote:hover { background: rgba(0, 0, 0, 0.1); }
.msg-quote-sender { font-weight: 600; color: var(--accent); font-size: 11px; }
.msg-quote-text {
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* When the agent's own (outbound) bubble has a quote, use a lighter accent
   that reads against the dark bubble */
.msg-agent .msg-quote,
.msg-ai .msg-quote {
  background: rgba(255, 255, 255, 0.15);
  border-left-color: rgba(255, 255, 255, 0.6);
}
.msg-agent .msg-quote-sender,
.msg-ai .msg-quote-sender { color: rgba(255, 255, 255, 0.9); }
.msg-agent .msg-quote-text,
.msg-ai .msg-quote-text { color: rgba(255, 255, 255, 0.85); }

/* Brief highlight when jumping to a quoted message */
@keyframes msg-flash {
  0%   { box-shadow: 0 0 0 2px rgba(0,72,172,0); background-color: transparent; }
  20%  { box-shadow: 0 0 0 3px rgba(0,72,172,0.5); }
  100% { box-shadow: 0 0 0 2px rgba(0,72,172,0); background-color: transparent; }
}
.msg-bubble-flash { animation: msg-flash 1.6s ease; }

/* The composer's "replying to ___" preview bar */
.chat-reply-bar {
  margin: 0 12px;
  border-top: 1px solid var(--border-light);
  border-left: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  background: var(--bg-secondary);
}
.chat-reply-bar-body {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
}
.chat-reply-bar-accent {
  width: 3px; align-self: stretch;
  background: var(--accent); border-radius: 2px;
}
.chat-reply-bar-text { flex: 1; min-width: 0; }
.chat-reply-bar-label {
  font-size: 11px; color: var(--accent); font-weight: 600;
}
.chat-reply-bar-label i { margin-right: 4px; }
.chat-reply-bar-preview {
  font-size: 12px; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-reply-bar-close {
  width: 28px; height: 28px;
  border: none; background: transparent;
  color: var(--text-muted); border-radius: 50%; cursor: pointer;
}
.chat-reply-bar-close:hover { background: rgba(0,0,0,0.08); color: var(--text-primary); }

/* ================================================================
 * Chat right-sidebar — collapsible sections
 * ================================================================
 * Replaces the old flat "h4 + content" pattern. Each section has a
 * button-shaped header with chevron; clicking toggles its body. State
 * persisted in localStorage by the loadChatTagsPicker bootstrap.
 */
.chat-side-section {
  border-top: 1px solid var(--border);
}
.chat-side-section:first-child { border-top: none; }

.chat-side-head {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  font-size: 13px; font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
}
.chat-side-head:hover { background: var(--bg-alt); }
.chat-side-head i:first-child { color: var(--primary); }
.chat-side-head > span { flex: 1; }
.chat-side-chev {
  font-size: 11px;
  color: var(--text-muted);
  transition: transform 0.18s ease;
}
.chat-side-section.collapsed .chat-side-chev { transform: rotate(-90deg); }

.chat-side-body {
  padding: 0 16px 16px;
  overflow: hidden;
  max-height: 1200px;
  transition: max-height 0.22s ease, padding 0.22s ease;
}
.chat-side-section.collapsed .chat-side-body {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
}
/* Reset the inner panels' own padding/margin — the section wrapper handles it now */
.chat-side-body .customer-info-panel,
.chat-side-body .notes-panel,
.chat-side-body .lead-form-panel { padding: 0; border: none; background: transparent; }
.chat-side-body .customer-info-panel h4,
.chat-side-body .notes-panel h4,
.chat-side-body .lead-form-panel h4 { display: none; }

/* ================================================================
 * Chat tag chips (both in sidebar picker and as filter pills)
 * ================================================================ */
.chat-tag-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.chat-tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  font-size: 11px; font-weight: 600;
  border-radius: 999px;
  border: 1.5px solid var(--primary);
  background: transparent;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.12s ease;
  white-space: nowrap;
}
.chat-tag-chip:hover { filter: brightness(1.1); transform: translateY(-1px); }
.chat-tag-chip.on { box-shadow: 0 1px 2px rgba(0,0,0,0.1); }

/* Filter strip at the top of the Chats list */
.sessions-tag-filter {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 16px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}
.sessions-tag-filter-label {
  font-size: 12px; font-weight: 600;
  color: var(--text-muted);
  margin-right: 4px;
}

/* Chat tag chips inside a session row (small + dense) */
.session-chat-tags-row {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 4px;
}
.session-chat-tag {
  color: #fff !important;
  border-radius: 4px !important;
  font-weight: 600;
}

/* ================================================================
 * Chat sidebar — Orders section
 * ================================================================
 * Compact, information-dense order cards used inside the chat
 * sidebar's collapsible "Orders" section. Reuses .order-status-badge
 * but renders the cards smaller than the full Orders dashboard.
 */
.chat-side-count {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: -2px;
}
.chat-orders-list {
  display: flex; flex-direction: column; gap: 8px;
}
.chat-order-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--bg-alt, var(--surface, transparent));
}
.chat-order-head {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.chat-order-num {
  font-size: 13px; font-weight: 600;
  color: var(--text-primary);
}
.chat-order-head .order-status-badge {
  font-size: 11px;
  padding: 2px 8px;
}
.chat-order-total {
  margin-left: auto;
  font-size: 13px; font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}
.chat-order-meta {
  font-size: 11px;
  line-height: 1.4;
  margin-bottom: 6px;
}
.chat-order-actions {
  display: flex; flex-wrap: wrap; gap: 4px;
}
.chat-order-actions .btn {
  padding: 3px 8px;
  font-size: 11px;
  line-height: 1.3;
}
.chat-order-actions .btn-xs {
  padding: 3px 8px;
  font-size: 11px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
}
.chat-order-actions .btn-xs:hover {
  background: var(--bg-alt, rgba(0,72,172,0.06));
  border-color: var(--primary);
}
.chat-order-actions .btn-xs:disabled {
  opacity: 0.6; cursor: wait;
}

/* Delivery push — compact chip used on chat-sidebar order cards once
   the invoice has been shipped to WordPress. The ⚡ icon next to the
   WP order number means "auto-pushed by the payment hook" (vs the
   agent manually clicking Push delivery). */
.chat-order-delivery-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600;
  color: var(--success, #15803d);
  background: rgba(34, 197, 94, 0.10);
  border: 1px solid rgba(34, 197, 94, 0.30);
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

/* Delivery push — order-detail card. Same green palette as the chip
   so the "pushed" state is visually consistent across both places. */
.delivery-pushed-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  font-size: 13px;
}
.delivery-pushed-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: var(--success, #15803d);
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}
.delivery-auto-teaser {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 500;
  color: var(--primary, #6366f1);
  background: rgba(99, 102, 241, 0.10);
  border: 1px solid rgba(99, 102, 241, 0.25);
  padding: 2px 8px;
  border-radius: 10px;
}
.delivery-pushed-time { font-size: 11px; }

/* Banner — sits below the pushed row when WP succeeded but ERP
   acknowledgement failed (yellow), or below the push button when the
   last manual attempt errored (red). */
.delivery-banner {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.delivery-banner-warn  { background: rgba(245, 158, 11, 0.10); border: 1px solid rgba(245, 158, 11, 0.35); color: #b45309; }
.delivery-banner-error { background: rgba(239, 68, 68, 0.10);  border: 1px solid rgba(239, 68, 68, 0.35);  color: #b91c1c; }
.delivery-banner .btn-xs {
  font-size: 11px; padding: 2px 8px;
  background: transparent; border: 1px solid currentColor;
  color: inherit; border-radius: 5px;
}

/* ================================================================
 * Chat Tags admin page
 * ================================================================ */
.chat-tags-page { padding: 16px; max-width: 1100px; margin: 0 auto; }
.chat-tags-table input[type="text"] {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text-primary);
}
.chat-tags-table input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(0,72,172,0.18);
}

/* ================================================================
 * Image lightbox — click-to-preview overlay
 * ================================================================ */
.img-lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  cursor: zoom-out;
}
.img-lightbox img {
  max-width: 95vw; max-height: 90vh; object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  cursor: default;
}
.img-lightbox-close {
  position: absolute; top: 20px; right: 20px;
  background: rgba(255,255,255,0.18);
  color: white;
  border: none;
  width: 46px; height: 46px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s ease, transform 0.08s ease;
}
.img-lightbox-close:hover { background: rgba(255,255,255,0.35); transform: scale(1.06); }
.img-lightbox-close:active { transform: scale(0.96); }
/* Images opted into the lightbox get a zoom-in cursor */
img.lb-img { cursor: zoom-in; }

/* =====================================================================
 * Orders → Customers + Invoice PDF Settings
 * ===================================================================== */

/* Customer table rows are clickable; hover hint reuses leads-table hover */
.cust-row:hover { background: var(--surface-hover, rgba(255,255,255,0.03)); }

/* Inline dedup banner inside the New-Customer modal */
.dedup-banner {
  background: rgba(245, 158, 11, 0.10);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 13px;
}
.dedup-banner-head {
  display: flex; align-items: center; gap: 6px;
  font-weight: 600; margin-bottom: 8px;
}
.dedup-banner-head .fa-exclamation-triangle { color: #f59e0b; }
.dedup-banner-actions {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}

/* Invoice PDF Settings — three stacked cards on a single column.
   Wider screens get the same single-column layout (each card is busy
   enough not to want to compete for horizontal space). */
.invoice-pdf-settings {
  display: flex; flex-direction: column; gap: 16px;
  max-width: 820px;
}
.invoice-pdf-settings .settings-card-head p { font-size: 12px; }

/* ERP key reveal row — input + Reveal/Hide button side-by-side */
.ips-secret-row {
  display: flex; gap: 6px; align-items: stretch;
}
.ips-secret-row input {
  flex: 1; padding: 8px 10px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text);
  font-family: ui-monospace, monospace; font-size: 13px;
}

/* Invoice logo upload row — thumbnail + controls */
.ips-logo-row {
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
}
.ips-logo-thumb {
  width: 120px; height: 90px;
  border-radius: 8px; background: #fff;
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.ips-logo-thumb img {
  max-width: 100%; max-height: 100%; object-fit: contain;
}
.ips-logo-thumb i { font-size: 28px; color: var(--text-muted); }

/* The settings-card pattern is reused as-is, but generic inputs/textarea
   inside the invoice page need the standard form polish */
.invoice-pdf-settings .form-group input[type="text"],
.invoice-pdf-settings .form-group textarea {
  width: 100%; padding: 8px 10px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text);
}
.invoice-pdf-settings .form-group textarea { resize: vertical; min-height: 80px; }

/* =====================================================================
 * ORDERS — Phase 6
 * ===================================================================== */

/* --- Status badges --- */
.order-status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  background: var(--surface, rgba(255,255,255,0.04));
  border: 1px solid var(--border);
  color: var(--text-primary);
  white-space: nowrap;
}
.order-status-badge-lg { padding: 6px 14px; font-size: 13px; }
.order-status-dot {
  width: 8px; height: 8px; border-radius: 999px; display: inline-block;
}
.order-status-badge.st-paid { background: rgba(16,185,129,0.12); border-color: rgba(16,185,129,0.35); }
.order-status-badge.st-unpaid { background: rgba(239,68,68,0.10); border-color: rgba(239,68,68,0.35); }
.order-status-badge.st-partial { background: rgba(245,158,11,0.10); border-color: rgba(245,158,11,0.35); }
.order-status-badge.st-cancelled { background: rgba(55,65,81,0.15); border-color: rgba(55,65,81,0.35); color: var(--text-muted); }
.order-status-badge.st-discarded { background: transparent; border-color: var(--border); color: var(--text-muted); }
.order-status-badge.st-draft { background: rgba(156,163,175,0.10); border-color: rgba(156,163,175,0.35); }
/* Delivery-created — sits next to the Paid badge on chat-sidebar
   order cards once the WP push has happened. Same green palette as
   .st-paid so the eye reads "another good thing happened". */
.order-status-badge.st-delivery-created {
  background: rgba(16,185,129,0.12);
  border-color: rgba(16,185,129,0.35);
  color: #047857;
}
/* Tracking-saved — third progress badge once CityPak has handed back
   the tracking number. Brand-blue palette so it's distinct from "paid"
   and "delivery created" while still reading positive. */
.order-status-badge.st-tracking-saved {
  background: rgba(0,72,172,0.12);
  border-color: rgba(0,72,172,0.35);
  color: #003784;
}

/* Tracking sub-block inside the order-detail Delivery card. Sits
   right below the green "Pushed to WP" pill. Two visual states:
   no-tracking-yet (just a button) vs tracking-saved (number + waybill
   + status chip + actions). */
.delivery-tracking-block {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.delivery-tracking-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  font-size: 13px;
  margin-bottom: 4px;
}
.delivery-tracking-row strong { font-weight: 600; margin-right: 4px; color: var(--text-muted); }
.tracking-status-chip {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600;
  background: rgba(0,72,172,0.10);
  border: 1px solid rgba(0,72,172,0.25);
  color: #003784;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.delivery-tracking-actions {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 6px;
}

/* Delivery-state badge — AI-derived journey stage shown on the order
   detail Delivery card AND as a small chip on chat-sidebar cards.
   Colour signals the stage: green = delivered, blue = in delivery,
   amber = handed over (waiting on first scan), grey = unknown. */
.delivery-state-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  border: 1px solid transparent;
}
.delivery-state-badge.st-delivered    { background: rgba(16,185,129,0.14); border-color: rgba(16,185,129,0.4); color: #047857; }
.delivery-state-badge.st-in-delivery  { background: rgba(59,130,246,0.12); border-color: rgba(59,130,246,0.35); color: #1d4ed8; }
.delivery-state-badge.st-handed-over  { background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.35); color: #b45309; }
.delivery-state-badge.st-unknown      { background: rgba(156,163,175,0.10); border-color: rgba(156,163,175,0.35); color: var(--text-muted); }
/* Two parallel status rows — Order (WP) on top, Delivery (AI scan)
   below. Stacked vertically so the agent sees them as separate
   facts rather than one merged status. */
.delivery-status-stack {
  display: flex; flex-direction: column; gap: 4px;
  margin-top: 8px;
}

/* Online card payment (OnePay) — order detail card */
.op-link-row {
  display: flex; gap: 6px; align-items: center;
  margin-bottom: 4px;
}
.op-link-url {
  flex: 1;
  padding: 8px 10px;
  font-size: 12px;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', Consolas, monospace;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-alt, rgba(0,72,172,0.04));
  color: var(--text-primary);
  cursor: text;
}
.op-actions {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 10px;
}
.op-paid-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
}
.op-paid-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(16,185,129,0.14);
  border: 1px solid rgba(16,185,129,0.4);
  color: #047857;
  font-weight: 600;
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 999px;
}

/* Replacement-order linkage banner (above the order title) */
.rep-banner {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin: 8px 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.rep-banner-child {
  background: rgba(245, 158, 11, 0.10);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #b45309;
}
.rep-banner-parent {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: var(--text-primary);
}
.rep-link {
  font-weight: 600;
  color: inherit;
  text-decoration: underline;
}
.rep-link:hover { text-decoration: none; }

/* Orders Report — KPI tiles + chart cards + status pills */
.rep-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.rep-tile {
  background: var(--bg-card, var(--surface));
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.rep-tile-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.rep-tile-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 6px 0 2px;
}
.rep-tile-meta { font-size: 12px; }
.rep-tile-warn { border-color: rgba(239, 68, 68, 0.35); background: rgba(239, 68, 68, 0.04); }
.rep-status-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.rep-status-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid var(--border);
}
.rep-status-pill.st-paid     { background: rgba(16,185,129,0.12); border-color: rgba(16,185,129,0.35); color: #047857; }
.rep-status-pill.st-unpaid   { background: rgba(239,68,68,0.10);  border-color: rgba(239,68,68,0.35);  color: #b91c1c; }
.rep-status-pill.st-partially_paid { background: rgba(245,158,11,0.10); border-color: rgba(245,158,11,0.35); color: #b45309; }
.rep-status-pill.st-cancelled { background: rgba(55,65,81,0.10); border-color: rgba(55,65,81,0.35); color: var(--text-muted); }
.rep-controls input[type="date"], .rep-controls select {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg-card, var(--surface)); color: var(--text-primary);
  font-size: 13px;
}

/* Text Templates — management page */
.tt-list { display: flex; flex-direction: column; gap: 8px; }
.tt-card {
  background: var(--bg-card, var(--surface));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  transition: border-color 0.15s;
}
.tt-card:hover { border-color: var(--primary, #6366f1); }
.tt-card-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin-bottom: 6px;
}
.tt-card-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.tt-slug {
  display: inline-block;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', Consolas, monospace;
  font-size: 12px;
  color: var(--primary, #6366f1);
  background: rgba(0,72,172,0.08);
  padding: 2px 8px; border-radius: 4px;
  margin-right: 8px;
}
.tt-title { font-weight: 600; font-size: 13px; }
.tt-body {
  font-size: 12px;
  color: var(--text-primary);
  white-space: pre-wrap;
  margin-bottom: 2px;
  line-height: 1.5;
}
.tt-desc { font-size: 11px; font-style: italic; }
/* Suggester preview line for templates — slightly larger so the
   snippet is readable. */
.collection-autocomplete .ac-item[data-trigger=",,,"] .ac-desc {
  white-space: pre-wrap;
  max-height: 38px;
  overflow: hidden;
}

/* PDF download split-button — main face triggers the default
   (invoice), caret opens a 3-option menu. Sits inline with the
   other order-detail action buttons. */
.pdf-dropdown {
  display: inline-flex; position: relative;
}
.pdf-dropdown .pdf-dropdown-main {
  border-top-right-radius: 0; border-bottom-right-radius: 0;
  border-right: 1px solid var(--border);
}
.pdf-dropdown .pdf-dropdown-toggle {
  border-top-left-radius: 0; border-bottom-left-radius: 0;
  padding-left: 8px; padding-right: 8px;
  margin-left: -1px;
}
.pdf-dropdown-menu {
  position: absolute; top: 100%; left: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  margin-top: 4px;
  z-index: 100;
  min-width: 230px;
  overflow: hidden;
}
.pdf-dropdown-menu button {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  background: transparent; border: none;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
}
.pdf-dropdown-menu button:hover {
  background: var(--bg-alt, rgba(0,72,172,0.08));
}
.pdf-dropdown-menu button i {
  color: var(--primary, #6366f1);
  width: 16px;
  text-align: center;
}

/* Same palette echoed for the compact chat-sidebar variants — they
   sit next to "Paid" + "Delivery order created" + tracking chips. */
.order-status-badge.st-delivered-final    { background: rgba(16,185,129,0.14); border-color: rgba(16,185,129,0.4); color: #047857; }
.order-status-badge.st-in-delivery-chip   { background: rgba(59,130,246,0.12); border-color: rgba(59,130,246,0.35); color: #1d4ed8; }
.order-status-badge.st-handed-over-chip   { background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.35); color: #b45309; }

/* Milestone preview — collapsible <details> block showing the
   sequence of messages that "Send tracking" will fire. Agent can
   sanity-check the AI-generated wording before clicking. */
.delivery-milestones {
  margin-top: 10px;
  padding: 8px 10px;
  background: rgba(0,72,172,0.04);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
}
.delivery-milestones summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
}
.delivery-milestones summary:hover { color: var(--text-primary); }
.delivery-milestones-list {
  margin: 8px 0 0;
  padding-left: 22px;
  line-height: 1.6;
}
.delivery-milestones-list li {
  color: var(--text-primary);
  margin-bottom: 2px;
}
/* Milestones that are skipped by the "delivered → last only" rule
   are shown strikethrough + muted so the agent can see exactly
   which lines won't be sent. */
.delivery-milestones-list li.milestone-skipped {
  color: var(--text-muted);
  text-decoration: line-through;
  opacity: 0.6;
}

/* --- Dashboard page --- */
.orders-page { display: flex; flex-direction: column; gap: 12px; }
.orders-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.orders-title { margin: 0; font-size: 20px; font-weight: 700; }
.orders-header-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.orders-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.orders-pill {
  padding: 6px 14px; border-radius: 999px;
  background: var(--surface, var(--bg)); border: 1px solid var(--border);
  color: var(--text-primary); font-size: 13px; font-weight: 500;
  cursor: pointer;
}
.orders-pill:hover { background: var(--surface-hover, rgba(255,255,255,0.04)); }
.orders-pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.orders-pill.faded { opacity: 0.55; }
.orders-pill.faded.active { opacity: 1; }

.orders-filters {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 12px; background: var(--surface, var(--bg)); border: 1px solid var(--border);
  border-radius: 10px;
}
.orders-search { flex: 1; min-width: 200px; position: relative; }
.orders-search input {
  width: 100%; padding: 8px 12px 8px 32px;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text-primary); border-radius: 8px; font-size: 14px;
}
.orders-search i {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}
.orders-date-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-muted);
}
.orders-date-label input[type="date"] {
  padding: 6px 8px;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text-primary); border-radius: 6px; font-size: 13px;
}
.orders-clear {
  font-size: 12px; color: var(--primary); cursor: pointer;
  text-decoration: underline; margin-left: 4px;
}
.orders-count { color: var(--text-muted); font-size: 13px; padding: 4px 2px; }

.orders-list { display: flex; flex-direction: column; gap: 8px; }
.ord-row {
  display: grid;
  grid-template-columns: 1.4fr 1.3fr auto auto;
  align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--bg-card, var(--surface)); border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer; transition: background 0.12s ease;
}
.ord-row:hover { background: var(--surface-hover, rgba(255,255,255,0.04)); }
.ord-row-main { min-width: 0; }
.ord-row-num { font-weight: 700; font-size: 14px; }
.ord-row-cust { font-size: 13px; color: var(--text-primary); margin-top: 2px; }
.ord-row-phone { color: var(--text-muted); font-size: 12px; }
.ord-row-meta {
  display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px;
  color: var(--text-muted);
}
.ord-row-amt { color: var(--text-primary); font-weight: 600; }
.ord-row-status { display: flex; align-items: center; }
.ord-row-menu { display: flex; align-items: center; }

.ord-row-popup {
  position: absolute; z-index: 200; min-width: 200px;
  background: var(--bg-card, var(--surface)); border: 1px solid var(--border);
  border-radius: 8px; padding: 4px; box-shadow: var(--shadow-lg);
}
.ord-row-popup button {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 12px;
  background: none; border: none; cursor: pointer;
  color: var(--text-primary); font-size: 13px; text-align: left;
  border-radius: 6px;
}
.ord-row-popup button:hover { background: var(--surface-hover, rgba(255,255,255,0.05)); }
.ord-row-popup button.danger { color: var(--danger); }

@media (max-width: 768px) {
  .ord-row { grid-template-columns: 1fr auto; gap: 8px; }
  .ord-row-meta { grid-column: 1 / -1; }
  .ord-row-status { grid-column: 1 / 2; }
  .ord-row-menu { grid-column: 2 / 3; justify-self: end; }
}

/* --- Detail page --- */
.order-detail { display: flex; flex-direction: column; gap: 14px; max-width: 1100px; }
.order-detail-top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.order-detail-status-wrap { flex: 1; text-align: center; }
.order-detail-head h2 { margin: 0; font-size: 22px; font-weight: 700; }
.order-detail-sub { font-size: 12px; margin-top: 4px; }

.order-meta-strip {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  padding: 14px; background: var(--surface, var(--bg-card)); border: 1px solid var(--border);
  border-radius: 10px;
}
.ord-meta-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.ord-meta-val { font-size: 15px; font-weight: 600; margin-top: 2px; }

.order-erp-row { font-size: 12px; padding: 4px 2px; }
.order-erp-row a { color: var(--primary); }

.order-action-row { display: flex; flex-wrap: wrap; gap: 6px; }

.order-detail-grid {
  display: grid; grid-template-columns: 1fr 320px; gap: 14px;
}
.order-detail-left { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.order-detail-right { position: sticky; top: 12px; align-self: start; }

.order-totals-card {
  background: var(--bg-card, var(--surface)); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px;
  display: flex; flex-direction: column; gap: 8px;
}
/* gap is the belt-and-braces — flex space-between alone fails to
   separate the label and the value when the card is narrow + both
   spans are bold (the browser pulls them flush). 12px gap guarantees
   visual separation in every viewport / theme. */
.ord-tot-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.ord-tot-row > span:last-child { white-space: nowrap; }
.ord-tot-final { font-size: 16px; font-weight: 700; padding-top: 8px; border-top: 1px solid var(--border); }
.ord-tot-paid { color: var(--success); }
.ord-tot-bal { font-size: 15px; font-weight: 700; padding-top: 8px; border-top: 1px dashed var(--border); }

.ord-cust-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; font-size: 13px;
}
@media (max-width: 600px) { .ord-cust-grid { grid-template-columns: 1fr; } }

.ord-items-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ord-items-table th, .ord-items-table td {
  text-align: left; padding: 8px 10px;
  border-bottom: 1px solid var(--border); vertical-align: middle;
}
.ord-items-table th { color: var(--text-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; }
.ord-items-table .ord-num-col { text-align: right; white-space: nowrap; }
.ord-item-thumb {
  width: 32px; height: 32px; object-fit: cover;
  border-radius: 4px; vertical-align: middle; margin-right: 8px;
}
span.ord-item-thumb.delivery {
  display: inline-flex; align-items: center; justify-content: center;
  background: #FFF4D6; color: #8A6708; border: 1px solid #EFDFA6;
}
span.ord-item-thumb.delivery i { font-size: 16px; }

@media (max-width: 900px) {
  .order-detail-grid { grid-template-columns: 1fr; }
  .order-detail-right { position: static; }
}

/* --- Record payment modal --- */
.ord-pay-balance {
  padding: 12px; background: var(--surface, rgba(255,255,255,0.03));
  border-radius: 8px; margin-bottom: 12px; font-size: 13px;
  border: 1px solid var(--border);
}
.ord-pay-balance strong { font-size: 16px; }

/* --- Cancel modal --- */
.ord-cancel-summary {
  padding: 12px; background: var(--surface, rgba(255,255,255,0.03));
  border-radius: 8px; margin-bottom: 12px; font-size: 13px;
  border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 4px;
}

/* =====================================================================
 * ORDER FORM (full-screen overlay)
 * ===================================================================== */
.order-form-overlay {
  position: fixed; inset: 0; z-index: 1100;
  background: var(--bg, #0b1220);
  overflow-y: auto;
}
.order-form-inner {
  max-width: 980px; margin: 0 auto;
  padding: 16px 16px 120px;
  position: relative;
  min-height: 100vh;
}
.order-form-header {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
  background: var(--bg, #0b1220);
  border-bottom: 1px solid var(--border);
}
.order-form-title { margin: 0; flex: 1; font-size: 18px; font-weight: 700; }
.order-form-status { margin-right: 8px; }
.order-form-close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
}
.order-form-banner {
  padding: 10px 12px; border-radius: 8px; font-size: 13px;
  margin: 12px 0;
}
.order-form-banner.warn {
  background: rgba(245,158,11,0.10); border: 1px solid rgba(245,158,11,0.35);
}
.order-form-banner.danger {
  background: rgba(239,68,68,0.10); border: 1px solid rgba(239,68,68,0.35);
}

.order-form-body {
  display: flex; flex-direction: column; gap: 14px; margin-top: 12px;
}
.order-form-card {
  background: var(--bg-card, var(--surface)); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px;
}
.ofc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 12px; }
.ofc-head h3 { margin: 0; font-size: 14px; }
.ofc-subtotal { font-size: 13px; color: var(--text-muted); }

.ofc-pills { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.ofc-pill {
  padding: 6px 12px; border-radius: 999px;
  background: var(--surface, var(--bg)); border: 1px solid var(--border);
  color: var(--text-primary); font-size: 13px; cursor: pointer;
}
.ofc-pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.ofc-pill:disabled { opacity: 0.5; cursor: not-allowed; }

.ofc-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px;
}
@media (max-width: 600px) { .ofc-grid { grid-template-columns: 1fr; } }

.ofc-cust-card {
  background: var(--surface, rgba(255,255,255,0.03));
  border: 1px solid var(--border); border-radius: 8px;
  padding: 12px;
}
.ofc-cust-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ofc-link { color: var(--primary); font-size: 12px; }

.ofc-search-wrap { position: relative; }
.ofc-search-wrap input {
  width: 100%; padding: 10px 12px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-primary); font-size: 14px;
}

.ord-autocomplete {
  position: absolute; z-index: 200; left: 0; right: 0; top: 100%;
  margin-top: 4px;
  background: var(--bg-card, var(--surface)); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow-lg);
  max-height: 280px; overflow-y: auto;
}
.ord-autocomplete .ac-item {
  display: flex; gap: 10px; align-items: center;
  padding: 8px 12px; cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.ord-autocomplete .ac-item:last-child { border-bottom: none; }
.ord-autocomplete .ac-item:hover { background: var(--surface-hover, rgba(255,255,255,0.05)); }
.ord-autocomplete .ac-thumb {
  width: 36px; height: 36px; object-fit: cover; border-radius: 4px;
  background: var(--surface);
}
.ord-autocomplete .ac-thumb.empty { background: var(--surface); }
.ord-autocomplete .ac-name { font-weight: 600; }
.ord-autocomplete .ac-meta { color: var(--text-muted); font-size: 12px; }
.ord-autocomplete .ac-empty { padding: 10px 12px; color: var(--text-muted); font-size: 13px; }

.ofg-amt { font-weight: 600; padding-top: 4px; }

/* Line items */
.line-item-row {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px; margin-bottom: 8px;
  background: var(--surface, rgba(255,255,255,0.02));
}
.line-item-top {
  display: flex; gap: 10px; align-items: center;
}
.line-item-thumb {
  width: 48px; height: 48px; object-fit: cover; border-radius: 6px;
  background: var(--bg); flex-shrink: 0;
}
.line-item-thumb.empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
}
.line-item-thumb.delivery {
  display: flex; align-items: center; justify-content: center;
  background: #FFF4D6; color: #8A6708;
  border: 1px solid #EFDFA6;
}
.line-item-thumb.delivery i { font-size: 18px; }
.order-detail-back-group { display: flex; gap: 6px; align-items: center; }
.line-item-desc-wrap { flex: 1; position: relative; min-width: 0; }
.line-item-desc-wrap input {
  width: 100%; padding: 8px 10px;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text-primary); border-radius: 6px; font-size: 14px;
}
.line-item-bottom {
  display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 10px;
  align-items: flex-end;
}
.line-item-bottom label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: var(--text-muted);
}
.line-item-bottom input, .line-item-bottom select {
  padding: 6px 8px;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text-primary); border-radius: 6px; font-size: 13px;
}
.line-item-bottom .li-qty   { width: 80px; }
.line-item-bottom .li-price { width: 120px; }
.line-item-bottom .li-dtype { width: 150px; }
.line-item-bottom .li-dval  { width: 100px; }
.line-item-bottom .li-total {
  margin-left: auto; font-size: 12px; color: var(--text-muted);
  text-align: right;
}
.line-item-bottom .li-total strong { display: block; font-size: 15px; color: var(--text-primary); }
@media (max-width: 600px) {
  .line-item-bottom .li-total { margin-left: 0; width: 100%; text-align: left; }
}

/* Sticky bottom action bar */
.order-form-sticky {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 6;
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 16px;
  background: var(--bg-card, var(--surface));
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(0,0,0,0.18);
}
@media (max-width: 600px) {
  .order-form-sticky { flex-wrap: wrap; padding: 10px; }
  .order-form-sticky .btn { flex: 1 1 auto; }
}

/* Final-total card */
.order-form-total { padding: 22px 16px; text-align: right; }
.order-final-total {
  display: flex; align-items: baseline; justify-content: flex-end; gap: 16px;
}
.ofc-tot-label { font-size: 12px; color: var(--text-muted); letter-spacing: 0.08em; }
.ofc-tot-value { font-size: 28px; font-weight: 800; }

/* Reuse the dedup banner inline */
.dedup-banner-inline {
  background: rgba(245, 158, 11, 0.10);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 13px;
}
.dedup-banner-inline .dedup-banner-head {
  display: flex; align-items: center; gap: 6px;
  font-weight: 600; margin-bottom: 8px;
}
.dedup-banner-inline .dedup-banner-head .fa-exclamation-triangle { color: #f59e0b; }
.dedup-banner-inline .dedup-banner-actions {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}

/* Order-detail HARD DELETE button (admin-only) — ghost variant with a
   red outline so it visually separates from the safe ghost actions. */
.od-delete-btn {
  color: var(--danger);
  border-color: var(--danger) !important;
  border-style: solid;
  border-width: 1px;
}
.od-delete-btn:hover:not(:disabled) {
  background: var(--danger-light);
}

/* AI auto-fill: customer-update banner shown when AI found contact
   info missing from the existing customer record. */
.ai-cust-update-banner {
  background: linear-gradient(135deg, #ede9fe, #f5f3ff);
  border: 1px solid #c4b5fd;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 13px;
}
.ai-cust-update-banner-head {
  font-weight: 600;
  color: #5b21b6;
  margin-bottom: 6px;
}
.ai-cust-update-banner-head i { margin-right: 4px; }
.ai-cust-update-banner-body { color: var(--text-primary); line-height: 1.5; }
.ai-cust-update-banner-body strong { color: var(--text-muted); font-weight: 600; }
.ai-cust-update-banner-actions {
  display: flex; gap: 8px;
  margin-top: 10px;
}
.ai-cust-old { color: var(--text-muted); text-decoration: line-through; }
.ai-cust-new { color: #5b21b6; font-weight: 600; }

/* ================================================================
 * Order Issues & Feedback
 * ================================================================
 * Card lives in the order-detail left column between Payments and
 * Notes. Reuses the .settings-card chrome. Each .issue-card has a
 * severity-coloured left border so the agent can scan a long list.
 * The small .order-alert-icon variant is also reused on the orders
 * dashboard row and the chat-sidebar order card. */

.order-issues-card .issues-card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.issues-count-badge {
  font-size: 11px; font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-hover, #f3f4f6);
  color: var(--text-muted);
}
.issues-empty {
  font-size: 13px;
  padding: 14px 4px;
  text-align: center;
  border: 1px dashed var(--border, #e5e7eb);
  border-radius: 8px;
}
.issues-list {
  display: flex; flex-direction: column;
  gap: 10px;
}
.issue-card {
  border: 1px solid var(--border, #e5e7eb);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--surface, #fff);
}
.issue-sev-critical { border-left-color: #dc2626; background: rgba(220, 38, 38, 0.04); }
.issue-sev-warning  { border-left-color: #ea580c; background: rgba(234, 88, 12, 0.04); }
.issue-sev-info     { border-left-color: #3b82f6; background: rgba(59, 130, 246, 0.04); }

.issue-head {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.issue-severity-icon {
  font-size: 14px;
  width: 18px;
  display: inline-flex; align-items: center; justify-content: center;
}
.issue-type-label {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}
.issue-status-badge {
  font-size: 11px; font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}
.issue-status-open      { background: #fef3c7; color: #92400e; }
.issue-status-resolved  { background: #d1fae5; color: #065f46; }
.issue-meta {
  font-size: 12px;
  margin-left: auto;
}
.issue-message {
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  color: var(--text-primary);
}
.issue-resolved-line {
  font-size: 12px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border, #e5e7eb);
}
.issue-resolution-note {
  margin-top: 4px;
  color: var(--text-muted);
}
.issue-actions {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 10px;
}
.issue-actions .btn-xs {
  padding: 4px 10px;
  font-size: 12px;
}
.issue-delete-btn {
  color: var(--danger, #dc2626);
}
.issue-modal-status {
  font-size: 13px;
  margin-bottom: 10px;
  color: var(--text-muted);
}

/* Small inline alert pip used on the orders dashboard row + chat
   sidebar order card. Sized to sit next to the customer name without
   pushing the layout around. Click bubbles up to the row → order
   detail (no separate handler needed). */
.order-alert-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px;
  border-radius: 50%;
  font-size: 11px;
  cursor: pointer;
  margin-left: 4px;
  vertical-align: middle;
}
.order-alert-critical { background: #fee2e2; color: #b91c1c; }
.order-alert-warning  { background: #ffedd5; color: #c2410c; }
.order-alert-info     { background: #dbeafe; color: #1d4ed8; }
.order-alert-icon:hover { filter: brightness(0.95); }
