/* ==========================================================================
   BLASTIFY V2 — Design System Layer
   Tiffany Blue (#0ABAB5) + Montserrat + Mobile-first
   
   This file OVERRIDES existing admin.html styles without modifying source.
   Inject via: <link rel="stylesheet" href="/blastify-v2.css">
   ========================================================================== */

/* ---------- CSS VARIABLES (Tiffany Blue Palette) ---------- */
:root {
  --tf-primary: #0ABAB5 !important;
  --tf-primary-hover: #08938F !important;
  --tf-primary-light: #E0F7F6 !important;
  --tf-primary-soft: #BAEDEB !important;
  --tf-primary-glow: rgba(10, 186, 181, 0.4);
  
  --tf-success: #10B981;
  --tf-warning: #F59E0B;
  --tf-danger: #EF4444;
  --tf-info: #3B82F6;
  
  --tf-radius-sm: 8px;
  --tf-radius-md: 12px;
  --tf-radius-lg: 16px;
  --tf-radius-xl: 24px;
  
  --tf-transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --tf-shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --tf-shadow-md: 0 4px 14px rgba(0,0,0,0.08);
  --tf-shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
  --tf-shadow-primary: 0 6px 20px rgba(10, 186, 181, 0.3);
}

[data-theme="dark"] {
  --tf-primary-light: rgba(10, 186, 181, 0.15) !important;
  --tf-primary-soft: rgba(10, 186, 181, 0.25) !important;
}

