:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2330;
  --muted: #5f6b7a;
  --border: #e1e5ea;
  --accent: #2f5bd3;
  --accent-text: #ffffff;
  --error-bg: #fdecec;
  --error-text: #9b1c1c;
  --ok: #1f7a4d;
  --warn: #9a6700;
  --bad: #b42318;
  --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --surface: #1a1f27;
    --text: #e6e9ee;
    --muted: #98a2b3;
    --border: #2b323d;
    --accent: #6f93ff;
    --accent-text: #0d1117;
    --error-bg: #3a1d1d;
    --error-text: #ffb4b4;
    --ok: #4cc38a;
    --warn: #e0b341;
    --bad: #ff8a80;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }

.topbar {
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  padding: 0.75rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 600; color: var(--text); text-decoration: none; }
.nav { display: flex; gap: 1rem; flex: 1; }
.nav a { color: var(--muted); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--text); font-weight: 600; }
.account { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; }
.account form { margin: 0; }

.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.stat { display: flex; flex-direction: column; gap: 0.25rem; }
.stat-label { color: var(--muted); font-size: 0.85rem; }
.stat-value { font-size: 1.75rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; }
td.num { font-variant-numeric: tabular-nums; }
td.url { max-width: 460px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.empty { color: var(--muted); margin: 0; }

.badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.8rem; border: 1px solid currentColor; }
.badge-success { color: var(--ok); }
.badge-pending, .badge-processing { color: var(--warn); }
.badge-failed, .badge-rejected { color: var(--bad); }
.badge-cancelled { color: var(--muted); }

.auth-card { max-width: 380px; margin: 4rem auto; }
form label { display: block; margin: 0.75rem 0 0.25rem; font-size: 0.9rem; }
form label.checkbox { display: flex; align-items: center; gap: 0.5rem; }
input[type="email"], input[type="password"], input[type="text"], textarea {
  width: 100%; padding: 0.55rem 0.65rem; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
}
input:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button { font: inherit; cursor: pointer; }
button.primary { margin-top: 1rem; width: 100%; padding: 0.6rem; background: var(--accent); color: var(--accent-text); border: 0; border-radius: 6px; font-weight: 600; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); }
.field-error { color: var(--error-text); font-size: 0.85rem; margin: 0.25rem 0 0; }
.flash { padding: 0.65rem 0.9rem; border-radius: 6px; margin-bottom: 1rem; }
.flash-error { background: var(--error-bg); color: var(--error-text); }

/* ---- step 2: submit, history */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; }
.break { overflow-wrap: anywhere; margin: 0; }
textarea.mono { resize: vertical; min-height: 16rem; line-height: 1.45; }
.submit-bar { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; margin-top: 0.75rem; }
.submit-bar p { margin: 0; }
.submit-bar #url-count { font-weight: 600; color: var(--text); }
button.primary.inline { width: auto; margin: 0 0 0 auto; padding: 0.55rem 1.5rem; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0.75rem 0 0; }
.samples { margin: 0.5rem 0 0; padding-left: 1.25rem; font-size: 0.85rem; }
.flash-success { background: color-mix(in srgb, var(--ok) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--ok) 35%, var(--border)); }
.flash p { margin: 0.25rem 0 0; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.filters { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 1rem; }
.filters label { margin: 0; color: var(--muted); }
select { font: inherit; padding: 0.35rem 0.5rem; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }
.batch-summary { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.batch-summary h2, .batch-summary p { margin: 0 0 0.35rem; }
.batch-actions { display: flex; align-items: center; gap: 1rem; }
.counts { display: flex; gap: 0.4rem; flex-wrap: wrap; }
a.button { display: inline-block; padding: 0.45rem 0.9rem; border: 1px solid var(--border); border-radius: 6px; text-decoration: none; color: var(--text); background: var(--bg); }
.reason { display: block; font-size: 0.78rem; color: var(--muted); margin-top: 0.15rem; }
.detail-row td { padding: 0; border-bottom: 0; }
.detail-row td:not(:empty) { padding: 0.75rem; border-bottom: 1px solid var(--border); background: var(--bg); }
.detail h3 { font-size: 0.95rem; margin: 1rem 0 0.4rem; }
.detail-head { display: flex; justify-content: space-between; gap: 1rem; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.2rem 1rem; margin: 0.5rem 0; font-size: 0.88rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.problems { margin: 0.25rem 0; padding-left: 1.25rem; color: var(--bad); }
.ok-text { color: var(--ok); margin: 0.25rem 0; }
table.mini { width: auto; min-width: 50%; font-size: 0.85rem; }
.pager { display: flex; justify-content: center; gap: 1.25rem; margin-top: 1rem; }
