/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
  --bg:        #08080f;
  --bg2:       #0f0f1a;
  --bg3:       #141420;
  --border:    #1e1e30;
  --border2:   #2a2a40;
  --accent:    #e8c547;
  --accent2:   #f0d060;
  --accent-dim:#a88c30;
  --text:      #e8e8f0;
  --text2:     #9090aa;
  --text3:     #5a5a70;
  --success:   #4caf82;
  --danger:    #e05555;
  --warn:      #e09a33;
  --info:      #5599ee;
  --sidebar-w: 240px;
  --radius:    10px;
  --shadow:    0 4px 24px rgba(0,0,0,0.5);
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input, textarea, select {
  font: inherit;
  background: var(--bg2);
  border: 1.5px solid var(--border2);
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 14px;
  width: 100%;
  transition: border-color .2s;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--text3); }
textarea { resize: vertical; }

/* ── Utilities ──────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.full   { width: 100%; }
.mt     { margin-top: 16px; }
.mt-sm  { margin-top: 8px; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 10px 20px; border-radius: var(--radius);
  font-family: 'Syne', sans-serif; font-weight: 600; font-size: .9rem;
  transition: all .15s; white-space: nowrap;
}
.btn-primary {
  background: var(--accent); color: #08080f;
}
.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(232,197,71,.25); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost {
  background: transparent; color: var(--text2);
  border: 1.5px solid var(--border2);
}
.btn-ghost:hover { border-color: var(--border); color: var(--text); background: var(--bg3); }
.btn-danger {
  background: var(--danger); color: #fff;
}
.btn-danger:hover { background: #ff6666; }
.btn-sm { padding: 6px 14px; font-size: .8rem; }
.btn-xs { padding: 4px 10px; font-size: .75rem; }

/* ── Screen ─────────────────────────────────────────────────────────────── */
.screen { min-height: 100vh; }

/* ── Auth ────────────────────────────────────────────────────────────────── */
.auth-bg {
  position: fixed; inset: 0; z-index: 0;
  background: radial-gradient(ellipse at 20% 50%, rgba(232,197,71,.06) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 20%, rgba(85,153,238,.06) 0%, transparent 50%);
  pointer-events: none;
}
.auth-wrap {
  position: relative; z-index: 1;
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px;
}
.auth-logo {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
  font-family: 'Syne', sans-serif; font-size: 2rem; font-weight: 800;
}
.logo-icon { font-size: 2rem; }
.logo-text  { color: var(--text); letter-spacing: -1px; }
.auth-tagline {
  color: var(--text2); font-size: .95rem; margin-bottom: 32px;
  text-align: center; max-width: 360px;
}
.auth-card {
  background: var(--bg2); border: 1.5px solid var(--border2);
  border-radius: 16px; padding: 32px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow);
}
.auth-tabs {
  display: flex; gap: 4px; background: var(--bg3);
  border-radius: var(--radius); padding: 4px; margin-bottom: 24px;
}
.tab-btn {
  flex: 1; padding: 8px; border-radius: 8px;
  font-family: 'Syne', sans-serif; font-weight: 600; font-size: .85rem;
  color: var(--text2); transition: all .2s;
}
.tab-btn.active { background: var(--accent); color: #08080f; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-family: 'Syne', sans-serif;
  font-size: .8rem; font-weight: 600; color: var(--text2);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: .05em;
}
.label-hint { font-size: .75rem; color: var(--text3); text-transform: none; font-weight: 400; }

.otp-step { margin-top: 16px; }
.otp-input {
  text-align: center; font-family: 'Space Mono', monospace;
  font-size: 1.6rem; letter-spacing: 8px; font-weight: 700;
}
.auth-msg {
  margin-top: 12px; padding: 10px 14px; border-radius: var(--radius);
  font-size: .85rem; border-left: 3px solid;
}
.auth-msg.success { background: rgba(76,175,130,.1); border-color: var(--success); color: var(--success); }
.auth-msg.error   { background: rgba(224,85,85,.1);  border-color: var(--danger);  color: var(--danger);  }
.auth-msg.info    { background: rgba(85,153,238,.1); border-color: var(--info);    color: var(--info);    }
.auth-footer { margin-top: 20px; color: var(--text3); font-size: .75rem; text-align: center; }

