/* ==========================================================================
   NotifyFlow Design System — Light Professional Theme
   Inspired by Stripe / Linear. Zero dark-theme remnants.
   ========================================================================== */

/* ---------- Design Tokens ---------- */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #fafafa;
  --bg-tertiary: #f5f5f5;
  --surface: #ffffff;
  --surface-hover: #fafafa;
  --text-primary: #171717;
  --text-secondary: #525252;
  --text-tertiary: #a3a3a3;
  --border-default: rgba(0,0,0,0.08);
  --border-hover: rgba(0,0,0,0.15);
  --accent: #5e6ad2;
  --accent-hover: #4f56b3;
  --accent-subtle: rgba(94,106,210,0.08);
  --accent-on: #ffffff;
  --status-success: #22c55e;
  --status-success-bg: rgba(34,197,94,0.10);
  --status-warning: #eab308;
  --status-warning-bg: rgba(234,179,8,0.10);
  --status-error: #ef4444;
  --status-error-bg: rgba(239,68,68,0.10);
  --status-info: #3b82f6;
  --status-info-bg: rgba(59,130,246,0.10);
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 8px -2px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 16px -4px rgba(0,0,0,0.08);
  --shadow-xl: 0 12px 24px -6px rgba(0,0,0,0.10);
  --shadow-focus: 0 0 0 2px #fff, 0 0 0 4px var(--accent);
  --sidebar-width: 240px;
  --transition-base: 150ms ease;

  /* Legacy aliases for backward compatibility with existing pages */
  --bg: var(--bg-secondary);
  --bg-alt: var(--bg-tertiary);
  --text: var(--text-primary);
  --text-bright: var(--text-primary);
  --text-dim: var(--text-tertiary);
  --border: var(--border-default);
  --font: var(--font-sans);
  --mono: var(--font-mono);
  --radius: var(--radius-md);
  --surface-glass: var(--surface);
  --glass-blur: 0px;
  --accent-green: var(--status-success);
  --accent-blue: var(--status-info);
  --accent-orange: var(--status-warning);
  --accent-red: var(--status-error);
  --accent-pink: #ec4899;
  --sidebar-w: var(--sidebar-width);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.5;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

button, a, input, select, textarea, [role="button"] {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

img, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }


/* ==========================================================================
   LOGIN SCREEN
   ========================================================================== */

.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-secondary);
  padding: 16px;
}

.login-card {
  max-width: 480px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 48px 40px;
  text-align: center;
}

.login-logo { margin-bottom: 32px; }
.login-logo .logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: var(--accent);
  color: var(--accent-on);
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 20px;
  margin-bottom: 16px;
}
.login-logo h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.login-logo p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.login-card label {
  display: block;
  text-align: left;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.login-card input[type="password"],
.login-card input[type="text"] {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 16px;
  outline: none;
  transition: border-color var(--transition-base);
}
.login-card input:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}

.login-card .btn-primary {
  height: 48px;
  border-radius: var(--radius-full);
  font-size: 15px;
}

.error-text {
  color: var(--status-error);
  font-size: 13px;
  margin-top: 8px;
}


/* ==========================================================================
   ONBOARDING SCREEN (full viewport, no sidebar)
   ========================================================================== */

.onboarding-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: var(--bg-secondary);
}

.onboarding-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-default);
  background: var(--surface);
  flex-shrink: 0;
}

.onboarding-header .logo-text {
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.onboarding-header .skip-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--font-sans);
}
.onboarding-header .skip-link:hover {
  color: var(--accent);
}

.onboarding-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
}

.onboarding-input-bar {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border-default);
  background: var(--surface);
  flex-shrink: 0;
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
}

/* Suggested prompt cards */
.suggested-prompts {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 12px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.suggested-prompts::-webkit-scrollbar { display: none; }

.suggested-prompt {
  flex-shrink: 0;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-base);
  font-family: var(--font-sans);
  white-space: nowrap;
  min-height: 48px;
  display: flex;
  align-items: center;
}
.suggested-prompt:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
}

/* Go to Dashboard button (after onboarding) */
.goto-dashboard-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 10px 20px;
  background: var(--accent);
  color: var(--accent-on);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-base);
}
.goto-dashboard-btn:hover { background: var(--accent-hover); }


/* ==========================================================================
   CHAT BUBBLES (shared between onboarding + agent page)
   ========================================================================== */

.chat-bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-on);
  border-bottom-right-radius: 4px;
}

.chat-bubble.assistant .bubble-content p { margin: 0 0 8px; }
.chat-bubble.assistant .bubble-content p:last-child { margin-bottom: 0; }
.chat-bubble.assistant code {
  background: var(--bg-tertiary);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
}

