/* Cloaker Pro — Mobile-first dashboard */
:root {
  --bg: #0b1020;
  --bg-2: #11172d;
  --surface: #161d3a;
  --surface-2: #1c2547;
  --border: #232c54;
  --text: #e8ecff;
  --text-dim: #9aa3c7;
  --primary: #6366f1;
  --primary-2: #22d3ee;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --shadow: 0 8px 30px rgba(0,0,0,.35);
  --radius: 14px;
  --radius-sm: 10px;
  --tap: 44px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
body { overscroll-behavior-y: contain; }
a { color: var(--primary-2); text-decoration: none; }
button { font: inherit; }
input, select, textarea { font: inherit; color: var(--text); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Layout */
#app { min-height: 100vh; display: flex; flex-direction: column; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px calc(14px); background: rgba(11,16,32,.85);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
  padding-top: calc(14px + env(safe-area-inset-top));
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; flex: 1; }
@media (max-width: 799px) { .topbar h1 { display: none; } .brand { flex: 1; } }
.topbar .actions { display: flex; gap: 8px; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--primary), var(--primary-2)); display: grid; place-items: center; color: white; font-weight: 800; font-size: 14px; }

main { flex: 1; padding: 16px; padding-bottom: 96px; max-width: 920px; width: 100%; margin: 0 auto; }

/* Bottom Nav */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: rgba(17,23,45,.95); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(5, 1fr);
  z-index: 60;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 8px 2px; color: var(--text-dim);
  font-size: 10px; font-weight: 500; min-width: 0;
}
.nav a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.nav a.active { color: var(--primary-2); }
.nav a svg { width: 20px; height: 20px; flex-shrink: 0; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card h2, .card h3 { margin: 0 0 12px; font-weight: 600; }
.card h2 { font-size: 16px; }
.card h3 { font-size: 14px; color: var(--text-dim); }

/* Stats grid */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.stat .label { color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 4px; }
.stat.success .value { color: var(--success); }
.stat.danger .value { color: var(--danger); }
.stat.primary .value { color: var(--primary-2); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap); padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; font-weight: 500; transition: transform .05s, background .15s; }
.btn:active { transform: scale(.98); }
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); border-color: transparent; color: white; font-weight: 600; }
.btn.danger { background: var(--danger); border-color: transparent; color: white; }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 13px; }
.btn.icon { width: var(--tap); height: var(--tap); padding: 0; flex-shrink: 0; }
.btn.icon svg { width: 20px; height: 20px; display: block; stroke: currentColor; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* Forms */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
.field .hint { color: var(--text-dim); font-size: 12px; margin-top: 4px; }
.input, .select, .textarea {
  width: 100%; padding: 12px 14px; min-height: var(--tap);
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  outline: none; transition: border-color .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); }
.textarea { min-height: 90px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 480px) { .row2 { grid-template-columns: 1fr; } }

/* Toggle */
.toggle { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--border); }
.toggle:first-child { border-top: none; }
.toggle .meta { flex: 1; }
.toggle .meta .t { font-weight: 500; }
.toggle .meta .d { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.switch { position: relative; width: 46px; height: 26px; background: var(--border); border-radius: 999px; cursor: pointer; transition: background .2s; flex-shrink: 0; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; background: white; border-radius: 50%; transition: transform .2s; }
.switch.on { background: var(--primary); }
.switch.on::after { transform: translateX(20px); }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; font-size: 12px; }
.chip .x { cursor: pointer; opacity: .6; }
.chip .x:hover { opacity: 1; }
.chip.active { background: var(--primary); border-color: var(--primary); color: white; }

/* Campaign list item */
.camp-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 8px; }
.camp-item .row { display: flex; align-items: center; gap: 10px; }
.camp-item .name { font-weight: 600; flex: 1; }
.camp-item .url { font-size: 12px; color: var(--text-dim); word-break: break-all; }
.camp-item .copy-btn { font-size: 11px; padding: 4px 8px; border-radius: 6px; background: var(--bg-2); border: 1px solid var(--border); color: var(--primary-2); cursor: pointer; }
.badge { padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: uppercase; }
.badge.active { background: rgba(16,185,129,.15); color: var(--success); }
.badge.paused { background: rgba(245,158,11,.15); color: var(--warning); }
.mini-stats { display: flex; gap: 12px; font-size: 12px; color: var(--text-dim); }
.mini-stats b { color: var(--text); }

