/* ════════════════════════════════════════════
   hCPaaS Design System v3
   ════════════════════════════════════════════ */

:root {
  /* Brand */
  --primary: #00a9df;
  --primary-dark: #0073c8;
  --primary-soft: #e6f7fc;
  --primary-rgb: 0, 169, 223;

  /* Semantic */
  --success: #059669;
  --success-soft: #d1fae5;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;

  /* Channels */
  --sms: #4f46e5;
  --rcs: #0284c7;
  --whatsapp: #16a34a;
  --email: #b45309;
  --obd: #dc2626;
  --viber: #7c3aed;
  --telegram: #0369a1;

  /* Surfaces */
  --nav-bg: #0089d8;
  --page-bg: #f2f7fa;
  --surface: #ffffff;
  --surface-alt: #f7f9fc;
  --surface-strong: #edfaf8;
  --border: #e2e8f0;
  --border-strong: #c8d4e0;

  /* Text */
  --text: #0f1b2d;
  --text-secondary: #3d4f68;
  --muted: #627187;
  --accent: #667080;
  --accent-soft: #eef1f4;

  /* Shape */
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.07), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-lg: 0 24px 64px rgba(10,20,40,0.13), 0 4px 12px rgba(0,0,0,0.06);
  --shadow-xl: 0 40px 100px rgba(5,15,35,0.22), 0 8px 30px rgba(0,0,0,0.1);

  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page-bg);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.6;
}

/* ── Typography ─────────────────────────────────── */

h1, h2, h3, p { margin-top: 0; }
p { margin-bottom: 8px; }

h1 {
  margin-bottom: 10px;
  font-size: clamp(30px, 5vw, 52px);
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-style: italic;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.015em;
}

h3 {
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.005em;
}

.muted { color: var(--muted); }

/* ── Form base ──────────────────────────────────── */

button, input, select, textarea { font: inherit; }

button {
  border: 0;
  cursor: pointer;
  border-radius: var(--radius-sm);
  min-height: 38px;
  padding: 0 16px;
  font-weight: 600;
  font-size: 13.5px;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  transition: background 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, transform 0.12s ease;
}

button:disabled { cursor: not-allowed; opacity: 0.45; }

button.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 2px 6px rgba(var(--primary-rgb), 0.2);
}

button.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  box-shadow: 0 5px 16px rgba(var(--primary-rgb), 0.28);
  transform: translateY(-1px);
}

button.primary:active:not(:disabled) { transform: translateY(0); }

button.secondary {
  color: var(--primary-dark);
  background: var(--primary-soft);
  border: 1px solid rgba(var(--primary-rgb), 0.25);
}

button.secondary:hover:not(:disabled) {
  background: rgba(var(--primary-rgb), 0.12);
  border-color: rgba(var(--primary-rgb), 0.3);
  transform: translateY(-1px);
}

button.secondary:active:not(:disabled) { transform: translateY(0); }

button.ghost {
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
}

button.ghost:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--text);
  border-color: var(--border-strong);
}

button.full { width: 100%; }

select, input, textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  padding: 9px 12px;
  color: var(--text);
  font-size: 13.5px;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
  box-shadow: var(--shadow-xs);
}

select:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.13), var(--shadow-xs);
}

input[type="color"] { min-height: 44px; padding: 4px; }

textarea {
  resize: vertical;
  min-height: 94px;
  line-height: 1.55;
}

.hidden { display: none !important; }

/* ════════════════════════════════════════════
   LOGIN SCREEN
   ════════════════════════════════════════════ */

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 70% at 15% 10%, rgba(0,181,170,0.14), transparent 55%),
    radial-gradient(ellipse 60% 60% at 85% 90%, rgba(79,70,229,0.1), transparent 50%),
    radial-gradient(ellipse 50% 50% at 50% 50%, rgba(0,181,170,0.05), transparent 65%),
    linear-gradient(160deg, #09182d 0%, #0b2040 55%, #071426 100%);
}

/* Dot grid overlay */
.login-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,0.025) 1px, transparent 0);
  background-size: 36px 36px;
  pointer-events: none;
}

/* Glowing orbs */
.login-screen::after {
  content: "";
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0,181,170,0.08), transparent 70%);
  top: -200px;
  left: -100px;
  pointer-events: none;
}

.login-panel {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(255,255,255,0.07);
}

/* Left: Brand panel */
.login-brand {
  padding: 52px 48px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  background: linear-gradient(150deg, #0e2040 0%, #0a1930 60%, #071322 100%);
  border-right: 1px solid rgba(255,255,255,0.07);
  position: relative;
  overflow: hidden;
}

.login-brand::before {
  content: "";
  position: absolute;
  right: -80px;
  bottom: -80px;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0,181,170,0.1), transparent 70%);
  pointer-events: none;
}

.login-brand .brand-mark {
  width: 62px;
  height: 62px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(0,181,170,0.25), rgba(0,150,140,0.15));
  border: 1px solid rgba(0,181,170,0.3);
  color: var(--primary);
  font-size: 34px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25), 0 0 0 4px rgba(0,181,170,0.08);
}

.login-brand h1 {
  color: #ffffff;
  margin-bottom: 8px;
  font-size: clamp(28px, 4vw, 48px);
  font-family: 'Sora', ui-sans-serif, sans-serif;
  font-style: normal;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--primary);
}

.login-brand .eyebrow { color: rgba(0,181,170,0.85); }

.login-desc {
  color: rgba(255,255,255,0.58);
  font-size: 13.5px;
  line-height: 1.65;
  margin: 0;
}

.login-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.login-strip span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.6);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Right: Login form */
.login-actions {
  padding: 52px 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  background: #ffffff;
}

.login-actions .eyebrow { color: var(--primary-dark); }

.login-actions > button {
  min-height: 56px;
  border-radius: var(--radius);
  text-align: left;
  padding: 12px 20px;
}

.login-field {
  display: grid;
  gap: 6px;
}

.login-field label {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
}

.login-field input {
  min-height: 44px;
}

.login-error {
  margin: -2px 0 0;
  padding: 9px 11px;
  border: 1px solid rgba(220,38,38,0.24);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: #991b1b;
  font-size: 12px;
  font-weight: 600;
}

#loginSubmit {
  margin-top: 4px;
  justify-content: center;
  text-align: center;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* ════════════════════════════════════════════
   APP SHELL
   ════════════════════════════════════════════ */

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  background: var(--page-bg);
  transition: grid-template-columns 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.app:has(.sidebar-state:checked),
.app.sidebar-expanded {
  grid-template-columns: 232px minmax(0, 1fr);
}

/* ── Sidebar ── */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 18px 8px;
  background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 55%, #11c4cf 100%);
  border-right: 0;
  overflow: hidden;
  transition: padding 200ms cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10;
}