/* ── App Layout ──────────────────────────────────────────────────────────── */
#app-screen { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w); min-height: 100vh;
  background: var(--bg2); border-right: 1.5px solid var(--border);
  display: flex; flex-direction: column; padding: 20px 16px;
  position: fixed; top: 0; left: 0; z-index: 100;
  transition: transform .25s;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 8px;
  font-family: 'Syne', sans-serif; font-size: 1.1rem; font-weight: 800;
  color: var(--text); padding: 8px 4px 20px;
  border-bottom: 1.5px solid var(--border); margin-bottom: 16px;
}
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius);
  color: var(--text2); font-weight: 500; font-size: .9rem;
  transition: all .15s; text-decoration: none;
}
.nav-item:hover { background: var(--bg3); color: var(--text); text-decoration: none; }
.nav-item.active { background: rgba(232,197,71,.12); color: var(--accent); }
.nav-icon { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-bottom { border-top: 1.5px solid var(--border); padding-top: 16px; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: var(--radius);
  background: var(--bg3); margin-bottom: 8px;
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  display: flex; align-items: center; justify-content: center;
  font-family: 'Syne', sans-serif; font-weight: 800; font-size: .85rem;
  color: #08080f; flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; overflow: hidden; }
.user-name { font-weight: 600; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-plan { font-size: .75rem; color: var(--accent-dim); }

/* Mobile header */
.mobile-header {
  display: none; position: fixed; top: 0; left: 0; right: 0; z-index: 90;
  background: var(--bg2); border-bottom: 1.5px solid var(--border);
  padding: 12px 16px; align-items: center; justify-content: space-between;
  font-family: 'Syne', sans-serif; font-weight: 700;
}
.hamburger { font-size: 1.3rem; color: var(--text); padding: 4px 8px; }

/* Main */
.main-content {
  margin-left: var(--sidebar-w); flex: 1; padding: 40px;
  max-width: calc(100% - var(--sidebar-w));
}

/* ── Views ──────────────────────────────────────────────────────────────── */
.view-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 28px;
}
.view-header h1 {
  font-family: 'Syne', sans-serif; font-size: 1.8rem; font-weight: 800;
  letter-spacing: -0.5px;
}
.section-title {
  font-family: 'Syne', sans-serif; font-size: .8rem; font-weight: 700;
  color: var(--text3); text-transform: uppercase; letter-spacing: .1em;
  margin: 28px 0 14px;
}

/* Stats grid */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px; margin-bottom: 8px;
}
.stat-card {
  background: var(--bg2); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 20px 18px;
  transition: border-color .2s;
}
.stat-card:hover { border-color: var(--border2); }
.stat-label {
  font-size: .75rem; color: var(--text3); font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em; margin-bottom: 8px;
}
.stat-value {
  font-family: 'Space Mono', monospace; font-size: 2rem; font-weight: 700;
  color: var(--accent);
}

/* Subs list */
.subs-list { display: flex; flex-direction: column; gap: 12px; }
.sub-card {
  background: var(--bg2); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px;
  display: flex; align-items: center; gap: 16px;
  transition: border-color .2s, box-shadow .2s;
}
.sub-card:hover { border-color: var(--border2); box-shadow: var(--shadow); }
.sub-status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.sub-status-dot.active    { background: var(--success); box-shadow: 0 0 6px var(--success); }
.sub-status-dot.paused    { background: var(--warn); }
.sub-status-dot.throttled { background: var(--danger); }
.sub-info { flex: 1; min-width: 0; }
.sub-title {
  font-weight: 600; font-size: .95rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sub-meta {
  font-size: .8rem; color: var(--text2); margin-top: 2px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.sub-badge {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--bg3); padding: 2px 8px; border-radius: 20px;
  font-size: .72rem; color: var(--text2); border: 1px solid var(--border);
}
.sub-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Progress bar */
.progress-bar {
  height: 4px; background: var(--bg3); border-radius: 2px;
  margin-top: 6px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--accent);
  border-radius: 2px; transition: width .4s;
}
.progress-fill.danger { background: var(--danger); }
.progress-fill.warn   { background: var(--warn); }

/* Empty state */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text3);
}
.empty-icon  { font-size: 3rem; margin-bottom: 16px; }
.empty-title { font-family: 'Syne', sans-serif; font-size: 1.2rem; font-weight: 700; color: var(--text2); margin-bottom: 8px; }
.empty-sub   { font-size: .9rem; }