/* Country search */
.country-search { position: relative; }
.country-search input { width: 100%; }
.country-dropdown { position: absolute; top: 100%; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 4px; max-height: 260px; overflow-y: auto; z-index: 10; box-shadow: var(--shadow); }
.country-dropdown div { padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.country-dropdown div:hover { background: var(--surface-2); }
.country-dropdown div:last-child { border-bottom: none; }

/* Logs table */
.log-list { display: flex; flex-direction: column; gap: 8px; }
.log-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; }
.log-item .top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.log-item .verdict { font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.log-item .verdict.money { background: rgba(16,185,129,.15); color: var(--success); }
.log-item .verdict.safe  { background: rgba(245,158,11,.15); color: var(--warning); }
.log-item .meta { color: var(--text-dim); font-size: 12px; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.login-card h1 { margin: 0 0 6px; font-size: 22px; text-align: center; }
.login-card p { text-align: center; color: var(--text-dim); margin: 0 0 24px; font-size: 14px; }

/* Toast */
.toast-wrap { position: fixed; left: 50%; transform: translateX(-50%); bottom: 90px; z-index: 100; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: var(--surface-2); border: 1px solid var(--border); padding: 10px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow); animation: toastIn .25s ease; }
.toast.success { border-color: var(--success); }
.toast.danger { border-color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Chart wrapper — forces fixed height even with Chart.js responsive */
.chart-wrap { position: relative; height: 220px; width: 100%; }
.chart-wrap canvas { position: absolute; top: 0; left: 0; width: 100% !important; height: 100% !important; }

/* Skeleton */
.skel { background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 80; display: grid; place-items: end center; padding: 0; }
.modal { background: var(--surface); border-top-left-radius: 20px; border-top-right-radius: 20px; width: 100%; max-width: 560px; padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); animation: slideUp .25s ease; max-height: 90vh; overflow-y: auto; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal h2 { margin: 0 0 16px; }

/* Tabs */
.tabs { display: flex; gap: 4px; background: var(--bg-2); border-radius: var(--radius-sm); padding: 4px; margin-bottom: 14px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: 1 0 auto; background: transparent; border: none; color: var(--text-dim); padding: 8px 12px; border-radius: 8px; font-weight: 500; cursor: pointer; white-space: nowrap; font-size: 13px; }
.tabs button.active { background: var(--surface); color: var(--text); }

/* Empty state */
.empty { text-align: center; padding: 40px 20px; color: var(--text-dim); }
.empty svg { width: 56px; height: 56px; margin-bottom: 12px; opacity: .5; }

/* Desktop tweaks */
@media (min-width: 800px) {
  #app { padding-bottom: 0; }
  .nav { position: sticky; bottom: auto; top: 0; border-top: none; border-bottom: 1px solid var(--border); grid-template-columns: max-content max-content max-content max-content max-content 1fr; padding: 0 16px; }
  .nav a { flex-direction: row; padding: 14px 18px; font-size: 13px; }
  .topbar { display: none; }
  .stats { grid-template-columns: repeat(4, 1fr); }
}

/* Utilities */
.flex { display: flex; }
.flex-1 { flex: 1; }
.center { display: grid; place-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.text-dim { color: var(--text-dim); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-center { text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.divider { height: 1px; background: var(--border); margin: 12px 0; }
.hidden { display: none !important; }

/* PWA install banner */
.pwa-install {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(78px + env(safe-area-inset-bottom));
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; border-radius: var(--radius); padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 12px 40px rgba(99,102,241,.45);
  z-index: 70; animation: slideUp .3s ease;
}
.pwa-install .pwa-icon { width: 36px; height: 36px; flex-shrink: 0; background: rgba(255,255,255,.2); border-radius: 8px; display: grid; place-items: center; font-weight: 800; }
.pwa-install .pwa-text { flex: 1; min-width: 0; }
.pwa-install .pwa-text b { display: block; font-size: 13px; font-weight: 600; }
.pwa-install .pwa-text small { font-size: 11px; opacity: .85; }
.pwa-install .pwa-actions { display: flex; gap: 6px; flex-shrink: 0; }
.pwa-install button { background: #fff; color: var(--primary); border: none; padding: 8px 12px; border-radius: 8px; font-weight: 600; font-size: 12px; cursor: pointer; }
.pwa-install button.dismiss { background: transparent; color: #fff; opacity: .8; padding: 8px; }
@media (min-width: 800px) {
  .pwa-install { left: auto; right: 16px; bottom: 16px; max-width: 380px; }
}
