@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #070b12;
  --bg-elevated: #0c121c;
  --card: #0f1623;
  --card-hover: #141e2e;
  --border: #1c2738;
  --border-soft: #2a3a52;
  --text: #f1f5f9;
  --muted: #8b9cb3;
  --brand: #14b8a6;
  --brand-soft: #2dd4bf;
  --brand-dim: rgba(20, 184, 166, 0.14);
  --brand-strong: #0d9488;
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.12);
  --warn: #fbbf24;
  --ok: #34d399;
  --info: #38bdf8;
  --purple: #a78bfa;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.25);
  --sidebar-w: 260px;
  --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --grid-line: rgba(255, 255, 255, 0.025);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html, body {
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Prevent iOS zoom on input focus */
@supports (-webkit-touch-callout: none) {
  input, select, textarea { font-size: 16px !important; }
}

a { color: var(--brand); text-decoration: none; transition: color .15s var(--ease); }
a:hover { color: var(--brand-soft); }

/* ========== SHELL ========== */
.app {
  display: flex;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 900px 500px at 10% -10%, rgba(20, 184, 166, 0.07), transparent 55%),
    radial-gradient(ellipse 700px 400px at 90% 0%, rgba(56, 189, 248, 0.05), transparent 50%),
    var(--bg);
}

.sidebar {
  width: var(--sidebar-w);
  position: fixed;
  inset: 0 auto 0 0;
  background: linear-gradient(180deg, #080e16 0%, #0a111a 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.15rem 0.85rem;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0.6rem 1.35rem;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #14b8a6 0%, #0ea5e9 100%);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.78rem;
  color: #042f2e;
  box-shadow:
    0 0 0 2px rgba(20, 184, 166, 0.2),
    0 8px 24px rgba(20, 184, 166, 0.25);
  flex-shrink: 0;
}

.brand-text { font-weight: 700; font-size: 0.92rem; letter-spacing: -0.02em; }
.brand-sub {
  font-size: 0.62rem;
  color: var(--muted);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.nav { display: flex; flex-direction: column; gap: 0.25rem; flex: 1; }

.nav a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background .18s var(--ease), color .18s var(--ease), box-shadow .18s var(--ease);
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.nav a.active {
  background: linear-gradient(90deg, rgba(20, 184, 166, 0.18), rgba(20, 184, 166, 0.04));
  color: var(--brand-soft);
  box-shadow: inset 3px 0 0 var(--brand);
}

.nav-icon {
  width: 1.25rem;
  height: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.9;
}

.nav-icon svg {
  width: 1.1rem;
  height: 1.1rem;
  stroke-width: 2;
}

.sidebar-foot {
  padding: 0.85rem 0.55rem 0.35rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.sidebar-foot a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 500;
  padding: 0.45rem 0.5rem;
  border-radius: 8px;
  transition: color .15s, background .15s;
}

.sidebar-foot a:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.6rem;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 11, 18, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar h1 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.topbar .sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.content { padding: 1.35rem 1.6rem 2.25rem; flex: 1; }

/* ========== KPIs ========== */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.15rem;
}

.kpi {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color .2s var(--ease), transform .2s var(--ease);
}

.kpi:hover {
  border-color: var(--border-soft);
  transform: translateY(-1px);
}

.kpi::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: 3px 0 0 3px;
}

.kpi.sent::before { background: var(--info); }
.kpi.delivered::before { background: var(--brand); }
.kpi.read::before { background: var(--ok); }
.kpi.fail::before { background: var(--danger); }

.kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.45rem;
}

.kpi .label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.kpi-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.kpi-icon svg { width: 16px; height: 16px; stroke-width: 2.2; }

.kpi.sent .kpi-icon { background: rgba(56, 189, 248, 0.12); color: var(--info); }
.kpi.delivered .kpi-icon { background: rgba(20, 184, 166, 0.12); color: var(--brand-soft); }
.kpi.read .kpi-icon { background: rgba(52, 211, 153, 0.12); color: var(--ok); }
.kpi.fail .kpi-icon { background: rgba(248, 113, 113, 0.12); color: var(--danger); }

