:root {
  --bg: #0b0e13; --bg2: #0f141b; --panel: #151b24; --border: #242c38; --border2: #303a48;
  --text: #e8eef6; --muted: #8d98a8; --accent: #4f8ff7; --accent2: #2f6fd6;
  --green: #3fb950; --red: #f85149; --amber: #d29922; --purple: #a371f7;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, sans-serif;
  background: radial-gradient(1200px 600px at 20% -10%, #14202e 0%, var(--bg) 55%);
  color: var(--text); min-height: 100vh; font-size: 15px; line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 0 26px; height: 58px;
  background: rgba(15, 20, 27, .85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.brand .logo {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--purple)); font-size: 14px;
}
.topnav { display: flex; gap: 2px; flex: 1; }
.topnav a {
  color: var(--muted); padding: 8px 14px; border-radius: 8px; font-size: 14px; font-weight: 500;
}
.topnav a:hover { color: var(--text); background: var(--panel); text-decoration: none; }
.topnav a.on { color: var(--text); background: var(--panel); box-shadow: inset 0 -2px 0 var(--accent); }
.who { color: var(--muted); font-size: 12.5px; text-align: right; line-height: 1.35; }
.who .name { color: var(--text); font-weight: 600; }

main { max-width: 1120px; margin: 0 auto; padding: 28px 26px 60px; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.page-head h1 { font-size: 22px; margin: 0; font-weight: 700; }
.page-head .sub { color: var(--muted); font-size: 13.5px; }
.page-head .spacer { flex: 1; }

/* ---------- cards / forms ---------- */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 20px 22px; margin-bottom: 18px;
}
.card h2 { font-size: 15.5px; margin: 0 0 12px; font-weight: 650; }
.card h2 .count { color: var(--muted); font-weight: 400; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 760px) { .grid.two { grid-template-columns: 1fr; } }

label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 5px; font-weight: 550; letter-spacing: .3px; text-transform: uppercase; }
input, textarea, select {
  width: 100%; background: var(--bg2); color: var(--text);
  border: 1px solid var(--border2); border-radius: 9px; padding: 10px 12px; font-size: 14px;
  transition: border-color .15s, box-shadow .15s; font-family: inherit;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 143, 247, .18);
}
textarea { min-height: 96px; resize: vertical; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.flex1 { flex: 1; min-width: 0; }

.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  background: var(--accent); color: #fff; border: none; border-radius: 9px;
  padding: 10px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .15s, transform .05s; white-space: nowrap;
}
.btn:hover { background: var(--accent2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.secondary { background: transparent; border: 1px solid var(--border2); color: var(--text); }
.btn.secondary:hover { background: var(--bg2); border-color: var(--muted); }
.btn.danger { background: transparent; border: 1px solid rgba(248,81,73,.5); color: var(--red); }
.btn.danger:hover { background: rgba(248,81,73,.12); }
.btn.small { padding: 6px 11px; font-size: 12.5px; border-radius: 7px; }
.btn.success { background: var(--green); }
.btn.success:hover { filter: brightness(1.08); }

/* ---------- badges / pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.running { background: rgba(79,143,247,.15); color: var(--accent); }
.badge.running::before { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.badge.completed { background: rgba(63,185,80,.14); color: var(--green); }
.badge.failed, .badge.cancelled, .badge.disabled { background: rgba(248,81,73,.13); color: var(--red); }
.badge.queued, .badge.pending { background: rgba(210,153,34,.14); color: var(--amber); }
.badge.approved, .badge.answered, .badge.admin, .badge.user { background: rgba(163,113,247,.14); color: var(--purple); }

.pill {
  background: var(--bg2); border: 1px solid var(--border2); border-radius: 8px;
  padding: 5px 10px; display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px;
}

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(79,143,247,.05); }

/* ---------- messages ---------- */
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error { color: var(--red); font-size: 13px; margin: 8px 0; }
.ok { color: var(--green); font-size: 13px; margin: 8px 0; }
.empty { text-align: center; color: var(--muted); padding: 34px 10px; font-size: 14px; }
.empty .big { font-size: 34px; margin-bottom: 8px; opacity: .6; }

/* ---------- toast ---------- */
#toasts { position: fixed; bottom: 22px; right: 22px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--panel); border: 1px solid var(--border2); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 12px 16px; font-size: 13.5px; min-width: 220px; max-width: 360px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: slideIn .18s ease;
}
.toast.ok { border-left-color: var(--green); margin: 0; color: var(--text); }
.toast.err { border-left-color: var(--red); margin: 0; color: var(--text); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } }

/* ---------- run log ---------- */
.log {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; max-height: 420px; overflow-y: auto;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px;
  white-space: pre-wrap; word-break: break-word; line-height: 1.55;
}
.log .ts { color: var(--muted); }
.log .tool { color: var(--purple); }
.log .err { color: var(--red); }

/* ---------- question card ---------- */
.qcard {
  border: 1px solid rgba(79,143,247,.55); border-radius: 12px; padding: 16px 18px; margin: 12px 0;
  background: linear-gradient(180deg, rgba(79,143,247,.09), rgba(79,143,247,.03));
  animation: slideIn .2s ease;
}
.qcard .qtitle { font-weight: 650; margin-bottom: 10px; }
.qcard .opt { margin: 4px 6px 0 0; }

/* ---------- auth page ---------- */
.auth-wrap { max-width: 420px; margin: 8vh auto 40px; padding: 0 18px; }
.auth-wrap .card { padding: 28px; }
.auth-wrap h1 { font-size: 20px; margin: 0 0 4px; }
.auth-tabs { display: flex; gap: 4px; background: var(--bg2); border-radius: 10px; padding: 4px; margin: 18px 0; }
.auth-tabs button {
  flex: 1; background: none; border: none; color: var(--muted); padding: 9px;
  border-radius: 8px; font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.auth-tabs button.on { background: var(--panel); color: var(--text); }

/* ---------- products ---------- */
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.thumb {
  position: relative; width: 104px; height: 104px; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--border2); background: var(--bg2); cursor: zoom-in;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .del {
  position: absolute; top: 5px; right: 5px; width: 22px; height: 22px; border-radius: 6px;
  background: rgba(10,10,12,.78); color: var(--red); border: none; cursor: pointer;
  font-size: 12px; line-height: 1; display: grid; place-items: center; opacity: 0; transition: opacity .15s;
}
.thumb:hover .del { opacity: 1; }
.thumb .fname {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 3px 6px; font-size: 9.5px;
  background: rgba(10,10,12,.7); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.drop {
  border: 1.5px dashed var(--border2); border-radius: 10px; padding: 18px; text-align: center;
  color: var(--muted); font-size: 13px; cursor: pointer; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: rgba(79,143,247,.07); color: var(--text); }

/* lightbox */
#lightbox {
  position: fixed; inset: 0; background: rgba(5,7,10,.85); z-index: 200;
  display: none; place-items: center; cursor: zoom-out;
}
#lightbox img { max-width: 88vw; max-height: 86vh; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }

/* modal */
.modal-bg {
  position: fixed; inset: 0; background: rgba(5,7,10,.6); z-index: 150;
  display: grid; place-items: center; padding: 20px;
}
.modal {
  background: var(--panel); border: 1px solid var(--border2); border-radius: 14px;
  padding: 22px; width: 100%; max-width: 460px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}

.stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.stat {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 18px; min-width: 130px;
}
.stat .v { font-size: 20px; font-weight: 700; }
.stat .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }

.progressbar { height: 5px; background: var(--bg2); border-radius: 99px; overflow: hidden; margin-top: 14px; }
.progressbar .fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--purple)); border-radius: 99px; transition: width .4s; }