/* ── Plans ──────────────────────────────────────────────────────────────── */
.plan-current {
  background: linear-gradient(135deg, rgba(232,197,71,.1) 0%, rgba(232,197,71,.03) 100%);
  border: 1.5px solid rgba(232,197,71,.3);
  border-radius: var(--radius); padding: 24px 28px; margin-bottom: 8px;
}
.plan-current .plan-name {
  font-family: 'Syne', sans-serif; font-size: 1.4rem; font-weight: 800;
  color: var(--accent); margin-bottom: 12px;
}
.plan-details { display: flex; gap: 24px; flex-wrap: wrap; margin-bottom: 12px; }
.plan-detail { font-size: .9rem; color: var(--text2); }
.plan-detail strong { color: var(--text); }

.plans-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.plan-card {
  background: var(--bg2); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 24px; transition: all .2s;
}
.plan-card:hover { border-color: var(--accent-dim); transform: translateY(-2px); box-shadow: 0 8px 32px rgba(0,0,0,.4); }
.plan-card.featured { border-color: var(--accent); position: relative; }
.plan-card.featured::before {
  content: 'Most Popular'; position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #08080f; font-size: .7rem; font-weight: 700;
  padding: 3px 12px; border-radius: 20px; font-family: 'Syne', sans-serif;
  letter-spacing: .05em; text-transform: uppercase;
}
.plan-card-name { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 1.1rem; margin-bottom: 6px; }
.plan-card-price { font-family: 'Space Mono', monospace; font-size: 1.4rem; color: var(--accent); margin-bottom: 14px; }
.plan-card-price span { font-size: .85rem; color: var(--text3); }
.plan-features { list-style: none; margin-bottom: 20px; }
.plan-features li { font-size: .85rem; color: var(--text2); padding: 4px 0; }
.plan-features li::before { content: '✓ '; color: var(--success); }

