/* ==========================================================================
   Cyntara — Design System (v2)
   Soft-surface cards, refined spacing, subtle shadows, brand-blue accents.
   ========================================================================== */

:root {
  /* Surfaces */
  --bg: #f2f2f4;
  --bg-subtle: #ebebf0;
  --surface: #ffffff;
  --surface-hover: #fafafb;
  --surface-alt: #f7f7fa;

  /* Text */
  --text: #0b0b14;
  --text-secondary: #474760;
  --text-muted: #8b8ba3;
  --text-subtle: #b4b4c6;

  /* Brand (keep Cyntara blue) */
  --brand: #2563eb;
  --brand-hover: #1d4ed8;
  --brand-soft: #dbeafe;
  --brand-softer: #eff6ff;

  /* Accents for stat tiles / chart colors */
  --accent-sky: #7eb3ff;
  --accent-sky-soft: #e0ecff;
  --accent-amber: #f59e0b;
  --accent-amber-soft: #fef3c7;
  --accent-emerald: #10b981;
  --accent-emerald-soft: #d1fae5;
  --accent-rose: #f43f5e;
  --accent-rose-soft: #ffe4e6;
  --accent-violet: #8b5cf6;
  --accent-violet-soft: #ede9fe;
  --accent-cream: #f5ead3;

  /* Status colors */
  --success: #10b981;
  --success-soft: #d1fae5;
  --warning: #f59e0b;
  --warning-soft: #fef3c7;
  --danger: #ef4444;
  --danger-soft: #fee2e2;
  --info: #3b82f6;
  --info-soft: #dbeafe;

  /* Borders */
  --border: #e7e7ec;
  --border-strong: #d8d8e0;
  --border-soft: #f0f0f4;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(10, 10, 30, 0.04);
  --shadow-sm:
    0 1px 2px rgba(10, 10, 30, 0.03), 0 2px 6px rgba(10, 10, 30, 0.04);
  --shadow:
    0 2px 4px rgba(10, 10, 30, 0.04), 0 8px 24px rgba(10, 10, 30, 0.06);
  --shadow-md:
    0 4px 8px rgba(10, 10, 30, 0.05), 0 16px 32px rgba(10, 10, 30, 0.08);
  --shadow-lg:
    0 8px 16px rgba(10, 10, 30, 0.08), 0 24px 48px rgba(10, 10, 30, 0.12);
  --shadow-focus: 0 0 0 3px rgba(37, 99, 235, 0.18);

  /* Radii */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-md: 14px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --radius-3xl: 32px;
  --radius-pill: 9999px;

  /* Typography */
  --font-sans:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  --font-mono: "SF Mono", Monaco, Menlo, Consolas, monospace;

  /* Motion */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out: cubic-bezier(0.33, 1, 0.68, 1);

  /* Legacy aliases — keep old tokens alive so existing pages keep working */
  --primary-blue: var(--brand);
  --primary-blue-light: #3b82f6;
  --primary-blue-dark: var(--brand-hover);
  --bg-blue-50: var(--brand-softer);
  --bg-blue-100: var(--brand-soft);
  --gray-50: var(--surface-alt);
  --gray-100: var(--border-soft);
  --gray-200: var(--border);
  --gray-300: var(--border-strong);
  --gray-400: var(--text-subtle);
  --gray-500: var(--text-muted);
  --gray-600: #6b7280;
  --gray-700: var(--text-secondary);
  --gray-800: var(--text);
  --border-radius: var(--radius);
  --border-radius-lg: var(--radius-lg);
}

/* -------------------------------------------------------------------------- */
/* Reset / Base                                                               */
/* -------------------------------------------------------------------------- */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 15px;
}

body {
  font-family: var(--font-sans);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  letter-spacing: -0.005em;
}

h1, h2, h3, h4, h5 {
  letter-spacing: -0.018em;
  color: var(--text);
  font-weight: 600;
}

h1 { font-size: 1.75rem; line-height: 1.2; font-weight: 700; }
h2 { font-size: 1.375rem; line-height: 1.25; }
h3 { font-size: 1.125rem; line-height: 1.3; }