/* ---------- OVERRIDE EXISTING TEAL/CYAN TO EXACT TIFFANY ---------- */
:root {
  --accent: #0ABAB5 !important;
  --accent-2: #08938F !important;
  --accent-soft: rgba(10, 186, 181, 0.12) !important;
  --grad: linear-gradient(135deg, #5FE8E2 0%, #0ABAB5 50%, #08938F 100%) !important;
}

/* ---------- TYPOGRAPHY ---------- */
body, html {
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

#login-screen {
  background: radial-gradient(ellipse at top, rgba(10, 186, 181, 0.08) 0%, transparent 60%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--surface, #134e4a);
  border: 1px solid rgba(10, 186, 181, 0.2);
  border-radius: var(--tf-radius-lg) !important;
  box-shadow: var(--tf-shadow-lg);
  padding: 32px !important;
  width: 100%;
  max-width: 420px !important;
  position: relative;
}

[data-theme="light"] .login-card {
  background: #ffffff;
  border-color: rgba(10, 186, 181, 0.25);
}

/* Hide bloated base64 logo, replace with clean small one */
.login-app-icon {
  display: none !important;
}

.logo-brand-wrap::before {
  content: '';
  display: block;
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background-image: url('/blastify-logo-clean-64.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  border-radius: 14px;
  box-shadow: var(--tf-shadow-primary);
}

.login-brand-block {
  text-align: center;
  margin-bottom: 24px;
}

.login-brand-img {
  max-height: 36px !important;
  width: auto;
  opacity: 0.95;
}

/* Auth tabs cleaner */
.auth-tabs {
  display: flex;
  gap: 4px;
  background: rgba(10, 186, 181, 0.08);
  padding: 4px;
  border-radius: var(--tf-radius-md);
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 10px 16px !important;
  border-radius: var(--tf-radius-sm) !important;
  border: none !important;
  background: transparent !important;
  color: var(--muted, #94a3b8) !important;
  font-weight: 600 !important;
  font-size: 14px !important;
  cursor: pointer;
  transition: var(--tf-transition);
  font-family: inherit !important;
}

.auth-tab:hover {
  color: var(--text, #f8fafc) !important;
}

.auth-tab.active {
  background: #0ABAB5 !important;
  color: #ffffff !important;
  box-shadow: var(--tf-shadow-sm);
}

/* Input fields */
#login-user, #login-pass,
#login-screen input[type="text"],
#login-screen input[type="email"],
#login-screen input[type="password"],
#login-screen input[type="tel"] {
  width: 100% !important;
  padding: 14px 16px !important;
  border-radius: var(--tf-radius-md) !important;
  border: 1.5px solid rgba(255,255,255,0.1) !important;
  background: rgba(0,0,0,0.2) !important;
  color: var(--text, #f8fafc) !important;
  font-size: 15px !important;
  font-family: 'Montserrat', sans-serif !important;
  transition: var(--tf-transition);
  margin-bottom: 12px;
  min-height: 48px;
  box-sizing: border-box;
}

[data-theme="light"] #login-user,
[data-theme="light"] #login-pass,
[data-theme="light"] #login-screen input {
  background: #f9fafb !important;
  border-color: #e5e7eb !important;
  color: #111827 !important;
}

#login-user:focus, #login-pass:focus,
#login-screen input:focus {
  outline: none !important;
  border-color: #0ABAB5 !important;
  box-shadow: 0 0 0 3px rgba(10, 186, 181, 0.15) !important;
}

/* Login button */
#login-btn,
.btn-green {
  background: linear-gradient(135deg, #0ABAB5 0%, #08938F 100%) !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  padding: 14px 24px !important;
  border-radius: var(--tf-radius-md) !important;
  border: none !important;
  font-size: 15px !important;
  font-family: 'Montserrat', sans-serif !important;
  min-height: 50px;
  box-shadow: var(--tf-shadow-primary);
  transition: var(--tf-transition);
  cursor: pointer;
  /* width:100% removed — was leaking to all .btn-green buttons (e.g., + Tambah Device).
     Only #login-btn needs full-width, handled by specific rule below. */
}

/* Login button — only place that should be full-width */
#login-btn,
.login-card .btn-green,
.auth-panel .btn-green {
  width: 100%;
}

#login-btn:hover, .btn-green:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(10, 186, 181, 0.4);
}

#login-btn:active, .btn-green:active {
  transform: translateY(0);
}

/* ==========================================================================
   GLOBAL BUTTON & LINK UPGRADES
   ========================================================================== */

.btn-primary,
button.primary,
.action-primary {
  background: linear-gradient(135deg, #0ABAB5 0%, #08938F 100%) !important;
  border: none !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  box-shadow: var(--tf-shadow-primary);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px var(--tf-primary-glow);
}

/* ==========================================================================
   MOBILE RESPONSIVE LAYER (< 768px)
   ========================================================================== */

@media (max-width: 768px) {
  /* General mobile fixes */
  body {
    padding-bottom: 72px !important; /* Space for bottom nav */
  }

  /* Login card mobile */
  .login-card {
    padding: 24px 20px !important;
    margin: 16px !important;
  }

  /* Hide sidebar nav on mobile, replaced by bottom nav */
  .sidebar,
  #sidebar,
  .nav-sidebar,
  aside.sidebar {
    transform: translateX(-100%);
    transition: transform 300ms;
  }
  .sidebar.open,
  #sidebar.open {
    transform: translateX(0);
  }

  /* Cards mobile padding */
  .card, .panel, .section-card {
    padding: 16px !important;
    border-radius: var(--tf-radius-md) !important;
  }

  /* Tables responsive scroll */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  /* Forms mobile */
  input, select, textarea {
    font-size: 16px !important; /* Prevents iOS zoom on focus */
    min-height: 48px;
  }

  /* Buttons mobile - bigger touch targets */
  button, .btn {
    min-height: 44px;
    padding: 12px 18px !important;
    font-size: 15px !important;
  }

  /* Modals fullscreen on mobile */
  .modal, .modal-content, .modal-overlay > div {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 16px 16px 0 0 !important;
    max-height: 90vh;
    overflow-y: auto;
  }

  /* Headers smaller mobile */
  h1 { font-size: 22px !important; }
  h2 { font-size: 18px !important; }
  h3 { font-size: 16px !important; }
}

/* ==========================================================================
   BOTTOM NAVIGATION (Mobile only)
   Injected dynamically by blastify-v2.js
   ========================================================================== */

#blastify-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface-elevated, #1E293B);
  border-top: 1px solid rgba(10, 186, 181, 0.15);
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  z-index: 999;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

[data-theme="light"] #blastify-bottom-nav {
  background: rgba(255, 255, 255, 0.96);
  border-top-color: #e5e7eb;
}

@media (max-width: 768px) {
  #blastify-bottom-nav {
    display: flex;
  }
}

.bn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  border: none;
  background: transparent;
  color: var(--muted, #94a3b8);
  cursor: pointer;
  font-family: 'Montserrat', sans-serif;
  font-size: 10.5px;
  font-weight: 600;
  transition: var(--tf-transition);
  text-decoration: none;
}

.bn-item .bn-ico {
  font-size: 22px;
  line-height: 1;
}

.bn-item.active {
  color: #0ABAB5;
}

.bn-item.active .bn-ico {
  transform: scale(1.1);
}

.bn-item:active {
  transform: scale(0.95);
}

/* ==========================================================================
   FLOATING ACTION BUTTON (Mobile blast quick)
   ========================================================================== */

#blastify-fab {
  display: none;
  position: fixed;
  right: 16px;
  bottom: 88px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0ABAB5, #08938F);
  color: white;
  font-size: 24px;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(10, 186, 181, 0.5);
  z-index: 998;
  align-items: center;
  justify-content: center;
  transition: var(--tf-transition);
}