.side-brand {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 40px;
  min-width: 0;
  width: 100%;
}

.brand-copy, .side-brand strong, .side-brand span { display: none; }

/* Sidebar toggle */
.sidebar-toggle {
  width: 34px;
  min-height: 30px;
  display: grid;
  place-items: center;
  appearance: none;
  padding: 0;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.5);
  background:
    linear-gradient(currentColor, currentColor) calc(50% - 5px) center / 1.5px 12px no-repeat,
    linear-gradient(currentColor, currentColor) 50% center / 1.5px 12px no-repeat,
    linear-gradient(currentColor, currentColor) calc(50% + 5px) center / 1.5px 12px no-repeat,
    linear-gradient(currentColor, currentColor) center calc(50% - 5px) / 14px 1.5px no-repeat,
    linear-gradient(currentColor, currentColor) center calc(50% + 5px) / 14px 1.5px no-repeat;
  border: 0;
  cursor: pointer;
  transition: color 0.14s ease;
}

.sidebar-toggle:hover { color: white; }

.sidebar .sidebar-toggle {
  width: 34px;
  min-height: 30px;
  padding: 0;
  border: 0;
  color: rgba(255,255,255,0.5);
  box-shadow: none;
  background:
    linear-gradient(currentColor, currentColor) calc(50% - 5px) center / 1.5px 12px no-repeat,
    linear-gradient(currentColor, currentColor) 50% center / 1.5px 12px no-repeat,
    linear-gradient(currentColor, currentColor) calc(50% + 5px) center / 1.5px 12px no-repeat,
    linear-gradient(currentColor, currentColor) center calc(50% - 5px) / 14px 1.5px no-repeat,
    linear-gradient(currentColor, currentColor) center calc(50% + 5px) / 14px 1.5px no-repeat;
}

.sidebar .sidebar-toggle:hover {
  color: #ffffff;
  box-shadow: none;
  background:
    linear-gradient(currentColor, currentColor) calc(50% - 5px) center / 1.5px 12px no-repeat,
    linear-gradient(currentColor, currentColor) 50% center / 1.5px 12px no-repeat,
    linear-gradient(currentColor, currentColor) calc(50% + 5px) center / 1.5px 12px no-repeat,
    linear-gradient(currentColor, currentColor) center calc(50% - 5px) / 14px 1.5px no-repeat,
    linear-gradient(currentColor, currentColor) center calc(50% + 5px) / 14px 1.5px no-repeat;
}

nav {
  display: grid;
  gap: 2px;
  flex: 1;
  align-content: start;
  width: 100%;
}

.nav-button {
  width: 38px;
  min-height: 38px;
  justify-content: center;
  text-align: left;
  background: transparent;
  color: rgba(255,255,255,0.72);
  display: flex;
  gap: 0;
  align-items: center;
  font-weight: 500;
  font-size: 13px;
  margin: 0 auto;
  padding: 0;
  border-radius: 999px;
  transition: background 0.14s ease, color 0.14s ease;
  min-width: 0;
  overflow-wrap: anywhere;
}

.nav-icon {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 20px;
  color: currentColor;
}

.nav-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-button.active {
  color: var(--primary);
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(0,0,0,0.13);
}

.nav-button:hover:not(.active) {
  background: rgba(255,255,255,0.16);
  color: #ffffff;
}

.nav-label { display: none; }

.nav-section {
  display: none;
  margin: 14px 0 2px;
  color: rgba(255,255,255,0.22);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-align: center;
}

/* ── Expanded sidebar ── */

.app:has(.sidebar-state:checked) .sidebar,
.app.sidebar-expanded .sidebar {
  align-items: stretch;
  padding: 20px 12px;
}

.app:has(.sidebar-state:checked) .side-brand,
.app.sidebar-expanded .side-brand {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
}

.app:has(.sidebar-state:checked) .brand-copy,
.app:has(.sidebar-state:checked) .side-brand strong,
.app:has(.sidebar-state:checked) .side-brand span,
.app:has(.sidebar-state:checked) .nav-label,
.app.sidebar-expanded .brand-copy,
.app.sidebar-expanded .side-brand strong,
.app.sidebar-expanded .side-brand span,
.app.sidebar-expanded .nav-label { display: block; }

.app:has(.sidebar-state:checked) .side-brand strong,
.app.sidebar-expanded .side-brand strong {
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.app:has(.sidebar-state:checked) .side-brand span,
.app.sidebar-expanded .side-brand span {
  margin-top: 1px;
  color: rgba(255,255,255,0.38);
  font-size: 10.5px;
}

.app:has(.sidebar-state:checked) nav,
.app.sidebar-expanded nav { gap: 2px; }

.app:has(.sidebar-state:checked) .nav-button,
.app.sidebar-expanded .nav-button {
  width: 100%;
  min-height: 38px;
  justify-content: flex-start;
  gap: 10px;
  padding: 0 10px;
}

.app:has(.sidebar-state:checked) .nav-button.active,
.app.sidebar-expanded .nav-button.active { position: relative; }

.app:has(.sidebar-state:checked) .nav-button.active::before,
.app.sidebar-expanded .nav-button.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 22%;
  bottom: 22%;
  width: 2.5px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}

.app:has(.sidebar-state:checked) .nav-label,
.app.sidebar-expanded .nav-label {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app:has(.sidebar-state:checked) .nav-section,
.app.sidebar-expanded .nav-section {
  display: block;
  margin: 16px 8px 4px;
  text-align: left;
}

.app:has(.sidebar-state:checked) #logout,
.app.sidebar-expanded #logout {
  width: 100%;
  min-height: 36px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.46);
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
}

.app:has(.sidebar-state:checked) #logout:hover,
.app.sidebar-expanded #logout:hover {
  background: rgba(255,255,255,0.09);
  color: rgba(255,255,255,0.7);
}

.app:has(.sidebar-state:checked) #logout::after,
.app.sidebar-expanded #logout::after { content: ""; }

#logout {
  width: 36px;
  min-height: 32px;
  padding: 0;
  border-radius: 999px;
  color: rgba(255,255,255,0.46);
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  font-size: 0;
  transition: all 0.14s ease;
}

#logout:hover {
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.78);
}

#logout::after {
  content: "CP";
  font-size: 11px;
  font-weight: 700;
}

/* ── Brand mark ── */

