:root {
  --bg: #08080f;
  --bg-2: #0d0e18;
  --card: rgba(20, 22, 38, 0.72);
  --card-border: rgba(255, 255, 255, 0.07);
  --text: #eef0f7;
  --text-2: #b7bccc;
  --text-3: #7e8496;
  --c1: #7c5cff;
  --c2: #22d3ee;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --radius: 16px;
  --font: ui-rounded, -apple-system, "SF Pro Rounded", "Segoe UI", system-ui, "Sora", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- aurora background ---- */
.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% -10%, #14142a 0%, var(--bg) 60%);
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.35;
  animation: drift 22s ease-in-out infinite alternate;
}
.b1 { width: 520px; height: 520px; left: -120px; top: -120px; background: var(--c1); }
.b2 { width: 460px; height: 460px; right: -100px; top: 20%; background: var(--c2); animation-delay: -7s; }
.b3 { width: 400px; height: 400px; left: 30%; bottom: -160px; background: #b452ff; animation-delay: -14s; }
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(40px, 30px) scale(1.12); }
}
@media (prefers-reduced-motion: reduce) {
  .blob { animation: none; }
}

.hidden { display: none !important; }

/* ---- layout ---- */
.view { min-height: 100vh; }

#auth-view {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

#app-view {
  display: flex;
  flex-direction: column;
}

/* ---- card ---- */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

/* ---- brand ---- */
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  font-size: 22px; color: #fff;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--c1), var(--c2));
  box-shadow: 0 8px 24px rgba(124, 92, 255, 0.4);
}
.brand h1 { margin: 0; font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; }
.brand-sub { margin: 3px 0 0; color: var(--text-3); font-size: 0.85rem; }
.brand-sm strong { font-size: 1rem; }

/* ---- auth ---- */
.auth-card { width: 100%; max-width: 400px; padding: 30px 28px; }

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 22px 0 18px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
}
.tab {
  border: 0;
  background: transparent;
  color: var(--text-3);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 9px;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.2s;
}
.tab.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--c1), var(--c2));
}

.form { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.82rem; color: var(--text-2); font-weight: 500; }
.field .opt { color: var(--text-3); font-weight: 400; }
.field input, .field textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  border-radius: 11px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 11px 13px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}
.field textarea { resize: vertical; min-height: 110px; }
.field input:focus, .field textarea:focus {
  border-color: var(--c1);
  background: rgba(255, 255, 255, 0.06);
}

.btn {
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 11px;
  border: 1px solid transparent;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 0.12s, opacity 0.2s, box-shadow 0.2s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--c1), var(--c2));
  box-shadow: 0 8px 24px rgba(124, 92, 255, 0.35);
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-2);
  border-color: var(--card-border);
}
.btn-ghost:hover { color: var(--text); }

.error { color: var(--err); font-size: 0.85rem; margin: 0; }
.fine { color: var(--text-3); font-size: 0.75rem; text-align: center; margin: 18px 0 0; }

/* ---- topbar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--card-border);
  background: rgba(8, 8, 15, 0.6);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user { color: var(--text-2); font-weight: 500; }
.quota {
  font-size: 0.78rem;
  color: var(--text-3);
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
}

/* ---- layout ---- */
.layout {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 32px 28px 80px;
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 28px;
  align-items: start;
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}

.composer { padding: 24px; }
.composer h2, .tasks h2 { margin: 0 0 4px; font-size: 1.2rem; letter-spacing: -0.01em; }
.muted { color: var(--text-3); font-size: 0.9rem; margin: 0 0 16px; }

/* ---- tasks ---- */
.tasks-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.tasks-head .muted { margin: 0; }
.task-list { display: flex; flex-direction: column; gap: 12px; }

