:root {
  --bg: #0b0e14;
  --bg-soft: #11151f;
  --card: #151a26;
  --card-2: #1b2230;
  --border: #232c3d;
  --text: #e6ebf3;
  --muted: #8b96aa;
  --accent: #ff3b30;
  --accent-2: #ff5c52;
  --green: #2ecc71;
  --blue: #3b82f6;
  --amber: #f5a623;
  --red: #ff4d4f;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(255, 59, 48, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(59, 130, 246, 0.08), transparent 55%),
    var(--bg);
  min-height: 100vh;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
}
.brand-mark svg { display: block; filter: drop-shadow(0 4px 12px rgba(255, 0, 0, 0.4)); }
.brand-mark-lg { width: 52px; height: 52px; }
.brand-name { font-weight: 700; letter-spacing: 0.2px; font-size: 18px; }
.brand-name-lg { font-size: 26px; }

/* role pill */
.role-pill {
  display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; padding: 2px 7px; border-radius: 999px; vertical-align: middle;
  color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.role-pill.subtle { color: var(--muted); background: rgba(139, 150, 170, 0.16); }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 14, 20, 0.7);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.who { color: var(--muted); font-size: 13px; }

/* ---------- Layout ---------- */
.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 26px 22px 80px;
}

.card {
  background: linear-gradient(180deg, var(--card), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-title { margin: 0 0 16px; font-size: 15px; font-weight: 600; color: var(--text); }

/* ---------- Submit card ---------- */
.submit-card { margin-bottom: 22px; }
.submit-grid {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 14px 16px;
  align-items: end;
}
.url-field { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 500; }

input[type="text"], input[type="url"], input[type="password"], select, input[type="file"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.18);
}
input[type="file"] { padding: 8px; color: var(--muted); }
select { appearance: none; cursor: pointer; }

.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle input { display: none; }
.toggle-track {
  width: 42px; height: 24px; border-radius: 999px; background: var(--card-2);
  border: 1px solid var(--border); position: relative; transition: background .15s;
  flex: none;
}
.toggle-thumb {
  position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s;
}
.toggle input:checked + .toggle-track { background: rgba(255, 59, 48, 0.25); border-color: var(--accent); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(18px); background: var(--accent); }
.toggle-label { font-size: 13px; color: var(--text); }

.submit-btn { align-self: end; }
.form-msg { margin: 12px 0 0; font-size: 13px; }
.form-msg.ok { color: var(--green); }
.form-msg.err { color: var(--red); }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-size: 14px; font-weight: 600;
  cursor: pointer; color: var(--text);
  background: var(--card-2);
  transition: transform .05s, background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: #222b3c; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border-color: transparent;
  box-shadow: 0 6px 18px rgba(255, 59, 48, 0.3);
}
.btn-primary:hover { filter: brightness(1.05); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--card-2); }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-danger { color: var(--red); border-color: rgba(255, 77, 79, 0.4); background: transparent; }
.btn-danger:hover { background: rgba(255, 77, 79, 0.12); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; margin: 0 0 16px; border-bottom: 1px solid var(--border); }
.tab {
  background: none; border: none; color: var(--muted);
  padding: 10px 14px; font-size: 14px; font-weight: 600; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- Jobs list ---------- */
.jobs-list { display: flex; flex-direction: column; gap: 12px; }
.job {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px;
}
.job-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.job-title { font-weight: 600; font-size: 14px; word-break: break-word; }
.job-url { color: var(--muted); font-size: 12px; word-break: break-all; margin-top: 2px; }
.job-meta { color: var(--muted); font-size: 12px; margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px 12px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  padding: 4px 9px; border-radius: 999px; white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-queued { color: var(--muted); background: rgba(139, 150, 170, 0.14); }
.badge-downloading { color: var(--blue); background: rgba(59, 130, 246, 0.14); }
.badge-done { color: var(--green); background: rgba(46, 204, 113, 0.14); }
.badge-failed { color: var(--red); background: rgba(255, 77, 79, 0.14); }
.badge-canceled { color: var(--amber); background: rgba(245, 166, 35, 0.14); }

.progress-wrap { margin-top: 12px; }
.progress-bar {
  height: 8px; border-radius: 999px; background: var(--bg);
  overflow: hidden; border: 1px solid var(--border);
}
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .4s ease;
}
.progress-meta {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 12px; color: var(--muted); margin-top: 7px;
}
.progress-meta .pct { color: var(--text); font-weight: 600; }

.job-error {
  margin-top: 10px; font-size: 12px; color: var(--red);
  background: rgba(255, 77, 79, 0.08); border: 1px solid rgba(255, 77, 79, 0.25);
  border-radius: 8px; padding: 8px 10px; white-space: pre-wrap; word-break: break-word;
}

/* ---------- Files / completed ---------- */
.files { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.file-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 12px;
}
.file-info { min-width: 0; }
.file-name { font-size: 13px; word-break: break-all; }
.file-size { font-size: 11px; color: var(--muted); margin-top: 2px; }
.file-actions { display: flex; gap: 8px; flex: none; }

/* ---------- Cookies ---------- */
.cookie-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 14px; align-items: end; }
.cookies-grid { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.cookie-card {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 15px;
}
.cookie-name { font-weight: 600; font-size: 14px; }
.cookie-date { color: var(--muted); font-size: 12px; }
.cookie-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.cookie-default {
  font-weight: 600; font-size: 11px; color: #facc15;
  margin-left: 6px; vertical-align: 1px; white-space: nowrap;
}

.empty { color: var(--muted); text-align: center; padding: 30px 0; font-size: 14px; }
.hidden, [hidden] { display: none !important; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--card-2); border: 1px solid var(--border); color: var(--text);
  padding: 11px 18px; border-radius: 999px; font-size: 13px; box-shadow: var(--shadow);
  z-index: 50; animation: toastIn .2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- Login ---------- */
.login-body {
  display: grid; place-items: center; min-height: 100vh; position: relative;
  overflow: hidden;
  background:
    radial-gradient(900px 600px at 70% -15%, rgba(255, 0, 0, 0.22), transparent 60%),
    radial-gradient(800px 600px at -10% 110%, rgba(226, 18, 43, 0.16), transparent 55%),
    radial-gradient(700px 500px at 110% 80%, rgba(59, 130, 246, 0.10), transparent 55%),
    #07090f;
}
/* soft blurred brand glow behind the card */
.login-body::before {
  content: ""; position: absolute; width: 460px; height: 460px; border-radius: 50%;
  top: 50%; left: 50%; transform: translate(-50%, -55%);
  background: radial-gradient(circle, rgba(255, 0, 0, 0.28), transparent 65%);
  filter: blur(60px); z-index: 0; pointer-events: none;
}
.login-wrap {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
  width: 100%; padding: 24px;
}
.login-card {
  width: 100%; max-width: 400px;
  background: linear-gradient(180deg, rgba(24, 29, 41, 0.92), rgba(15, 19, 28, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 22px; padding: 38px 34px 30px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(14px);
  animation: cardIn .35s cubic-bezier(.2, .8, .2, 1);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.login-brand { justify-content: center; gap: 12px; margin-bottom: 6px; }
.login-sub { text-align: center; color: var(--muted); font-size: 13.5px; margin: 0 0 26px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-form .field > span { font-size: 12px; letter-spacing: .2px; }
.login-form input {
  padding: 13px 14px; font-size: 15px;
  background: rgba(10, 13, 20, 0.85);
  border-color: rgba(255, 255, 255, 0.10);
}
.login-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 0, 0, 0.20);
}
.btn-lg { padding: 14px 16px; font-size: 15px; margin-top: 4px; }
.login-divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  margin: 22px 0 12px;
}
.login-divider::before, .login-divider::after {
  content: ""; flex: 1; height: 1px; background: rgba(255, 255, 255, 0.09);
}
.login-note { text-align: center; color: var(--muted); font-size: 13px; margin: 0; }
.login-note strong { color: var(--text); }
.login-foot { color: rgba(139, 150, 170, 0.65); font-size: 12px; }
.error-msg {
  color: #ff8b8b; font-size: 13px; margin: -2px 0 0; text-align: center;
  background: rgba(255, 0, 0, 0.10); border: 1px solid rgba(255, 0, 0, 0.28);
  border-radius: 9px; padding: 9px 12px;
}
.shake { animation: shake .4s cubic-bezier(.36, .07, .19, .97); }
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-5px); }
  40%, 60% { transform: translateX(5px); }
}

/* ---------- Users (admin) ---------- */
.user-form { display: grid; grid-template-columns: 1fr 1fr 140px auto; gap: 14px; align-items: end; }
.users-table-card { padding: 0; margin-top: 18px; overflow: hidden; }
.users-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.users-table th {
  text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); padding: 13px 18px; border-bottom: 1px solid var(--border);
}
.users-table td { padding: 13px 18px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.users-table tr:last-child td { border-bottom: none; }
.users-table .u-name { font-weight: 600; }
.users-table .u-date { color: var(--muted); font-size: 13px; }
.ta-r { text-align: right; white-space: nowrap; }
.ta-r .btn { margin-left: 6px; }

/* ---------- Responsive ---------- */
@media (max-width: 680px) {
  .submit-grid { grid-template-columns: 1fr; }
  .cookie-form { grid-template-columns: 1fr; }
  .user-form { grid-template-columns: 1fr; }
  .container { padding: 20px 14px 70px; }
  .topbar { padding: 12px 14px; }
  .users-table th:nth-child(3), .users-table td:nth-child(3) { display: none; }
  .ta-r .btn { margin: 4px 0 0 6px; }
}