.brand-mark {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: white;
  background: linear-gradient(135deg, #0d2240, #0a1a30);
  border: 1.5px solid rgba(255,255,255,0.12);
  font-size: 34px;
  font-weight: 900;
  font-style: italic;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  letter-spacing: -0.03em;
}

.brand-mark.small {
  width: 34px;
  height: 34px;
  font-size: 18px;
  border-radius: 999px;
  border-width: 1px;
  background: rgba(255,255,255,0.16);
  border-color: rgba(255,255,255,0.24);
  box-shadow: none;
}

/* ── Main ── */

.main { min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 28px;
  background: rgba(255,255,255,0.9);
  border-bottom: 1px solid rgba(226,232,240,0.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.topbar > div { min-width: 0; }

.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  min-width: 0;
}

.top-actions select {
  width: auto;
  min-width: 180px;
  max-width: 240px;
}

.top-actions button { flex: 0 1 auto; }

#view { padding: 22px 28px 48px; }

/* ════════════════════════════════════════════
   LAYOUT
   ════════════════════════════════════════════ */

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.dashboard-hero {
  position: relative;
  min-height: 108px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
  padding: 22px 56px 22px 24px;
  overflow: hidden;
  color: #ffffff;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(155deg, rgba(var(--primary-rgb), 0.94), var(--primary-dark)),
    linear-gradient(90deg, rgba(255,255,255,0.1), transparent);
  box-shadow: 0 14px 34px rgba(var(--primary-rgb), 0.2);
}

.dashboard-hero::before,
.dashboard-hero::after {
  content: "";
  position: absolute;
  left: -8%;
  right: -8%;
  height: 54px;
  border: 1px solid rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.14) transparent transparent;
  border-radius: 50%;
  pointer-events: none;
}

.dashboard-hero::before { bottom: -28px; transform: rotate(-3deg); }
.dashboard-hero::after { bottom: 8px; transform: rotate(2deg); opacity: 0.55; }

.dashboard-hero-copy,
.dashboard-hero-actions {
  position: relative;
  z-index: 1;
}

.dashboard-hero-close {
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 12px;
  width: 30px;
  min-height: 30px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  color: rgba(255,255,255,0.76);
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 999px;
  box-shadow: none;
}

.dashboard-hero-close:hover {
  color: #ffffff;
  background: rgba(255,255,255,0.18);
}

.dashboard-hero-close svg {
  width: 15px;
  height: 15px;
  stroke-width: 2.4;
}

.dashboard-hero-copy {
  min-width: 0;
}

.dashboard-hero .hero-kicker {
  display: block;
  margin-bottom: 5px;
  color: rgba(255,255,255,0.78);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.dashboard-hero h2 {
  margin: 0 0 4px;
  color: #ffffff;
  font-size: 24px;
  letter-spacing: 0;
}

.dashboard-hero p {
  max-width: 670px;
  margin: 0;
  color: rgba(255,255,255,0.76);
  font-size: 12.5px;
  line-height: 1.45;
}

.dashboard-hero-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  flex: 0 0 auto;
}

.dashboard-hero-actions button {
  min-height: 34px;
  border-radius: 999px;
  padding: 0 15px;
  font-size: 12px;
  box-shadow: none;
}

.dashboard-hero-actions button.secondary {
  color: #ffffff;
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.48);
}

.dashboard-hero-actions button.primary {
  color: var(--primary-dark);
  background: #ffffff;
}

/* ════════════════════════════════════════════
   SURFACES
   ════════════════════════════════════════════ */

.panel, .kpi, .table-wrap, .phone, .builder-pane {
  background: var(--surface);
  border: 1px solid rgba(226,232,240,0.9);
  border-radius: var(--radius);
  min-width: 0;
  box-shadow: 0 7px 22px rgba(21, 35, 55, 0.055);
}

.panel, .table-wrap, .builder-pane { padding: 16px; }

/* ════════════════════════════════════════════
   KPI CARDS
   ════════════════════════════════════════════ */

.kpi {
  position: relative;
  min-height: 84px;
  padding: 15px 46px 15px 16px;
  overflow: hidden;
  border-radius: var(--radius);
}

/* Left accent stripe */
.kpi::before {
  content: "";
  position: absolute;
  right: 14px;
  top: 16px;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 8px 16px rgba(var(--primary-rgb), 0.22);
}

/* Decorative radial glow */
.kpi::after {
  content: "";
  position: absolute;
  right: 24px;
  top: 25px;
  width: 9px;
  height: 9px;
  border-top: 2px solid #fff;
  border-right: 2px solid #fff;
  transform: rotate(45deg);
  pointer-events: none;
}

.kpi label {
  position: relative;
  z-index: 1;
  display: block;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.kpi strong {
  position: relative;
  z-index: 1;
  display: block;
  margin-top: 5px;
  font-size: 20px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text);
}

.delta {
  position: relative;
  z-index: 1;
  display: inline-block;
  margin-top: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(var(--primary-rgb), 0.1);
  color: var(--primary-dark);
  font-size: 10.5px;
  font-weight: 700;
}

/* ════════════════════════════════════════════
   SECTION HEADS
   ════════════════════════════════════════════ */

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.section-head > * { min-width: 0; }
.section-head h3 { margin-bottom: 0; }
.section-head button { flex: 0 1 auto; }

/* ════════════════════════════════════════════
   TABLES
   ════════════════════════════════════════════ */

.table {
  width: 100%;
  min-width: 660px;
  border-collapse: collapse;
}

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

/* table-wrap nested inside a panel — strip panel chrome, just scroll */
.panel .table-wrap {
  background: none;
  border: none;
  box-shadow: none;
  border-radius: 0;
  padding: 0;
}

.table th, .table td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
  font-size: 13.5px;
}

.table th {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  padding-top: 10px;
  padding-bottom: 10px;
  white-space: nowrap;
}

.table th:first-child { border-radius: 6px 0 0 6px; }
.table th:last-child { border-radius: 0 6px 6px 0; }

.table td { border-bottom: 1px solid rgba(226,232,240,0.7); }
.table tbody tr:last-child td { border-bottom: 0; }

.table tbody tr { transition: background 0.1s ease; }
.table tbody tr:hover td { background: rgba(var(--primary-rgb), 0.03); }

.table-action {
  min-height: 32px;
  padding: 7px 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.table-action svg {
  width: 15px;
  height: 15px;
}

.recent-campaigns-panel {
  display: grid;
  align-content: start;
}

.campaign-list {
  display: grid;
  min-width: 0;
  gap: 10px;
  overflow: visible;
  background: transparent;
}

.campaign-list-head {
  display: none;
}

.campaign-list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
}

.campaign-list-row {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
}

.campaign-list-row:hover {
  background: rgba(var(--primary-rgb), 0.03);
}

.campaign-summary,
.campaign-meta,
.campaign-actions {
  min-width: 0;
}

.campaign-summary {
  display: grid;
  gap: 8px;
}

.campaign-summary strong {
  display: block;
  max-width: 100%;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.campaign-details {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 12px;
  align-items: center;
  min-width: 0;
}

.campaign-meta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.3;
}

.campaign-meta::before {
  content: attr(data-label) ": ";
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.campaign-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-direction: row;
  flex-wrap: nowrap;
  min-width: 76px;
}

