:root {
  --paper: #f5efe2;
  --paper-2: #efe6d2;
  --surface: #fbf7ec;
  --surface-2: #f1ead9;
  --ink: #241d12;
  --muted: #7a6f5a;
  --line: #ddd2bc;
  --accent: #c2410c;
  --accent-ink: #7c2d12;
  --accent-soft: #fbe7d2;
  --ok: #2f6f4f;
  --warn: #a16207;
  --err: #b91c1c;
  --blue: #1d4ed8;
  --shadow: 0 1px 3px rgba(60, 45, 20, 0.08), 0 4px 14px rgba(60, 45, 20, 0.05);
}

[data-theme="dark"] {
  --paper: #17130d;
  --paper-2: #1e1912;
  --surface: #211b13;
  --surface-2: #2a2319;
  --ink: #efe6d2;
  --muted: #a2957c;
  --line: #3a3224;
  --accent: #f97316;
  --accent-ink: #ffd9bd;
  --accent-soft: #3a2a17;
  --ok: #4ade80;
  --warn: #fbbf24;
  --err: #f87171;
  --blue: #93c5fd;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.5;
}

.shell { max-width: 980px; margin: 0 auto; padding: 0 20px; }

.top {
  background: var(--paper-2);
  border-bottom: 1px solid var(--line);
  padding: 14px 0 0;
}
.top .shell { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
h1 { font-family: "Fraunces", Georgia, serif; font-size: 22px; margin: 0 0 12px; }
.dim { color: var(--muted); font-weight: 400; }
.top-actions { margin-left: auto; display: flex; gap: 12px; align-items: center; padding-bottom: 12px; }
.top-actions a { color: var(--muted); text-decoration: none; font-size: 13px; }
.top-actions a:hover { color: var(--accent); }
.link-btn { background: none; border: none; color: var(--err); cursor: pointer; font-size: 13px; padding: 0; }

.tabs { display: flex; gap: 2px; }
.tab {
  font: inherit; font-weight: 500; font-size: 14px;
  background: none; border: none; color: var(--muted);
  padding: 10px 14px; cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent-ink); border-bottom-color: var(--accent); }

main { padding: 26px 0 60px; }
.view { display: block; }

.hidden { display: none !important; }

h2 { font-family: "Fraunces", Georgia, serif; font-size: 20px; margin: 22px 0 10px; }
h3 { font-family: "Fraunces", Georgia, serif; font-size: 16px; margin: 8px 0; }
.muted { color: var(--muted); }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 12.5px; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
  margin: 14px 0;
}

.login-card { max-width: 420px; margin: 60px auto; }

input, select, textarea {
  font: inherit; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 64px; resize: vertical; font-size: 13px; }

button {
  font: inherit; font-weight: 500;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.06); }
button.danger { background: var(--err); border-color: var(--err); color: #fff; }
button.small { padding: 4px 9px; font-size: 12.5px; }
button:disabled { opacity: 0.5; cursor: default; }

form.card { display: flex; flex-direction: column; gap: 14px; }
form.inline { display: flex; gap: 8px; max-width: 460px; }
form.inline input { flex: 1; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.field .hint { font-size: 11.5px; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; color: var(--muted); font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 7px 8px; border-bottom: 1px solid var(--line);
}
td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }
td.url { word-break: break-all; max-width: 360px; }
td.actions { white-space: nowrap; }
a { color: var(--accent-ink); }
td a { text-decoration: none; }
td a:hover { text-decoration: underline; }

.badge {
  display: inline-block; font-size: 11px; font-weight: 600;
  border-radius: 999px; padding: 2px 9px;
  background: var(--surface-2); color: var(--muted);
}
.badge.ok, .badge.fetched { background: var(--accent-soft); color: var(--ok); }
.badge.running, .badge.queued { background: #dbeafe; color: var(--blue); }
.badge.error, .badge.blocked { background: #fee2e2; color: var(--err); }

.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .n { font-family: "Fraunces", Georgia, serif; font-size: 26px; }
.stat .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }

.notice { color: var(--err); font-size: 13px; margin-top: 8px; }
.ok-msg { color: var(--ok); font-size: 13px; margin-top: 8px; }

.filters { display: flex; gap: 10px; margin: 12px 0; flex-wrap: wrap; }
.filters select, .filters input { flex: 1; min-width: 140px; }
.filters button { flex: 0; }

.pager { margin: 12px 0; display: flex; gap: 10px; align-items: center; }
.pager .info { color: var(--muted); font-size: 12.5px; }

.foot {
  border-top: 1px solid var(--line);
  padding: 20px;
  color: var(--muted);
  font-size: 12.5px;
  background: var(--paper-2);
  text-align: center;
}

pre {
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 12px; overflow-x: auto;
  font-size: 12.5px;
}

.key-copied { color: var(--ok); font-size: 12px; margin-top: 6px; }
.empty { color: var(--muted); padding: 10px; }