/* ============================================================
   AGAVAL — REDESIGNED DESIGN SYSTEM v2.0
   Premium dark-sidebar + clean white content area
   Same HTML structure, completely refreshed look
   ============================================================ */

/* ---- CSS Variables ---- */
:root {
  --brand: #25D366;           /* WhatsApp green — primary */
  --brand-dark: #1aad52;
  --brand-pale: #e8fdf0;
  --brand-glow: rgba(37,211,102,0.18);

  --ink: #0f172a;             /* Near-black */
  --ink-2: #334155;
  --ink-3: #64748b;
  --ink-4: #94a3b8;
  --ink-5: #cbd5e1;

  --surface: #ffffff;
  --canvas: #f1f5f9;
  --line: #e2e8f0;
  --line-soft: #f1f5f9;

  --sidebar-bg: #0f172a;      /* Deep navy sidebar */
  --sidebar-hover: rgba(255,255,255,0.07);
  --sidebar-active: rgba(37,211,102,0.15);
  --sidebar-active-border: var(--brand);
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --sidebar-text-brand: var(--brand);

  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 20px;

  --shadow-sm: 0 1px 3px rgba(15,23,42,0.08), 0 1px 2px rgba(15,23,42,0.06);
  --shadow-md: 0 4px 16px rgba(15,23,42,0.1), 0 2px 6px rgba(15,23,42,0.06);
  --shadow-lg: 0 10px 40px rgba(15,23,42,0.14), 0 4px 16px rgba(15,23,42,0.08);

  --transition: 0.18s cubic-bezier(0.4,0,0.2,1);
}

/* ---- Reset & Base ---- */
* { box-sizing: border-box; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  margin: 0;
  color: var(--ink) !important;
  background: var(--canvas) !important;
  height: 100dvh !important;
  font-size: 13px;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { cursor: pointer; transition: background var(--transition), border-color var(--transition), box-shadow var(--transition), color var(--transition); }
button:disabled { opacity: .45; cursor: not-allowed; }
button:active:not(:disabled) { transform: translateY(1px); }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2.5px solid var(--brand); outline-offset: 2px;
}
svg { flex-shrink: 0; }
button svg { width: 18px; height: 18px; }
.hidden, [hidden] { display: none !important; }
.skip-link { position: fixed; left: 18px; top: -80px; padding: 12px 18px; background: var(--brand); color: white; z-index: 200; border-radius: var(--radius-sm); }
.skip-link:focus { top: 12px; }
.mobile-only { display: none; }
.grid > *, .flex-1 { min-width: 0; }
main { min-height: 0; }
body > #workspaceShell { background: var(--canvas) !important; min-height: 0; }
main > section:not(#view-inbox) {
  padding: 32px 40px !important;
  max-width: 1500px !important;
  width: 100%;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
main > section { min-width: 0; }
h1, h2, h3, p { margin: 0; }
h2, h3 { letter-spacing: -.4px; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-thumb { background: var(--ink-5); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }

/* ===== SIDEBAR ===== */
.workspace-sidebar {
  width: 240px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
  padding: 24px 14px 20px;
  background: var(--sidebar-bg);
  border-right: none;
  z-index: 40;
  overflow-y: auto;
}

/* Brand logo */
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 2px 10px 24px;
  color: white; text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 20px;
}
.brand-mark {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--brand);
  color: #fff; font-size: 22px;
  box-shadow: 0 4px 14px var(--brand-glow);
  flex-shrink: 0;
}
.brand strong { font-size: 20px; font-weight: 700; letter-spacing: -0.8px; line-height: 1.1; color: white; }
.brand-dot { color: var(--brand); }
.brand small { display: block; font-size: 7px; letter-spacing: 1.5px; color: rgba(255,255,255,0.35); margin-top: 4px; text-transform: uppercase; }

