:root {
  --bg: #0b0f1a;
  --card: #141a2b;
  --card-2: #1b2236;
  --border: #263049;
  --text: #e8ecf5;
  --muted: #93a0bd;
  --accent: #6d5efc;
  --accent-2: #22c1c3;
  --green: #3fe0a0;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  position: relative;
}
.bg-glow {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(50vw 40vh at 12% -5%, rgba(109,94,252,.25), transparent 60%),
    radial-gradient(45vw 40vh at 100% 0%, rgba(34,193,195,.14), transparent 55%);
}
.brand { display: flex; align-items: center; gap: 9px; font-size: 19px; font-weight: 700; }
.brand .mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-size: 15px;
}
.btn {
  border: none; border-radius: 11px; cursor: pointer;
  background: linear-gradient(90deg, var(--accent), #8a7bff); color: #fff;
  font-weight: 700; font-size: 15px; padding: 13px 22px; font-family: inherit;
  transition: transform .15s;
}
.btn:hover { transform: translateY(-1px); }
.link { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; }
.link:hover { color: var(--text); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.err { color: #ff97ab; font-size: 13px; margin-top: 4px; }

/* Login */
.login-wrap {
  position: relative; z-index: 1; min-height: 100vh;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 18px;
  padding: 32px; width: 100%; max-width: 360px; text-align: center;
  box-shadow: 0 30px 70px rgba(0,0,0,.5);
}
.login-sub { color: var(--muted); font-size: 13.5px; margin: 12px 0 20px; }
#user,
#pw {
  width: 100%; padding: 13px 14px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--card-2); color: var(--text); font-size: 15px; outline: none; margin-bottom: 12px;
}
#user::placeholder,
#pw::placeholder { color: #5f6b85; }
#user:focus,
#pw:focus { border-color: var(--accent); }
.login-card .btn { width: 100%; }

/* Password field with a show/hide toggle */
.pw-field { position: relative; }
.pw-field #pw { padding-right: 46px; } /* room for the eye button */
.pw-toggle {
  position: absolute; top: 0; right: 0;
  height: calc(100% - 12px); /* match input height, minus its bottom margin */
  width: 44px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; cursor: pointer;
  font-size: 17px; line-height: 1; opacity: 0.75;
  border-radius: 11px;
  transition: opacity 0.15s ease;
}
.pw-toggle:hover { opacity: 1; }
.pw-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pw-toggle.on { opacity: 1; }

/* Dashboard */
.dash { position: relative; z-index: 1; max-width: 1000px; margin: 0 auto; padding: 24px 20px 60px; }
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 26px; }
.top-right { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.livedot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse 2s infinite; }
@keyframes pulse { 0%{opacity:1} 50%{opacity:.35} 100%{opacity:1} }

.stats { display: flex; flex-direction: column; gap: 16px; margin-bottom: 24px; }
.stat-row {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 18px 22px; box-shadow: 0 16px 40px rgba(0,0,0,.3);
  display: flex; align-items: center; gap: 18px;
}
.row-label { font-size: 16px; font-weight: 700; min-width: 130px; }
.cells { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; flex: 1; }
.cell {
  background: var(--card-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; text-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
}
.cell.live { border-color: rgba(63,224,160,.35); }
.cn { font-size: 30px; font-weight: 800; letter-spacing: -0.5px; line-height: 1; }
.cell.live .cn { color: var(--green); }
.cl { font-size: 12px; color: var(--muted); }

/* Ads card */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 24px; margin-bottom: 18px; box-shadow: 0 16px 40px rgba(0,0,0,.22); }
.card:last-child { margin-bottom: 0; }
.ads-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.ads-head h2 { font-size: 19px; }
.switch-lbl { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 7px; cursor: pointer; }
.switch-lbl input { width: 16px; height: 16px; accent-color: var(--accent); }
.ad-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 18px 0; }
.ad-field { display: flex; flex-direction: column; }
.ad-field label { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.ad-field textarea {
  width: 100%;
  min-height: 78px; resize: vertical; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card-2); color: var(--text);
  font-family: "Consolas", monospace; font-size: 12px; outline: none;
}
.ad-field textarea:focus { border-color: var(--accent); }
/* text/number inputs inside ad/download fields — always full width, consistent look */
.ad-field input[type="text"],
.ad-field input[type="number"] {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card-2); color: var(--text);
  font-size: 13px; outline: none;
}
.ad-field input[type="text"]:focus,
.ad-field input[type="number"]:focus { border-color: var(--accent); }
.ad-field input::placeholder { color: #5f6b85; }
.save-msg { margin-left: 12px; color: var(--green); font-size: 13px; }

/* ---- buttons: ghost + danger variants ---- */
.btn.ghost {
  background: var(--card-2); color: var(--text); border: 1px solid var(--border);
}
.btn.ghost:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.link.danger { color: #ff6b6b; }
.link.danger:hover { color: #ff8f8f; }

/* ---- file / image upload blocks ---- */
.upload-field { background: rgba(255,255,255,.02); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.upload-field > label { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 10px; display: block; }
.up-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.up-status { font-size: 12px; color: var(--muted); margin: 8px 0 4px; word-break: break-all; }
.up-status.ok { color: var(--green); }
.up-progress { height: 8px; background: var(--card-2); border-radius: 6px; overflow: hidden; margin: 6px 0; }
.up-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .15s; }
.link-alt {
  display: block; width: 100%; margin-top: 10px; padding: 10px 12px; border-radius: 9px;
  border: 1px dashed var(--border); background: rgba(255,255,255,.02); color: var(--text);
  font-size: 12.5px; outline: none;
}
.link-alt::placeholder { color: #5f6b85; }
.link-alt:focus { border-color: var(--accent); border-style: solid; background: var(--card-2); }

/* image-ad sub-block inside an ad field */
.img-ad { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.img-ad-head {
  font-size: 13px; font-weight: 600; margin-bottom: 4px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.size-tag {
  font-size: 11px; font-weight: 700; color: var(--accent-2); white-space: nowrap;
  background: rgba(34,193,195,.12); border: 1px solid rgba(34,193,195,.3);
  padding: 3px 9px; border-radius: 20px;
}
.img-preview {
  display: block; max-width: 100%; max-height: 180px; margin: 10px 0;
  border-radius: 8px; border: 1px solid var(--border); background: var(--card-2);
}

@media (max-width: 720px) {
  .stat-row { flex-direction: column; align-items: stretch; }
  .row-label { min-width: 0; }
  .ad-grid { grid-template-columns: 1fr; }
}