.kpi .value {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.kpi.sent .value { color: var(--info); }
.kpi.delivered .value { color: var(--brand-soft); }
.kpi.read .value { color: var(--ok); }
.kpi.fail .value { color: var(--danger); }
.kpi .meta { font-size: 0.72rem; color: var(--muted); margin-top: 0.4rem; }

/* Status lanes */
.status-lanes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.15rem;
}

.lane {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow-sm);
}

.lane .lane-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.lane .lane-value {
  font-size: 1.35rem;
  font-weight: 800;
  margin: 0.4rem 0 0.55rem;
  font-variant-numeric: tabular-nums;
}

.lane-bar {
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.lane-bar > span {
  display: block;
  height: 100%;
  border-radius: 99px;
  width: 0%;
  transition: width .45s var(--ease);
}

.lane.queued .lane-bar > span { background: var(--info); }
.lane.sending .lane-bar > span { background: var(--brand); }
.lane.done .lane-bar > span { background: var(--ok); }

/* ========== CARDS / TABLES ========== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.1rem;
  overflow: hidden;
}

.card > h2, .card-head h2 {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.2rem 0.85rem;
  border-bottom: 1px solid var(--border);
}

.card-head p { font-size: 0.78rem; color: var(--muted); margin-top: 0.25rem; }
.card > h2 { padding: 1.1rem 1.2rem 0.55rem; }

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

table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }

thead th {
  text-align: left;
  padding: 0.7rem 1.05rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.22);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 0.75rem 1.05rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(20, 184, 166, 0.045); }
tbody tr:last-child td { border-bottom: none; }
.empty { text-align: center; color: var(--muted); padding: 2.25rem 1rem !important; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.6rem;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge.sent { background: rgba(56, 189, 248, 0.15); color: #7dd3fc; }
.badge.delivered { background: rgba(20, 184, 166, 0.15); color: #5eead4; }
.badge.read { background: rgba(52, 211, 153, 0.15); color: #6ee7b7; }
.badge.failed { background: rgba(248, 113, 113, 0.15); color: #fca5a5; }
.badge.unknown { background: rgba(148, 163, 184, 0.12); color: #94a3b8; }

/* ========== BUTTONS / FORMS ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.58rem 1.05rem;
  border-radius: 10px;
  font-size: 0.845rem;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s var(--ease), border-color .15s, transform .1s, box-shadow .15s;
}

.btn svg { width: 1rem; height: 1rem; stroke-width: 2.2; flex-shrink: 0; }
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: linear-gradient(135deg, #14b8a6, #0d9488);
  color: #042f2e;
  box-shadow: 0 4px 16px rgba(20, 184, 166, 0.28);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #2dd4bf, #14b8a6);
  box-shadow: 0 6px 20px rgba(20, 184, 166, 0.35);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-soft);
  color: var(--text);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--muted);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.3);
}

.btn-danger:hover { background: rgba(248, 113, 113, 0.2); }

label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.38rem;
}

input, select, textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.68rem 0.9rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-dim);
}

input::placeholder, textarea::placeholder { color: #5a6b82; }
textarea { min-height: 100px; resize: vertical; }

.form-group { margin-bottom: 1rem; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-items: flex-end;
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid var(--border);
}

.filters > div { min-width: 140px; }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1.05rem;
}

.msg {
  font-size: 0.85rem;
  margin: 0.5rem 0 1rem;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  display: none;
}

.msg.ok, .msg.error.ok {
  display: block;
  background: rgba(52, 211, 153, 0.12);
  color: #6ee7b7;
  border: 1px solid rgba(52, 211, 153, 0.25);
}

.msg.err, .msg.error {
  display: block;
  background: var(--danger-bg);
  color: #fca5a5;
  border: 1px solid rgba(248, 113, 113, 0.3);
}

.welcome-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 1.2rem;
  margin-bottom: 1.1rem;
  border-radius: var(--radius);
  background: linear-gradient(105deg, rgba(20, 184, 166, 0.16), rgba(14, 165, 233, 0.08));
  border: 1px solid rgba(20, 184, 166, 0.22);
}

.welcome-bar .hello { font-weight: 700; font-size: 0.95rem; }
.welcome-bar .meta { font-size: 0.78rem; color: var(--muted); }

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.8rem 1.2rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
}

.live-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5);
  animation: pulse 2s infinite;
  display: inline-block;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.cc-banner {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  padding: 0.42rem 0.75rem;
  border-radius: 99px;
  background: rgba(20, 184, 166, 0.1);
  border: 1px solid rgba(20, 184, 166, 0.2);
  font-size: 0.76rem;
  color: var(--muted);
  font-weight: 500;
}

.cc-banner strong { color: var(--brand-soft); font-weight: 600; }

/* ========== AUTH ========== */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse 700px 450px at 50% -5%, rgba(20, 184, 166, 0.14), transparent 55%),
    var(--bg);
}

