:root {
  --red: #c21b17;
  --red-dark: #9d1511;
  --ink: #3a2e22;
  --muted: #7d6b56;
  --line: #e5d9c3;
  --bg: #f3ead8;
  --card: #fbf6ec;
  --soft: #f0e6d2;
  --soft-hover: #ebdfc7;
  --field: #fffcf6;
  --ok: #3f7d4e;
  --warn: #a5560f;
  --err: #b4233a;
  --radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }
:focus-visible { outline: 2px solid rgba(194,27,23,.45); outline-offset: 2px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; gap: 12px; align-items: center; }
.logo {
  width: 36px; height: 36px; border-radius: 9px; background: var(--red); color: #fff;
  display: grid; place-items: center; font-weight: 700;
}
.title { font-weight: 700; font-size: 17px; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.who { font-weight: 600; font-size: 14px; }

main { max-width: 960px; margin: 28px auto; padding: 0 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: 0 1px 2px rgba(80,60,30,.06); }
.narrow { max-width: 420px; margin: 40px auto; }
h1 { margin: 0 0 6px; font-size: 22px; }
h2 { margin: 0 0 14px; font-size: 18px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small-print { font-size: 12.5px; margin-top: 12px; }

label { display: block; margin: 14px 0; font-size: 14px; font-weight: 600; }
label input { display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-weight: 400; background: var(--field); color: var(--ink); }
label input:focus { outline: 2px solid rgba(194,27,23,.25); border-color: var(--red); }
label small { font-weight: 400; display: block; margin-top: 4px; }

.primary, .ghost {
  border-radius: 8px; padding: 9px 16px; font-weight: 600; border: 1px solid transparent; white-space: nowrap;
}
a.primary, a.ghost { display: inline-block; text-decoration: none; }
.primary { background: var(--red); color: #fff; }
.primary:hover:not(:disabled) { background: var(--red-dark); }
.ghost { background: var(--field); border-color: var(--line); color: var(--ink); }
.ghost:hover:not(:disabled) { background: var(--soft); }
.small { padding: 6px 11px; font-size: 13px; }
.wide { width: 100%; padding: 11px; }
.danger { color: var(--err); }
.link { background: none; border: none; color: var(--muted); font-weight: 600; font-size: 13px; }

.segmented { display: flex; background: var(--soft); border-radius: 9px; padding: 3px; margin: 18px 0 4px; }
.seg { flex: 1; border: none; background: transparent; padding: 8px; border-radius: 7px; font-weight: 600; color: var(--muted); }
.seg.active { background: var(--field); color: var(--ink); box-shadow: 0 1px 2px rgba(80,60,30,.1); }
.error { color: var(--err); min-height: 1.2em; font-size: 14px; margin: 6px 0; }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tab { border: 1px solid transparent; background: transparent; padding: 8px 14px; border-radius: 8px; font-weight: 600; color: var(--muted); }
.tab.active { background: var(--card); color: var(--ink); border-color: var(--line); }

.dropzone {
  border: 2px dashed #d6c6a6; border-radius: var(--radius); padding: 34px 20px; text-align: center;
  background: var(--field); transition: background .15s, border-color .15s;
}
.dropzone.over { background: #fbeee4; border-color: var(--red); }
.dz-icon { font-size: 28px; color: var(--red); }
.dz-title { font-weight: 700; font-size: 16px; margin: 6px 0 4px; }
.dz-buttons { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

.queue-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 20px 0 10px; flex-wrap: wrap; }
.queue-head:first-child { margin-top: 0; }
.queue-actions { display: flex; gap: 8px; }

.file-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--field); }
.file-list li { padding: 10px 14px; border-top: 1px solid var(--line); }
.file-list li:first-child { border-top: none; }
.file-list li li { border: none; padding: 2px 0; }
.file-row { display: flex; align-items: center; gap: 12px; }
.file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.file-name .path { color: var(--muted); }
.file-actions { display: flex; gap: 6px; align-items: center; }
.badge { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.badge.done { background: #e4efdc; color: var(--ok); }
.badge.error { background: #f8e1df; color: var(--err); }
.badge.skipped { background: #f7e9cf; color: var(--warn); }
.badge.busy { background: #f8e4dc; color: var(--red); }
.icon-btn { border: none; background: none; color: var(--muted); padding: 4px 6px; border-radius: 6px; font-size: 15px; }
.icon-btn:hover { background: var(--soft); color: var(--ink); }

details.report { margin-top: 8px; font-size: 13px; color: var(--muted); }
details.report summary {
  cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 4px 10px 4px 8px; border-radius: 7px; background: var(--soft); user-select: none;
}
details.report summary::-webkit-details-marker { display: none; }
details.report summary:hover { background: var(--soft-hover); }
details.report summary .chev { display: inline-block; transition: transform .15s; color: var(--red); font-size: 11px; }
details.report[open] summary .chev { transform: rotate(90deg); }
details.report summary .hint { color: var(--red); font-weight: 600; }
details.report summary .hint-close { display: none; }
details.report[open] summary .hint-open { display: none; }
details.report[open] summary .hint-close { display: inline; }
details.report ul { margin: 6px 0 2px; padding-left: 18px; }
details.report .warnline { color: var(--warn); }

.progress { height: 10px; background: var(--soft); border-radius: 999px; overflow: hidden; margin: 14px 0 6px; }
.bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--red), #e5483f); transition: width .25s ease; }
.progress-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 12px; }

.result-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; flex-wrap: wrap; }

.notice { border-radius: 10px; padding: 14px; margin: 12px 0; font-size: 14px; }
.notice.warn { background: #f8ecd2; border: 1px solid #e8cf9b; }
.notice ul { margin: 8px 0; padding-left: 18px; max-height: 160px; overflow: auto; }
.notice-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 10px; }

.batch { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 14px; overflow: hidden; }
.batch-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--soft); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.batch-head .when { font-weight: 600; font-size: 14px; }
.batch .file-list { border: none; border-radius: 0; }

dialog { border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; width: min(400px, 92vw); background: var(--card); color: var(--ink); box-shadow: 0 20px 50px rgba(60,40,20,.25); }
dialog::backdrop { background: rgba(58,46,34,.35); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.dialog-head h2 { margin: 0; }
dialog h3 { margin: 12px 0 0; font-size: 15px; padding-top: 12px; border-top: 1px solid var(--line); }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 9px; font-size: 14px; z-index: 20;
}

@media (max-width: 600px) {
  .topbar { padding: 12px 14px; }
  .card { padding: 16px; }
}