/* Workspace picker */
.business-picker { padding: 0 8px 20px; border-bottom: 1px solid rgba(255,255,255,0.07); margin-bottom: 16px; }
.business-picker label, .nav-caption {
  font-size: 9px; letter-spacing: 1.5px; font-weight: 600;
  display: block; color: rgba(255,255,255,0.3); margin-bottom: 8px; text-transform: uppercase;
}
.business-picker select {
  min-height: 38px; width: 100%;
  padding: 9px 10px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  font-size: 11px; color: rgba(255,255,255,0.75); font-weight: 500; cursor: pointer;
}
.business-picker select:focus { border-color: var(--brand); }

/* Nav links */
.workspace-sidebar nav { display: flex; flex-direction: column; gap: 2px; padding: 0; }
.nav-caption { padding-left: 10px; margin-bottom: 8px; }
.nav-link {
  display: flex; align-items: center; gap: 11px;
  border: none;
  border-radius: var(--radius-sm);
  min-height: 42px; width: 100%;
  padding: 10px 12px;
  color: var(--sidebar-text);
  background: transparent;
  text-align: left; font-size: 12px; font-weight: 500;
  position: relative;
  transition: background var(--transition), color var(--transition);
}
.nav-link svg { width: 17px; height: 17px; opacity: .8; }
.nav-link:hover { color: rgba(255,255,255,0.85); background: var(--sidebar-hover); }
.nav-link.nav-item-active {
  background: var(--sidebar-active);
  color: var(--brand);
  font-weight: 600;
}
.nav-link.nav-item-active svg { opacity: 1; }
.nav-link.nav-item-active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%;
  background: var(--brand);
  border-radius: 0 3px 3px 0;
}

/* Nav badge */
.nav-count {
  margin-left: auto;
  border-radius: 20px; font-size: 9px; min-width: 18px;
  padding: 2px 6px;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.5);
  text-align: center; font-weight: 600;
}
.nav-item-active .nav-count {
  background: rgba(37,211,102,0.25);
  color: var(--brand);
}

/* Sidebar upsell note */
.sidebar-note {
  margin-top: auto;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 14px 12px;
}
.sidebar-note-icon {
  height: 26px; width: 26px; display: grid; place-items: center;
  border: 1px solid rgba(37,211,102,0.3);
  background: rgba(37,211,102,0.1);
  border-radius: 7px; color: var(--brand); margin-bottom: 10px;
}
.sidebar-note-icon svg { width: 14px; height: 14px; }
.sidebar-note strong { display: block; font-size: 11px; font-weight: 600; color: rgba(255,255,255,0.75); line-height: 1.6; }
.sidebar-note p { font-size: 10px; color: rgba(255,255,255,0.35); line-height: 1.8; margin-top: 6px; }
.sidebar-note button {
  display: flex; justify-content: space-between;
  background: transparent; color: var(--brand);
  border-top: 1px solid rgba(255,255,255,0.07);
  padding-top: 10px; margin-top: 12px;
  font-size: 10px; font-weight: 600; width: 100%;
}

/* Sidebar footer */
.sidebar-footer {
  display: flex; align-items: center; gap: 9px;
  padding: 18px 8px 0;
  border-top: 1px solid rgba(255,255,255,0.07);
  margin-top: 12px;
}
.brand-mark.mini {
  height: 28px; width: 28px; border-radius: 8px; font-size: 18px;
  background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.4);
  box-shadow: none;
}
.sidebar-footer strong { display: block; font-size: 10px; font-weight: 500; color: rgba(255,255,255,0.45); }
.sidebar-footer small { font-size: 8px; color: rgba(255,255,255,0.25); display: block; margin-top: 2px; }
.close-navigation { display: none !important; }
.nav-scrim { display: none; }