a { color: var(--brand); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--brand-hover); }

/* -------------------------------------------------------------------------- */
/* Layout shell (3-column)                                                    */
/* -------------------------------------------------------------------------- */

.app-shell {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr) 320px;
  min-height: 100vh;
  background: var(--bg);
  padding: 16px;
  gap: 16px;
}

.app-shell.no-rail {
  grid-template-columns: 252px minmax(0, 1fr);
}

@media (max-width: 1279px) {
  .app-shell,
  .app-shell.no-rail {
    grid-template-columns: 252px minmax(0, 1fr);
  }
  .app-rail { display: none !important; }
}

@media (max-width: 1023px) {
  .app-shell,
  .app-shell.no-rail {
    grid-template-columns: minmax(0, 1fr);
    padding: 0;
    gap: 0;
  }
}

.app-sidebar {
  background: var(--surface);
  border-radius: var(--radius-2xl);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 32px);
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  box-shadow: var(--shadow-xs);
}

.app-main {
  background: var(--surface);
  border-radius: var(--radius-2xl);
  padding: 32px 40px;
  min-height: calc(100vh - 32px);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.app-rail {
  background: var(--surface);
  border-radius: var(--radius-2xl);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: calc(100vh - 32px);
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  box-shadow: var(--shadow-xs);
}

@media (max-width: 1023px) {
  .app-sidebar {
    position: fixed;
    left: 12px;
    top: 12px;
    bottom: 12px;
    width: 256px;
    transform: translateX(calc(-100% - 24px));
    transition: transform 0.3s var(--ease);
    z-index: 50;
    max-height: calc(100vh - 24px);
    box-shadow: var(--shadow-lg);
  }
  .app-sidebar.open { transform: translateX(0); }
  .app-main {
    border-radius: 0;
    min-height: 100vh;
    padding: 20px 16px;
    box-shadow: none;
  }
}

/* -------------------------------------------------------------------------- */
/* Sidebar                                                                    */
/* -------------------------------------------------------------------------- */

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 24px;
  margin-bottom: 8px;
}
.sidebar-brand img { width: 28px; height: 28px; object-fit: contain; }
.sidebar-brand-name {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #2563eb 0%, #14b8a6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
  margin: 0 -4px;
  padding: 0 4px;
}

.nav-item,
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.9375rem;
  font-weight: 500;
  transition: all 0.15s var(--ease);
  cursor: pointer;
  position: relative;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.nav-item i,
.nav-link i {
  width: 18px;
  font-size: 1rem;
  color: var(--text-muted);
  transition: color 0.15s;
}

.nav-item:hover,
.nav-link:not(.active):hover {
  background: var(--surface-alt);
  color: var(--text);
}
.nav-item:hover i,
.nav-link:not(.active):hover i {
  color: var(--text);
}

.nav-item.active,
.nav-link.active,
.nav-link.active:hover {
  background: var(--text) !important;
  color: #ffffff !important;
  border-left: none !important;
  font-weight: 600;
}
.nav-item.active i,
.nav-link.active i {
  color: #ffffff !important;
}

.sidebar-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 16px 14px 6px;
}

.sidebar-upgrade {
  margin: 16px 4px 8px;
  background: linear-gradient(
    180deg,
    var(--surface-alt) 0%,
    var(--bg-subtle) 100%
  );
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  text-align: center;
}
.sidebar-upgrade-title { font-size: 0.95rem; font-weight: 600; margin-bottom: 4px; }
.sidebar-upgrade-copy { font-size: 0.8125rem; color: var(--text-muted); margin-bottom: 14px; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* -------------------------------------------------------------------------- */
/* Main page header                                                           */
/* -------------------------------------------------------------------------- */

.page-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}
.page-hero h1 {
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1.15;
}
.page-hero-subtitle {
  color: var(--text-muted);
  font-size: 0.9375rem;
  margin-top: 6px;
}
.page-hero-aside {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.875rem;
}
.page-hero-aside .icon-chip {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  background: var(--surface-alt);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}

