:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #fbfcfd;
  --line: #e3e6ea;
  --text: #16191d;
  --muted: #6b7280;
  --accent: #2f6fed;
  --accent-soft: #e8f0fe;
  --ok: #14855c;
  --warn: #9a6400;
  --warn-bg: #fff6e0;
  --err: #c0392b;
  --err-bg: #fdecea;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --panel: #1c1f25;
    --panel-2: #21252c;
    --line: #2e333b;
    --text: #e7e9ec;
    --muted: #9aa2ad;
    --accent: #6a9bff;
    --accent-soft: #23314f;
    --ok: #4fc39a;
    --warn: #e0b25a;
    --warn-bg: #33291394;
    --err: #ef7a6d;
    --err-bg: #3a1f1c;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: 0 16px 64px;
}

a { color: var(--accent); }

/* ---------------------------------------------------------- login / setup */

.card {
  max-width: 440px;
  margin: 12vh auto 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
}

.card h1 { margin: 0 0 4px; font-size: 22px; }
.card .sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }

label { display: block; margin-bottom: 16px; font-size: 13px; font-weight: 600; }
label small { display: block; margin-top: 5px; font-weight: 400; color: var(--muted); }

input[type=text], input[type=password], input[type=search] {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

input:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button {
  font: inherit;
  font-weight: 600;
  padding: 10px 18px;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

button.link {
  padding: 0;
  color: var(--accent);
  background: none;
  font-weight: 600;
  text-decoration: underline;
}

.alert {
  margin-bottom: 16px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--err);
  background: var(--err-bg);
  border-radius: 8px;
}

.alert.warn { color: var(--warn); background: var(--warn-bg); }
.alert code { font-size: 13px; }

/* ------------------------------------------------------------------- app */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 0 18px;
  flex-wrap: wrap;
}

.brand { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.meta { display: flex; align-items: center; gap: 16px; font-size: 13px; color: var(--muted); }
.ghost {
  padding: 0;
  font: inherit;
  color: var(--muted);
  background: none;
  border: 0;
  text-decoration: none;
  cursor: pointer;
}
.ghost:hover { color: var(--text); }

main, .alert.warn { max-width: 900px; margin: 0 auto; }

.drop {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 40px 20px;
  text-align: center;
  transition: border-color .15s, background .15s;
}

.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-inner { display: grid; gap: 6px; }
.drop-inner strong { font-size: 16px; }
.drop-inner span { color: var(--muted); font-size: 14px; }
.drop-inner small { margin-top: 6px; color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------------ queue */

.queue { margin-top: 18px; display: grid; gap: 10px; }

.job {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.job-top { display: flex; align-items: baseline; gap: 10px; }
.job-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-pct { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); }

.bar { height: 6px; margin: 9px 0 7px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .2s; }
.job.done .bar > i { background: var(--ok); }
.job.error .bar > i { background: var(--err); }

.job-bottom { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--muted); }
.job-bottom .spacer { flex: 1; }
.job-bottom button { padding: 3px 10px; font-size: 12px; font-weight: 600; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); }

/* ------------------------------------------------------------------ files */

.files { margin-top: 28px; }
.files-head { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.files-head h2 { flex: 1; margin: 0; font-size: 15px; }
.files-head input { max-width: 220px; margin: 0; padding: 7px 10px; font-size: 13px; }

.list { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }

.row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row-main { flex: 1; min-width: 0; }
.row-by {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1px;
}
.row-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 12px; color: var(--muted); }
.row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.row-actions a, .row-actions button {
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  text-decoration: none;
  cursor: pointer;
}
.row-actions .danger { color: var(--err); }
.empty { padding: 26px 14px; text-align: center; color: var(--muted); font-size: 14px; }

/* ------------------------------------------------------------------ modal */

.modal[hidden] { display: none; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px 16px;
  overflow: auto;
  z-index: 20;
}

.modal-box {
  width: 100%;
  max-width: 560px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px 24px;
}

.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-head .ghost { background: none; border: 0; cursor: pointer; }

.panel { margin-top: 22px; }
.panel h3 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.panel .list { margin-bottom: 12px; }
.panel button[type=submit] { padding: 8px 16px; font-size: 14px; }

.grid-form { display: grid; gap: 12px; }
.grid-form label { margin: 0; }
.grid-form .row-actions { display: flex; gap: 8px; }
.grid-form .row-actions button { padding: 8px 16px; font-size: 14px; }
.grid-form .row-actions button[type=button] { color: var(--text); background: var(--panel-2); border: 1px solid var(--line); }

.row-edit { display: block; padding: 16px 14px; background: var(--panel-2); }

details#addUser { margin-top: 4px; }
details#addUser > summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  list-style: none;
}
details#addUser > summary::-webkit-details-marker { display: none; }
details#addUser > summary::before { content: '+ '; }
details#addUser[open] > summary::before { content: '– '; }
details#addUser > form { margin-top: 14px; }

.hint { margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.muted { font-weight: 400; color: var(--muted); }
.ghost.strong { font-weight: 600; color: var(--accent); }

.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline input[type=text], .inline input[type=password] { flex: 1 1 150px; width: auto; margin: 0; padding: 8px 10px; font-size: 14px; }
.check { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; font-weight: 500; white-space: nowrap; }
.check input { margin: 0; }

/* ------------------------------------------------------------------ toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 10px 16px;
  font-size: 14px;
  color: #fff;
  background: #24272d;
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
  z-index: 10;
}

@media (max-width: 560px) {
  .row { flex-wrap: wrap; }
  .row-actions { width: 100%; }
  .files-head input { max-width: 140px; }
}