.campaign-actions button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  white-space: nowrap;
  overflow-wrap: normal;
}

.campaign-action-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 34px;
}

.campaign-action-icon svg {
  width: 15px;
  height: 15px;
  stroke-width: 2.2;
}

.api-key-table .status-col {
  width: 92px;
  text-align: center;
  white-space: nowrap;
}

.api-key-table .action-col {
  width: 64px;
  text-align: center;
  white-space: nowrap;
}

.brand-swatch {
  width: 14px;
  height: 14px;
  display: inline-block;
  margin-right: 8px;
  border-radius: 4px;
  background: var(--swatch);
  vertical-align: middle;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12);
}

/* ════════════════════════════════════════════
   BADGES
   ════════════════════════════════════════════ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 19px;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--text-secondary);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.025em;
  max-width: 100%;
  line-height: 1;
  white-space: nowrap;
}

.badge.running, .badge.active, .badge.approved, .badge.delivered, .badge.read {
  color: #065f46;
  background: #d1fae5;
  border-color: #a7f3d0;
}

.badge.draft, .badge.pending, .badge.pending-review, .badge.changes-requested, .badge.scheduled, .badge.sent, .badge.queued {
  color: #92400e;
  background: #fef3c7;
  border-color: #fde68a;
}

.badge.failed, .badge.rejected, .badge.retired, .badge.paused, .badge.overdue {
  color: #7f1d1d;
  background: #fee2e2;
  border-color: #fca5a5;
}

/* Channel badges — light tint with matching outline */
.badge.channel {
  font-weight: 700;
  letter-spacing: 0.04em;
  border-width: 1px;
  font-size: 10px;
}

.badge.channel.sms      { color: var(--sms);      background: rgba(79,70,229,0.08);   border-color: rgba(79,70,229,0.28); }
.badge.channel.rcs      { color: var(--rcs);      background: rgba(2,132,199,0.08);   border-color: rgba(2,132,199,0.28); }
.badge.channel.whatsapp { color: var(--whatsapp); background: rgba(22,163,74,0.08);   border-color: rgba(22,163,74,0.28); }
.badge.channel.email    { color: var(--email);    background: rgba(180,83,9,0.08);    border-color: rgba(180,83,9,0.28); }
.badge.channel.obd      { color: var(--obd);      background: rgba(220,38,38,0.08);   border-color: rgba(220,38,38,0.28); }
.badge.channel.viber    { color: var(--viber);    background: rgba(124,58,237,0.08);  border-color: rgba(124,58,237,0.28); }
.badge.channel.telegram { color: var(--telegram); background: rgba(3,105,161,0.08);   border-color: rgba(3,105,161,0.28); }

/* ════════════════════════════════════════════
   CHANNEL ACCENT PANELS
   ════════════════════════════════════════════ */

.channel { border-left: 3px solid var(--primary); }
.channel.sms      { border-left-color: var(--sms); }
.channel.rcs      { border-left-color: var(--rcs); }
.channel.whatsapp { border-left-color: var(--whatsapp); }
.channel.email    { border-left-color: var(--email); }
.channel.obd      { border-left-color: var(--obd); }

/* ════════════════════════════════════════════
   CHARTS / BAR METERS
   ════════════════════════════════════════════ */

.chart-row { display: grid; gap: 6px; }

.bar {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  width: var(--w, 50%);
  background: linear-gradient(90deg, rgba(var(--primary-rgb), 0.55), var(--primary));
  border-radius: 999px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.daily-chart {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  grid-template-rows: 166px 22px 18px;
  column-gap: 8px;
  row-gap: 4px;
  margin-top: 10px;
}

.daily-y-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
  padding: 1px 0 3px;
}

.daily-plot {
  position: relative;
  min-width: 0;
  border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.daily-gridline {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid rgba(148, 163, 184, 0.28);
}

.daily-gridline.top { top: 0; }
.daily-gridline.middle { top: 50%; }
.daily-gridline.bottom { bottom: 0; }

.daily-bars {
  position: absolute;
  inset: 0;
  display: grid;
  gap: 6px;
  align-items: end;
  padding: 0 4px 0 6px;
}

.daily-bar {
  min-width: 0;
  background: linear-gradient(180deg, var(--accent), var(--primary));
  border-radius: 6px 6px 0 0;
}

.daily-x-axis {
  grid-column: 2;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.1;
}

.daily-x-axis span {
  min-width: 0;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
  text-align: center;
}

.daily-axis-labels {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
  padding-left: 2px;
}

/* ════════════════════════════════════════════
   CAMPAIGN BUILDER
   ════════════════════════════════════════════ */

.builder {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) 340px;
  gap: 16px;
  align-items: stretch;
  min-height: 620px;
}

.builder-pane {
  display: flex;
  flex-direction: column;
}

.wizard-body { flex: 1 1 auto; }

.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 22px;
}

.step {
  min-height: 36px;
  padding: 6px 8px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  border: 1.5px solid var(--border);
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-align: center;
  overflow-wrap: anywhere;
  transition: all 0.15s ease;
}

.step.active {
  color: white;
  background: var(--primary);
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(var(--primary-rgb), 0.28);
}

/* ════════════════════════════════════════════
   FORMS
   ════════════════════════════════════════════ */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field { display: grid; gap: 6px; }
.field.full { grid-column: 1 / -1; }

.field label {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* ════════════════════════════════════════════
   CHANNEL PICKER
   ════════════════════════════════════════════ */

.channel-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
}

.channel-option {
  min-height: 76px;
  border: 1.5px solid var(--border);
  background: white;
  display: grid;
  place-items: center;
  gap: 4px;
  color: var(--text);
  border-radius: var(--radius);
  transition: all 0.15s ease;
}

.channel-option:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.channel-option.active {
  outline: 2.5px solid var(--primary);
  outline-offset: 1px;
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-dark);
  box-shadow: 0 4px 14px rgba(var(--primary-rgb), 0.18);
}

.channel-option.sms.active      { outline-color: var(--sms); border-color: var(--sms); background: rgba(79,70,229,0.07); color: var(--sms); }
.channel-option.rcs.active      { outline-color: var(--rcs); border-color: var(--rcs); background: rgba(2,132,199,0.07); color: var(--rcs); }
.channel-option.whatsapp.active { outline-color: var(--whatsapp); border-color: var(--whatsapp); background: rgba(22,163,74,0.07); color: var(--whatsapp); }
.channel-option.email.active    { outline-color: var(--email); border-color: var(--email); background: rgba(180,83,9,0.07); color: var(--email); }
.channel-option.obd.active      { outline-color: var(--obd); border-color: var(--obd); background: rgba(220,38,38,0.07); color: var(--obd); }

/* ════════════════════════════════════════════
   PHONE PREVIEW
   ════════════════════════════════════════════ */