@media (max-width: 768px) {
  #blastify-fab {
    display: flex;
  }
}

#blastify-fab:hover {
  transform: scale(1.08);
}

#blastify-fab:active {
  transform: scale(0.95);
}

/* ==========================================================================
   CARDS UPGRADE (subtle Tiffany accent)
   ========================================================================== */

.card, .panel {
  border-radius: var(--tf-radius-lg) !important;
  transition: var(--tf-transition);
}

.card-highlight,
.card-primary {
  background: linear-gradient(135deg, #0ABAB5, #08938F) !important;
  color: white !important;
  border: none !important;
}

.card-highlight h1, .card-highlight h2, .card-highlight h3,
.card-primary h1, .card-primary h2, .card-primary h3 {
  color: white !important;
}

/* ==========================================================================
   TOASTS / NOTIFICATIONS UPGRADE
   ========================================================================== */

.toast {
  border-radius: var(--tf-radius-md) !important;
  box-shadow: var(--tf-shadow-lg) !important;
  font-family: 'Montserrat', sans-serif !important;
}

.toast.success {
  border-left: 4px solid #0ABAB5 !important;
}

/* ==========================================================================
   SCROLLBAR (subtle Tiffany)
   ========================================================================== */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(10, 186, 181, 0.3);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(10, 186, 181, 0.5);
}

/* ==========================================================================
   ACCESSIBILITY
   ========================================================================== */

*:focus-visible {
  outline: 2px solid #0ABAB5;
  outline-offset: 2px;
}

button, a, input, select, textarea {
  -webkit-tap-highlight-color: transparent;
}

/* ==========================================================================
   SURGICAL MOBILE FIXES — Dashboard & Cards (v2 hotfix)
   Based on actual admin.html structure scan
   ========================================================================== */