.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
}

@media (max-width: 860px) {
  .auth-page { grid-template-columns: 1fr; }
}

.auth-hero {
  padding: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background:
    radial-gradient(ellipse 600px 400px at 30% 40%, rgba(20, 184, 166, 0.14), transparent 60%),
    linear-gradient(160deg, #0a1018, #070b10);
  border-right: 1px solid var(--border);
}

.auth-hero h1 {
  font-size: 2.05rem;
  font-weight: 800;
  letter-spacing: -0.035em;
  margin: 1.6rem 0 0.65rem;
  line-height: 1.15;
}

.auth-hero p { color: var(--muted); max-width: 360px; line-height: 1.6; font-size: 0.95rem; }

.auth-features {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.auth-feature {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.auth-feature-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(20, 184, 166, 0.12);
  color: var(--brand-soft);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.auth-feature-icon svg { width: 18px; height: 18px; }

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 2.1rem;
  box-shadow: var(--shadow);
}

.auth-card h2 {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-card .subtitle {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0.35rem 0 1.5rem;
}

.auth-card .btn { width: 100%; margin-top: 0.35rem; padding: 0.78rem; }

/* Send page helpers */
.type-row { display: flex; gap: 1.25rem; margin: 0.85rem 0; }
.type-row label {
  text-transform: none;
  font-weight: 500;
  font-size: 0.88rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
}

.hidden { display: none !important; }

.ga-embed-wrap { padding: 0.75rem 1rem 1.25rem; width: 100%; }
.ga-embed-wrap iframe {
  display: block; width: 100%; min-height: 720px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--bg-elevated);
}

.chip-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; }
.row-2 + .row-2 { margin-top: 1rem; }

/* Mobile menu button */
.mobile-menu-btn {
  display: none;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 0.55rem;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  flex-shrink: 0;
}

.mobile-menu-btn svg { width: 1.25rem; height: 1.25rem; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 35;
  -webkit-tap-highlight-color: transparent;
}

/* Topbar actions cluster */
.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  justify-content: flex-end;
}

.topbar-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  flex: 1;
}

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