.phone {
  padding: 20px 16px;
  min-height: 560px;
  background: linear-gradient(160deg, #f7f9fc, #eef2f8);
  border-radius: var(--radius);
  overflow: hidden;
}

.phone-shell {
  margin: 0 auto;
  width: min(260px, 100%);
  min-height: 500px;
  border: 8px solid #17212f;
  border-radius: 32px;
  background: white;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,0.28), 0 0 0 1px rgba(255,255,255,0.08) inset;
}

.phone-head {
  padding: 12px 14px;
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  font-weight: 700;
  font-size: 13px;
}

.phone-body { padding: 14px; }

.rich-image {
  height: 110px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.1), rgba(79,70,229,0.07));
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  border: 1px dashed var(--border-strong);
}

.message-bubble {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f0fdf9;
  line-height: 1.55;
  overflow-wrap: anywhere;
  font-size: 13px;
  border: 1px solid rgba(var(--primary-rgb), 0.12);
}

.phone-cta {
  width: 100%;
  margin-top: 10px;
}

/* ════════════════════════════════════════════
   CONTROLS BAR
   ════════════════════════════════════════════ */

.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.controls > div {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

/* ════════════════════════════════════════════
   EVENT FEED
   ════════════════════════════════════════════ */

.event-feed {
  display: grid;
  gap: 4px;
  max-height: 340px;
  overflow: auto;
}

.event {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  background: #090f1c;
  color: #7dd3c0;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
  border: 1px solid rgba(255,255,255,0.04);
}

/* ════════════════════════════════════════════
   QA LIST
   ════════════════════════════════════════════ */

.qa-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.qa-list li {
  padding: 10px 12px 10px 36px;
  border: 1px solid rgba(var(--primary-rgb), 0.12);
  border-radius: var(--radius-sm);
  background: rgba(var(--primary-rgb), 0.03);
  color: var(--text);
  font-size: 13px;
  position: relative;
}

.qa-list li::before {
  content: "✓";
  position: absolute;
  left: 12px;
  color: var(--success);
  font-weight: 700;
  font-size: 12px;
}

/* ════════════════════════════════════════════
   UNIFIED INBOX
   ════════════════════════════════════════════ */

.inbox-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.inbox-queue-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 8px;
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
  scrollbar-width: none;
}

.inbox-queue-bar::-webkit-scrollbar { display: none; }

.queue-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  min-height: 30px;
  box-shadow: none;
  transition: all 0.14s ease;
}

.queue-tab:hover {
  background: var(--surface-alt);
  color: var(--text);
  border-color: var(--border);
}

.queue-tab.active {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-color: rgba(var(--primary-rgb), 0.2);
  font-weight: 600;
}

.queue-tab strong {
  font-size: 10.5px;
  font-weight: 700;
  background: var(--surface-alt);
  color: var(--muted);
  border-radius: 999px;
  padding: 1px 7px;
  min-width: 18px;
  text-align: center;
  transition: all 0.14s ease;
}

.queue-tab.active strong {
  background: rgba(var(--primary-rgb), 0.15);
  color: var(--primary-dark);
}

.queue-tab-sep {
  width: 1px;
  height: 16px;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 6px;
}

.queue-tab-meta {
  margin-left: auto;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.inbox {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
  height: 700px; /* fallback; overridden to flex:1 by .page-inbox on desktop */
}

.inbox-list, .inbox-detail {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

/* ── Inbox search / filter bar ── */

.inbox-search-area {
  flex-shrink: 0;
  padding: 10px 12px 6px;
}

.inbox-search-area input {
  width: 100%;
}

.inbox-filter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.inbox-filter-row select {
  flex: 1;
  min-height: 28px;
  padding: 3px 6px;
  font-size: 12px;
}

/* ── Conversation rows ── */

.convo-list {
  flex: 1;
  overflow-y: auto;
}

.convo-row {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  position: relative;
  cursor: pointer;
  transition: background 0.1s;
}

.convo-row:hover { background: var(--surface-alt); }

.convo-row.is-active { background: var(--primary-soft); }

.convo-row.is-active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--primary);
}

.convo-row.is-hot:not(.needs-reply) .convo-name::after {
  content: '●';
  color: #f59e0b;
  font-size: 7px;
  vertical-align: super;
  margin-left: 4px;
}

.convo-row.is-hot:not(.needs-reply) .convo-name::after {
  content: none;
  display: none;
}

.convo-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
}

.convo-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.convo-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.convo-title .convo-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reply-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.14);
}

.convo-time {
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.convo-sub {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 3px;
  font-size: 11.5px;
  color: var(--muted);
}

.convo-snippet {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  line-height: 1.4;
}

.convo-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ── Legacy: .conversation.compact used in bot builder ── */

.conversation.compact {
  text-align: left;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  box-shadow: none;
  min-height: 0;
  display: grid;
  gap: 4px;
  overflow-wrap: anywhere;
}

/* ── Detail header (name + inline meta strip) ── */

.detail-header {
  flex-shrink: 0;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--border);
}

.detail-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
}

.detail-name-row h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.detail-meta-row {
  display: flex;
  align-items: flex-start;
  gap: 0;
  flex-wrap: nowrap;
  overflow: hidden;
}

.meta-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 14px 0 0;
  min-width: 0;
}

.meta-field:first-child { padding-left: 0; }

/* Fixed fields — never shrink */
.mf-channel { flex: 0 0 66px; }
.mf-age     { flex: 0 0 52px; padding-right: 0; }

/* Flexible fields — shrink proportionally, truncate text */
.mf-intent { flex: 1 1 90px; min-width: 60px; }
.mf-owner  { flex: 1 1 110px; min-width: 80px; }
.mf-route  { flex: 1 1 130px; min-width: 96px; }

/* Status pills — sized by content, never shrink */
.mf-status { flex: 0 0 auto; }

.meta-label {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  line-height: 1;
  white-space: nowrap;
}