.task {
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.12s;
}
.task:hover { border-color: rgba(124, 92, 255, 0.4); transform: translateY(-1px); }
.task-head { display: flex; align-items: center; gap: 10px; }
.task-title { font-weight: 600; font-size: 0.98rem; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-preview { color: var(--text-3); font-size: 0.85rem; margin: 6px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-time { color: var(--text-3); font-size: 0.72rem; margin-top: 10px; }

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-pending { background: rgba(251, 191, 36, 0.14); color: var(--warn); }
.badge-running { background: rgba(34, 211, 238, 0.14); color: var(--c2); }
.badge-done { background: rgba(52, 211, 153, 0.14); color: var(--ok); }
.badge-failed { background: rgba(248, 113, 113, 0.14); color: var(--err); }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 12px; height: 12px;
  border: 2px solid rgba(34, 211, 238, 0.25);
  border-top-color: var(--c2);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex: none;
}

.empty {
  text-align: center;
  color: var(--text-3);
  padding: 40px 20px;
  border: 1px dashed var(--card-border);
  border-radius: var(--radius);
}

/* ---- modal ---- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
}
.modal-card {
  width: 100%;
  max-width: 640px;
  max-height: 86vh;
  overflow-y: auto;
  padding: 26px 28px;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 12px; right: 16px;
  background: none; border: 0;
  color: var(--text-3);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { color: var(--text); }
#modal-title { margin: 0 0 10px; font-size: 1.3rem; padding-right: 30px; }
#modal-prompt { margin: 12px 0; }
.mono { font-family: var(--mono); font-size: 0.82rem; }
.result { color: var(--text-2); line-height: 1.65; font-size: 0.95rem; }
.result h1, .result h2, .result h3 { color: var(--text); line-height: 1.3; }
.result h1 { font-size: 1.25rem; }
.result h2 { font-size: 1.1rem; }
.result h3 { font-size: 1rem; }
.result code {
  font-family: var(--mono);
  font-size: 0.82em;
  background: rgba(255, 255, 255, 0.07);
  padding: 2px 6px;
  border-radius: 6px;
}
.result pre {
  font-family: var(--mono);
  font-size: 0.82rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 14px;
  overflow-x: auto;
  white-space: pre-wrap;
}
.result ul, .result ol { padding-left: 22px; }
.result a { color: var(--c2); }
.modal-actions { margin-top: 20px; display: flex; justify-content: flex-end; }

/* ---- verify banner ---- */
.banner {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border: 1px solid rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.08);
  border-radius: 12px;
  color: var(--text-2);
  font-size: 0.9rem;
  flex-wrap: wrap;
}
.banner-actions { display: flex; gap: 8px; }

/* ---- toast ---- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 20px);
  background: #16182a;
  border: 1px solid var(--card-border);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 0.9rem;
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 100;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-ok { border-color: rgba(52, 211, 153, 0.4); }
.toast-error { border-color: rgba(248, 113, 113, 0.4); }

/* ---- small + danger buttons ---- */
.btn-sm { padding: 7px 12px; font-size: 0.82rem; border-radius: 9px; }
.btn-danger {
  color: #fff;
  background: linear-gradient(135deg, #f87171, #dc2626);
  box-shadow: 0 8px 20px rgba(248, 113, 113, 0.3);
}

/* ---- settings ---- */
.settings-section { padding: 18px 0; border-top: 1px solid var(--card-border); }
.settings-section:first-of-type { border-top: 0; padding-top: 8px; }
.settings-section h4 { margin: 0 0 10px; font-size: 1rem; }
.settings-section .field { margin: 10px 0; }
.settings-section .muted { margin: 0 0 10px; }
.is-ok { color: var(--ok) !important; }
.qr {
  display: block;
  width: 180px; height: 180px;
  background: #fff;
  border-radius: 12px;
  padding: 8px;
  margin: 10px 0;
}
.row { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* ---- admin ---- */
.admin-card { max-width: 860px; }
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}
.stat-num { font-size: 1.6rem; font-weight: 700; background: linear-gradient(135deg, var(--c1), var(--c2)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.stat-label { color: var(--text-3); font-size: 0.75rem; margin-top: 4px; text-transform: uppercase; letter-spacing: 0.05em; }

.admin-table {
  border: 1px solid var(--card-border);
  border-radius: 12px;
  overflow: hidden;
  font-size: 0.85rem;
}
.arow {
  display: grid;
  grid-template-columns: 1.6fr 0.9fr 0.7fr 0.6fr 0.6fr 1.6fr;
  gap: 10px;
  align-items: center;
  padding: 11px 14px;
  border-bottom: 1px solid var(--card-border);
}
.arow:last-child { border-bottom: 0; }
.ahead { background: rgba(255,255,255,0.04); color: var(--text-3); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.acell-main strong { font-size: 0.88rem; }
.acell-main .mono { font-size: 0.72rem; color: var(--text-3); }
.acell-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.mini {
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-2);
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--card-border);
  border-radius: 7px;
  padding: 4px 8px;
  cursor: pointer;
}
.mini:hover { color: var(--text); }
.mini-danger { color: var(--err); border-color: rgba(248,113,113,0.3); }

/* ---- tasks head right ---- */
.tasks-head-right { display: flex; align-items: center; gap: 12px; }