@media (max-width: 768px) {

  /* --- Page container: tighten padding --- */
  .page {
    padding: 12px !important;
  }

  /* --- THE BIG ONE: .grid-4 → 2 columns on mobile (was hardcoded 4) --- */
  .grid-4 {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }

  /* On very small screens (≤360px), single column to prevent cramping */
  @media (max-width: 360px) {
    .grid-4 {
      grid-template-columns: 1fr !important;
    }
  }

  /* Force grid children to shrink (prevents overflow) */
  .grid-4 > *,
  .device-grid > *,
  .apik-stats > * {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* --- Stat cards: smaller, tighter --- */
  .stat-card {
    padding: 14px 12px !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    min-width: 0 !important;
    /* Single shadow only on mobile (was likely multi-layer) */
    box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
    /* Disable gradient backgrounds on mobile for perf */
    background-image: none !important;
  }

  /* Restore gradient on cards that explicitly want it via inline style */
  .stat-card[style*="linear-gradient"] {
    /* Inline style wins, but keep simpler */
    box-shadow: 0 2px 6px rgba(0,0,0,0.1) !important;
  }

  /* Stat icon smaller on mobile */
  .stat-icon {
    width: 36px !important;
    height: 36px !important;
    font-size: 18px !important;
    margin-bottom: 8px !important;
    border-radius: 10px !important;
  }

  /* Stat value (the big number) — responsive font with overflow protection */
  .stat-val {
    font-size: clamp(18px, 5.5vw, 24px) !important;
    line-height: 1.2 !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    font-weight: 700 !important;
    margin-bottom: 4px !important;
  }

  /* Stat label */
  .stat-label {
    font-size: 11px !important;
    line-height: 1.3 !important;
    overflow-wrap: break-word !important;
    color: var(--muted, #94a3b8) !important;
  }

  /* --- Universal card overflow protection --- */
  .card,
  .device-card-new,
  .panel,
  .stat-card,
  .apik-stat {
    overflow: hidden !important;
    min-width: 0 !important;
    word-wrap: break-word !important;
    overflow-wrap: anywhere !important;
    /* Prevent click delay on iOS */
    touch-action: manipulation;
  }

  /* Card internal padding tighter on mobile */
  .card {
    padding: 14px !important;
    margin-bottom: 12px !important;
    border-radius: 14px !important;
  }

  .card-header {
    margin-bottom: 10px !important;
    padding-bottom: 10px !important;
  }

  .card-title {
    font-size: 15px !important;
    line-height: 1.3 !important;
  }

  .card-subtitle {
    font-size: 12px !important;
  }

  /* --- Device card: prevent overflow --- */
  .device-card-new {
    padding: 14px !important;
    border-radius: 14px !important;
  }

  .device-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  /* --- Disable expensive backdrop-filter on mobile (perf killer) --- */
  .apik-modal-overlay,
  .wh-modal-overlay,
  .blf-modal-overlay,
  [style*="backdrop-filter"] {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(0,0,0,0.85) !important;
  }

  /* --- Margin utilities: reduce on mobile --- */
  .mt-3 { margin-top: 12px !important; }
  .mb-3 { margin-bottom: 12px !important; }
  .grid-4.mt-3 { margin-top: 10px !important; }

  /* --- Override common inline styles that bloat mobile --- */
  [style*="padding:24px"],
  [style*="padding: 24px"] {
    padding: 14px !important;
  }
  [style*="padding:20px"],
  [style*="padding: 20px"] {
    padding: 12px !important;
  }
  [style*="padding:16px"],
  [style*="padding: 16px"] {
    padding: 12px !important;
  }

  /* --- Inbox layout: stack on mobile --- */
  .inbox-container {
    flex-direction: column !important;
    height: calc(100vh - 120px) !important;
  }

  .inbox-sidebar {
    width: 100% !important;
    max-height: 40vh !important;
  }

  .inbox-main {
    width: 100% !important;
  }

  /* --- API keys row: stack on tight mobile --- */
  .apik-row {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  .apik-row-action {
    width: 100% !important;
    justify-content: flex-end !important;
  }

  /* --- Tables horizontal scroll --- */
  .card table,
  .panel table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  /* --- Buttons in card actions: flex-wrap to prevent overflow --- */
  .flex.gap-2,
  .flex.items-center.gap-2 {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  /* --- Headers smaller on mobile --- */
  h1 { font-size: 22px !important; }
  h2 { font-size: 18px !important; }
  h3 { font-size: 16px !important; }

  /* --- Page header (refresh button etc) --- */
  .page > div:first-child {
    flex-wrap: wrap !important;
    gap: 10px !important;
  }

  /* --- Status badges: don't overflow --- */
  .apik-status-badge,
  .device-status,
  .health-status {
    font-size: 10px !important;
    padding: 3px 8px !important;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* --- Trx history & warmer cards --- */
  .trx-history-card,
  .warmer-status-card {
    padding: 14px !important;
  }

  /* --- Disable expensive animations on mobile --- */
  * {
    animation-duration: 200ms !important;
  }
}

/* ==========================================================================
   EXTRA SMALL SCREENS (≤380px) — Tightest mobile
   ========================================================================== */

@media (max-width: 380px) {
  .page { padding: 10px !important; }
  .stat-card { padding: 12px 10px !important; }
  .stat-val { font-size: clamp(16px, 5vw, 20px) !important; }
  .card { padding: 12px !important; }
}

/* ==========================================================================
   V3 CRITICAL FIXES — Based on actual production screenshots
   ========================================================================== */

@media (max-width: 768px) {

  /* === FIX: Server Info & all inline 4-col grids === */
  /* Server Info rendered via JS at line ~3013 with inline 4-col grid */
  [style*="grid-template-columns:repeat(4"],
  [style*="grid-template-columns: repeat(4"],
  [style*="grid-template-columns:repeat(3"],
  [style*="grid-template-columns: repeat(3"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  /* Children inside inline grids must shrink */
  [style*="grid-template-columns:repeat"] > *,
  [style*="grid-template-columns: repeat"] > * {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    word-break: break-word !important;
  }

  /* Numbers inside server info boxes — responsive */
  #server-status [style*="font-size"] {
    font-size: clamp(16px, 5vw, 22px) !important;
    line-height: 1.2 !important;
    word-break: keep-all !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* === FIX: .page-header (title + button) — stack on mobile === */
  .page-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    margin-bottom: 14px !important;
  }

  .page-header > div:first-child {
    width: 100%;
    min-width: 0;
  }

  .page-header h1 {
    font-size: 22px !important;
    line-height: 1.25 !important;
    margin: 0 0 4px 0 !important;
    word-break: keep-all;
  }

  .page-header p {
    font-size: 13px !important;
    margin: 0 !important;
    color: var(--muted, #94a3b8);
  }

  .page-header > button,
  .page-header > .btn,
  .page-header > a.btn {
    width: 100% !important;
    justify-content: center !important;
    align-self: stretch !important;
    min-height: 44px;
  }

  /* === FIX: Inbox container force stack === */
  .inbox-container {
    display: flex !important;
    flex-direction: column !important;
    height: auto !important;
    min-height: 0 !important;
    gap: 8px !important;
  }

  .inbox-sidebar {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 auto !important;
    max-height: 45vh !important;
    overflow-y: auto !important;
    border: 1px solid var(--border, rgba(255,255,255,0.08)) !important;
    border-radius: 12px !important;
  }

  .inbox-main {
    width: 100% !important;
    max-width: 100% !important;
    flex: 1 1 auto !important;
    min-height: 50vh !important;
    border: 1px solid var(--border, rgba(255,255,255,0.08)) !important;
    border-radius: 12px !important;
  }

  /* Inbox header inside sidebar — tighter */
  .inbox-header {
    padding: 12px !important;
  }

  /* === FIX: Multi-IP banner shrink === */
  #blastify-announce-multi-ip {
    padding: 6px 30px 6px 8px !important;
    font-size: 11px !important;
    line-height: 1.35 !important;
  }

  #blastify-announce-multi-ip strong {
    display: inline;
  }

  #blastify-announce-multi-ip br {
    display: none;
  }

  /* === FIX: Table responsive horizontal scroll === */
  .card table {
    display: block !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap !important;
    width: 100% !important;
  }

  .card table th,
  .card table td {
    padding: 8px 10px !important;
    font-size: 12px !important;
    white-space: nowrap !important;
  }

  /* Empty state in tables — center properly */
  .card table td[colspan] {
    white-space: normal !important;
    text-align: center !important;
    padding: 20px !important;
  }

  /* === FIX: Bottom nav 5-item fit (no overflow) === */
  #blastify-bottom-nav {
    padding: 4px 0 calc(4px + env(safe-area-inset-bottom)) !important;
    gap: 0 !important;
  }

  .bn-item {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    max-width: 20% !important;
    padding: 6px 2px !important;
    gap: 2px !important;
    overflow: hidden !important;
    font-size: 9.5px !important;
    font-weight: 600 !important;
  }

  .bn-item span:not(.bn-ico) {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 100% !important;
    width: 100% !important;
    text-align: center !important;
    display: block !important;
  }

  .bn-item .bn-ico {
    font-size: 20px !important;
    line-height: 1 !important;
  }

  /* === FIX: Card padding when empty state === */
  .card[id*="server-status"],
  .card .empty-state,
  .card > div[style*="text-align:center"] {
    padding: 16px 12px !important;
  }

  /* === FIX: Stat cards inside dashboard — better mobile sizing === */
  .grid-4 .stat-card .stat-val {
    font-size: clamp(20px, 6vw, 26px) !important;
  }
}

/* ==========================================================================
   MORE SHEET (Bottom drawer for extra menu items)
   ========================================================================== */

#blastify-more-sheet {
  position: fixed;
  inset: 0;
  z-index: 1001;
  display: none;
  pointer-events: none;
  font-family: 'Montserrat', sans-serif;
}

#blastify-more-sheet.open {
  display: block;
  pointer-events: auto;
}

