:root {
  --bg: #f6f4f1;
  --panel: #ffffff;
  --ink: #1f1d1a;
  --muted: #6b665e;
  --line: #e4dfd7;
  --accent: #b4532a;
  --accent-ink: #ffffff;
  --ok: #2f7d4f;
  --warn: #a86a00;
  --bad: #b3261e;
  --chip: #f1ece4;
  --new: #fff1d6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514; --panel: #1f1e1c; --ink: #ece8e2; --muted: #a39d93; --line: #34312d;
    --accent: #e07a4b; --accent-ink: #1a1a1a; --ok: #6cc28f; --warn: #e3b04b; --bad: #ef7b72;
    --chip: #2a2825; --new: #3a3020; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 18px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 16px; text-decoration: none; color: var(--ink); }
.brand span { color: var(--accent); }
#nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
#nav a { padding: 6px 10px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500; }
#nav a.active, #nav a:hover { background: var(--chip); color: var(--ink); }
.me { color: var(--muted); display: flex; gap: 10px; align-items: center; }
main { padding: 20px; max-width: 1400px; margin: 0 auto; }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 22px 0 10px; }
.sub { color: var(--muted); margin: 0 0 16px; }
.loading { color: var(--muted); padding: 40px; text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.stat .n { font-size: 26px; font-weight: 700; }
.stat .l { color: var(--muted); }
.btn { border: 1px solid var(--line); background: var(--panel); padding: 7px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.danger { color: var(--bad); }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=email], input[type=date], input[type=number], input[type=search], select, textarea {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 10px; min-width: 0;
}
textarea { width: 100%; min-height: 70px; }
table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; position: sticky; top: 52px; background: var(--panel); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.sec-row td { background: var(--chip); font-weight: 700; }
.thumb { width: 56px; height: 56px; object-fit: contain; border-radius: 6px; background: #fff; border: 1px solid var(--line); }
.thumb.big { width: 150px; height: 150px; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 99px; background: var(--chip); font-size: 12px; margin: 1px 2px 1px 0; }
.chip.new { background: var(--new); }
.chip.ok { color: var(--ok); }
.chip.warn { color: var(--warn); }
.chip.bad { color: var(--bad); }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; word-break: break-all; }
.clip { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs a { padding: 5px 10px; border: 1px solid var(--line); border-radius: 99px; text-decoration: none; color: var(--ink); background: var(--panel); }
.tabs a.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.summary { background: var(--panel); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.jobs { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); }
.job { display: grid; grid-template-columns: 150px 1fr; gap: 14px; }
.job.done { opacity: .72; }
.job .meta { display: grid; gap: 4px; min-width: 0; }
.job .title { font-weight: 600; }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 2px 8px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.drop { border: 1.5px dashed var(--line); border-radius: 8px; padding: 8px; text-align: center; color: var(--muted); cursor: pointer; font-size: 12px; position: relative; }
.drop.over { border-color: var(--accent); background: var(--chip); }
.drop.has { border-style: solid; border-color: var(--ok); color: var(--ok); }
.drop input { display: none; }
.drops { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; margin-top: 6px; }
.files { display: grid; gap: 3px; margin-top: 6px; }
.files a { font-size: 12px; }
.progress { height: 3px; background: var(--accent); width: 0; transition: width .2s; position: absolute; left: 0; bottom: 0; }
details summary { cursor: pointer; color: var(--muted); }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; z-index: 50; }
#toast.show { opacity: 1; }
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 0; background: var(--panel); color: var(--ink); width: min(640px, 94vw); }
dialog::backdrop { background: rgba(0,0,0,.35); }
#modal-body { padding: 18px; display: grid; gap: 10px; }
#modal-body label { display: grid; gap: 4px; }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.edit { cursor: pointer; border-bottom: 1px dotted var(--muted); }
@media (max-width: 640px) {
  main { padding: 12px; }
  .jobs { grid-template-columns: 1fr; }
  .job { grid-template-columns: 1fr; }
  .thumb.big { width: 100%; height: 220px; }
  th { top: 0; }
}