/* Action cards inside assistant bubbles */
.action-cards {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}
.action-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--accent-subtle);
  border: 1px solid rgba(94,106,210,0.15);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-primary);
}
.action-card .action-icon {
  font-size: 14px;
  color: var(--accent);
  flex-shrink: 0;
}
.action-card .action-type {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  font-weight: 600;
}
.action-card .action-detail {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
}
.action-card a {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  margin-left: auto;
  flex-shrink: 0;
}
.action-card a:hover { text-decoration: underline; }

/* Typing indicator */
.typing-indicator {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 20px;
  background: var(--surface);
  border: 1px solid var(--border-default);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}
.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: typingBounce 1.4s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Chat input bar (shared pill style) */
.chat-input-bar {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chat-input-bar textarea,
.chat-input-bar input {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 10px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  outline: none;
  resize: none;
  transition: border-color var(--transition-base);
  line-height: 1.4;
}
.chat-input-bar textarea:focus,
.chat-input-bar input:focus {
  border-color: var(--accent);
}
.chat-input-bar textarea::placeholder,
.chat-input-bar input::placeholder {
  color: var(--text-tertiary);
}

.chat-send-btn {
  width: 44px;
  height: 44px;
  background: var(--accent);
  color: var(--accent-on);
  border: none;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  transition: background var(--transition-base);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }


/* ==========================================================================
   DASHBOARD LAYOUT
   ========================================================================== */

.dashboard {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-width);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  background: var(--surface);
  border-right: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-header {
  padding: 20px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-default);
}
.sidebar-header .logo-mark {
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: var(--accent-on);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.sidebar-header .logo-text {
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

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

.nav-group-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  padding: 16px 12px 6px;
}
.nav-group-label:first-child { padding-top: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition-base);
}
.nav-item:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--accent-subtle);
  color: var(--accent);
}
.nav-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.7;
}
.nav-item.active .nav-icon { opacity: 1; }

.nav-highlight {
  color: var(--accent) !important;
}
.nav-highlight::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  margin-right: -4px;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-default);
}
.session-info {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}
.env-badge {
  display: inline-block;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--accent-subtle);
  color: var(--accent);
  border-radius: var(--radius-sm);
  margin-left: 4px;
}

/* ---------- Content Area ---------- */
.content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 32px;
  max-width: calc(1200px + 64px);
  min-height: 100vh;
}


/* ==========================================================================
   MOBILE BOTTOM TAB BAR
   ========================================================================== */

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(56px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface);
  border-top: 1px solid var(--border-default);
  z-index: 200;
  justify-content: space-around;
  align-items: center;
}
.bottom-nav a,
.bottom-nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 48px;
  min-height: 48px;
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-tertiary);
  text-decoration: none;
  background: none;
  border: none;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: color var(--transition-base);
}
.bottom-nav a.active,
.bottom-nav button.active {
  color: var(--accent);
}
.bottom-nav .tab-icon {
  font-size: 20px;
  line-height: 1;
}

/* More drawer */
.more-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 300;
  animation: fadeIn 150ms ease;
}
.more-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 12px 0;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 301;
  animation: slideUp 200ms ease;
}
.more-drawer-handle {
  width: 36px;
  height: 4px;
  background: var(--border-hover);
  border-radius: 2px;
  margin: 0 auto 12px;
}
.more-drawer a,
.more-drawer button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
  background: none;
  border: none;
  font-family: var(--font-sans);
  cursor: pointer;
  text-align: left;
}
.more-drawer a:hover,
.more-drawer button:hover {
  background: var(--surface-hover);
}
.more-drawer .drawer-icon { font-size: 18px; width: 24px; text-align: center; }
.more-drawer .text-danger { color: var(--status-error); }

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}


/* ==========================================================================
   CARDS
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}


/* ==========================================================================
   KPI CARDS
   ========================================================================== */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  padding: 20px;
  border-left: 4px solid var(--accent);
}
.kpi-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.kpi-label {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}
.kpi-rate {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.kpi-card.green { border-left-color: var(--status-success); }
.kpi-card.blue { border-left-color: var(--status-info); }
.kpi-card.pink { border-left-color: #ec4899; }
.kpi-card.orange { border-left-color: var(--status-warning); }
.kpi-card.red { border-left-color: var(--status-error); }


/* ==========================================================================
   TABLES
   ========================================================================== */

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-tertiary);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
}
td {
  padding: 12px;
  border-bottom: 1px solid var(--border-default);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-hover); }

.clickable-row { cursor: pointer; }
.clickable-row:hover td { background: var(--accent-subtle); }


