:root {
  --bg: #0b0c12;
  --bg2: #12141e;
  --card: rgba(22, 25, 38, 0.88);
  --border: rgba(255, 255, 255, 0.08);
  --text: #eef0f7;
  --muted: #9aa3b8;
  --accent: #7c6cff;
  --accent2: #4fd1c5;
  --danger: #ff6b8a;
  --ok: #3dd68c;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --radius: 18px;
  font-family: "Segoe UI", ui-sans-serif, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--text);
  background: radial-gradient(1200px 600px at 20% -10%, rgba(124, 108, 255, 0.22), transparent 55%),
              radial-gradient(900px 500px at 90% 10%, rgba(79, 209, 197, 0.12), transparent 50%),
              var(--bg);
}

.bg-glow {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.35));
  z-index: 0;
}

.wrap {
  position: relative;
  z-index: 1;
  width: min(760px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 3.5rem 0 3rem;
}

.hero { text-align: center; margin-bottom: 1.75rem; }
.badge {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(124, 108, 255, 0.15);
  border: 1px solid rgba(124, 108, 255, 0.35);
  color: #cfc8ff;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  margin-bottom: 0.9rem;
}
h1 {
  margin: 0 0 0.6rem;
  font-size: clamp(2rem, 5vw, 2.8rem);
  letter-spacing: -0.03em;
}
.subtitle {
  margin: 0 auto;
  max-width: 36rem;
  color: var(--muted);
  line-height: 1.55;
  font-size: 1.02rem;
}
.subtitle strong { color: var(--text); font-weight: 600; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  padding: 1.35rem 1.35rem 1.2rem;
}

.label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.row {
  display: flex;
  gap: 0.65rem;
}
.row input {
  flex: 1;
  min-width: 0;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(8, 10, 16, 0.7);
  color: var(--text);
  padding: 0.9rem 1rem;
  font-size: 1rem;
  outline: none;
}
.row input:focus {
  border-color: rgba(124, 108, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(124, 108, 255, 0.18);
}
.row button, .ghost, .linkbtn {
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
}
.row button {
  background: linear-gradient(135deg, #7c6cff, #5b8cff);
  color: white;
  padding: 0 1.25rem;
  min-width: 7rem;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.row button:hover { filter: brightness(1.08); }
.row button:active { transform: translateY(1px); }
.row button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1.25rem;
  align-items: center;
  margin-top: 0.9rem;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.88rem;
}
.api-key-row input {
  width: 9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(8, 10, 16, 0.7);
  color: var(--text);
  padding: 0.35rem 0.55rem;
}

.status {
  margin-top: 1rem;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  color: var(--muted);
}
.status.loading { color: #cfc8ff; border-color: rgba(124,108,255,0.35); }
.status.ok { color: var(--ok); border-color: rgba(61,214,140,0.35); }
.status.err { color: var(--danger); border-color: rgba(255,107,138,0.35); }

.progress-panel {
  margin-top: 0.85rem;
  padding: 0.85rem 0.95rem;
  border-radius: 12px;
  border: 1px solid rgba(124, 108, 255, 0.28);
  background: rgba(124, 108, 255, 0.06);
}
.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
  font-size: 0.88rem;
  color: #d7d2ff;
  margin-bottom: 0.55rem;
}
#progressElapsed {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.progress-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6d5efc, #3dd68c);
  transition: width 0.35s ease;
  min-width: 2%;
}
.progress-bar.indeterminate {
  width: 35% !important;
  animation: progress-slide 1.4s ease-in-out infinite;
}
@keyframes progress-slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}
.progress-steps {
  margin: 0.75rem 0 0;
  padding: 0 0 0 1.1rem;
  max-height: 11rem;
  overflow-y: auto;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}
.progress-steps li {
  margin-bottom: 0.28rem;
}
.progress-steps li.current {
  color: #e8e4ff;
  font-weight: 600;
}
.progress-steps li.done {
  color: #9ef0c4;
}

.result {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 12px;
  background: rgba(61, 214, 140, 0.06);
  border: 1px solid rgba(61, 214, 140, 0.25);
}
.result-head { display: flex; gap: 0.45rem; margin-bottom: 0.65rem; }
.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: rgba(124, 108, 255, 0.2);
  color: #d7d2ff;
}
.pill.muted {
  background: rgba(255,255,255,0.06);
  color: var(--muted);
}
.pill.ok {
  background: rgba(61, 214, 140, 0.2);
  color: #9ef0c4;
}
.pill.bad {
  background: rgba(255, 107, 129, 0.2);
  color: #ffb3bf;
}
.dest {
  display: block;
  word-break: break-all;
  color: var(--accent2);
  text-decoration: none;
  font-weight: 600;
  line-height: 1.45;
}
.dest:hover { text-decoration: underline; }
.actions { display: flex; gap: 0.5rem; margin-top: 0.85rem; }
.ghost, .linkbtn {
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border: 1px solid var(--border) !important;
  padding: 0.45rem 0.85rem;
  text-decoration: none;
}
.ghost:hover, .linkbtn:hover { background: rgba(255,255,255,0.09); }
.raw {
  margin: 0.85rem 0 0;
  padding: 0.75rem;
  border-radius: 10px;
  background: #0a0b10;
  color: #b7c0d4;
  font-size: 0.78rem;
  overflow: auto;
  max-height: 180px;
}

