html { touch-action: manipulation; }
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
* { -webkit-user-select: none; -moz-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea { -webkit-user-select: text; -moz-user-select: text; user-select: text; }
button, .btn, .btn-icon { touch-action: manipulation; cursor: pointer; }

:root {
  --bg: #09090b;
  --bg2: #0f0f12;
  --primary: #7c3aed;
  --primary-dim: rgba(124,58,237,0.2);
  --primary-glow: rgba(124,58,237,0.4);
  --secondary: #06b6d4;
  --secondary-dim: rgba(6,182,212,0.2);
  --muted: rgba(255,255,255,0.45);
  --muted-dim: rgba(255,255,255,0.12);
  --border: rgba(255,255,255,0.08);
  --destructive: #ef4444;
  --destructive-dim: rgba(239,68,68,0.15);
  --glass: rgba(255,255,255,0.04);
  --glass-border: rgba(255,255,255,0.07);
  --cyan: #22d3ee;
  --blue: #60a5fa;
  --amber: #fbbf24;
  --emerald: #34d399;
  --yellow: #fde047;
  --red: #f87171;
}

html { font-size: 16px; }

body {
  background: var(--bg);
  color: #e5e5e5;
  font-family: system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ─── LOGIN CENTER MODE ─── */
.login-mode {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-mode .page {
  width: 100%;
  padding: 1.5rem;
  align-items: center;
}
.login-mode #add-account-section {
  width: 100%;
  max-width: 28rem;
}

@media(min-width:768px) { .page { padding: 2rem; } }

/* ─── GLASS CARD ─── */
.glass-card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 1rem;
  overflow: hidden;
}

/* ─── HEADER ─── */
.header {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-top: none;
  border-left: none;
  border-right: none;
  border-bottom: 2px solid rgba(124,58,237,0.3);
  border-radius: 1rem;
  padding: 1.25rem 1.5rem;
  position: relative;
  overflow: hidden;
}
.header-glow-1 {
  position: absolute; top: 0; right: 0;
  width: 16rem; height: 16rem;
  background: rgba(124,58,237,0.2);
  filter: blur(100px);
  border-radius: 50%;
  transform: translate(33%, -50%);
  pointer-events: none;
}
.header-glow-2 {
  position: absolute; bottom: 0; left: 0;
  width: 16rem; height: 16rem;
  background: rgba(6,182,212,0.2);
  filter: blur(100px);
  border-radius: 50%;
  transform: translate(-33%, 50%);
  pointer-events: none;
}
.header-inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.header-icon {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 0.75rem;
  padding: 0.75rem;
  font-size: 1.5rem;
  box-shadow: 0 4px 20px rgba(124,58,237,0.3);
  display: flex; align-items: center; justify-content: center;
}
.header-title {
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: #fff;
}
.text-gradient {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.header-sub {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

/* ─── ADD ACCOUNT CARD ─── */
.add-card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 1rem;
  overflow: hidden;
}
.add-card-bar { display: none; }
.add-card-header {
  padding: 1.25rem 1.5rem 0.75rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #fff;
  display: flex; align-items: center; gap: 0.5rem;
}
.add-card-body { padding: 0 1.5rem 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.field-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.input {
  width: 100%;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 0.6rem;
  padding: 0.6rem 0.75rem;
  color: #fff;
  font-family: monospace;
  font-size: 0.9rem;
  height: 2.75rem;
  outline: none;
  transition: border-color 0.15s;
}
.input:focus { border-color: var(--primary); }
.input:disabled { opacity: 0.5; cursor: not-allowed; }
.input[type="number"] {
  width: 5rem;
  text-align: center;
  font-weight: 700;
  height: 1.75rem;
  padding: 0.25rem 0.5rem;
}

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  border: none; cursor: pointer; font-weight: 700;
  border-radius: 0.75rem; transition: opacity 0.15s, transform 0.1s;
  font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.btn-full { width: 100%; height: 2.75rem; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  box-shadow: 0 0 12px rgba(124,58,237,0.3);
}
.btn-primary:hover { opacity: 0.88; }
.btn-danger { background: var(--destructive); color: #fff; }
.btn-danger:hover { opacity: 0.85; }
.btn-ghost { background: transparent; border: 1px solid rgba(255,255,255,0.1); color: var(--muted); }
.btn-ghost:hover { background: rgba(255,255,255,0.05); }
.btn-redeem {
  background: rgba(251,191,36,0.15);
  border: 1px solid rgba(251,191,36,0.3);
  color: var(--amber);
  border-radius: 0.5rem;
  padding: 0.15rem 0.75rem;
  height: 1.5rem;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
}
.btn-redeem:hover { background: rgba(251,191,36,0.3); }
.btn-icon { background: transparent; border: none; cursor: pointer; color: rgba(255,255,255,0.25); padding: 0.25rem; border-radius: 4px; transition: color 0.15s; }
.btn-icon:hover { color: var(--destructive); }

/* ─── ACCOUNTS GRID ─── */
.accounts-grid { display: grid; gap: 1.25rem; }
@media(min-width:768px) { .accounts-grid { grid-template-columns: repeat(2, 1fr); } }
@media(min-width:1280px) { .accounts-grid { grid-template-columns: repeat(3, 1fr); } }

/* ─── ACCOUNT CARD ─── */
.account-card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 1rem;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.card-top-bar { display: none; }
.card-top-bar.running { background: linear-gradient(135deg, var(--primary), var(--secondary)); }
.card-top-bar.idle { background: rgba(255,255,255,0.1); }

.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 1rem 1rem 0.5rem;
}
.card-msisdn { font-family: monospace; font-weight: 700; color: #fff; font-size: 1rem; letter-spacing: 0.08em; }
.card-uid { font-size: 0.62rem; color: var(--muted); font-family: monospace; margin-top: 0.2rem; }
.card-head-right { display: flex; align-items: center; gap: 0.5rem; }

.status-badge {
  padding: 0.15rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border: 1px solid;
  display: flex; align-items: center; gap: 0.3rem;
}
.status-running { background: rgba(124,58,237,0.2); color: var(--primary); border-color: var(--primary); }
.status-idle    { background: rgba(255,255,255,0.05); color: var(--muted); border-color: rgba(255,255,255,0.15); }
.status-stopped { background: rgba(6,182,212,0.15); color: var(--secondary); border-color: var(--secondary); }
.status-error   { background: var(--destructive-dim); color: var(--destructive); border-color: var(--destructive); }
.ping-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: ping 1.2s ease-in-out infinite; display: inline-block; }
@keyframes ping { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:0.4;transform:scale(1.4)} }

/* ─── MINI STATS GRID ─── */
.stats-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 0.5rem; padding: 0.75rem 1rem; }
.mini-stat {
  background: rgba(0,0,0,0.3);
  border-radius: 0.75rem;
  padding: 0.6rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
}
.mini-stat-label { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; color: var(--muted); display: flex; align-items: center; gap: 0.25rem; }
.mini-stat-value { font-family: monospace; font-weight: 700; font-size: 0.875rem; }
.c-cyan { color: var(--cyan); }
.c-blue { color: var(--blue); }
.c-purple { color: var(--primary); }
.c-amber { color: var(--amber); }
.c-emerald { color: var(--emerald); }
.c-muted { color: var(--muted); }

/* ─── INLINE ALERTS ─── */
.alert-bar {
  margin: 0 1rem 0.6rem;
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.65rem; font-weight: 600;
  padding: 0.4rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid;
}
.alert-success { background: rgba(52,211,153,0.1); border-color: rgba(52,211,153,0.2); color: var(--emerald); }
.alert-error   { background: var(--destructive-dim); border-color: rgba(239,68,68,0.2); color: var(--red); }
.alert-uptime  { background: transparent; border-color: transparent; color: var(--muted); font-size: 0.62rem; font-weight: 400; }

/* ─── MILESTONE BARS ─── */
.milestone-bars { display: flex; gap: 0.25rem; padding: 0 1rem 0.75rem; }
.milestone-item { flex: 1; }
.milestone-label { font-size: 0.55rem; color: rgba(255,255,255,0.3); margin-bottom: 0.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress-track { height: 4px; border-radius: 2px; background: rgba(255,255,255,0.12); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 2px; transition: width 0.4s ease; }
.progress-fill.claimed { background: var(--emerald); }
.progress-fill.normal  { background: transparent; }

/* ─── COINS EXCHANGE ─── */
.exchange-section { padding: 0 1rem 0.75rem; }
.exchange-title {
  font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.1em;
  font-weight: 700; color: var(--muted);
  display: flex; align-items: center; gap: 0.35rem; margin-bottom: 0.5rem;
}
.exchange-row {
  display: flex; align-items: center; gap: 0.5rem;
  background: rgba(0,0,0,0.3); border-radius: 0.75rem;
  padding: 0.5rem 0.75rem; margin-bottom: 0.35rem;
}
.exchange-row:last-child { margin-bottom: 0; }
.exchange-coins { font-family: monospace; font-weight: 700; font-size: 0.75rem; color: var(--amber); }
.exchange-runs  { font-family: monospace; font-weight: 700; font-size: 0.75rem; color: var(--blue); flex: 1; }
.exchange-arrow { color: var(--muted); font-size: 0.7rem; }

/* ─── CARD BOTTOM ACTIONS ─── */
.card-actions { padding: 0 1rem 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.gift-row {
  display: flex; align-items: center; gap: 0.5rem;
  background: rgba(0,0,0,0.3); border-radius: 0.75rem;
  padding: 0.5rem 0.75rem;
}
.gift-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; color: var(--muted); flex: 1; }
.log-toggle-row { display: flex; justify-content: center; padding: 0.25rem 0; }
.log-toggle-btn { background: transparent; border: none; cursor: pointer; color: rgba(255,255,255,0.3); font-size: 0.8rem; transition: color 0.15s; padding: 0.25rem 0.5rem; }
.log-toggle-btn:hover { color: rgba(255,255,255,0.6); }

/* ─── ACCOUNT WRAPPER ─── */
.account-wrapper { display: flex; flex-direction: column; gap: 0.5rem; }

/* ─── LOG CARD ─── */
.log-card {
  background: var(--bg2);
  border: 1px solid var(--glass-border);
  border-radius: 1rem;
  overflow: hidden;
}
.log-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  background: rgba(0,0,0,0.3);
}
.log-card-title {
  font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.1em;
  font-weight: 700; color: var(--muted);
  display: flex; align-items: center; gap: 0.35rem;
}
.log-card-body {
  max-height: 16rem;
  overflow-y: auto;
  padding: 0.5rem 0.75rem;
  display: flex; flex-direction: column; gap: 0.35rem;
}
.log-card-body::-webkit-scrollbar { width: 4px; }
.log-card-body::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); border-radius: 4px; }
.log-card-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
.log-card-body::-webkit-scrollbar-thumb:hover { background: rgba(124,58,237,0.5); }

