/* ===== پنل وب مدیریت تاب‌یار (Cloudflare Pages) ===== */
:root {
  --accent: #3d7bff; --accent-2: #7c5cff;
  --accent-grad: linear-gradient(135deg, #3d7bff, #7c5cff);
  --danger: #ef4444; --ok: #22c55e;
  --text: #1c2333; --text-2: #5b657a; --text-3: #9aa3b8;
  --line: #e6eaf3; --inner: #f4f6fb;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
  background: linear-gradient(160deg, #e8edf8, #f2f0fa);
  color: var(--text); font-size: 14px; min-height: 100vh;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; color: inherit; }
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: rgba(120,130,160,.35); border-radius: 8px; }

.admin-shell { max-width: 1080px; margin: 0 auto; padding: 26px 20px 60px; }

.topbar {
  display: flex; align-items: center; gap: 12px; margin-bottom: 22px;
  background: #fff; border-radius: 20px; padding: 16px 22px; box-shadow: 0 8px 30px rgba(25,35,70,.08);
  flex-wrap: wrap;
}
.topbar .logo { width: 44px; height: 44px; border-radius: 14px; background: var(--accent-grad); display: grid; place-items: center; color: #fff; box-shadow: 0 8px 20px rgba(90,90,255,.35); flex-shrink: 0; }
.topbar .logo svg { width: 24px; height: 24px; }
.topbar h1 { font-size: 17px; font-weight: 800; }
.topbar .sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.topbar .grow { flex: 1; }
.srv-chip { font-size: 10px; color: var(--text-3); direction: ltr; }

.nav { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.nav button {
  padding: 10px 18px; border-radius: 14px; font-size: 13px; font-weight: 700; color: var(--text-2);
  background: #fff; box-shadow: 0 4px 14px rgba(25,35,70,.06); display: inline-flex; gap: 7px; align-items: center;
  transition: all .15s;
}
.nav button:hover { color: var(--accent); }
.nav button svg { width: 16px; height: 16px; }
.nav button.active { background: var(--accent-grad); color: #fff; }

.panel { background: #fff; border-radius: 20px; padding: 24px; box-shadow: 0 8px 30px rgba(25,35,70,.08); }

/* صفحه ورود */
.gate { max-width: 440px; margin: 7vh auto; background: #fff; border-radius: 26px; padding: 36px; box-shadow: 0 16px 50px rgba(25,35,70,.14); text-align: center; }
.gate .big { width: 66px; height: 66px; border-radius: 20px; background: var(--accent-grad); display: grid; place-items: center; color: #fff; margin: 0 auto 16px; box-shadow: 0 12px 30px rgba(90,90,255,.35); }
.gate .big svg { width: 32px; height: 32px; }
.gate h2 { font-size: 18px; font-weight: 800; margin-bottom: 6px; }
.gate p { font-size: 12px; color: var(--text-3); line-height: 2; margin-bottom: 20px; }
.gate .field { text-align: right; }

.field { margin-bottom: 13px; text-align: right; }
.field label { display: block; font-size: 12.3px; font-weight: 700; margin-bottom: 6px; }
.field .hint { font-size: 10.5px; color: var(--text-3); margin-top: 5px; }
.inp {
  width: 100%; height: 42px; border: 1.5px solid var(--line); border-radius: 13px;
  padding: 0 13px; font-size: 13px; outline: none; background: #fff; transition: border-color .15s, box-shadow .15s;
}
.inp:focus { border-color: var(--accent); box-shadow: 0 0 0 3.5px rgba(61,123,255,.13); }
textarea.inp { height: auto; padding: 10px 13px; line-height: 1.9; resize: vertical; }

.btn { padding: 10px 18px; border-radius: 13px; font-size: 12.8px; font-weight: 700; transition: all .16s; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--accent-grad); color: #fff; box-shadow: 0 6px 18px rgba(80,90,255,.35); }
.btn-primary:hover { transform: translateY(-1px); }
.btn-ghost { background: var(--inner); color: var(--text-2); border: 1px solid var(--line); }
.btn-ghost:hover { color: var(--accent); border-color: var(--accent); }
.btn-danger { background: rgba(239,68,68,.1); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 13px; font-size: 11.8px; border-radius: 11px; }
.grow { flex: 1; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--inner); border-radius: 16px; padding: 16px; text-align: center; }
.stat .v { font-size: 24px; font-weight: 800; }
.stat .k { font-size: 11px; color: var(--text-3); margin-top: 3px; }

.list-row { display: flex; align-items: center; gap: 12px; padding: 13px 14px; background: var(--inner); border-radius: 16px; margin-bottom: 10px; }
.list-row .ic { width: 38px; height: 38px; border-radius: 12px; background: #fff; display: grid; place-items: center; color: var(--accent-2); flex-shrink: 0; box-shadow: 0 3px 10px rgba(25,35,70,.07); }
.list-row .ic svg { width: 18px; height: 18px; }
.list-row .bd { flex: 1; min-width: 0; }
.list-row .t1 { font-size: 13px; font-weight: 800; }
.list-row .t2 { font-size: 10.5px; color: var(--text-3); margin-top: 2px; direction: ltr; text-align: right; }
.list-row .t3 { font-size: 10.5px; color: var(--text-2); margin-top: 3px; }

.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th { text-align: right; color: var(--text-3); font-size: 11px; padding: 8px 10px; border-bottom: 1.5px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid var(--line); }

.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 700; background: var(--inner); border: 1px solid var(--line); padding: 4px 10px; border-radius: 99px; }
.chip.ok { background: rgba(34,197,94,.1); color: var(--ok); border-color: transparent; }
.chip.err { background: rgba(239,68,68,.1); color: var(--danger); border-color: transparent; }
.chip.active { background: var(--accent-grad); color: #fff; border-color: transparent; }

.sec-title { font-size: 14px; font-weight: 800; margin: 6px 0 12px; display: flex; align-items: center; gap: 8px; }
.note { font-size: 11.5px; color: var(--text-2); line-height: 2.1; background: rgba(61,123,255,.06); border: 1px solid rgba(61,123,255,.18); border-radius: 14px; padding: 12px 14px; margin-bottom: 16px; }
.note.warn { background: rgba(245,158,11,.07); border-color: rgba(245,158,11,.25); }
.code-box { direction: ltr; text-align: left; font-family: monospace; background: #232a3d; color: #c9d6f2; padding: 12px 14px; border-radius: 12px; font-size: 12px; overflow-x: auto; white-space: pre; }

.icon-btn { width: 30px; height: 30px; border-radius: 10px; display: inline-grid; place-items: center; color: var(--text-2); flex-shrink: 0; }
.icon-btn:hover { background: rgba(61,123,255,.12); color: var(--accent); }
.icon-btn svg { width: 17px; height: 17px; }

.switch { position: relative; width: 40px; height: 23px; flex-shrink: 0; cursor: pointer; display: inline-block; }
.switch input { display: none; }
.switch i { position: absolute; inset: 0; background: #d6dcea; border-radius: 99px; transition: background .18s; }
.switch i::after { content: ''; position: absolute; top: 2.5px; right: 2.5px; width: 18px; height: 18px; background: #fff; border-radius: 99px; transition: transform .18s; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.switch input:checked + i { background: var(--ok); }
.switch input:checked + i::after { transform: translateX(-17px); }

.model-row { display: flex; gap: 8px; margin-bottom: 8px; }
.model-row .inp { flex: 1; }
.model-row .del { width: 36px; border-radius: 11px; color: var(--text-3); display: grid; place-items: center; }
.model-row .del:hover { color: var(--danger); background: rgba(239,68,68,.1); }
.model-row .del svg { width: 16px; height: 16px; }
.add-model { width: 100%; border: 1.5px dashed #ccd4e6; border-radius: 13px; padding: 9px; font-size: 12px; font-weight: 700; color: var(--text-2); }
.add-model:hover { border-color: var(--accent); color: var(--accent); }

/* بنر تبلیغ پیش‌نمایش */
.ad-banner {
  display: flex; align-items: center; gap: 9px; text-decoration: none;
  background: linear-gradient(90deg, #ff4f8b, #ff2d70); color: #fff;
  border-radius: 99px; padding: 10px 16px; box-shadow: 0 6px 18px rgba(255, 77, 139, .35);
}
.ad-banner .ad-ic { font-size: 15px; }
.ad-banner .ad-tx { flex: 1; font-size: 12.5px; font-weight: 800; }
.ad-banner .ad-go { opacity: .85; display: inline-flex; }
.ad-banner .ad-go svg { width: 13px; height: 13px; }
.preview-wrap { width: 300px; max-width: 100%; }

.invite-code { font-size: 15px; font-weight: 800; letter-spacing: 2.5px; direction: ltr; text-align: right; }

/* توست و مودال */
.toast-wrap { position: fixed; bottom: 26px; right: 50%; transform: translateX(50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #232a3d; color: #fff; font-size: 12.5px; font-weight: 600; padding: 11px 20px; border-radius: 14px; box-shadow: 0 12px 40px rgba(10,20,50,.4); animation: toastIn .25s; }
.toast.ok { background: #0f9d58; } .toast.err { background: #d93025; }
@keyframes toastIn { from { transform: translateY(16px); opacity: 0; } }
.modal-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(15,22,45,.45); display: grid; place-items: center; padding: 20px; animation: fadeIn .18s; }
@keyframes fadeIn { from { opacity: 0; } }
.modal { background: #fbfcff; border-radius: 24px; box-shadow: 0 30px 90px rgba(10,20,50,.4); width: 100%; max-width: 480px; max-height: 88vh; display: flex; flex-direction: column; animation: pop .22s; }
.modal.wide { max-width: 660px; }
@keyframes pop { from { transform: scale(.92) translateY(14px); opacity: 0; } }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 18px 22px 12px; }
.modal-head .mtitle { font-size: 15.5px; font-weight: 800; flex: 1; }
.modal-body { padding: 6px 22px 18px; overflow-y: auto; }
.modal-foot { display: flex; gap: 8px; padding: 12px 22px 20px; }

@media (max-width: 640px) { .panel { padding: 16px; } }

/* ===== لیست تبلیغ‌ها ===== */
.ad-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.ad-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.ad-idx { font-size: 12.5px; font-weight: 800; color: var(--accent); }
.icon-btn { width: 30px; height: 30px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; color: var(--text-2); transition: all .12s; }
.icon-btn:hover { background: rgba(239, 68, 68, .1); color: #dc2626; }
.icon-btn svg { width: 15px; height: 15px; }
