* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: -apple-system, system-ui, Segoe UI, Roboto, Arial, sans-serif; background: #0e0e12; color: #e5e7eb; }

a { color: #06b6d4; text-decoration: none; }

/* ---------- Inline CAPTCHA on login page ---------- */
.captcha-field { margin: 16px 0; padding: 14px; background: #1a1a22; border: 1px solid #2a2a35; border-radius: 8px; }
.captcha-field .captcha-title { font-size: 14px; font-weight: 700; color: #e5e7eb; margin: 0 0 10px; }
.captcha-field .shield-field { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.captcha-field .shield-field .shield-txt { position: static; font-size: 13px; color: #9ca3af; text-align: center; margin: 0; }
.captcha-field .shield-btn { width: 100%; padding: 10px; background: #2a2a35; color: #e5e7eb; border: 0; border-radius: 6px; font-size: 14px; font-weight: 700; cursor: default; }
.captcha-field .shield-btn:not([disabled]) { background: #c724b1; cursor: pointer; }
.captcha-field .shield-btn:not([disabled]):hover { background: #a81e97; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { max-width: 380px; width: 100%; margin: 0 auto; padding: 32px; background: #1a1a22; border: 1px solid #2a2a35; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.4); }
.brand { font-size: 22px; font-weight: 800; margin-bottom: 8px; color: #fff; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.brand small { display: block; font-weight: 400; font-size: 11px; opacity: 0.7; margin-top: 4px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: #9ca3af; margin-bottom: 6px; }
.form-group input { width: 100%; padding: 10px; border: 1px solid #333; border-radius: 6px; font-size: 14px; background: #0c0c10; color: #e5e7eb; box-sizing: border-box; }
.btn { border: none; border-radius: 7px; padding: 10px 16px; font-size: 14px; cursor: pointer; font-weight: 600; }
.btn.primary { background: #c724b1; color: #fff; }
.btn.primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn.secondary { background: #2a2a35; color: #e5e7eb; }
.btn.secondary:hover { background: #333340; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.danger { background: #ef4444; border-color: #dc2626; color: #fff; }
.btn.danger:hover { background: #dc2626; }
.error { color: #ef4444; font-size: 13px; margin-top: 12px; }
.hint { font-size: 12px; color: #9ca3af; margin-top: 4px; }

/* ---------- App layout (SMS Sender pattern) ---------- */
.app-layout { width: 100vw; height: 100vh; min-height: 100vh; overflow: hidden; position: relative; }

.sidebar { position: fixed; top: 0; left: 0; width: 220px; height: 100vh; background: #15151c; border-right: 1px solid #2a2a35; padding: 18px 0; overflow-y: auto; z-index: 50; }
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px 14px 48px;
  font-size: 13px;
  color: #cbd5e1;
  text-align: center;
}
.wa-text { font-size: 13px; font-weight: 800; letter-spacing: 0.5px; }
.sidebar-brand small { display: block; font-weight: 400; font-size: 9px; opacity: 0.85; margin-top: 2px; }

/* ---------- Header logo (centered) ---------- */
.header-logo {
  flex: 1;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.wa-logo { width: 32px; height: 32px; background: #25d366; border-radius: 7px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.phone { width: 16px; height: 16px; border: 2px solid #fff; border-radius: 50%; position: relative; }
.phone::before { content: ''; position: absolute; top: -4px; right: -4px; width: 7px; height: 11px; background: #25d366; border-top-right-radius: 4px; transform: rotate(45deg); }
.wa-text { font-size: 18px; font-weight: 800; letter-spacing: 0.5px; }

/* ---------- Collapsible sidebar (desktop) ---------- */
.sidebar.collapsed { width: 70px; }
.sidebar.collapsed .wa-text { display: none; }
.sidebar.collapsed .sidebar-brand small { display: none; }
.sidebar.collapsed .sidebar-brand { justify-content: center; padding: 14px 8px; }
.sidebar.collapsed .wa-logo { width: 32px; height: 32px; margin: 0 auto; }
.sidebar.collapsed .nav-link { justify-content: center; padding: 12px 0; font-size: 0; }
.sidebar.collapsed .nav-link::before { content: ''; font-size: 16px; width: 100%; }
.sidebar.collapsed .nav-link[data-page="check"]::before { content: '🔍'; font-size: 16px; }
.sidebar.collapsed .nav-link[data-page="bulk"]::before { content: '📢'; font-size: 16px; }
.sidebar.collapsed .nav-link[data-page="history"]::before { content: '📋'; font-size: 16px; }
.sidebar.collapsed .nav-link[data-page="settings"]::before { content: '⚙️'; font-size: 16px; }
.sidebar.collapsed .nav-footer { padding: 12px 0; }
.sidebar.collapsed ~ .main-content { margin-left: 70px; }
.sidebar.collapsed .nav-footer button { width: auto; padding: 10px 6px; font-size: 0; }
.sidebar.collapsed .nav-footer button::before { content: '🚪'; font-size: 16px; }
.sidebar-user { padding: 12px 18px; font-size: 13px; border-bottom: 1px solid #2a2a35; margin-bottom: 12px; opacity: 0.9; }
.nav-list { list-style: none; padding: 0; margin: 0; }
.nav-list li { border-bottom: 1px solid #2a2a35; }
.nav-link { display: block; color: #cbd5e1; padding: 11px 18px; text-decoration: none; font-size: 14px; border-left: 3px solid transparent; }
.nav-link:hover { background: #22222e; color: #fff; }
.nav-link.active { background: #241024; border-left-color: #c724b1; color: #fff; }
.nav-footer { padding: 16px 18px; margin-top: auto; }

.main-content { margin-left: 220px; height: 100vh; overflow-y: auto; padding: 22px; background: #0e0e12; }

/* ---------- Header ---------- */
.app-header { display: flex; flex-direction: column; align-items: center; margin-bottom: 22px; gap: 12px; width: 100%; }
.header-logo { width: 100%; text-align: center; display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 8px; }
.session-row { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; }
.session-badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 700; }
.session-badge-disconnected { background: #3a0e0e; color: #ef4444; border: 1px solid #5b1a1a; }
.session-badge-connected { background: #0e3a1f; color: #22c55e; border: 1px solid #1a521e; }
.session-badge-qr { background: #3a2a0e; color: #f59e0b; border: 1px solid #5b3a0e; }

/* ---------- QR Panel ---------- */
.qr-panel { display: none; text-align: center; padding: 20px; margin: 10px 0; }
.qr-panel.visible { display: block; }
#qrCode { margin: 0 auto 10px; }
.qr-hint { font-size: 13px; color: #9ca3af; }

/* ---------- Cards ---------- */
.card { background: #1a1a22; border: 1px solid #2a2a35; border-radius: 10px; padding: 18px; margin-bottom: 18px; }
.card-header { font-weight: 700; margin-bottom: 12px; font-size: 15px; color: #e5e7eb; }
.section-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: #1a1a22; border-bottom: 1px solid #2a2a35; font-weight: 700; color: #e5e7eb; cursor: pointer; user-select: none; }
.row { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; flex-wrap: wrap; }
.flex-1 { flex: 1; min-width: 200px; }
.right { margin-left: auto; align-self: center; }

label { display: block; font-size: 13px; font-weight: 600; color: #9ca3af; margin-bottom: 6px; }
textarea, select, input[type="file"], input[type="text"], input[type="password"], input[type="number"] { width: 100%; padding: 9px; border: 1px solid #333; border-radius: 6px; font-size: 14px; background: #0c0c10; color: #e5e7eb; box-sizing: border-box; }
textarea { font-family: monospace; resize: vertical; }

/* ---------- Stats ---------- */
.stats { display: flex; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.stat { display: inline-block; background: #1a1a22; border: 1px solid #2a2a35; border-radius: 8px; padding: 12px 18px; margin: 6px 0; }
.stat b { color: #c724b1; font-size: 22px; display: block; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid #2a2a35; border-radius: 6px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; color: #e5e7eb; }
th, td { padding: 7px 8px; border-bottom: 1px solid #26262f; text-align: left; }
th { background: #1a1a22; font-weight: 700; color: #9ca3af; }
tr:last-child td { border-bottom: none; }
td.ok { color: #22c55e; font-weight: 700; }
td.bad { color: #ef4444; font-weight: 700; }
td.null { color: #9ca3af; }

/* ---------- Filter / Log ---------- */
.filter { display: inline-block; padding: 4px 10px; border-radius: 12px; background: #2a2a35; color: #9ca3af; font-size: 12px; cursor: pointer; margin: 2px 4px; }
.filter.active { background: #c724b1; color: #fff; }
.log-panel { height: 200px; overflow-y: auto; background: #0c0c10; color: #e2e8f0; padding: 10px; border-radius: 6px; font-family: monospace; font-size: 12px; line-height: 1.4; border: 1px solid #2a2a35; }
.log-entry { margin: 2px 0; white-space: pre-wrap; }
.log-time { color: #9ca3af; margin-right: 8px; }

.page { display: block; }

/* ---------- Mobile ---------- */
.sidebar-toggle { position: absolute; top: 12px; left: 12px; z-index: 60; width: 36px; height: 36px; background: #c724b1; border: none; color: #fff; font-size: 22px; cursor: pointer; border-radius: 7px; display: flex; align-items: center; justify-content: center; line-height: 1; }
.sidebar-toggle:hover { background: #a81e97; }

@media (max-width: 768px) {
  .sidebar { position: fixed; left: -220px; transition: left 0.2s; z-index: 55; }
  .sidebar.open { left: 0; }
  .main-content { margin-left: 0 !important; padding: 16px; }
  .app-header { flex-direction: column; align-items: flex-start; }
  .session-chip { width: 100%; justify-content: space-between; }
  .stats { grid: none; display: block; }
  .stat { display: inline-block; width: 48%; margin-bottom: 8px; }
  .table-wrap { font-size: 11px; }
  th, td { padding: 4px 6px; }
}

/* ---------- Shield Slide CAPTCHA ---------- */
.captcha-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 9999; background: rgba(0,0,0,.95); display: flex; align-items: center; justify-content: center; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; opacity: 1; }
.captcha-card { background: #1a1a22; border: 1px solid #2a2a35; border-radius: 16px; padding: 40px; max-width: 420px; width: 90%; box-shadow: 0 4px 24px rgba(0,0,0,.4); text-align: center; }
.captcha-logo { font-size: 40px; margin-bottom: 16px; }
.captcha-title { font-size: 22px; font-weight: 700; color: #fff; margin: 0 0 8px; }
.captcha-body { font-size: 14px; color: #9ca3af; line-height: 1.5; margin: 0 0 24px; }
.shield-track-wrap { position: relative; height: 52px; background: #2a2a35; border: 1px solid #333; border-radius: 26px; overflow: hidden; margin: 0 0 16px; user-select: none; touch-action: none; }
.shield-track { position: relative; height: 100%; }
.shield-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: #22c55e; transition: width 0.1s linear; }
.shield-txt { position: absolute; left: 0; right: 0; top: 0; bottom: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; color: #9ca3af; pointer-events: none; }
.shield-knob { position: absolute; left: 2px; top: 2px; width: 46px; height: 46px; border-radius: 50%; background: #fff; border: 1px solid #cbd5e1; display: flex; align-items: center; justify-content: center; font-size: 17px; color: #0ba9eb; box-shadow: 0 1px 4px rgba(0,0,0,.3); cursor: grab; touch-action: none; }
.shield-knob:active { cursor: grabbing; }
.shield-btn { width: 100%; padding: 14px; background: #2a2a35; color: #e5e7eb; border: 0; border-radius: 10px; font-size: 15px; font-weight: 700; cursor: default; transition: background 0.2s; }
.shield-btn:not([disabled]) { background: #c724b1; cursor: pointer; }
.shield-btn:not([disabled]):hover { background: #a81e97; }
.shield-track.verified { background: #0e3a1f; border-color: #16a34a; }
.shield-track.verified .shield-fill { width: 100%; }
.shield-track.verified .shield-txt { color: #22c55e; font-weight: 700; }
.shield-track.verified .shield-knob { color: #22c55e; border-color: #86efac; background: #fff; }

/* ---------- Footer ---------- */
.page-footer { margin-top: 30px; padding: 18px; background: #15151c; border-radius: 10px; color: #9ca3af; font-size: 13px; border-top: 1px solid #2a2a35; }
.footer-contact { font-weight: 700; margin-bottom: 6px; color: #c724b1; }
.footer-contact a { color: #06b6d4; text-decoration: none; }
.footer-contact a:hover { text-decoration: underline; }
.footer-disclaimer { font-size: 12px; color: #6b7280; line-height: 1.5; }

/* ---------- Bulk Messaging ---------- */
.stat .val.cyn { color: #06b6d4; }
.badge-running { background: #1e293b; color: #3b82f6; border: 1px solid #3b82f6; }
.badge-scheduled { background: #3a2a0e; color: #f59e0b; border: 1px solid #5b3a0e; }
.badge-queued { background: #1e293b; color: #9ca3af; border: 1px solid #475569; }
.badge-done { background: #0e3a1f; color: #22c55e; border: 1px solid #1a521e; }
.badge-cancelled { background: #3a0e0e; color: #9ca3af; border: 1px solid #5b1a1a; }
.badge-error { background: #3a0e0e; color: #ef4444; border: 1px solid #5b1a1a; }
.card-header { display: flex; justify-content: space-between; align-items: center; }