.meta-value {
  font-size: 12.5px;
  color: var(--text);
  font-weight: 500;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta-field-sep {
  width: 1px;
  background: var(--border);
  align-self: stretch;
  margin: 0 14px 0 0;
  flex-shrink: 0;
}

.meta-select {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  min-height: auto;
  padding: 0 18px 0 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.1s, background 0.1s;
  line-height: 1;
  width: 100%;
  box-sizing: border-box;
}

.meta-select:hover {
  border-color: var(--border-strong);
  background: var(--surface-alt);
}

.meta-select:focus {
  outline: 2px solid rgba(var(--primary-rgb), 0.2);
  border-color: var(--primary);
}

/* ── Status pill buttons ── */

.status-pills {
  display: inline-flex;
  gap: 2px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.status-pill {
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 600;
  border: none;
  border-radius: calc(var(--radius-sm) - 1px);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  min-height: auto;
  line-height: 1.5;
}

.status-pill:hover:not(.is-active) {
  background: var(--surface);
  color: var(--text);
}

.status-pill.is-active { color: #fff; }

.status-pill.sp-open { background: #2e7d32; }
.status-pill.sp-pending { background: #b45309; }
.status-pill.sp-resolved { background: #1565c0; }

/* ── Thread + reply area ── */

.detail-thread-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.detail-thread-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.detail-thread-label h4 {
  margin: 0;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.thread-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 0;
}

.detail-reply-area {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 16px 16px 18px;
  background: var(--surface-alt);
}

.external-reply-lock,
.handoff-card {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid rgba(180, 83, 9, 0.22);
  border-radius: var(--radius-sm);
  background: #fff7ed;
  color: #7c2d12;
  font-size: 13px;
}

.external-reply-lock span,
.handoff-card span {
  color: #9a3412;
}

.handoff-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.handoff-grid label {
  display: block;
  color: #9a3412;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.reply-compose {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 10px 10px 14px;
  transition: border-color 0.14s;
}

.reply-compose:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.reply-compose textarea {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  font-size: 13px;
  min-height: 52px;
  max-height: 120px;
  outline: none;
  padding: 0;
  line-height: 1.5;
  box-shadow: none;
}

.reply-send-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.14s, transform 0.1s;
  min-height: auto;
  box-shadow: none;
  padding: 0;
}

.reply-send-btn:hover { background: var(--primary-dark); }
.reply-send-btn:active { transform: scale(0.94); }

.agent-workspace {
  display: grid;
  gap: 16px;
}

.agent-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.agent-metric {
  min-width: 0;
  min-height: 78px;
  padding: 14px 16px;
  border: 1px solid rgba(226,232,240,0.9);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: 0 7px 22px rgba(21, 35, 55, 0.045);
}

.agent-metric-label {
  display: block;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.agent-metric strong {
  display: block;
  margin-top: 5px;
  color: var(--text);
  font-size: 21px;
  line-height: 1.05;
  font-weight: 800;
}

.agent-metric-detail {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.agent-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
  min-height: calc(100vh - 250px);
}

.agent-list,
.agent-detail {
  min-width: 0;
}

.agent-detail {
  display: flex;
  flex-direction: column;
}

.agent-meta {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.empty-state {
  display: grid;
  place-content: center;
  text-align: center;
}

.conversation-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.conversation-top strong {
  font-size: 13.5px;
  font-weight: 600;
}

.conversation-snippet {
  color: var(--muted);
  line-height: 1.4;
  font-size: 13px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.conversation-foot {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.assist-card {
  border: 1px solid rgba(var(--primary-rgb), 0.18);
  background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.05), rgba(79,70,229,0.03));
}

.thread-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  margin-bottom: 8px;
}

.thread-head h4 {
  margin: 0;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.thread-event {
  display: grid;
  gap: 4px;
  max-width: 78%;
}

.thread-event.outbound { justify-self: end; }

.thread-event.system {
  justify-self: center;
  max-width: 92%;
}

.thread-event .message-bubble { margin-top: 0; }

.thread-event.outbound .message-bubble {
  background: #eff6ff;
  border-color: rgba(59,130,246,0.14);
}

.thread-event.system .message-bubble {
  background: var(--surface-alt);
  border-color: var(--border);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.thread-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
}

.thread-meta strong { font-weight: 600; color: var(--text); }

.thread-event.outbound .thread-meta { justify-content: flex-end; }
.thread-event.system .thread-meta { justify-content: center; }

.inbox-toolbar { display: none; }

/* ── Inbox: fill viewport, no global scroll (desktop only) ── */
@media (min-width: 1041px) {
  body.page-inbox { overflow: hidden; }

  body.page-inbox .app {
    height: 100vh;
    overflow: hidden;
  }

  body.page-inbox .main {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
  }

  body.page-inbox .topbar {
    position: static; /* sticky requires a scroll parent; .main is overflow:hidden here */
    flex-shrink: 0;
  }

  body.page-inbox #view {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding-bottom: 0;
  }

  body.page-inbox .inbox-wrap {
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  body.page-inbox .inbox {
    flex: 1;
    min-height: 0;
    height: auto;
  }
}

.sla {
  display: inline-flex;
  min-height: 20px;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.sla.hot {
  background: #fee2e2;
  color: #7f1d1d;
}

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

/* ════════════════════════════════════════════
   FLOW BUILDER / DESIGNER
   ════════════════════════════════════════════ */

.designer {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) 360px;
  gap: 16px;
  align-items: stretch;
}

.flow-canvas {
  position: relative;
  min-height: 380px;
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  grid-auto-rows: 72px;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(var(--primary-rgb), 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--primary-rgb), 0.04) 1px, transparent 1px),
    #fafcfb;
  background-size: 24px 24px;
  overflow: auto;
}

.flow-connectors {
  position: absolute;
  inset: 14px;
  z-index: 3;
  width: calc(100% - 28px);
  height: calc(100% - 28px);
  pointer-events: none;
  overflow: visible;
}

.edge-controls {
  position: absolute;
  inset: 14px;
  z-index: 3;
  pointer-events: none;
}

.edge-remove {
  position: absolute;
  width: 20px;
  min-height: 20px;
  padding: 0;
  border-radius: 999px;
  background: #fee2e2;
  color: #7f1d1d;
  font-size: 11px;
  line-height: 1;
  transform: translate(-50%, -50%);
  cursor: pointer;
  pointer-events: auto;
  transition: background 0.14s ease;
}

.edge-remove:hover { background: #fca5a5; }

.menu-route-editor {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.menu-route-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.menu-route-refresh {
  min-height: 28px;
  padding: 5px 10px;
  font-size: 11.5px;
  white-space: nowrap;
}

.menu-route-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 0.9fr);
  gap: 10px;
  align-items: center;
}

.menu-route-item {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.menu-route-row select {
  width: 100%;
}

.flow-palette {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.palette-item {
  border: 1.5px dashed rgba(var(--primary-rgb), 0.4);
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: all 0.14s ease;
}

.palette-item:hover {
  border-style: solid;
  background: rgba(var(--primary-rgb), 0.12);
  transform: translateY(-1px);
}

.flow-node-wrap {
  position: relative;
  display: grid;
  align-self: start;
  height: 72px;
  z-index: 2;
}

.flow-node {
  height: 64px;
  min-height: 64px;
  display: grid;
  align-content: start;
  gap: 2px;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: white;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
  overflow: hidden;
}

.flow-node:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.flow-node[draggable="true"] { cursor: grab; }
.flow-node[draggable="true"]:active { cursor: grabbing; }

.flow-node.active {
  outline: 2.5px solid var(--primary);
  outline-offset: 1px;
  background: var(--primary-soft);
  border-color: rgba(var(--primary-rgb), 0.3);
  transform: none;
}

.node-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 5;
  width: 18px;
  min-height: 18px;
  padding: 0;
  border-radius: 999px;
  background: #fee2e2;
  color: #7f1d1d;
  font-weight: 900;
  font-size: 10px;
  line-height: 1;
  transition: background 0.14s ease;
}

.node-remove:hover { background: #fca5a5; }

.connect-handle {
  position: absolute;
  top: 50%;
  z-index: 4;
  display: inline-grid;
  width: 20px;
  min-height: 20px;
  place-items: center;
  padding: 0;
  border: 1.5px solid rgba(var(--primary-rgb), 0.55);
  border-radius: 999px;
  background: white;
  color: var(--primary-dark);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
  transform: translateY(-50%);
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
}

.connect-handle svg {
  width: 11px;
  height: 11px;
  stroke-width: 2.5;
}

.connect-in {
  left: -10px;
  cursor: copy;
}

.connect-out {
  right: -10px;
  cursor: pointer;
}

.connect-out:active {
  cursor: pointer;
}

.connect-handle:hover,
.connect-handle.is-drop-target {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 8px 18px rgba(var(--primary-rgb), 0.22);
  transform: translateY(-50%) scale(1.08);
}

/* === Connecting mode === */

/* Source node out-handle glows to show it's the origin */
.connect-out.is-active-source {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary-dark);
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.25);
  animation: source-pulse 1.2s ease-in-out infinite;
}

/* Source node gets a strong teal ring */
.flow-node.is-connecting-source {
  outline: 2.5px solid var(--primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgba(var(--primary-rgb), 0.15);
}

/* Target nodes highlight their in-handle */
body.is-connecting-flow .connect-in {
  width: 30px;
  min-height: 30px;
  border-color: var(--primary);
  background: var(--primary-soft);
  animation: target-pulse 0.9s ease-in-out infinite alternate;
  cursor: pointer;
}

body.is-connecting-flow .connect-in:hover {
  background: var(--primary);
  color: #fff;
  transform: translateY(-50%) scale(1.2);
  animation: none;
}

/* Target nodes dim their out-handle so user focuses on in-handles */
body.is-connecting-flow .connect-out:not(.is-active-source) {
  opacity: 0.35;
  pointer-events: none;
}

/* Target node hover: show it's clickable */
body.is-connecting-flow .flow-node.is-connecting-target {
  cursor: pointer;
}
body.is-connecting-flow .flow-node.is-connecting-target:hover {
  border-color: rgba(var(--primary-rgb), 0.5);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
}

@keyframes source-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.25); }
  50% { box-shadow: 0 0 0 7px rgba(var(--primary-rgb), 0.08); }
}

@keyframes target-pulse {
  0% { box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0.3); transform: translateY(-50%) scale(1); }
  100% { box-shadow: 0 0 0 5px rgba(var(--primary-rgb), 0.0); transform: translateY(-50%) scale(1.1); }
}

/* Connecting hint banner */
.flow-connecting-hint {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  margin-bottom: 10px;
  background: rgba(var(--primary-rgb), 0.07);
  border: 1.5px solid rgba(var(--primary-rgb), 0.22);
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--primary-dark);
  flex-wrap: wrap;
}
.flow-connecting-hint kbd {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  background: rgba(var(--primary-rgb), 0.1);
  border: 1px solid rgba(var(--primary-rgb), 0.3);
  border-radius: 4px;
  font-size: 11px;
  font-family: inherit;
  font-weight: 700;
}
.hint-sep {
  color: var(--muted);
  font-weight: 400;
}

/* Rubber-band SVG (fixed overlay while connecting) */
#flow-rubber-band {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
}