/* Table mobile helper */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .status-lanes { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  .sidebar {
    width: min(var(--sidebar-w), 86vw);
    transform: translateX(-105%);
    transition: transform .28s var(--ease);
    box-shadow: none;
    padding-top: max(1.15rem, env(safe-area-inset-top));
    padding-bottom: max(0.85rem, env(safe-area-inset-bottom));
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.45);
  }
  .sidebar-overlay.open { display: block; }

  .mobile-menu-btn { display: grid; place-items: center; }

  .main { margin-left: 0; }

  .topbar {
    padding: 0.75rem 0.9rem;
    padding-top: max(0.75rem, env(safe-area-inset-top));
    flex-wrap: wrap;
    gap: 0.65rem;
    row-gap: 0.55rem;
  }
  .topbar h1 {
    font-size: 1.05rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar .sub {
    font-size: 0.72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .topbar-actions .btn {
    flex: 1 1 auto;
    min-height: 42px;
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
  }

  .content {
    padding: 0.9rem 0.85rem 1.75rem;
    padding-bottom: max(1.75rem, env(safe-area-inset-bottom));
  }

  .kpis {
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
  }
  .kpi {
    padding: 0.9rem 0.85rem;
  }
  .kpi .value { font-size: 1.35rem; }
  .kpi-icon { width: 28px; height: 28px; border-radius: 8px; }
  .kpi-icon svg { width: 14px; height: 14px; }

  .status-lanes {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

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

  .filters {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    padding: 0.85rem;
  }
  .filters > div {
    min-width: 0;
    width: 100%;
  }
  .filters .btn { width: 100%; min-height: 44px; }

  .tabs {
    gap: 0.35rem;
  }
  .tabs .btn {
    flex: 1 1 auto;
    min-height: 42px;
    font-size: 0.78rem;
    padding: 0.5rem 0.65rem;
  }

  .card-head {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    padding: 0.95rem 0.95rem 0.75rem;
  }
  .card-head .btn { width: 100%; }

  table { font-size: 0.78rem; }
  thead th {
    padding: 0.55rem 0.7rem;
    font-size: 0.62rem;
  }
  tbody td {
    padding: 0.6rem 0.7rem;
  }

  .welcome-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    padding: 0.85rem 0.95rem;
  }

  .pager {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.7rem 0.85rem;
  }

  .type-row {
    flex-direction: column;
    gap: 0.55rem;
  }

  .btn {
    min-height: 42px;
  }

  .auth-hero {
    padding: 1.75rem 1.25rem 1.25rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .auth-hero h1 { font-size: 1.55rem; margin: 1.1rem 0 0.5rem; }
  .auth-panel { padding: 1.25rem 1rem 2rem; }
  .auth-card { padding: 1.5rem 1.2rem; border-radius: 16px; }
  .auth-features { margin-top: 1.25rem; }

  .ga-embed-wrap iframe { min-height: 480px; }
}

/* Phones in portrait — tighter */
@media (max-width: 480px) {
  .kpis { grid-template-columns: 1fr; }
  .kpi .value { font-size: 1.5rem; }

  .brand-text { font-size: 0.85rem; }
  .nav a {
    padding: 0.78rem 0.85rem;
    font-size: 0.9rem;
    min-height: 46px;
  }

  .cc-banner {
    font-size: 0.7rem;
    padding: 0.35rem 0.6rem;
  }

  /* Stack action buttons full width on very small screens */
  .topbar-actions .btn { width: 100%; }
}

/* Landscape phones */
@media (max-width: 900px) and (max-height: 500px) {
  .auth-hero { padding: 1.25rem; }
  .auth-hero h1 { font-size: 1.35rem; margin: 0.75rem 0 0.4rem; }
  .auth-features { display: none; }
}


.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8em;
  word-break: break-all;
}

/* Icon utility for inline Lucide */
[data-lucide] { display: inline-block; vertical-align: middle; }


.btn-spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(4, 47, 46, 0.25);
  border-top-color: #042f2e;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -0.15rem;
  margin-right: 0.35rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn:disabled { opacity: 0.75; cursor: wait; }


/* Customer log expandable timeline */
.log-row.expanded { background: rgba(20, 184, 166, 0.06); }
.expand-btn {
  background: transparent; border: none; color: var(--muted, #94a3b8);
  cursor: pointer; font-size: 0.9rem; padding: 0.25rem 0.4rem; line-height: 1;
}
.expand-btn:hover { color: var(--accent, #14b8a6); }
.name-missing { color: var(--muted, #64748b); font-style: italic; }
.mono { font-size: 0.82rem; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted, #94a3b8); font-size: 0.82rem; }
.status-pill {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.2rem 0.55rem; border-radius: 999px; font-size: 0.72rem;
  font-weight: 600; letter-spacing: 0.02em;
}
.status-pill.status-sent { background: rgba(56,189,248,0.15); color: #7dd3fc; }
.status-pill.status-delivered { background: rgba(45,212,191,0.15); color: #5eead4; }
.status-pill.status-read { background: rgba(52,211,153,0.18); color: #6ee7b7; }
.status-pill.status-failed { background: rgba(248,113,113,0.15); color: #fca5a5; }
.log-error { color: #fca5a5; font-size: 0.75rem; margin-top: 0.2rem; }
.status-timeline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  padding: 0.85rem 0.75rem;
  justify-content: center;
  align-items: center;
  text-align: center;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}
.tl-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.4rem 0.85rem;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148,163,184,0.12);
  font-size: 0.82rem;
  margin: 0 auto;
}
.tl-item.tl-sent { border-color: rgba(56,189,248,0.25); }
.tl-item.tl-delivered { border-color: rgba(45,212,191,0.25); }
.tl-item.tl-read { border-color: rgba(52,211,153,0.3); }
.tl-item.tl-failed { border-color: rgba(248,113,113,0.3); }
.tl-item.tl-missing { opacity: 0.45; }
.tl-label { text-transform: capitalize; color: var(--text, #e2e8f0); font-weight: 500; }
.tl-time { color: var(--muted, #94a3b8); font-size: 0.78rem; }
.tl-icon { width: 1.1rem; text-align: center; }
.log-detail td {
  background: rgba(8, 12, 20, 0.55);
  text-align: center;
}
tr.log-detail > td {
  text-align: center;
}


.btn-spinner-light {
  border-color: rgba(148, 163, 184, 0.35);
  border-top-color: #5eead4;
}

/* Customer log — mobile */
@media (max-width: 800px) {
  .table-wrap table thead { display: none; }
  .table-wrap table,
  .table-wrap tbody,
  .table-wrap tr.log-row,
  .table-wrap tr.log-detail {
    display: block;
    width: 100%;
  }
  .table-wrap tr.log-row {
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 12px;
    margin-bottom: 0.5rem;
    padding: 0.65rem 0.75rem;
    background: rgba(12, 17, 24, 0.85);
  }
  .table-wrap tr.log-row td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    border: none;
    padding: 0.25rem 0;
  }
  .table-wrap tr.log-row td.log-expand {
    justify-content: flex-start;
  }
  .table-wrap tr.log-row td::before {
    content: attr(data-label);
    color: var(--muted, #94a3b8);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
  }
  .table-wrap tr.log-detail {
    margin: -0.35rem 0 0.75rem;
    border-radius: 0 0 12px 12px;
    border: 1px solid rgba(20, 184, 166, 0.2);
    border-top: none;
    padding: 0.5rem 0.75rem 0.75rem;
  }
  .table-wrap tr.log-detail td {
    display: block;
    padding: 0;
  }
  .status-timeline {
    flex-direction: column;
    padding: 0.65rem 0.5rem;
    gap: 0.5rem;
    justify-content: center;
    align-items: center;
    width: 100%;
  }
  .tl-item {
    width: auto;
    min-width: 14rem;
    max-width: 90%;
    margin-left: auto;
    margin-right: auto;
    justify-content: center;
  }
  .table-wrap tr.log-detail {
    text-align: center;
  }
  .table-wrap tr.log-detail td {
    text-align: center;
    display: flex;
    justify-content: center;
    width: 100%;
  }
  .filters {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
  .filters > div:last-child {
    grid-column: 1 / -1;
  }
}
@media (max-width: 480px) {
  .filters { grid-template-columns: 1fr !important; }
  .status-pill { font-size: 0.68rem; }
}


.status-pill .status-ico,
.tl-item .status-ico {
  width: 0.95rem;
  height: 0.95rem;
  stroke-width: 2.25;
  flex-shrink: 0;
}
.status-ico-sent { color: #38bdf8; }
.status-ico-delivered { color: #2dd4bf; }
.status-ico-read { color: #34d399; }
.status-ico-failed { color: #f87171; }
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.tl-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}
.log-row {
  cursor: pointer;
}
.log-row:hover {
  background: rgba(20, 184, 166, 0.05);
}
.expand-chevron {
  color: var(--muted, #94a3b8);
  font-size: 0.75rem;
  display: inline-block;
  width: 1rem;
}
.log-row.expanded .expand-chevron {
  color: #14b8a6;
}

.log-row-failed {
  cursor: default;
  opacity: 0.95;
}
.log-row-failed:hover {
  background: transparent;
}
.log-row-expandable {
  cursor: pointer;
}


/* Send progress + result modal */
.send-progress-wrap {
  margin-top: 0.85rem;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: rgba(12, 17, 24, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.12);
}
.send-progress-label {
  font-size: 0.82rem;
  color: var(--muted, #94a3b8);
  margin-bottom: 0.45rem;
}
.send-progress-track {
  height: 0.45rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.15);
  overflow: hidden;
}
.send-progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #14b8a6, #38bdf8);
  transition: width 0.35s ease;
}
.send-progress-bar.indeterminate {
  width: 40% !important;
  animation: send-progress-slide 1.1s ease-in-out infinite;
}
@keyframes send-progress-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(280%); }
}
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 12, 0.72);
  backdrop-filter: blur(4px);
  padding: 1rem;
}
.modal-card {
  width: min(24rem, 100%);
  background: #0f1620;
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 16px;
  padding: 1.5rem 1.35rem 1.25rem;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.45);
}
.modal-card h3 {
  margin: 0.5rem 0 0.35rem;
  font-size: 1.15rem;
  color: var(--text, #e2e8f0);
}
.modal-body-text {
  color: var(--muted, #94a3b8);
  font-size: 0.88rem;
  line-height: 1.5;
  white-space: pre-wrap;
  margin: 0 0 1.1rem;
}
.modal-icon {
  width: 3rem;
  height: 3rem;
  margin: 0 auto;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-icon.ok {
  background: rgba(52, 211, 153, 0.15);
  color: #34d399;
}
.modal-icon.err {
  background: rgba(248, 113, 113, 0.15);
  color: #f87171;
}
.modal-icon i, .modal-icon svg {
  width: 1.5rem;
  height: 1.5rem;
}


/* ── Global page loading overlay ── */
.wbs-page-loader {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(6, 10, 18, 0.55);
  backdrop-filter: blur(2px);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.75rem;
}
.wbs-page-loader.show { display: flex; }
.wbs-page-loader .wbs-spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(148,163,184,.25);
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: wbs-spin 0.7s linear infinite;
}
.wbs-page-loader .wbs-loader-text {
  color: #e2e8f0; font-size: 0.9rem; font-weight: 600;
}
@keyframes wbs-spin { to { transform: rotate(360deg); } }

/* Inline table loading row spinner */
.wbs-inline-loading {
  display: inline-flex; align-items: center; gap: 0.5rem;
  color: #94a3b8; font-size: 0.9rem;
}
.wbs-inline-loading .wbs-spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(148,163,184,.25);
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: wbs-spin 0.7s linear infinite;
}

/* Mobile: keep table headers visible */
@media (max-width: 768px) {
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap table { border-collapse: separate; border-spacing: 0; }
  .table-wrap thead th {
    position: sticky; top: 0; z-index: 5;
    background: #152033 !important;
    color: #e2e8f0 !important;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(0,0,0,.35);
    white-space: nowrap;
  }
}


/* ========== TOASTS ========== */
.wbs-toast-host {
  position: fixed; z-index: 9999; right: 1rem; bottom: 1rem;
  display: flex; flex-direction: column; gap: 0.5rem;
  max-width: min(380px, calc(100vw - 2rem));
  pointer-events: none;
}
.wbs-toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 0.65rem;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  background: #0f1623;
  border: 1px solid rgba(148,163,184,0.2);
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
  color: #e2e8f0;
  font-size: 0.88rem;
  animation: wbs-toast-in 0.28s var(--ease);
}
.wbs-toast.ok { border-color: rgba(52,211,153,0.35); }
.wbs-toast.err { border-color: rgba(248,113,113,0.4); }
.wbs-toast.info { border-color: rgba(56,189,248,0.35); }
.wbs-toast .wbs-toast-icon { flex-shrink: 0; margin-top: 1px; color: #94a3b8; }
.wbs-toast.ok .wbs-toast-icon { color: #34d399; }
.wbs-toast.err .wbs-toast-icon { color: #f87171; }
.wbs-toast.info .wbs-toast-icon { color: #38bdf8; }
.wbs-toast .wbs-toast-body { flex: 1; min-width: 0; line-height: 1.4; }
.wbs-toast .wbs-toast-close {
  background: transparent; border: 0; color: #64748b; cursor: pointer;
  padding: 0; line-height: 1; font-size: 1.1rem;
}
@keyframes wbs-toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== EMPTY STATE ========== */
.wbs-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 2.25rem 1.25rem; color: #94a3b8;
}
.wbs-empty .wbs-empty-icon {
  width: 3rem; height: 3rem; margin-bottom: 0.75rem;
  color: #475569; opacity: 0.9;
}
.wbs-empty .wbs-empty-title {
  color: #e2e8f0; font-weight: 600; font-size: 1rem; margin-bottom: 0.35rem;
}
.wbs-empty .wbs-empty-desc {
  font-size: 0.88rem; max-width: 28rem; margin-bottom: 1rem; line-height: 1.45;
}

/* Button icon spacing */
.btn i[data-lucide], .btn svg {
  width: 1rem; height: 1rem; vertical-align: -0.15em; margin-right: 0.35rem;
}
.btn-icon-only i[data-lucide], .btn-icon-only svg { margin-right: 0; }

/* Form section label */
.form-section-title {
  display: flex; align-items: center; gap: 0.45rem;
  font-size: 0.8rem; font-weight: 600; color: #94a3b8;
  text-transform: uppercase; letter-spacing: 0.04em;
  margin: 1rem 0 0.65rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(148,163,184,0.1);
}
.form-section-title:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.form-section-title i[data-lucide], .form-section-title svg {
  width: 0.95rem; height: 0.95rem; color: #38bdf8;
}

/* Outstanding / bill cues */
.bill-kpis.mini .kpi.failed .value { color: #fbbf24; }
.bill-kpis.mini .kpi.sent .value { color: #e2e8f0; }
.bill-kpis.mini .kpi.delivered .value { color: #34d399; }


/* ========== FORM MODALS (edit/create) ========== */
.form-modal-bg {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 4500;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.form-modal-bg.open,
.form-modal-bg[style*="flex"] {
  display: flex !important;
}
.form-modal {
  width: 100%;
  max-width: 560px;
  max-height: min(92vh, 920px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(165deg, #0f172a 0%, #0b1220 100%);
  border: 1px solid rgba(56, 189, 248, 0.28);
  border-bottom: none;
  border-radius: 18px 18px 0 0;
  padding: 1.1rem 1.15rem calc(1.35rem + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45);
  margin-top: auto;
}
.form-modal .form-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  position: sticky;
  top: 0;
  background: #0f172a;
  z-index: 2;
}
.form-modal .form-modal-head h2,
.form-modal .form-modal-head h3 {
  margin: 0;
  font-size: 1.1rem;
  color: #f1f5f9;
  line-height: 1.3;
}
.form-modal .form-modal-head .sub,
.form-modal .form-modal-head p {
  margin: 0.25rem 0 0;
  font-size: 0.82rem;
  color: #94a3b8;
}
.form-modal .form-modal-close {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.8);
  color: #94a3b8;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
}
.form-modal .form-modal-close:hover {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.12);
}
.form-modal .form-group {
  margin-bottom: 0.75rem;
}
.form-modal .form-group label {
  display: block;
  font-size: 0.8rem;
  color: #94a3b8;
  margin-bottom: 0.3rem;
}
.form-modal .form-group input,
.form-modal .form-group select,
.form-modal .form-group textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid #1e293b;
  background: #0c121c;
  color: #e2e8f0;
  font-size: 0.95rem;
}
.form-modal .form-group input:focus,
.form-modal .form-group select:focus,
.form-modal .form-group textarea:focus {
  outline: none;
  border-color: rgba(56, 189, 248, 0.55);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}
.form-modal .form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  position: sticky;
  bottom: 0;
  background: #0f172a;
  z-index: 2;
}
.form-modal .row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}
@media (max-width: 560px) {
  .form-modal .row-2 {
    grid-template-columns: 1fr;
  }
  .form-modal {
    max-height: 94vh;
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .form-modal .form-actions {
    flex-direction: column-reverse;
  }
  .form-modal .form-actions .btn {
    width: 100%;
    justify-content: center;
  }
}
@media (min-width: 640px) {
  .form-modal-bg {
    align-items: center;
    padding: 1.25rem;
  }
  .form-modal {
    border-radius: 16px;
    border-bottom: 1px solid rgba(56, 189, 248, 0.28);
    margin-top: 0;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  }
}


/* Brand logo mark (OS + WhatsApp) */
img.logo-mark,
.logo img.logo-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
  background: transparent;
}
.sidebar .brand img.logo-mark,
.sidebar-brand img {
  width: 36px;
  height: 36px;
  border-radius: 9px;
}


/* Brand mark image (logo) */
img.brand-mark, .brand-mark img {
  width: 36px; height: 36px; border-radius: 50%;
  object-fit: contain; display: block; flex-shrink: 0;
  background: transparent;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  -ms-interpolation-mode: nearest-neighbor;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.35);
}
.brand { display: flex; align-items: center; gap: 0.65rem; }
img.logo-mark {
  width: 40px; height: 40px; border-radius: 50%;
  object-fit: contain; display: block; flex-shrink: 0;
  image-rendering: -webkit-optimize-contrast;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.35);
}
