:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text: #16181d;
  --muted: #646b78;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-soft: #e8efff;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --warn: #b45309;
  --warn-soft: #fdf3e2;
  --danger: #b91c1c;
  --danger-soft: #fdecec;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1e222a;
    --border: #2a2f39;
    --text: #e8eaee;
    --muted: #9aa2b1;
    --primary: #5b8cff;
    --primary-hover: #7aa2ff;
    --primary-soft: #1b2540;
    --ok: #4ade80;
    --ok-soft: #12291b;
    --warn: #fbbf24;
    --warn-soft: #2d230f;
    --danger: #f87171;
    --danger-soft: #2f1515;
    --shadow: none;
    color-scheme: dark;
  }
}

* { 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;
}

.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- botões e campos ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover:not(:disabled) { color: var(--text); }

input[type="email"], input[type="password"], input[type="text"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
input:focus-visible, .btn:focus-visible, summary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- marca ---------- */

.brand { display: flex; align-items: center; gap: 12px; }
.brand div { display: flex; flex-direction: column; line-height: 1.25; }
.brand span { color: var(--muted); font-size: 13px; }

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

body.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card {
  width: 100%;
  max-width: 380px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.auth-card form { display: grid; gap: 14px; margin-top: 24px; }
.auth-card label { display: grid; gap: 6px; font-weight: 500; font-size: 14px; }
.auth-card .btn { width: 100%; padding: 10px; }
.form-error { margin: 0; color: var(--danger); font-size: 14px; }

/* ---------- topo ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar .user { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }

.container { max-width: 960px; margin: 0 auto; padding: 24px 16px 48px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- upload ---------- */

.upload { padding: 20px; display: grid; gap: 18px; }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 36px 16px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone strong { color: var(--text); font-size: 16px; }
.dropzone span { font-size: 13px; max-width: 560px; }
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone svg { color: var(--primary); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dropzone:focus-within { border-color: var(--primary); }

.naming { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; }
.naming legend { font-weight: 600; font-size: 14px; margin-bottom: 8px; padding: 0; }
.naming label { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.naming .muted { font-size: 13px; }
.naming input[type="text"] { width: 190px; padding: 5px 10px; }
.naming input[type="text"]:disabled { opacity: .5; }

/* ---------- lista ---------- */

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin: 28px 0 12px;
}
.list-header h2 { margin: 0; font-size: 18px; }
.list-header .count { color: var(--muted); font-weight: 400; font-size: 14px; margin-left: 6px; }
.list-header .actions { display: flex; gap: 8px; }

.files { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.empty { text-align: center; padding: 32px 0; }

.file {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 14px;
  align-items: start;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.file[data-status="failed"], .file[data-status="upload-error"] { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }

.thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }

.info { min-width: 0; display: grid; gap: 4px; }
.names { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; min-width: 0; }
.names .original { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.names .arrow { color: var(--muted); }
.names .output { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; color: var(--ok); word-break: break-all; }

.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; font-size: 13px; }
.status { font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.status.done { background: var(--ok-soft); color: var(--ok); }
.status.processing, .status.uploading, .status.queued { background: var(--primary-soft); color: var(--primary); }
.status.failed, .status.upload-error { background: var(--danger-soft); color: var(--danger); }
.status.expired { background: var(--warn-soft); color: var(--warn); }

.progress { height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 4px; }
.progress .bar { height: 100%; width: 0; background: var(--primary); transition: width .2s; }
.progress.indeterminate .bar { width: 35%; animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
@media (prefers-reduced-motion: reduce) { .progress.indeterminate .bar { animation: none; width: 100%; opacity: .5; } }

.error { margin: 0; color: var(--danger); font-size: 13px; }
.error:empty { display: none; }

.report { font-size: 13px; margin-top: 2px; }
.report summary { cursor: pointer; color: var(--muted); width: fit-content; }
.report summary:hover { color: var(--text); }
.report .notes { margin: 8px 0 0; padding-left: 18px; color: var(--muted); }
.report .notes:empty { display: none; }
.report table { width: 100%; margin-top: 8px; border-collapse: collapse; display: block; max-height: 280px; overflow: auto; }
.report th, .report td { text-align: left; padding: 4px 10px 4px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.report th { color: var(--muted); font-weight: 500; position: sticky; top: 0; background: var(--surface); }
.report td:first-child { color: var(--muted); white-space: nowrap; }
.report td:nth-child(2) { white-space: nowrap; font-weight: 500; }
.report td:last-child { word-break: break-word; }

.file-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }

.footnote { font-size: 13px; text-align: center; margin-top: 28px; }

@media (max-width: 640px) {
  .topbar { padding: 10px 16px; }
  .topbar .brand span { display: none; }
  .file { grid-template-columns: 44px 1fr; }
  .thumb { width: 44px; height: 44px; }
  .file-actions { grid-column: 1 / -1; flex-direction: row; justify-content: flex-end; }
  .list-header .actions { width: 100%; }
  .list-header .actions .btn { flex: 1; }
}