/* ===== HEADER ===== */
.workspace-header {
  display: flex; align-items: center; justify-content: space-between;
  height: 68px; flex-shrink: 0;
  padding: 0 32px; gap: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.header-heading { display: flex; align-items: center; gap: 12px; min-width: 0; }
.header-eyebrow {
  display: block; font-size: 8px; letter-spacing: 1.5px;
  font-weight: 600; color: var(--ink-3); text-transform: uppercase; margin-bottom: 2px;
}
.workspace-header h1 {
  font-size: 18px !important; font-weight: 700; letter-spacing: -.5px; color: var(--ink);
}
.header-actions { display: flex; align-items: center; gap: 10px; }

/* ===== BUTTONS ===== */
.button, button.button {
  display: inline-flex; align-items: center; gap: 7px;
  border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600;
  padding: 0 16px; min-height: 36px;
  border: 1.5px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
}
.button-primary {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
  box-shadow: 0 2px 10px var(--brand-glow);
}
.button-primary:hover:not(:disabled) {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  box-shadow: 0 4px 18px rgba(37,211,102,0.3);
}
.button-secondary {
  background: white;
  color: var(--ink-2);
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}
.button-secondary:hover:not(:disabled) {
  background: var(--line-soft);
  border-color: var(--ink-5);
}
.icon-button {
  width: 36px; height: 36px; min-width: 36px;
  border-radius: var(--radius-sm);
  background: white; border: 1.5px solid var(--line);
  display: grid; place-items: center; color: var(--ink-3);
  box-shadow: var(--shadow-sm);
}
.icon-button:hover { background: var(--canvas); color: var(--ink-2); }

/* ===== METRIC CARDS (Dashboard) ===== */
.metric-card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
  position: relative; overflow: hidden;
}
.metric-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.metric-top {
  font-size: 9px; letter-spacing: 1.5px; font-weight: 700;
  color: var(--ink-3); text-transform: uppercase; margin-bottom: 14px;
  display: flex; align-items: center; gap: 7px;
}
.metric-icon {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--brand-pale);
  color: var(--brand);
  margin-bottom: 14px;
}
.metric-icon svg { width: 16px; height: 16px; }
.metric-value {
  font-size: 36px; font-weight: 800; letter-spacing: -1.5px;
  color: var(--ink); line-height: 1; margin-bottom: 6px;
}
.metric-card > p {
  font-size: 11px; color: var(--ink-3); margin-top: 8px;
}
.metric-delta {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 600;
  padding: 2px 7px; border-radius: 20px;
  background: var(--brand-pale); color: var(--brand);
}
.metric-delta.down { background: #fff1f2; color: #e11d48; }

/* ===== PAGE INTRO ===== */
.page-intro { margin-bottom: 28px; }
.page-intro h2 { font-size: 26px; font-weight: 800; letter-spacing: -.8px; color: var(--ink); }
.page-intro p { font-size: 13px; color: var(--ink-3); margin-top: 7px; line-height: 1.6; }
.page-eyebrow {
  font-size: 9px; letter-spacing: 1.5px; font-weight: 700;
  color: var(--brand); text-transform: uppercase; margin-bottom: 10px; display: block;
}

/* ===== META CARDS / PANELS ===== */
.meta-card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 24px 28px;
  box-shadow: var(--shadow-sm);
}
.panel-heading { margin-bottom: 20px; }
.panel-heading h3 { font-size: 14px; font-weight: 700; color: var(--ink); }
.panel-heading p { font-size: 11px; color: var(--ink-3); margin-top: 4px; }
.panel-title-with-icon {
  display: flex; align-items: flex-start; gap: 12px; margin-bottom: 20px;
}
.panel-title-with-icon svg { color: var(--brand); flex-shrink: 0; margin-top: 2px; }
.panel-title-with-icon h3 { font-size: 14px; font-weight: 700; color: var(--ink); }
.panel-title-with-icon p { font-size: 11px; color: var(--ink-3); margin-top: 4px; }

/* ===== STUDIO / CAMPAIGN HERO ===== */
.studio-hero {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f3460 100%);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  position: relative; overflow: hidden; min-height: 220px;
  border: none;
}
.studio-hero::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at 70% 50%, rgba(37,211,102,0.12) 0%, transparent 60%);
}
.studio-hero h2 {
  font-size: 36px; font-weight: 800; letter-spacing: -1.5px;
  color: white; max-width: 400px; line-height: 1.1; position: relative; z-index: 1;
}
.studio-hero p { font-size: 13px; color: rgba(255,255,255,0.6); margin-top: 10px; max-width: 340px; position: relative; z-index: 1; }
.page-eyebrow.studio-hero { color: var(--brand); }
.hero-art {
  position: absolute; right: 20px; top: 50%; transform: translateY(-50%);
  opacity: .12; color: white;
}
.studio-hero > .hero-refresh {
  position: absolute; top: 16px; right: 16px;
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.6); border-radius: var(--radius-sm);
  width: 32px; height: 32px; display: grid; place-items: center;
  z-index: 2;
}
.studio-hero > .hero-refresh:hover { background: rgba(255,255,255,0.18); color: white; }
.studio-hero > .button { z-index: 1; position: relative; margin-top: 20px; }