/* ── Admin ──────────────────────────────────────────────────────────────── */
.admin-tabs {
  display: flex; gap: 4px; background: var(--bg2);
  border-radius: var(--radius); padding: 4px;
  margin-bottom: 24px; width: fit-content;
  border: 1.5px solid var(--border);
}
.admin-tab {
  padding: 8px 20px; border-radius: 8px;
  font-family: 'Syne', sans-serif; font-weight: 600; font-size: .85rem;
  color: var(--text2); transition: all .2s;
}
.admin-tab.active { background: var(--accent); color: #08080f; }
.admin-pane { display: none; }
.admin-pane.active { display: block; }

.admin-search-bar {
  display: flex; gap: 10px; margin-bottom: 18px;
}
.admin-search-bar input { flex: 1; }

.admin-user-row {
  background: var(--bg2); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px;
  display: flex; align-items: center; gap: 14px; margin-bottom: 8px;
  cursor: pointer; transition: border-color .2s;
}
.admin-user-row:hover { border-color: var(--border2); }
.admin-user-main { flex: 1; min-width: 0; }
.admin-user-email { font-weight: 600; font-size: .9rem; }
.admin-user-meta { font-size: .78rem; color: var(--text2); margin-top: 2px; }
.admin-badge {
  font-size: .7rem; font-weight: 700; padding: 2px 8px;
  border-radius: 20px; font-family: 'Syne', sans-serif;
}
.badge-admin   { background: rgba(232,197,71,.15); color: var(--accent); border: 1px solid rgba(232,197,71,.3); }
.badge-banned  { background: rgba(224,85,85,.15);  color: var(--danger);  border: 1px solid rgba(224,85,85,.3);  }
.badge-paid    { background: rgba(76,175,130,.15);  color: var(--success); border: 1px solid rgba(76,175,130,.3); }
.badge-free    { background: var(--bg3); color: var(--text3); border: 1px solid var(--border); }

.log-output {
  background: var(--bg2); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 16px; font-family: 'Space Mono', monospace;
  font-size: .75rem; color: var(--text2); overflow-x: auto;
  max-height: 480px; overflow-y: auto; margin-top: 12px;
  line-height: 1.7; white-space: pre-wrap; word-break: break-all;
}

.pagination {
  display: flex; gap: 6px; justify-content: center;
  margin-top: 20px; flex-wrap: wrap;
}
.page-btn {
  padding: 6px 12px; border-radius: 6px;
  font-size: .8rem; border: 1.5px solid var(--border);
  color: var(--text2); transition: all .15s;
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); color: #08080f; border-color: var(--accent); }

/* ── Modals ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.75); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--bg2); border: 1.5px solid var(--border2);
  border-radius: 16px; width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
  animation: modalIn .2s ease;
}
.modal.modal-wide { max-width: 680px; }
@keyframes modalIn {
  from { opacity: 0; transform: scale(.96) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 0;
}
.modal-header h2 { font-family: 'Syne', sans-serif; font-size: 1.2rem; font-weight: 800; }
.modal-close {
  color: var(--text3); font-size: 1.1rem;
  padding: 4px 8px; border-radius: 6px;
  transition: color .15s;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px 24px 24px; }

/* Step indicators */
.step-label {
  font-family: 'Syne', sans-serif; font-size: .75rem; font-weight: 700;
  color: var(--text3); text-transform: uppercase; letter-spacing: .1em;
  margin-bottom: 18px;
}
.feed-result {
  margin-top: 12px; padding: 12px 14px; border-radius: var(--radius);
  border: 1.5px solid; font-size: .85rem;
}
.feed-result.ok    { border-color: var(--success); background: rgba(76,175,130,.08); color: var(--success); }
.feed-result.error { border-color: var(--danger);  background: rgba(224,85,85,.08);  color: var(--danger); }

/* Destination buttons */
.dest-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.dest-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 16px 12px; background: var(--bg3); border: 1.5px solid var(--border);
  border-radius: var(--radius); transition: all .15s;
  font-size: .85rem;
}
.dest-btn:hover   { border-color: var(--accent-dim); }
.dest-btn.selected { border-color: var(--accent); background: rgba(232,197,71,.08); }
.dest-icon  { font-size: 1.4rem; }
.dest-label { font-weight: 600; color: var(--text); }
.dest-sub   { font-size: .72rem; color: var(--text3); }

/* Template choice */
.template-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.tpl-btn {
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px; background: var(--bg3); border: 1.5px solid var(--border);
  border-radius: var(--radius); text-align: left; font-size: .85rem;
  transition: all .15s;
}
.tpl-btn:hover   { border-color: var(--accent-dim); }
.tpl-btn.active  { border-color: var(--accent); background: rgba(232,197,71,.08); }
.tpl-sub { font-size: .75rem; color: var(--text3); }

/* ── User detail modal ───────────────────────────────────────────────────── */
.detail-section { margin-bottom: 24px; }
.detail-section h3 {
  font-family: 'Syne', sans-serif; font-size: .8rem; font-weight: 700;
  color: var(--text3); text-transform: uppercase; letter-spacing: .1em;
  margin-bottom: 12px;
}
.detail-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: .88rem;
}
.detail-row:last-child { border-bottom: none; }
.detail-key { color: var(--text2); }
.detail-val { color: var(--text); font-weight: 500; font-family: 'Space Mono', monospace; font-size: .82rem; }
.action-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

.plan-form {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 12px;
}
.plan-form input { font-size: .85rem; }

/* ── Toast ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  background: var(--bg2); border: 1.5px solid var(--border2);
  border-radius: var(--radius); padding: 12px 20px;
  font-size: .88rem; box-shadow: var(--shadow);
  animation: toastIn .25s ease;
  max-width: 320px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--info); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0,0,0,.5);
  }
  .mobile-header { display: flex; }
  .main-content {
    margin-left: 0; padding: 20px 16px;
    margin-top: 56px; max-width: 100%;
  }
  .dest-options, .template-choice { grid-template-columns: 1fr; }
  .plan-form { grid-template-columns: 1fr 1fr; }
  .view-header { flex-wrap: wrap; gap: 12px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .sub-card { flex-wrap: wrap; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .plans-grid { grid-template-columns: 1fr; }
  .admin-tabs { width: 100%; }
  .auth-card { padding: 20px; }
}