/* ─── LOG LINES ─── */
.log-line {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.35rem 0.5rem;
  border-radius: 0.4rem;
  border-left: 2px solid;
}
.log-success { background: rgba(6,78,59,0.4);  border-color: rgba(52,211,153,0.6); }
.log-warn    { background: rgba(92,67,0,0.3);  border-color: rgba(253,224,71,0.6); }
.log-error   { background: rgba(127,29,29,0.4); border-color: rgba(248,113,113,0.6); }
.log-info    { background: rgba(30,58,138,0.2); border-color: rgba(96,165,250,0.3); }
.log-time { font-size: 0.55rem; color: rgba(255,255,255,0.25); flex-shrink: 0; font-family: monospace; }
.log-icon { flex-shrink: 0; }
.log-msg { font-size: 0.62rem; line-height: 1.4; word-break: break-all; flex: 1; }
.log-success .log-msg { color: #6ee7b7; font-weight: 600; }
.log-warn    .log-msg { color: #fde68a; }
.log-error   .log-msg { color: var(--red); font-weight: 600; }
.log-info    .log-msg { color: rgba(186,214,255,0.8); }
.log-empty { text-align: center; color: rgba(255,255,255,0.25); font-style: italic; font-size: 0.65rem; padding: 1rem 0; }

/* ─── ADD ACCOUNT FLOATING BTN (when accounts exist) ─── */
.fab-add {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff; border: none; border-radius: 50%; width: 3.5rem; height: 3.5rem;
  font-size: 1.5rem; cursor: pointer;
  box-shadow: 0 4px 20px rgba(124,58,237,0.5);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s, opacity 0.15s; z-index: 50;
}
.fab-add:hover { transform: scale(1.08); opacity: 0.9; }

/* ─── MODAL ─── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100;
  padding: 1rem;
}
@media(min-width:640px) { .modal-overlay { align-items: center; } }
.modal {
  background: #141418; border: 1px solid var(--glass-border);
  border-radius: 1rem; width: 100%; max-width: 28rem;
  overflow: hidden;
}
.modal-bar { height: 4px; background: linear-gradient(135deg, var(--primary), var(--secondary)); }
.modal-head {
  padding: 1.25rem 1.5rem 0.75rem;
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: #fff;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-close { background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 1.1rem; }
.modal-close:hover { color: #fff; }
.modal-body { padding: 0 1.5rem 1.5rem; display: flex; flex-direction: column; gap: 1rem; }

/* ─── TOAST ─── */
.toast-container {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 0.5rem;
  z-index: 200; pointer-events: none;
  align-items: center; width: max-content; max-width: 90vw;
}
.toast {
  background: #1a1a20; border: 1px solid var(--glass-border);
  border-radius: 0.6rem; padding: 0.6rem 1rem;
  color: #fff; font-size: 0.8rem; font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  animation: toastIn 0.2s ease;
  pointer-events: auto;
}
.toast.success { border-left: 3px solid var(--emerald); }
.toast.error   { border-left: 3px solid var(--destructive); }
@keyframes toastIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }
@keyframes toastOut { from{opacity:1} to{opacity:0} }
.toast.out { animation: toastOut 0.2s ease forwards; }

/* ─── MISC ─── */
.divider { height: 1px; background: var(--border); margin: 0; }