.more-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  opacity: 0;
  transition: opacity 280ms;
}

#blastify-more-sheet.open .more-backdrop {
  opacity: 1;
}

.more-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface-2, #1E293B);
  border-radius: 24px 24px 0 0;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 80vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 320ms cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] .more-panel {
  background: #ffffff;
}

#blastify-more-sheet.open .more-panel {
  transform: translateY(0);
}

.more-handle {
  width: 40px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  margin: 0 auto 12px;
}

[data-theme="light"] .more-handle {
  background: rgba(0, 0, 0, 0.15);
}

.more-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text, #f1f5f9);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.more-close-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--text, #f1f5f9);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}

.more-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.more-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  background: rgba(10, 186, 181, 0.08);
  border: 1px solid rgba(10, 186, 181, 0.18);
  border-radius: 14px;
  color: var(--text, #f1f5f9);
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: 180ms;
  min-height: 56px;
  width: 100%;
  box-sizing: border-box;
}

[data-theme="light"] .more-item {
  background: rgba(10, 186, 181, 0.06);
  color: #0F172A;
}

.more-item:hover, .more-item:active {
  background: rgba(10, 186, 181, 0.18);
  transform: scale(0.98);
}

.more-item .more-ico {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}

.more-item .more-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
}

.more-item.upgrade {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(245, 158, 11, 0.08)) !important;
  border-color: rgba(245, 158, 11, 0.35) !important;
  color: #fbbf24 !important;
}

/* ==========================================================================
   PWA INSTALL BANNERS (Android, iOS, Update)
   ========================================================================== */

@keyframes blf-slide-down {
  from { transform: translate(-50%, -100%); opacity: 0; }
  to   { transform: translate(-50%, 0); opacity: 1; }
}