/* Launch card */
.launch-card {
  background: linear-gradient(135deg, #0f172a, #1a3050);
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 32px; color: white;
}
.launch-card h3 { font-size: 28px; font-weight: 800; letter-spacing: -1px; }
.launch-card p { color: rgba(255,255,255,0.55); font-size: 12px; margin-top: 8px; }

/* ===== FORMS ===== */
.form-label, label {
  font-size: 11px; font-weight: 600; color: var(--ink-2); display: block; margin-bottom: 6px;
}
.form-hint { font-size: 10px; color: var(--ink-4); margin-top: 5px; line-height: 1.6; }
input[type="text"], input[type="email"], input[type="tel"], input[type="number"],
select, textarea {
  width: 100%;
  background: var(--canvas);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 13px; color: var(--ink);
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37,211,102,0.12);
  outline: none; background: white;
}
textarea { resize: vertical; min-height: 80px; }

/* ===== TABLES ===== */
table { width: 100%; border-collapse: collapse; }
thead th {
  font-size: 9px; letter-spacing: 1.2px; font-weight: 700;
  color: var(--ink-3); text-transform: uppercase;
  padding: 10px 12px; text-align: left;
  border-bottom: 1.5px solid var(--line);
  background: var(--canvas);
}
tbody tr { border-bottom: 1px solid var(--line-soft); }
tbody tr:hover { background: rgba(37,211,102,0.03); }
tbody td { padding: 12px 12px; font-size: 12px; color: var(--ink-2); }
.table-empty, .empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 56px 24px; text-align: center;
  color: var(--ink-3);
}
.table-empty strong, .empty-state strong { font-size: 15px; font-weight: 700; color: var(--ink-2); }
.table-empty p, .empty-state p { font-size: 12px; line-height: 1.7; }
.empty-state svg { opacity: .2; }

/* ===== BADGES / STATUS PILLS ===== */
.badge, [class*="bg-green"], [class*="bg-blue"], [class*="bg-rose"], [class*="bg-amber"] {
  display: inline-flex; align-items: center;
  border-radius: 20px; font-size: 10px; font-weight: 600;
  padding: 3px 10px; white-space: nowrap;
}

/* ===== TEMPLATE CARDS ===== */
.template-card { transition: box-shadow var(--transition), transform var(--transition); }
.template-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.template-card-heading {
  display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px;
}
.template-icon {
  width: 34px; height: 34px; display: grid; place-items: center;
  background: var(--brand-pale); color: var(--brand);
  border-radius: 9px; flex-shrink: 0;
}
.template-card h3 { font-size: 13px !important; font-weight: 700; color: var(--ink) !important; line-height: 1.4; }
.template-card-heading p { font-size: 10px; color: var(--ink-3); margin-top: 2px; font-family: 'JetBrains Mono', monospace; }
.template-status {
  margin-left: auto; font-size: 9px; font-weight: 700; padding: 3px 9px;
  border-radius: 20px; background: var(--brand-pale); color: var(--brand);
  white-space: nowrap; flex-shrink: 0;
}
.template-body {
  font-size: 12px; color: var(--ink-2); line-height: 1.8;
  max-height: 60px; overflow: hidden; position: relative;
  margin-bottom: 14px;
}
.template-body.is-expanded { max-height: none; }
.template-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 10px; color: var(--ink-3); padding-top: 12px;
  border-top: 1px solid var(--line);
}
.template-meta button { color: var(--brand); font-weight: 600; font-size: 10px; background: none; border: none; padding: 0; }
.template-read-more { color: var(--ink-3); font-size: 10px; background: none; border: none; padding: 2px 0; cursor: pointer; }