/* ==========================================================================
   STATUS BADGES
   ========================================================================== */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-delivered, .badge-sent {
  background: var(--status-success-bg);
  color: var(--status-success);
}
.badge-opened {
  background: var(--status-info-bg);
  color: var(--status-info);
}
.badge-clicked {
  background: var(--accent-subtle);
  color: var(--accent);
}
.badge-bounced, .badge-soft_bounced, .badge-failed, .badge-hard_bounce {
  background: var(--status-error-bg);
  color: var(--status-error);
}
.badge-complained, .badge-partial {
  background: var(--status-warning-bg);
  color: var(--status-warning);
}
.badge-suppressed, .badge-skipped, .badge-duplicate {
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
}
.badge-accepted, .badge-processing {
  background: var(--accent-subtle);
  color: var(--accent);
}


/* ==========================================================================
   BUTTONS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 16px;
  min-height: 48px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition-base);
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}
.btn:focus-visible { box-shadow: var(--shadow-focus); outline: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-on);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-danger {
  border-color: var(--status-error);
  color: var(--status-error);
  background: var(--surface);
}
.btn-danger:hover {
  background: var(--status-error-bg);
}

.btn-ghost {
  border: none;
  background: transparent;
  box-shadow: none;
  padding: 0 12px;
  color: var(--text-secondary);
  min-height: 36px;
}
.btn-ghost:hover { background: var(--surface-hover); }

.btn-sm {
  padding: 0 10px;
  min-height: 32px;
  font-size: 12px;
}
.btn-full { width: 100%; }
.btn-group { display: flex; gap: 8px; }


/* ==========================================================================
   FORMS
   ========================================================================== */

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  outline: none;
  transition: border-color var(--transition-base);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}
.form-input::placeholder, .form-textarea::placeholder {
  color: var(--text-tertiary);
}

.form-textarea {
  font-family: var(--font-mono);
  font-size: 14px;
  min-height: 120px;
  height: auto;
  padding: 12px 14px;
  resize: vertical;
  line-height: 1.5;
}

.form-select {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23a3a3a3' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-inline { display: flex; gap: 8px; align-items: flex-end; }
.form-inline .form-group { flex: 1; }


/* ==========================================================================
   SEARCH BAR
   ========================================================================== */

.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
}
.search-bar .form-input { flex: 1; }
.search-bar .form-select { width: auto; min-width: 140px; flex-shrink: 0; }


/* ==========================================================================
   PAGINATION
   ========================================================================== */

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}


/* ==========================================================================
   PAGE HEADER
   ========================================================================== */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}


/* ==========================================================================
   TABS
   ========================================================================== */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-default);
  margin-bottom: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-base);
  white-space: nowrap;
  min-height: 44px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.tab:hover { color: var(--text-primary); }
.tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}


/* ==========================================================================
   MODALS
   ========================================================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal {
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
}
.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}


/* ==========================================================================
   TOASTS
   ========================================================================== */

.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
}

.toast {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  color: var(--text-primary);
  animation: toastSlideIn 200ms ease;
}
.toast-success { border-left: 3px solid var(--status-success); }
.toast-error { border-left: 3px solid var(--status-error); }
.toast-info { border-left: 3px solid var(--status-info); }

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


/* ==========================================================================
   CODE BLOCKS
   ========================================================================== */

.code-block {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 14px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary);
}


/* ==========================================================================
   CHARTS
   ========================================================================== */

.chart-container { margin: 20px 0; }

/* Funnel bars */
.funnel-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.funnel-label {
  width: 80px;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: right;
  font-weight: 500;
}
.funnel-track {
  flex: 1;
  height: 32px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}
.funnel-fill {
  height: 100%;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  padding-left: 10px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  min-width: 40px;
  transition: width 300ms ease;
}
.funnel-value {
  width: 80px;
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* SVG charts */
svg text { font-family: var(--font-sans); }
.chart-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart-dot { stroke-width: 2; }
.chart-grid { stroke: var(--border-default); stroke-width: 1; }
.chart-axis-text { fill: var(--text-tertiary); font-size: 10px; }


/* ==========================================================================
   DETAIL PANEL
   ========================================================================== */

.detail-panel { margin-top: 16px; }
.detail-row {
  display: flex;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-default);
}
.detail-label {
  width: 140px;
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
  font-weight: 500;
}
.detail-value {
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-all;
}


/* ==========================================================================
   TEMPLATE EDITOR
   ========================================================================== */

.editor-layout { display: grid; grid-template-columns: 1fr 280px; gap: 16px; }
.editor-main { min-width: 0; }

.shortcode-section { margin-bottom: 16px; }
.shortcode-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  margin-bottom: 8px;
  font-weight: 600;
}
.shortcode-list { display: flex; flex-direction: column; gap: 2px; }
.shortcode-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--status-info);
  border: 1px solid transparent;
  transition: all var(--transition-base);
  background: none;
}
.shortcode-chip:hover {
  background: var(--status-info-bg);
  border-color: rgba(59,130,246,0.2);
}
.shortcode-chip::before { content: '{{'; color: var(--text-tertiary); font-size: 10px; }
.shortcode-chip::after { content: '}}'; color: var(--text-tertiary); font-size: 10px; }
.shortcode-chip.custom { color: var(--status-success); }
.shortcode-chip.custom:hover {
  background: var(--status-success-bg);
  border-color: rgba(34,197,94,0.2);
}