.node-type {
  color: var(--accent);
  font-size: 8.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1;
}

.flow-node strong {
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.flow-node .muted {
  font-size: 11px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ════════════════════════════════════════════
   CHAT TEST
   ════════════════════════════════════════════ */

.chat-test {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}

.chat-line {
  max-width: 85%;
  padding: 9px 12px;
  border-radius: 12px;
  background: white;
  border: 1px solid var(--border);
  font-size: 13.5px;
  line-height: 1.45;
}

.chat-line.user {
  justify-self: end;
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.25);
}

.wa-options { display: grid; gap: 8px; }

.wa-option {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid rgba(var(--primary-rgb), 0.2);
  background: var(--primary-soft);
  font-weight: 600;
  color: var(--primary-dark);
}

/* ════════════════════════════════════════════
   DOCS / CODE
   ════════════════════════════════════════════ */

.json-panel { min-height: 340px; }

.docs-code {
  padding: 16px;
  border-radius: var(--radius-sm);
  background: #08101e;
  color: #7dd3c0;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.65;
  border: 1px solid rgba(255,255,255,0.05);
  margin: 0;
}

/* ════════════════════════════════════════════
   UTILITIES
   ════════════════════════════════════════════ */

.docs-test-panel {
  display: grid;
  gap: 14px;
}

.docs-wide-panel {
  grid-column: 1 / -1;
}

.docs-test-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.docs-test-head h3 {
  margin-bottom: 8px;
}

.endpoint-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.endpoint-chip span {
  color: var(--primary-dark);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.endpoint-chip code {
  font-size: 12px;
  color: var(--text);
}

.docs-send-button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.docs-send-button svg {
  width: 16px;
  height: 16px;
}

.docs-test-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(280px, 1.1fr);
  gap: 16px;
  align-items: start;
}

.docs-test-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.docs-test-form input,
.docs-test-form select,
.docs-test-form textarea {
  box-shadow: none;
}

.docs-test-form textarea {
  min-height: 72px;
}

.docs-inline-note {
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.docs-preview {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.docs-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.docs-test-result {
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  border: 1px solid var(--border);
}

.docs-test-result .docs-code {
  margin-top: 8px;
}

.suppression-upload-card {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(220px, 1.2fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.suppression-upload-card input[type="file"] {
  min-width: 0;
  box-shadow: none;
  background: #fff;
}

.suppression-upload-card p {
  margin: 4px 0 0;
}

.suppression-import-note {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
}

.suppression-summary {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(var(--primary-rgb), 0.08);
  color: var(--primary-dark);
  border: 1px solid rgba(var(--primary-rgb), 0.16);
  font-size: 12.5px;
  font-weight: 700;
}

.button-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.compact-form {
  margin: 12px 0;
}

.docs-actions {
  margin-bottom: 12px;
}

.local-result {
  margin-top: 12px;
}

.result-note {
  display: grid;
  gap: 6px;
  position: relative;
  padding-right: 28px;
}

.result-note p {
  margin: 0;
}

.result-dismiss {
  position: absolute;
  top: 0;
  right: 0;
  width: 22px;
  min-height: 22px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
}

.result-dismiss:hover { color: var(--text); background: var(--accent-soft); }

.icon-action {
  width: 34px;
  min-height: 34px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.icon-action svg {
  width: 16px;
  height: 16px;
}

.icon-action.danger {
  color: #b4232a;
  border-color: rgba(180, 35, 42, 0.2);
}

.icon-action.danger:hover {
  background: #fff1f2;
}

.icon-action.warning {
  color: #b45309;
  border-color: rgba(180, 83, 9, 0.22);
}

.icon-action.warning:hover {
  background: #fff7ed;
}

.icon-action.is-working,
.icon-action:disabled {
  opacity: 0.55;
  cursor: wait;
}

.telegram-actions {
  margin-top: 18px;
}

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

/* ════════════════════════════════════════════
   MODAL
   ════════════════════════════════════════════ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5,12,28,0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal {
  width: min(720px, 100%);
  max-height: min(840px, calc(100vh - 40px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
}

.modal-head, .modal-foot { padding: 16px 22px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.modal-head h3 {
  margin-bottom: 0;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.modal-close-icon {
  display: inline-grid;
  width: 34px;
  min-height: 34px;
  place-items: center;
  padding: 0;
  border-radius: 999px;
  color: var(--muted);
}

.modal-close-icon svg {
  width: 17px;
  height: 17px;
  stroke-width: 2.4;
}

.modal-body { padding: 22px; overflow: auto; }

.modal-foot {
  border-top: 1px solid var(--border);
  border-bottom: 0;
  background: var(--surface-alt);
}

/* ════════════════════════════════════════════
   CHECK GRID
   ════════════════════════════════════════════ */

.check-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.check-tile {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  font-weight: 600;
  font-size: 13px;
  transition: all 0.14s ease;
  cursor: pointer;
}

.check-tile:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.check-tile input {
  width: auto;
  accent-color: var(--primary);
  box-shadow: none;
  border: none;
  background: transparent;
  padding: 0;
  min-height: auto;
}

/* ════════════════════════════════════════════
   TOAST
   ════════════════════════════════════════════ */

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  max-width: 360px;
  padding: 13px 18px;
  border-radius: var(--radius);
  color: white;
  background: linear-gradient(135deg, #0d1c32, #142440);
  box-shadow: 0 8px 32px rgba(0,0,0,0.32), 0 2px 8px rgba(0,0,0,0.16);
  font-size: 13.5px;
  line-height: 1.45;
  border: 1px solid rgba(255,255,255,0.07);
}

/* ════════════════════════════════════════════
   RESPONSIVE — 1040px
   ════════════════════════════════════════════ */

@media (max-width: 1040px) {
  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: static;
    height: auto;
    align-items: stretch;
    gap: 14px;
    padding: 14px;
  }

  .dashboard-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .side-brand {
    display: flex;
    justify-content: flex-start;
    gap: 10px;
  }

  .side-brand strong, .side-brand span, .nav-label { display: block; }
  .side-brand strong { color: #ffffff; }
  .side-brand span { color: rgba(255,255,255,0.5); }

  .nav-button {
    width: 100%;
    justify-content: flex-start;
    gap: 8px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
  }

  .nav-button.active::before { display: none; }

  #logout { width: 100%; font-size: 13px; }
  #logout::after { content: ""; }

  .topbar { background: rgba(240,244,248,0.96); }

  .builder, .designer, .inbox,
  .grid.cols-4, .grid.cols-3, .grid.cols-2 {
    grid-template-columns: 1fr;
  }

  .inbox { height: auto; gap: 0; border: none; box-shadow: none; }
  .inbox-list { border-right: none; border-bottom: 1px solid var(--border); max-height: 420px; }
  .convo-list { max-height: 300px; }
  .detail-thread-wrap { max-height: 360px; }
  .thread-event { max-width: 100%; }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px 20px;
  }

  .top-actions, .login-actions { width: 100%; flex-wrap: wrap; }
  .top-actions { justify-content: flex-start; }

  .login-panel { grid-template-columns: 1fr; }

  .login-brand {
    padding: 36px 32px;
    gap: 20px;
  }

  .login-actions {
    padding: 36px 32px;
    justify-content: flex-start;
  }
}

/* ════════════════════════════════════════════
   RESPONSIVE — 720px
   ════════════════════════════════════════════ */

@media (max-width: 720px) {
  .login-screen { padding: 14px; }

  .login-panel { border-radius: 14px; }
  .login-brand { padding: 28px 24px; }
  .login-actions { padding: 28px 24px; }

  .panel, .table-wrap, .builder-pane { padding: 14px; }

  #view { padding: 16px 14px 36px; }

  .topbar { padding: 12px 14px; }

  .dashboard-hero {
    min-height: 0;
    padding: 18px 48px 18px 18px;
  }

  .dashboard-hero h2 {
    font-size: 21px;
  }

  .dashboard-hero-actions,
  .dashboard-hero-actions button {
    width: 100%;
  }

  nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .steps, .form-grid { grid-template-columns: 1fr; }

  .agent-summary { grid-template-columns: 1fr; }

  .kpi { min-height: 100px; }

  .channel-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .top-actions select, .top-actions button,
  .login-actions button, .controls button,
  .controls > div { width: 100%; }

  .controls { align-items: stretch; }

  .docs-test-head {
    align-items: stretch;
    flex-direction: column;
  }

  .docs-test-grid,
  .docs-test-form {
    grid-template-columns: 1fr;
  }

  .suppression-upload-card {
    grid-template-columns: 1fr;
  }

  .docs-send-button {
    width: 100%;
    justify-content: center;
  }

  .phone { min-height: auto; }
  .builder { min-height: 0; }
  .builder-pane { min-height: 0; }

  .phone-shell {
    min-height: 420px;
    border-width: 7px;
  }

  .toast { right: 12px; left: 12px; max-width: none; }

  .modal-backdrop { padding: 10px; align-items: end; }
  .modal {
    max-height: calc(100vh - 20px);
    border-radius: 14px 14px 0 0;
  }

  .check-grid { grid-template-columns: 1fr; }
  .button-row button { width: 100%; }
}

/* ════════════════════════════════════════════
   RESPONSIVE — 420px
   ════════════════════════════════════════════ */

@media (max-width: 560px) {
  .campaign-list-row {
    grid-template-columns: 1fr;
  }

  .campaign-actions {
    min-width: 0;
    flex-direction: row;
    justify-content: flex-start;
  }

  .campaign-actions button {
    width: 34px;
    flex: 0 0 34px;
  }
}

@media (max-width: 420px) {
  h1 { font-size: 28px; }
  h2 { font-size: 20px; }
  .grid { gap: 12px; }
  .channel-picker { grid-template-columns: 1fr; }
}
