:root {
  --bg: #0e1014;
  --panel: #16191f;
  --panel-2: #1c2029;
  --line: #272c36;
  --text: #e7e9ee;
  --dim: #9aa1ae;
  --faint: #6b7280;
  --accent: #7c9cff;
  --accent-dim: #2c3654;
  --ok: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

.hidden { display: none !important; }

/* ---------- каркас ---------- */

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}
.logo { font-weight: 700; letter-spacing: .5px; }
.logo span { color: var(--accent); }
.spacer { flex: 1; }

.chip {
  font-size: 13px;
  color: var(--dim);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
}

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
@media (max-width: 900px) {
  main { grid-template-columns: 1fr; padding: 14px; }
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 20px;
}
.card h2 {
  margin: 0 0 4px;
  font-size: 15px;
  letter-spacing: .3px;
}
.card .note { color: var(--faint); font-size: 13px; margin: 0 0 14px; }

/* ---------- вхід ---------- */

#login {
  max-width: 420px;
  margin: 14vh auto;
  text-align: center;
}
#login .big { font-size: 26px; font-weight: 700; margin-bottom: 6px; }
#login p { color: var(--dim); margin: 0 0 22px; }
#code {
  width: 100%;
  text-align: center;
  letter-spacing: 4px;
  text-transform: uppercase;
  font-size: 18px;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}
#code:focus { outline: none; border-color: var(--accent); }

/* ---------- кнопки ---------- */

.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 9px;
  padding: 9px 16px;
  transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--faint); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #10131a;
  font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:disabled {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  color: var(--faint);
  cursor: not-allowed;
  filter: none;
}
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 11px; font-size: 13px; }
.btn.wide { width: 100%; margin-top: 14px; }
.btn.danger { color: var(--bad); }

/* ---------- джерело ---------- */

#drop {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 30px 20px;
  text-align: center;
  color: var(--dim);
  transition: border-color .15s, background .15s;
  cursor: pointer;
}
#drop:hover, #drop.over { border-color: var(--accent); background: #171b26; }
#drop .icon { font-size: 30px; display: block; margin-bottom: 8px; }
#drop b { color: var(--text); }
#drop small { display: block; margin-top: 6px; color: var(--faint); }

.or {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--faint);
  font-size: 12px;
  margin: 16px 0;
}
.or::before, .or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

#url {
  width: 100%;
  padding: 11px 14px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}
#url:focus { outline: none; border-color: var(--accent); }

.picked {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
  margin-top: 12px;
  font-size: 14px;
}
.picked .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picked .size { color: var(--faint); font-size: 13px; }

/* ---------- завдання ---------- */

.job {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 12px;
  background: var(--panel-2);
}
.job .head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.job .title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}
.job .stage { color: var(--dim); font-size: 13px; }
.job.done .stage { color: var(--ok); }
.job.error .stage, .job.canceled .stage { color: var(--bad); }

.bar {
  height: 3px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
  margin: 10px 0;
}
.bar i {
  display: block;
  height: 100%;
  width: 35%;
  background: var(--accent);
  animation: slide 1.4s ease-in-out infinite;
}
.bar.pct i { animation: none; transition: width .2s; }
@keyframes slide {
  0%   { margin-left: -35%; }
  100% { margin-left: 100%; }
}

.err {
  color: var(--bad);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 8px;
}
.err pre {
  color: var(--faint);
  font-size: 11px;
  max-height: 130px;
  overflow: auto;
  background: #11141a;
  padding: 8px;
  border-radius: 7px;
  margin: 8px 0 0;
}

.files { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.file {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #11141a;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
}
.file:hover { border-color: var(--accent); }
.file .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .size { color: var(--faint); font-size: 13px; }

.dead { color: var(--faint); font-size: 13px; margin-top: 8px; }

/* ---------- налаштування ---------- */

.presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }

.group { border-top: 1px solid var(--line); }
.group:first-of-type { border-top: none; }
.group > summary {
  cursor: pointer;
  padding: 12px 2px;
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.group > summary::-webkit-details-marker { display: none; }
.group > summary::after {
  content: "›";
  margin-left: auto;
  color: var(--faint);
  transform: rotate(90deg);
  transition: transform .15s;
}
.group[open] > summary::after { transform: rotate(-90deg); }
.group > summary small { color: var(--faint); font-size: 12px; font-weight: 400; }
.group > summary b { font-size: 14px; }

.field { padding: 10px 2px 14px; }
.field .row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.field .label { font-size: 14px; }
.field .val {
  margin-left: auto;
  color: var(--accent);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.field .hint { color: var(--faint); font-size: 12px; margin-top: 4px; }
.field .unit { color: var(--faint); font-size: 13px; width: 22px; flex: none; }
/* специфічність навмисне вища за `.field input[type=text]` нижче — інакше
   правило ширини 100% перебиває це і числове поле розповзається */
.field .row input.num {
  width: 76px;
  text-align: right;
  padding: 4px 8px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}
.field input.num:focus { outline: none; border-color: var(--accent); }
.field .row .label { white-space: nowrap; }

input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  border-radius: 3px;
  background: var(--line);
  outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
input[type=range]::-moz-range-thumb {
  width: 15px; height: 15px; border: none;
  border-radius: 50%; background: var(--accent); cursor: pointer;
}

.field select, .field input[type=text] {
  width: 100%;
  padding: 8px 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}
.field select:focus, .field input[type=text]:focus {
  outline: none;
  border-color: var(--accent);
}
.field input.bad { border-color: var(--bad); }

.switch {
  margin-left: auto;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: var(--line);
  border: none;
  position: relative;
  transition: background .15s;
  flex: none;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--faint);
  transition: transform .15s, background .15s;
}
.switch.on { background: var(--accent-dim); }
.switch.on::after { transform: translateX(18px); background: var(--accent); }

/* ---------- адмінка ---------- */

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  color: var(--faint);
  font-weight: 500;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}
td { padding: 8px; border-bottom: 1px solid var(--line); }
td.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 1px; }
.admin-form { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.admin-form input[type=text] {
  flex: 1;
  min-width: 130px;
  padding: 8px 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}
.admin-form label { display: flex; align-items: center; gap: 6px; color: var(--dim); font-size: 13px; }
.fresh-code {
  background: #11141a;
  border: 1px solid var(--accent-dim);
  border-radius: 9px;
  padding: 12px;
  margin-bottom: 14px;
  text-align: center;
}
.fresh-code b {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 18px;
  letter-spacing: 2px;
  color: var(--accent);
}
.fresh-code div { color: var(--faint); font-size: 12px; margin-top: 6px; }

/* ---------- дрібне ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.bad { border-color: var(--bad); color: var(--bad); }