/* -------------------------------------------------------------------------- */
/* Cards & surfaces                                                            */
/* -------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.2s, transform 0.2s;
}
.card:hover { box-shadow: var(--shadow-sm); }
.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-body { padding: 20px 24px; }

.surface-soft {
  background: var(--surface-alt);
  border-radius: var(--radius-lg);
  padding: 20px;
}

/* Stat tile (row form, matching the reference "Finished / Tracked / Efficiency") */
.stat-row {
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-pill);
  background: var(--surface-alt);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  flex-shrink: 0;
}
.stat-icon i { font-size: 1.1rem; }
.stat-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 2px;
  font-weight: 500;
}
.stat-value {
  font-size: 1.625rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}
.stat-delta {
  font-size: 0.8125rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.stat-delta.positive { color: var(--success); }
.stat-delta.negative { color: var(--danger); }

/* Stats row separator (dividers between stats like the reference) */
.stats-divider {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0;
}
.stats-divider > * {
  padding: 8px 24px;
  border-right: 1px solid var(--border);
}
.stats-divider > *:first-child { padding-left: 0; }
.stats-divider > *:last-child { padding-right: 0; border-right: none; }

/* Card with darker cream icon — used when stat icons should feel warm */
.stat-icon.cream { background: var(--accent-cream); }
.stat-icon.sky { background: var(--accent-sky-soft); color: var(--brand); }
.stat-icon.amber { background: var(--accent-amber-soft); color: #b45309; }
.stat-icon.emerald { background: var(--accent-emerald-soft); color: #047857; }
.stat-icon.rose { background: var(--accent-rose-soft); color: #be123c; }
.stat-icon.violet { background: var(--accent-violet-soft); color: #6d28d9; }

/* -------------------------------------------------------------------------- */
/* Data row (for task / campaign lists à la reference "Current Tasks")        */
/* -------------------------------------------------------------------------- */

.data-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border-soft);
  transition: background 0.15s;
}
.data-row:last-child { border-bottom: none; }
.data-row:hover { background: var(--surface-hover); }

.data-row-icon {
  width: 40px; height: 40px; border-radius: var(--radius-pill);
  background: var(--surface-alt);
  display: flex; align-items: center; justify-content: center;
  color: var(--text);
  flex-shrink: 0;
}
.data-row-title {
  flex: 1;
  font-weight: 500;
  font-size: 0.9375rem;
  color: var(--text);
  min-width: 0;
}
.data-row-title small { display: block; font-weight: 400; font-size: 0.8125rem; color: var(--text-muted); margin-top: 2px; }

.data-row-status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.8125rem; color: var(--text-secondary);
  min-width: 110px;
}
.status-dot { width: 8px; height: 8px; border-radius: var(--radius-pill); background: var(--text-muted); }
.status-dot.running,
.status-dot.progress { background: var(--warning); }
.status-dot.hold,
.status-dot.paused { background: var(--info); }
.status-dot.done,
.status-dot.complete,
.status-dot.sent { background: var(--success); }
.status-dot.failed { background: var(--danger); }

.data-row-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
  display: inline-flex; align-items: center; gap: 6px;
  min-width: 64px;
}
.data-row-actions {
  color: var(--text-muted); padding: 6px; border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.data-row-actions:hover { background: var(--surface-alt); color: var(--text); }

/* -------------------------------------------------------------------------- */
/* Right rail — profile card & activity                                       */
/* -------------------------------------------------------------------------- */

.rail-profile {
  background: var(--surface-alt);
  border-radius: var(--radius-xl);
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}
.rail-avatar {
  width: 84px; height: 84px;
  border-radius: var(--radius-pill);
  background: var(--accent-cream);
  display: flex; align-items: center; justify-content: center;
  color: var(--text); font-weight: 600; font-size: 1.75rem;
  position: relative;
  overflow: hidden;
}
.rail-avatar img { width: 100%; height: 100%; object-fit: cover; }
.rail-avatar-dot {
  position: absolute; right: 4px; bottom: 4px;
  width: 14px; height: 14px;
  border-radius: var(--radius-pill);
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--surface-alt);
}
.rail-name { font-weight: 600; font-size: 1.125rem; }
.rail-handle { font-size: 0.8125rem; color: var(--text-muted); }
.rail-actions { display: flex; gap: 10px; margin-top: 10px; }
.rail-actions .icon-btn {
  width: 40px; height: 40px; border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.rail-actions .icon-btn:hover {
  color: var(--brand); border-color: var(--brand);
  box-shadow: var(--shadow-focus);
}

.rail-section-title {
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
  text-align: center;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.activity-item { display: flex; gap: 12px; padding: 10px 0; }
.activity-avatar {
  width: 36px; height: 36px; border-radius: var(--radius-pill);
  background: var(--accent-sky-soft);
  display: flex; align-items: center; justify-content: center;
  color: var(--brand); font-weight: 600; font-size: 0.8125rem;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.activity-avatar img { width: 100%; height: 100%; object-fit: cover; }
.activity-avatar.online::after {
  content: ""; position: absolute; right: 0; bottom: 0;
  width: 10px; height: 10px;
  background: var(--success); border-radius: var(--radius-pill);
  border: 2px solid var(--surface);
}
.activity-body { flex: 1; min-width: 0; }
.activity-name { font-weight: 600; font-size: 0.9375rem; }
.activity-meta { font-size: 0.8125rem; color: var(--text-muted); }
.activity-time { font-size: 0.75rem; color: var(--text-muted); }

.message-bubble {
  background: var(--brand-softer);
  padding: 10px 14px;
  border-radius: 14px 14px 14px 4px;
  font-size: 0.875rem;
  color: var(--text);
  margin-top: 8px;
  line-height: 1.45;
  position: relative;
}
.message-bubble.own {
  background: var(--brand);
  color: white;
  border-radius: 14px 14px 4px 14px;
}

.message-input {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-alt);
  border-radius: var(--radius-pill);
  padding: 6px 8px 6px 16px;
  margin-top: auto;
}
.message-input input {
  flex: 1; border: none !important; background: transparent !important;
  font-size: 0.875rem; padding: 6px 0 !important;
  box-shadow: none !important;
}
.message-input .icon-btn {
  width: 32px; height: 32px; border-radius: var(--radius-pill);
  background: transparent; border: none;
  color: var(--text-muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.message-input .icon-btn:hover { color: var(--brand); }

/* -------------------------------------------------------------------------- */
/* Buttons                                                                    */
/* -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  transition: all 0.18s var(--ease);
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1.2;
  font-family: inherit;
  text-decoration: none;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--brand);
  color: white;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) {
  background: var(--brand-hover);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-alt);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--surface-alt); color: var(--text); }

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { background: #b91c1c; }

.btn-pill {
  background: var(--surface-alt);
  color: var(--text);
  border-radius: var(--radius-pill);
  padding: 8px 14px;
  font-size: 0.8125rem;
  border: 1px solid transparent;
}
.btn-pill:hover { background: var(--border-soft); }

.btn-sm { padding: 6px 12px; font-size: 0.8125rem; }
.btn-lg { padding: 12px 22px; font-size: 0.9375rem; }
.btn-xl { padding: 14px 28px; font-size: 1rem; font-weight: 600; }

/* Floating upgrade button (reference) */
.btn-soft-brand {
  background: var(--brand-soft);
  color: var(--brand-hover);
  border-radius: var(--radius-pill);
  font-weight: 600;
  padding: 10px 20px;
}
.btn-soft-brand:hover { background: #bfdbfe; color: var(--brand-hover); }

/* -------------------------------------------------------------------------- */
/* Inputs                                                                     */
/* -------------------------------------------------------------------------- */

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="search"],
input[type="url"],
textarea,
select {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.15s;
  background: var(--surface);
  line-height: 1.45;
}
textarea { min-height: 88px; resize: vertical; }

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--shadow-focus);
}

input::placeholder,
textarea::placeholder { color: var(--text-muted); }

input.pl-10 { padding-left: 2.5rem !important; }

/* Search input variant */
.search-input {
  background: var(--surface-alt);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  padding-left: 38px;
}
.search-input:focus { background: var(--surface); }

label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* -------------------------------------------------------------------------- */
/* Badges / chips / tags                                                      */
/* -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
  background: var(--surface-alt);
  color: var(--text);
}
.badge-green { background: var(--success-soft); color: #047857; }
.badge-blue { background: var(--info-soft); color: var(--brand-hover); }
.badge-yellow { background: var(--warning-soft); color: #92400e; }
.badge-red { background: var(--danger-soft); color: #b91c1c; }
.badge-purple { background: var(--accent-violet-soft); color: #6d28d9; }
.badge-outline { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--surface-alt);
  font-size: 0.8125rem;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
}
.chip:hover { background: var(--border-soft); }
.chip.active {
  background: var(--text);
  color: white;
}

/* -------------------------------------------------------------------------- */
/* Tables                                                                     */
/* -------------------------------------------------------------------------- */

.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
table thead {
  background: transparent;
}
table thead th {
  padding: 12px 20px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  background: transparent;
}
table tbody tr {
  transition: background-color 0.12s;
  border-bottom: 1px solid var(--border-soft);
}
table tbody tr:last-child { border-bottom: none; }
table tbody tr:hover { background: var(--surface-alt); }
table tbody td {
  padding: 14px 20px;
  font-size: 0.875rem;
  color: var(--text);
  vertical-align: middle;
}

/* -------------------------------------------------------------------------- */
/* Avatars                                                                    */
/* -------------------------------------------------------------------------- */

.avatar {
  border-radius: var(--radius-pill);
  background: var(--surface-alt);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 32px; height: 32px; font-size: 0.75rem; }
.avatar-md { width: 40px; height: 40px; font-size: 0.875rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.125rem; }
.avatar-xl { width: 80px; height: 80px; font-size: 1.625rem; }

/* -------------------------------------------------------------------------- */
/* Channel + selection cards                                                  */
/* -------------------------------------------------------------------------- */

.channel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  cursor: pointer;
  transition: all 0.15s;
}
.channel-card:hover { border-color: var(--brand); box-shadow: var(--shadow-sm); }
.channel-card.selected {
  border-color: var(--brand);
  background: var(--brand-softer);
  box-shadow: var(--shadow-focus);
}

.filter-btn {
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}
.filter-btn:hover { background: var(--surface-alt); color: var(--text); }
.filter-btn.active {
  background: var(--text);
  color: white;
  font-weight: 500;
}

.template-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all 0.2s;
}
.template-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

/* -------------------------------------------------------------------------- */
/* Wizard                                                                     */
/* -------------------------------------------------------------------------- */

.wizard-step { display: none; }
.wizard-step.active { display: block; }

/* -------------------------------------------------------------------------- */
/* Scrollbar                                                                  */
/* -------------------------------------------------------------------------- */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); }

