:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e3e5e8;
  --text: #16191d;
  --muted: #6b7280;
  --accent: #1a56db;
  --accent-hover: #1547b8;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --success: #067647;
  --success-bg: #ecfdf3;
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a1f;
    --border: #2a2e35;
    --text: #e8eaed;
    --muted: #9aa1ab;
    --accent: #5b8def;
    --accent-hover: #7aa3f5;
    --danger: #f97066;
    --danger-bg: #2d1614;
    --success: #4ade80;
    --success-bg: #10241a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 40px 20px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

.card {
  max-width: 560px;
  margin: 0 auto;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card--wide { max-width: 1040px; }

h1 { margin: 0 0 8px; font-size: 22px; line-height: 1.3; }
h2 { margin: 32px 0 12px; font-size: 16px; }
.lede { margin: 0 0 28px; color: var(--muted); }

label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 600;
}

.hint { margin: 6px 0 0; font-size: 13px; color: var(--muted); }

input[type='email'],
input[type='password'],
input[type='text'],
input[type='date'],
select {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

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

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

button:hover:not(:disabled) { background: var(--accent-hover); }
button:disabled { opacity: .55; cursor: not-allowed; }

button.secondary {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
}

.field { margin-bottom: 20px; }

.msg {
  margin: 0 0 20px;
  padding: 12px 14px;
  border-radius: 6px;
  font-size: 14px;
}

.msg--error { color: var(--danger); background: var(--danger-bg); }
.msg--success { color: var(--success); background: var(--success-bg); }
.msg[hidden] { display: none; }

/* Drop zone */
.dropzone {
  padding: 32px 20px;
  text-align: center;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

.dropzone p { margin: 0; color: var(--muted); }
.dropzone strong { color: var(--accent); }

/* File list */
.files { margin: 20px 0 0; padding: 0; list-style: none; }

.file {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  font-size: 14px;
}

.file__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file__size { color: var(--muted); font-variant-numeric: tabular-nums; }

.file__status { min-width: 82px; text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; }
.file__status--done { color: var(--success); }
.file__status--error { color: var(--danger); }

.progress { width: 100%; height: 4px; margin-top: 6px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress__bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* Admin */
.filters { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.filters > div { flex: 1 1 160px; }

.stats { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 24px; }

.stat {
  flex: 1 1 140px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.stat__value { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat__label { font-size: 13px; color: var(--muted); }

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }

th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
td.wrap { white-space: normal; word-break: break-word; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

.row-actions a { color: var(--accent); text-decoration: none; }
.row-actions a:hover { text-decoration: underline; }

.pagination { display: flex; gap: 12px; align-items: center; margin-top: 20px; font-size: 14px; }
.pagination span { color: var(--muted); }

.topbar { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 4px; }
.topbar a { font-size: 14px; color: var(--muted); }

.empty { padding: 32px; text-align: center; color: var(--muted); }