@keyframes blf-slide-up {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* Android Chrome install banner — top center */
#blastify-install-banner {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #0ABAB5 0%, #08938F 100%);
  color: white;
  padding: 12px 14px;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(10, 186, 181, 0.45);
  z-index: 9999;
  max-width: 94vw;
  width: 380px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'Montserrat', sans-serif;
  animation: blf-slide-down 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

#blastify-install-banner .install-icon {
  font-size: 26px;
  line-height: 1;
  flex-shrink: 0;
}

#blastify-install-banner .install-text {
  flex: 1;
  min-width: 0;
}

#blastify-install-banner .install-title {
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
}

#blastify-install-banner .install-subtitle {
  font-size: 11px;
  opacity: 0.92;
  line-height: 1.35;
  margin-top: 2px;
}

#blastify-install-banner .install-btn {
  background: white;
  color: #0ABAB5;
  border: none;
  padding: 9px 14px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: transform 150ms;
  flex-shrink: 0;
}

#blastify-install-banner .install-btn:active {
  transform: scale(0.95);
}

#blastify-install-banner .install-close {
  background: rgba(255,255,255,0.22);
  border: none;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: inherit;
  padding: 0;
}

/* iOS Safari install hint — bottom banner */
#blastify-ios-install {
  position: fixed;
  bottom: calc(72px + env(safe-area-inset-bottom));
  left: 12px;
  right: 12px;
  background: linear-gradient(135deg, #0ABAB5 0%, #08938F 100%);
  color: white;
  padding: 14px;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(10, 186, 181, 0.45);
  z-index: 9999;
  font-family: 'Montserrat', sans-serif;
  animation: blf-slide-up 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 480px;
  margin: 0 auto;
}

#blastify-ios-install .ios-install-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

#blastify-ios-install #blf-ios-close {
  background: rgba(255,255,255,0.22);
  border: none;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
  flex-shrink: 0;
  font-family: 'Montserrat', sans-serif;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* SW update available banner — bottom right */
#blastify-update-banner {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom));
  right: 12px;
  background: linear-gradient(135deg, #6366F1 0%, #4F46E5 100%);
  color: white;
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
  z-index: 9998;
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: blf-slide-up 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#blastify-update-banner #blf-update-yes {
  background: white;
  color: #4F46E5;
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}

#blastify-update-banner #blf-update-no {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0;
  font-family: inherit;
}

/* When PWA is installed (standalone mode), hide install banners + adjust UI */
@media all and (display-mode: standalone) {
  #blastify-install-banner,
  #blastify-ios-install {
    display: none !important;
  }
  
  /* Add extra padding bottom for home indicator on iOS */
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* Mobile-specific install banner adjustments */
@media (max-width: 480px) {
  #blastify-install-banner {
    top: 8px;
    width: calc(100vw - 16px);
    padding: 10px 12px;
    gap: 10px;
  }
  
  #blastify-install-banner .install-icon {
    font-size: 22px;
  }
  
  #blastify-install-banner .install-title {
    font-size: 13px;
  }
  
  #blastify-install-banner .install-subtitle {
    font-size: 10.5px;
  }
  
  #blastify-install-banner .install-btn {
    padding: 8px 12px;
    font-size: 12px;
  }
}

/* ==========================================================================
   DESKTOP RESET — Prevent mobile page-header rules leaking to wider screens
   ========================================================================== */

@media (min-width: 769px) {
  .page-header {
    flex-direction: row !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    gap: 16px !important;
  }

  .page-header > button,
  .page-header > .btn,
  .page-header > a.btn {
    width: auto !important;
    max-width: max-content !important;
    flex-shrink: 0 !important;
    align-self: auto !important;
    min-height: 0 !important;
    justify-content: center !important;
  }

  .page-header h1 {
    font-size: 22px !important;
    margin: 0 0 4px 0 !important;
  }

  /* Hide bottom nav + More sheet on desktop entirely */
  #blastify-bottom-nav,
  #blastify-more-sheet {
    display: none !important;
  }
}

/* ==========================================================================
   MORE SHEET — Divider + Logout styling
   ========================================================================== */

.more-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 16px -16px 14px;
}

[data-theme="light"] .more-divider {
  background: rgba(0, 0, 0, 0.08);
}

.more-logout {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.22);
  border-radius: 14px;
  color: #f87171;
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: 180ms;
  min-height: 56px;
  width: 100%;
  box-sizing: border-box;
}

[data-theme="light"] .more-logout {
  background: rgba(239, 68, 68, 0.06);
  color: #DC2626;
  border-color: rgba(239, 68, 68, 0.25);
}

.more-logout:hover,
.more-logout:active {
  background: rgba(239, 68, 68, 0.18);
  transform: scale(0.98);
}

.more-logout .more-ico {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}

.more-logout span:not(.more-ico) {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
}