.preview-panel {
  background: #fff;
  color: #333;
  border-radius: var(--radius-sm);
  min-height: 200px;
  font-family: -apple-system, sans-serif;
  font-size: 14px;
  overflow: hidden;
}
.preview-panel iframe {
  width: 100%;
  min-height: 200px;
  border: none;
  background: #fff;
  border-radius: var(--radius-sm);
}

.sample-data-textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
  line-height: 1.4;
}
.sample-data-textarea:focus { border-color: var(--accent); outline: none; }

/* TinyMCE overrides for light theme */
.tox.tox-tinymce {
  border: 1px solid var(--border-default) !important;
  border-radius: var(--radius-sm) !important;
}
.tox .tox-toolbar__primary {
  background: var(--bg-secondary) !important;
  border-bottom: 1px solid var(--border-default) !important;
}
.tox .tox-edit-area { background: var(--surface) !important; }
.tox .tox-statusbar {
  background: var(--bg-secondary) !important;
  border-top: 1px solid var(--border-default) !important;
}

.version-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.version-badge {
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  cursor: default;
}
.version-badge.current { border-color: var(--accent); color: var(--accent); }


/* ==========================================================================
   DOCS
   ========================================================================== */

.docs-section { margin-bottom: 32px; }
.docs-section h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}
.endpoint-card { margin-bottom: 12px; padding: 14px; }
.endpoint-method {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
}
.method-GET { background: var(--status-info-bg); color: var(--status-info); }
.method-POST { background: var(--status-success-bg); color: var(--status-success); }
.method-PUT { background: var(--status-warning-bg); color: var(--status-warning); }
.method-DELETE { background: var(--status-error-bg); color: var(--status-error); }
.endpoint-path {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-primary);
  margin-left: 8px;
}


/* ==========================================================================
   LOADING / SPINNER / SKELETON
   ========================================================================== */

.loading {
  text-align: center;
  padding: 60px;
  color: var(--text-tertiary);
}
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-default);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-secondary) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}


/* ==========================================================================
   UTILITY CLASSES
   ========================================================================== */

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-dim { color: var(--text-tertiary); }
.text-bright { color: var(--text-primary); }
.text-accent { color: var(--accent); }
.text-green { color: var(--status-success); }
.text-red { color: var(--status-error); }
.text-sm { font-size: 12px; }
.text-mono { font-family: var(--font-mono); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-2 { margin-bottom: 16px; }
.gap-2 { gap: 16px; }
.flex { display: flex; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }


/* ==========================================================================
   RESPONSIVE — TABLET (< 768px)
   ========================================================================== */

@media (max-width: 1024px) {
  .editor-layout { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  /* Hide sidebar, show bottom nav */
  .sidebar { display: none; }
  .bottom-nav { display: flex; }

  .content {
    margin-left: 0;
    padding: 16px;
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }

  .page-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
  .page-title { font-size: 20px; }

  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi-value { font-size: 24px; }
  .kpi-card { padding: 16px; }

  .card { padding: 16px; }

  .form-row { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }

  .search-bar { flex-direction: column; }
  .search-bar .form-input { width: 100%; }
  .search-bar .form-select { width: 100%; min-width: unset; }

  .btn-group { flex-wrap: wrap; }

  table { font-size: 12px; }
  th, td { padding: 8px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }

  .modal { max-width: 95%; padding: 20px; }

  .funnel-label { width: 60px; font-size: 10px; }
  .funnel-value { width: 60px; font-size: 11px; }

  .toast-container { left: 16px; right: 16px; max-width: unset; }

  /* Onboarding adjustments */
  .onboarding-messages { padding: 16px; }
  .chat-bubble { max-width: 90%; }
}


/* ==========================================================================
   RESPONSIVE — STACKED CARDS FOR TABLES (< 640px)
   ========================================================================== */

@media (max-width: 640px) {
  .table-responsive thead { display: none; }
  .table-responsive tbody tr {
    display: block;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-default);
  }
  .table-responsive tbody tr:last-child { border-bottom: none; }
  .table-responsive td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: none;
    font-size: 13px;
  }
  .table-responsive td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-tertiary);
    margin-right: 12px;
  }
}


/* ==========================================================================
   RESPONSIVE — VERY SMALL (< 400px)
   ========================================================================== */

@media (max-width: 400px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .login-card { padding: 24px 20px; }
}