/* ===== CAMPAIGN SECTION ===== */
.campaign-tip {
  background: linear-gradient(to right, rgba(37,211,102,0.07), transparent);
  border-left: 3px solid var(--brand);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 18px; margin: 16px 0;
}
.campaign-tip p { font-size: 12px; color: var(--ink-2); line-height: 1.8; }

/* ===== PRICING NOTE ===== */
.pricing-note { font-size: 10px; color: var(--ink-3); line-height: 1.8; }
.queue-progress-heading { font-size: 10px; font-weight: 600; color: var(--ink-3); margin-bottom: 8px; }

/* ===== PROGRESS BAR ===== */
progress, [role="progressbar"] {
  border-radius: 99px; height: 6px; overflow: hidden;
}

/* ===== MESSAGE PREVIEW CARD (Campaign) ===== */
.message-preview-card {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.wa-chat-bg {
  background: #e5ddd5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 200 200'%3E%3Cpath fill='%23c8bbae' fill-opacity='0.3' d='M20 20h10v10H20zm30 0h10v10H50zm30 0h10v10H80zm30 0h10v10H110zm30 0h10v10H140zm30 0h10v10H170zM5 50h10v10H5zm30 0h10v10H35zm30 0h10v10H65zm30 0h10v10H95zm30 0h10v10H125zm30 0h10v10H155zm30 0h10v10H185z'/%3E%3C/svg%3E");
  padding: 16px 12px; min-height: 120px;
}
.preview-card-title { margin-bottom: 6px; }
.preview-card-title strong { font-size: 11px; font-weight: 700; color: #0f172a; }
.preview-card-title > div > span { font-size: 10px; color: #64748b; display: block; margin-top: 2px; }
.preview-message { font-size: 13px; color: #1e293b; line-height: 1.8; }
.preview-card-footer { font-size: 9px; color: #94a3b8; text-align: right; margin-top: 6px; }

/* ===== AUDIENCE FILTER BUTTONS ===== */
#view-audience button[id^="audFilter-"] {
  min-height: 34px; padding: 7px 14px;
  border-radius: 20px; font-size: 11px;
  background: white; border: 1.5px solid var(--line); color: var(--ink-2);
  box-shadow: var(--shadow-sm);
}
#view-audience button[id^="audFilter-"]:hover { border-color: var(--brand); color: var(--brand); }
#view-audience button[id^="audFilter-"].active-filter, #view-audience button.active-filter {
  background: var(--brand-pale); border-color: var(--brand); color: var(--brand); font-weight: 700;
}

/* ===== SETTINGS ===== */
#view-settings > div.meta-card { padding: 28px !important; }
#view-settings h3 { font-size: 17px !important; font-weight: 700; color: var(--ink) !important; }
#view-settings .text-slate-500 { color: var(--ink-3) !important; font-size: 11px !important; }
#view-settings .font-mono { font-size: 12px !important; color: var(--ink-2) !important; font-family: 'JetBrains Mono', 'Fira Code', monospace; }
#view-settings .bg-slate-50 { background: var(--canvas) !important; border-radius: var(--radius-sm) !important; padding: 16px !important; }
#view-settings .text-slate-700 { color: var(--ink-2) !important; }
#view-settings .text-slate-900 { color: var(--ink) !important; }
#view-settings label { color: var(--ink-2) !important; font-weight: 600 !important; }

/* ===== INBOX / CHAT ===== */
#view-inbox { margin: 0 !important; border-radius: 0 !important; }

/* CRM sidebar (contact list) */
#crmSidebar > div:first-child {
  padding: 18px 16px !important;
  border-bottom: 1px solid var(--line) !important;
  background: white !important;
}
#crmSidebar > div:first-child h3 { font-size: 15px !important; font-weight: 700; color: var(--ink); }
#crmSidebar > div:first-child p { font-size: 10px !important; color: var(--ink-3); }

/* Search */
#crmSearchInput {
  font-size: 13px !important;
  background: var(--canvas);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
}
#crmSearchInput:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,211,102,0.1); background: white; }

/* CRM filter buttons */
#crmSidebar button[id^="crmFilter"] {
  font-size: 10px; min-height: 30px;
  border-radius: 20px;
  background: transparent; border: 1.5px solid var(--line);
  color: var(--ink-3);
  padding: 4px 11px;
}
#crmSidebar button[id^="crmFilter"]:hover { border-color: var(--brand); color: var(--brand); }
#crmSidebar button[id^="crmFilter"].crm-filter-active {
  background: var(--brand-pale); border-color: var(--brand); color: var(--brand); font-weight: 700;
}