.error {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: rgba(255, 107, 138, 0.08);
  border: 1px solid rgba(255, 107, 138, 0.28);
  color: #ffc0cd;
  white-space: pre-wrap;
  word-break: break-word;
}

.hidden { display: none !important; }

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  margin-top: 1.35rem;
}
.grid article {
  background: rgba(18, 20, 30, 0.7);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
}
.grid h3 { margin: 0 0 0.4rem; font-size: 0.98rem; }
.grid p { margin: 0; color: var(--muted); font-size: 0.88rem; line-height: 1.45; }
.grid code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  color: #d7d2ff;
}

footer {
  margin-top: 1.75rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}
footer a { color: #cfc8ff; text-decoration: none; }
footer a:hover { text-decoration: underline; }
.sep { margin: 0 0.35rem; opacity: 0.5; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.nav {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  font-size: 0.9rem;
}
.nav a { color: #cfc8ff; text-decoration: none; }
.nav a:hover { text-decoration: underline; }
.linkish {
  background: none;
  border: 0;
  color: #cfc8ff;
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.linkish:hover { text-decoration: underline; }
.userchip {
  margin: 0.75rem auto 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.wrap.narrow { width: min(440px, calc(100% - 2rem)); }
.wrap.wide { width: min(980px, calc(100% - 2rem)); }
.card input[type="text"],
.card input[type="password"],
.card input[type="url"],
.card select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(8, 10, 16, 0.7);
  color: var(--text);
  padding: 0.85rem 1rem;
  font-size: 1rem;
  outline: none;
}
.card input:focus, .card select:focus {
  border-color: rgba(124, 108, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(124, 108, 255, 0.18);
}
.card > button,
.admin-form button {
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  background: linear-gradient(135deg, #7c6cff, #5b8cff);
  color: white;
  padding: 0.75rem 1.1rem;
}
.section-title {
  margin: 0 0 0.85rem;
  font-size: 1.1rem;
}
.kv {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem 1rem;
}
.kv div {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  font-size: 0.9rem;
}
.kv span { color: var(--muted); }
.admin-form {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 0.7fr auto;
  gap: 0.55rem;
}
.table-wrap { overflow: auto; margin-top: 0.85rem; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.table th, .table td {
  text-align: left;
  padding: 0.55rem 0.45rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.table th { color: var(--muted); font-weight: 600; }
.table .clip {
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.ghost.mini { padding: 0.3rem 0.55rem; font-size: 0.8rem; }
.ghost.danger, .danger { color: #ffb3c2 !important; border-color: rgba(255,107,138,0.35) !important; }

@media (max-width: 720px) {
  .row { flex-direction: column; }
  .row button { width: 100%; min-height: 2.8rem; }
  .grid { grid-template-columns: 1fr; }
  .wrap { padding-top: 2rem; }
  .admin-form { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
}