/* -------------------------------------------------------------------------- */
/* Loading spinner                                                            */
/* -------------------------------------------------------------------------- */

.loading {
  display: inline-block; width: 20px; height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 1s ease-in-out infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(
    90deg,
    var(--border-soft) 0%,
    var(--surface-alt) 50%,
    var(--border-soft) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* -------------------------------------------------------------------------- */
/* Toast notifications (kept compatible with existing showToast())            */
/* -------------------------------------------------------------------------- */

.toast {
  position: fixed;
  top: 24px; right: 24px;
  min-width: 320px; max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  animation: slideInToast 0.28s var(--ease) forwards;
  overflow: hidden;
  font-family: inherit;
}

.toast + .toast { top: calc(24px + var(--toast-offset, 0px)); }

@keyframes slideInToast {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes slideOutToast {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(24px); opacity: 0; }
}
.toast.removing { animation: slideOutToast 0.2s var(--ease-out) forwards; }

.toast-content {
  display: flex; align-items: flex-start;
  padding: 14px 16px; gap: 12px;
  position: relative;
}
.toast::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: currentColor; opacity: 0.9;
}
.toast-icon {
  flex-shrink: 0; width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px; font-size: 16px;
}
.toast-body { flex: 1; min-width: 0; }
.toast-title {
  font-size: 13px; font-weight: 600; line-height: 18px;
  margin: 0 0 2px; color: var(--text);
}
.toast-message {
  font-size: 13px; line-height: 19px; margin: 0;
  color: var(--text-secondary); word-wrap: break-word;
}
.toast-message strong { color: var(--text); font-weight: 600; }
.toast-message code {
  background: var(--surface-alt); padding: 1px 6px;
  border-radius: 4px; font-size: 12px;
  font-family: var(--font-mono); color: var(--text);
}
.toast-message ul {
  margin: 6px 0 0; padding-left: 16px;
  font-size: 12.5px; line-height: 18px; color: var(--text-muted);
}
.toast-message ul li { margin: 2px 0; }
.toast-close {
  flex-shrink: 0; width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-muted);
  transition: all 0.12s; background: none; border: none;
  padding: 0; margin-top: 1px; border-radius: 4px; font-size: 11px;
}
.toast-close:hover { color: var(--text); background: var(--surface-alt); }
.toast-progress {
  height: 2px; background: rgba(15, 23, 42, 0.04);
  position: relative; overflow: hidden;
}
.toast-progress-bar {
  height: 100%; width: 100%;
  transform-origin: left;
  animation: progressBar 5s linear forwards;
  background: currentColor; opacity: 0.7;
}
@keyframes progressBar {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

.toast.success { color: var(--success); }
.toast.success .toast-title { color: #064e3b; }
.toast.error { color: var(--danger); }
.toast.error .toast-title { color: #7f1d1d; }
.toast.warning { color: var(--warning); }
.toast.warning .toast-title { color: #78350f; }
.toast.info { color: var(--brand); }
.toast.info .toast-title { color: #1e3a8a; }

/* Modals */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(11, 11, 20, 0.55);
  backdrop-filter: blur(4px);
  z-index: 9998;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s var(--ease-out);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Drag & drop */
.drag-drop-area {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 48px;
  text-align: center;
  transition: all 0.3s;
  background: var(--surface-alt);
}
.drag-drop-area.dragging {
  border-color: var(--brand);
  background: var(--brand-softer);
}

/* Charts responsive */
.chart-container {
  position: relative;
  width: 100%;
  min-height: 240px;
}
.chart-container canvas { width: 100% !important; height: auto !important; }

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* -------------------------------------------------------------------------- */
/* Legacy Tailwind-style helpers (keep old pages working)                     */
/* -------------------------------------------------------------------------- */

.bg-white { background-color: var(--surface) !important; }
.bg-gray-50 { background-color: var(--surface-alt) !important; }
.bg-gray-100 { background-color: var(--bg-subtle) !important; }

/* Fallback — don't rely on Tailwind CDN generating this */
.hidden { display: none !important; }

/* -------------------------------------------------------------------------- */
/* Print                                                                      */
/* -------------------------------------------------------------------------- */

@media print {
  .no-print,
  .app-sidebar,
  .app-rail { display: none !important; }
  .app-shell { padding: 0; }
  .app-main { box-shadow: none; border-radius: 0; padding: 0; }
}

/* -------------------------------------------------------------------------- */
/* Responsive fine-tuning                                                     */
/* -------------------------------------------------------------------------- */

@media (max-width: 1023px) {
  .page-hero h1 { font-size: 1.5rem; }
  .app-main { padding: 20px 16px; }
}

@media (max-width: 639px) {
  html { font-size: 14px; }
  .toast {
    right: 10px; left: 10px;
    min-width: auto; max-width: calc(100vw - 20px);
    top: 10px;
  }
  @keyframes slideInToast {
    from { transform: translateY(-100px) scale(0.95); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
  }
  .stats-divider > * {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
  }
  .stats-divider > *:last-child { border-bottom: none; }
  .page-hero { flex-direction: column; gap: 8px; }
  h1.text-2xl { font-size: 1.375rem; }
}

@media (max-width: 1023px) {
  table tbody td, table thead th {
    padding: 10px 14px;
    font-size: 0.8125rem;
  }
}

@media (max-width: 767px) {
  .btn,
  button,
  a.px-4 {
    min-height: 40px;
  }
  input[type="checkbox"],
  input[type="radio"] {
    min-width: 18px; min-height: 18px;
  }
}