/* Conversation items */
.conversation-item {
  min-height: 72px; padding: 12px 14px; gap: 12px;
  background: white;
  border-left: 3px solid transparent !important;
  border-radius: 0 !important;
  transition: background var(--transition), border-color var(--transition);
}
.conversation-item:hover { background: var(--canvas); }
.conversation-item.is-selected {
  background: rgba(37,211,102,0.07) !important;
  border-left-color: var(--brand) !important;
}
.conversation-avatar {
  height: 42px; width: 42px; flex-shrink: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #0f172a, #1e40af);
  color: white; font-size: 13px; font-weight: 700;
  display: grid; place-items: center;
}
.conversation-item.is-selected .conversation-avatar {
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
}
.conversation-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.conversation-snippet { font-size: 11px; color: var(--ink-3); }
.conversation-time { font-size: 10px; color: var(--ink-4); }
.conversation-unread {
  background: var(--brand); color: white;
  font-size: 9px; height: 18px; min-width: 18px; border-radius: 20px;
  display: grid; place-items: center; font-weight: 700; padding: 0 4px;
}
.conversation-line + .conversation-line { margin-top: 5px; }

/* Chat header */
#rightCanvas > div:first-child {
  height: 68px !important;
  padding: 0 20px !important;
  background: white !important;
  border-bottom: 1px solid var(--line) !important;
  box-shadow: var(--shadow-sm) !important;
  gap: 12px !important;
}
#chatAvatar {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  font-size: 13px; font-weight: 700; color: white;
  display: grid; place-items: center; flex-shrink: 0;
}
#chatCustomerName { font-size: 14px !important; font-weight: 700; color: var(--ink); }
#chatCustomerPhone { font-size: 10px !important; color: var(--ink-3) !important; margin-top: 2px; }
.chat-back {
  width: 32px; min-width: 32px; height: 32px; min-height: 32px;
  border-radius: 9px; background: var(--canvas); border: 1.5px solid var(--line); color: var(--ink-3);
}

/* Chat thread */
#chatThread {
  padding: 24px 20px 28px !important;
  scrollbar-gutter: auto;
}
.chat-notice { font-size: 10px; color: var(--ink-4); padding-bottom: 8px !important; }
.chat-date {
  font-size: 10px; color: var(--ink-4);
  letter-spacing: .2px; padding: 10px 0 !important;
}
.message-row { margin: 10px 0 !important; }

/* Messages */
.message-row .msg-out {
  font-size: 13px !important;
  max-width: 72%; padding: 11px 14px 9px !important;
  background: linear-gradient(135deg, #25D366, #1aad52);
  color: white !important; border-radius: 16px 16px 4px 16px;
  box-shadow: 0 2px 8px rgba(37,211,102,0.2);
}
.message-row .msg-in {
  font-size: 13px !important;
  max-width: 72%; padding: 11px 14px 9px !important;
  background: white; color: var(--ink) !important;
  border-radius: 16px 16px 16px 4px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
}
.message-row p { line-height: 1.7; }
.message-meta { font-size: 9px; color: rgba(255,255,255,0.7); }
.msg-in + .message-meta { color: var(--ink-4); }
.message-delete {
  width: 26px; height: 26px; padding: 6px; opacity: .6;
  border-color: transparent; border-radius: 6px; background: transparent;
}
.message-delete:hover, .message-delete:focus-visible {
  opacity: 1; background: var(--canvas); border-color: var(--line);
}
.message-delete svg { width: 12px; height: 12px; }

/* Quick replies */
#rightCanvas > .chat-quick-replies {
  padding: 10px 20px !important; min-height: 50px; gap: 7px;
  background: var(--canvas) !important;
  border-top: 1px solid var(--line) !important;
}
#rightCanvas > .chat-quick-replies > span { font-size: 9px; color: var(--ink-4); white-space: nowrap; }
#rightCanvas > .chat-quick-replies button {
  font-size: 11px; min-height: 30px !important; padding: 5px 12px;
  border-radius: 20px;
  background: white; border: 1.5px solid var(--line); color: var(--ink-2);
  box-shadow: var(--shadow-sm);
}
#rightCanvas > .chat-quick-replies button:hover { border-color: var(--brand); color: var(--brand); }