/* ==========================================================================
   TIER 2 — UNIVERSAL MOBILE FIXES (covers Profile, Webhooks, AI, Kontak, 
   Auto Warmer, Tier, Riwayat, Media Library)
   ========================================================================== */

@media (max-width: 768px) {

  /* === 1. ALL .grid-2 and .grid-3 → stack 1 col on mobile === */
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* === 2. ALL form inputs full-width === */
  .page input[type="text"],
  .page input[type="email"],
  .page input[type="password"],
  .page input[type="url"],
  .page input[type="number"],
  .page input[type="tel"],
  .page input[type="search"],
  .page input[type="date"],
  .page input[type="time"],
  .page input[type="datetime-local"],
  .page select,
  .page textarea {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  /* === 3. Long URLs/API keys/tokens wrap properly === */
  .page code,
  .page pre,
  .page kbd,
  [class*="api-key"],
  [class*="webhook-url"],
  [class*="webhook-secret"],
  [class*="token-display"],
  [class*="key-display"],
  [class*="copy-text"],
  [id*="api-key"],
  [id*="webhook-url"],
  [class*="key-value"] {
    word-break: break-all !important;
    overflow-wrap: anywhere !important;
    white-space: pre-wrap !important;
    font-size: 12px !important;
    line-height: 1.4 !important;
    max-width: 100% !important;
  }

  /* === 4. Form rows: stack === */
  .form-row,
  .form-group-inline,
  [class*="form-2col"],
  [class*="form-3col"],
  [class*="settings-row"],
  [class*="config-row"] {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  .form-row > *,
  .form-group-inline > * {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* === 5. Tier/Pricing cards: stack vertical === */
  [class*="tier-card"],
  [class*="pricing-card"],
  [class*="plan-card"],
  [class*="upgrade-card"] {
    padding: 16px !important;
    margin-bottom: 12px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Pricing buttons full-width */
  [class*="tier-card"] button,
  [class*="pricing-card"] button,
  [class*="plan-card"] button {
    width: 100% !important;
    justify-content: center !important;
  }

  /* === 6. Contact list: better mobile cards === */
  [class*="contact-row"],
  [class*="contact-item"],
  [id*="contact-list"] > * {
    padding: 12px !important;
    word-break: break-word !important;
  }

  /* === 7. Webhook cards/rows === */
  [class*="webhook-card"],
  [class*="webhook-row"],
  [class*="webhook-item"] {
    padding: 14px !important;
    margin-bottom: 10px !important;
    word-break: break-word !important;
  }

  /* === 8. Auto Warmer status cards: tighter === */
  .warmer-status-card,
  [class*="warmer-card"],
  [id*="warmer-status"] {
    padding: 14px !important;
  }

  [class*="warmer-stat"],
  [class*="warmer-metric"] {
    padding: 10px !important;
  }

  /* === 9. AI Pintar settings: tighter === */
  [class*="aismart-section"],
  [class*="ai-section"],
  [class*="ai-config"] {
    padding: 14px !important;
    margin-bottom: 12px !important;
  }

  /* === 10. Profile fields: stack === */
  [class*="profile-form"],
  [class*="profile-grid"],
  [id*="profile-form"] {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* === 11. Modal: fullscreen on mobile === */
  .modal,
  .modal-content,
  .modal-dialog,
  [class*="modal-box"],
  [class*="modal-overlay"] > div {
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px) !important;
    max-height: calc(100vh - 32px) !important;
    margin: 8px auto !important;
    border-radius: 14px !important;
  }

  /* === 12. All buttons in lists: min touch target === */
  .card button,
  .card .btn {
    min-height: 40px !important;
    touch-action: manipulation;
  }

  /* === 13. Toggle switches: visible size === */
  input[type="checkbox"][role="switch"],
  .toggle-switch,
  [class*="switch"] {
    transform: scale(1.1) !important;
  }

  /* === 14. Multi-column lists / kpi grids === */
  [class*="kpi-grid"],
  [class*="metric-grid"],
  [class*="dashboard-grid"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  /* === 15. Long device names / phone numbers === */
  [class*="device-name"],
  [class*="phone-number"],
  [class*="device-number"] {
    word-break: break-all !important;
    overflow-wrap: anywhere !important;
  }
}

/* ==========================================================================
   INBOX WHATSAPP-STYLE (Mobile — single panel view at a time)
   Default: show chat list. Tap chat → show conversation fullscreen.
   ========================================================================== */

@media (max-width: 768px) {
  /* Reset existing inbox layout */
  .inbox-container {
    position: relative !important;
    display: block !important;
    height: auto !important;
    min-height: 0 !important;
  }

  /* Chat list (default visible) */
  .inbox-container .inbox-sidebar {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: none !important;
    height: auto !important;
    min-height: 60vh !important;
    border-radius: 12px !important;
    border: 1px solid var(--border, rgba(255,255,255,0.08)) !important;
  }

  /* Conversation panel (hidden by default) */
  .inbox-container .inbox-main {
    display: none !important;
  }

  /* When conversation opened: hide list, show conversation fullscreen */
  .inbox-container.show-conversation .inbox-sidebar {
    display: none !important;
  }

  .inbox-container.show-conversation .inbox-main {
    display: flex !important;
    flex-direction: column !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 999 !important;
    background: var(--bg-base, #0A1929) !important;
    margin: 0 !important;
    border-radius: 0 !important;
    border: none !important;
    padding-bottom: calc(70px + env(safe-area-inset-bottom)) !important;
    width: 100% !important;
    max-width: 100% !important;
    animation: inbox-slide-in 280ms cubic-bezier(0.4, 0, 0.2, 1);
  }

  @keyframes inbox-slide-in {
    from { transform: translateX(15%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
  }

  /* Back button at top of conversation */
  .inbox-back-btn {
    position: sticky;
    top: 0;
    width: 100%;
    background: linear-gradient(135deg, #0ABAB5 0%, #08938F 100%);
    color: #ffffff;
    border: none;
    padding: 14px 16px;
    text-align: left;
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 12px rgba(10, 186, 181, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  .inbox-back-btn .ibb-icon {
    font-size: 22px;
    font-weight: bold;
    line-height: 1;
    width: 24px;
    text-align: center;
  }

  .inbox-back-btn .ibb-label {
    flex: 1;
  }

  .inbox-back-btn:active {
    transform: scale(0.98);
    background: linear-gradient(135deg, #08938F 0%, #066b67 100%);
  }
}

/* Hide back button on desktop */
@media (min-width: 769px) {
  .inbox-back-btn {
    display: none !important;
  }
}

/* ==========================================================================
   RIWAYAT BLAST — Table → Card-friendly on mobile
   ========================================================================== */

@media (max-width: 768px) {
  /* History page table: stronger horizontal scroll with snap */
  #page-history .card table,
  [id*="history-table"],
  [id*="blast-history"] table {
    display: block !important;
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    white-space: nowrap !important;
  }

  /* Headers don't wrap */
  #page-history thead th,
  [id*="history-table"] thead th {
    white-space: nowrap !important;
    font-size: 11px !important;
    padding: 8px 12px !important;
    text-transform: uppercase;
  }

  /* Add subtle scroll hint shadow on the right edge */
  #page-history .card {
    position: relative;
  }

  #page-history .card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 20px;
    pointer-events: none;
    background: linear-gradient(to right, transparent, var(--bg-card, #132F4C));
    border-radius: 0 14px 14px 0;
    opacity: 0.7;
  }
}

/* ==========================================================================
   MEDIA LIBRARY — Better copy/delete buttons (replace plain emoji)
   ========================================================================== */

button[onclick*="copyMedia"],
button[onclick*="copyMediaUrl"],
button[onclick*="copyMediaPath"],
button[onclick*="copy-media"],
.media-copy-btn,
.btn-copy-media {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  padding: 8px 14px !important;
  border-radius: 8px !important;
  font-family: 'Montserrat', sans-serif !important;
  font-size: 12.5px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  transition: 180ms !important;
  background: rgba(10, 186, 181, 0.12) !important;
  border: 1px solid rgba(10, 186, 181, 0.3) !important;
  color: #0ABAB5 !important;
  min-height: 36px !important;
  white-space: nowrap !important;
}

button[onclick*="copyMedia"]:hover,
button[onclick*="copy-media"]:hover {
  background: rgba(10, 186, 181, 0.22) !important;
  transform: scale(0.97);
}

button[onclick*="deleteMedia"],
button[onclick*="hapusMedia"],
button[onclick*="removeMedia"],
button[onclick*="delete-media"],
.media-delete-btn,
.btn-delete-media {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  padding: 8px 14px !important;
  border-radius: 8px !important;
  font-family: 'Montserrat', sans-serif !important;
  font-size: 12.5px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  transition: 180ms !important;
  background: rgba(239, 68, 68, 0.1) !important;
  border: 1px solid rgba(239, 68, 68, 0.28) !important;
  color: #ef4444 !important;
  min-height: 36px !important;
  white-space: nowrap !important;
}

button[onclick*="deleteMedia"]:hover,
button[onclick*="hapusMedia"]:hover {
  background: rgba(239, 68, 68, 0.2) !important;
  transform: scale(0.97);
}

/* End of blastify-v2.css */