/* Chat composer */
#rightCanvas > .chat-composer {
  padding: 14px 20px !important; gap: 10px;
  align-items: flex-end; min-height: 76px;
  background: white !important;
  border-top: 1px solid var(--line) !important;
  padding-bottom: max(14px, env(safe-area-inset-bottom)) !important;
}
#agentReplyInput {
  font-size: 13px !important; line-height: 1.6 !important;
  min-height: 44px !important; padding: 11px 14px !important;
  max-height: 128px; border-radius: var(--radius-sm) !important;
  background: var(--canvas) !important; border: 1.5px solid var(--line) !important;
  color: var(--ink) !important;
}
#agentReplyInput:focus {
  border-color: var(--brand) !important;
  box-shadow: 0 0 0 3px rgba(37,211,102,0.1) !important;
  background: white !important;
}
#btnSend {
  height: 44px; width: 44px; min-width: 44px; border-radius: var(--radius-sm);
  background: var(--brand); border-color: var(--brand); color: white;
  box-shadow: 0 2px 10px var(--brand-glow);
}
#btnSend:hover:not(:disabled) { background: var(--brand-dark); }
#btnSend svg { height: 18px; width: 18px; }

/* Inbox empty / welcome */
#view-inbox .inbox-empty {
  min-height: 350px !important; padding: 48px 24px !important;
}
.inbox-empty strong { font-size: 16px; line-height: 1.6; color: var(--ink-2); }
.inbox-empty p { font-size: 12px; color: var(--ink-3); line-height: 1.8; }
.inbox-empty .button { font-size: 12px; min-height: 40px; }

/* Welcome screen art */
.welcome-art svg { color: var(--brand); opacity: .15; }

/* ===== DIALOG / MODAL ===== */
.dialog-backdrop {
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(4px);
}
.dialog-card {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  padding: 32px 36px;
  box-shadow: var(--shadow-lg);
}
.dialog-top h2 { font-size: 22px; font-weight: 800; letter-spacing: -.6px; color: var(--ink); }
.dialog-top p { font-size: 12px; color: var(--ink-3); margin-top: 8px; line-height: 1.7; }
.dialog-card label { font-size: 11px; font-weight: 600; color: var(--ink-2) !important; }
.dialog-card input, .dialog-card textarea { font-size: 13px !important; }
.dialog-actions .button { min-height: 42px; font-size: 12px; }

/* ===== TOAST NOTIFICATIONS ===== */
.toast-region { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--ink);
  color: white; font-size: 13px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
  max-width: 320px;
}
.toast-error { background: #991b1b; }
.toast button { color: rgba(255,255,255,0.6); background: none; border: none; font-size: 18px; line-height: 1; padding: 0 0 0 4px; }
.toast button:hover { color: white; }
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ===== OVERVIEW PAGE EXTRAS ===== */
.overview-heading { margin-bottom: 28px; }
.workspace-shortcut {
  background: white; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px;
  display: flex; flex-direction: column; gap: 4px;
  transition: box-shadow var(--transition), transform var(--transition);
  cursor: pointer;
}
.workspace-shortcut:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.workspace-shortcut strong { font-size: 13px; font-weight: 700; color: var(--ink); }
.workspace-shortcut small { font-size: 11px; color: var(--ink-3); }

/* ===== ACCESSIBLE FOREGROUNDS ===== */
.page-intro p, .overview-heading p, .studio-hero p { color: rgba(255,255,255,0.6); }
.page-eyebrow, .header-eyebrow { color: var(--brand); }
.metric-top { color: var(--ink-3); }
.metric-value { color: var(--ink); }
.meta-card .text-slate-500 { color: var(--ink-3) !important; }
.meta-card .text-slate-700 { color: var(--ink-2) !important; }
.meta-card .text-slate-900 { color: var(--ink) !important; }
.meta-card label { color: var(--ink-2) !important; }
.meta-card .font-mono { color: var(--ink-3) !important; }
.table-empty p, .empty-state p { color: var(--ink-3); }
.table-empty strong, .empty-state strong { color: var(--ink-2); }

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 1023px) {
  .workspace-sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(0.4,0,0.2,1);
    z-index: 100; width: 260px;
  }
  body.navigation-open .workspace-sidebar { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .nav-scrim {
    display: block !important; position: fixed; inset: 0;
    background: rgba(15,23,42,0.5); z-index: 99;
    backdrop-filter: blur(2px);
  }
  .close-navigation { display: flex !important; }
  .mobile-only { display: flex; }
  main > section:not(#view-inbox) { padding: 20px 18px !important; }
  .workspace-header { padding: 0 18px; height: 60px; }
  .workspace-header h1 { font-size: 16px !important; }
  .metric-value { font-size: 28px; }
  .studio-hero { padding: 26px 24px; min-height: 180px; }
  .studio-hero h2 { font-size: 26px; }
  .meta-card { padding: 18px 20px; }
  .dialog-card { padding: 24px 20px; }
  .dialog-top h2 { font-size: 20px; }
  #view-inbox { margin: 8px !important; border-radius: var(--radius) !important; }
}

@media (max-width: 767px) {
  .workspace-header h1 { font-size: 14px !important; }
  main > section:not(#view-inbox) { padding: 16px 14px !important; }
  .meta-card { padding: 16px 14px; }
  .studio-hero { padding: 22px 18px; min-height: 160px; }
  .studio-hero h2 { font-size: 22px; max-width: 220px; }
  .metric-value { font-size: 24px; }
  #view-inbox { margin: 0 !important; border-radius: 0 !important; }
  .message-row .msg-out, .message-row .msg-in { max-width: 86% !important; }
  #rightCanvas > .chat-composer { padding: 10px 14px !important; }
  #rightCanvas > .chat-quick-replies { padding: 8px 14px !important; }
  #agentReplyInput { font-size: 16px !important; min-height: 44px !important; }
  .dialog-card { padding: 20px 18px; border-radius: var(--radius); }
}

@media (max-width: 479px) {
  .header-actions .button-primary { font-size: 10px; padding: 0 10px; }
  .metric-card { padding: 14px 16px; }
  .metric-value { font-size: 22px; }
  .launch-card h3 { font-size: 22px; }
  #crmSidebar > div:first-child { padding: 14px 12px !important; }
  .conversation-item { gap: 10px; padding: 12px; }
  .conversation-name { font-size: 12px; }
  .conversation-snippet { font-size: 11px; }
  .message-row .msg-out, .message-row .msg-in { max-width: 90% !important; font-size: 12px !important; }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  .metric-card, .nav-link, .button, .template-card { transition: none !important; }
  #chatThread { scroll-behavior: auto !important; }
  .workspace-sidebar { transition: none !important; }
  @keyframes slideUp { from { opacity: 0; } to { opacity: 1; } }
}

/* ===== TOUCH DEVICE TWEAKS ===== */
@media (pointer: coarse) {
  .message-meta .message-delete {
    position: static; float: none; margin: 0 0 0 4px;
    height: 26px; width: 26px; min-height: 26px; padding: 7px;
    display: inline-grid; place-items: center; flex-shrink: 0;
    opacity: .7;
  }
  .message-meta { align-items: center; min-height: 22px; }
}
