:root {
  --bg: #f4f1ec;
  --panel: #ffffff;
  --ink: #1a1a1a;
  --muted: #6b6b6b;
  --line: #e4e0d8;
  --accent: #111;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar strong { font-size: 15px; }
.topbar nav { display: flex; gap: 8px; }
.topbar nav a {
  font-size: 13px; font-weight: 600; text-decoration: none; color: var(--muted);
  padding: 7px 13px; border-radius: 999px; display: inline-flex; align-items: center; gap: 7px;
}
.topbar nav a.active { background: #111; color: #fff; }
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: #ddd; color: #444; font-size: 11px; font-weight: 700;
}
.topbar nav a.active .badge { background: rgba(255,255,255,0.25); color: #fff; }
.badge.has { background: #e5484d; color: #fff; }

main {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 28px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 36px 28px;
  align-items: start;
}
main.single { display: block; }
main.single .sub { margin-bottom: 22px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 26px;
  position: sticky;
  top: 36px;
}
h1 { font-size: 20px; margin: 0 0 4px; }
.sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; line-height: 1.5; }
form { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
input {
  font-size: 15px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 9px; background: #fff;
  font-family: inherit;
}
input:focus { outline: 2px solid #cdb; border-color: #aaa; }
.id-row {
  display: flex; align-items: center; justify-content: space-between;
  background: #faf8f4; border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 12px; gap: 12px;
}
.id-label { font-size: 12px; font-weight: 600; color: var(--muted); }
#idDisplay { font-size: 14px; letter-spacing: 0.5px; }
button#generate {
  margin-top: 4px; padding: 12px; font-size: 15px; font-weight: 600;
  background: var(--accent); color: #fff; border: 0; border-radius: 9px; cursor: pointer;
}
button#generate:disabled { opacity: 0.5; cursor: progress; }
.status { font-size: 13px; color: var(--muted); min-height: 18px; margin: 2px 0 0; }
.status.error { color: #b00; }
.downloads { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 18px; }
.downloads h2 { font-size: 14px; margin: 0 0 12px; }
.downloads a {
  display: block; padding: 11px 14px; margin-bottom: 8px;
  background: #faf8f4; border: 1px solid var(--line); border-radius: 9px;
  text-decoration: none; color: var(--ink); font-size: 14px; font-weight: 600;
}
.downloads a:hover { background: #f1ede5; }
.kit-btn {
  background: #111 !important; color: #fff !important; text-align: center;
  border-color: #111 !important;
}
.kit-btn:hover { background: #000 !important; }
.kit-note { font-size: 12px; color: var(--muted); margin: -2px 0 14px; }
.individual summary { font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted); margin-bottom: 8px; }
.individual a { font-weight: 500; font-size: 13px; }
.hidden { display: none; }

.preview { display: flex; flex-direction: column; gap: 14px; }
.preview-tabs { display: flex; gap: 8px; }
.preview-tabs button {
  padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
  background: #fff; border: 1px solid var(--line); border-radius: 999px; color: var(--muted);
}
.preview-tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.preview-stage {
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 24px; display: flex; align-items: center; justify-content: center;
  min-height: 480px;
}
#frame { border: 0; box-shadow: 0 12px 40px rgba(0,0,0,0.12); display: block; }

/* Review queue */
.empty {
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 40px; text-align: center; color: var(--muted); font-size: 15px;
}
.queue { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 20px; }
.card {
  display: flex; gap: 16px; background: #fff; border: 1px solid var(--line);
  border-radius: 14px; padding: 16px; align-items: flex-start;
}
.card .thumb {
  flex: 0 0 168px; display: block; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--line); line-height: 0; width: 168px; height: 118.7px;
  position: relative; background: #fbf2e4;
}
.card .thumb iframe {
  width: 842px; height: 595px; border: 0; display: block;
  transform: scale(0.19952); transform-origin: 0 0; pointer-events: none;
}
.card-body { flex: 1; min-width: 0; }
.card-body h3 { margin: 0 0 2px; font-size: 17px; }
.card-body .role { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.card-body .meta { margin: 0 0 12px; display: grid; gap: 5px; font-size: 12.5px; }
.card-body .meta div { display: flex; gap: 8px; }
.card-body .meta dt { color: var(--muted); min-width: 92px; margin: 0; }
.card-body .meta dd { margin: 0; overflow: hidden; text-overflow: ellipsis; }
.card-body .meta code { font-size: 12px; }
.files { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.files a {
  font-size: 12px; font-weight: 600; text-decoration: none; color: #111;
  background: #faf8f4; border: 1px solid var(--line); border-radius: 7px; padding: 6px 10px;
}
.files a:hover { background: #f1ede5; }
.files a.kit { background: #111; color: #fff; border-color: #111; }
.files a.kit:hover { background: #000; }
.actions { display: flex; gap: 8px; }
.actions button { font-size: 13px; font-weight: 600; border-radius: 8px; padding: 9px 14px; cursor: pointer; border: 1px solid var(--line); }
.actions .primary { background: #111; color: #fff; border-color: #111; }
.actions .ghost { background: #fff; color: #b00; border-color: #f0d4d4; }
.actions button:disabled { opacity: 0.5; cursor: progress; }

/* History */
.history-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.history-head #search {
  flex: 0 0 360px; max-width: 100%; font-size: 14px; padding: 10px 13px;
  border: 1px solid var(--line); border-radius: 9px; background: #fff;
}
.history-head .stats { color: var(--muted); font-size: 13px; }
table.history {
  width: 100%; border-collapse: collapse; background: #fff;
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
}
table.history th, table.history td { text-align: left; padding: 12px 14px; font-size: 13px; vertical-align: middle; }
table.history thead th { background: #faf8f4; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
table.history tbody tr { border-top: 1px solid var(--line); }
table.history tbody tr:hover { background: #fcfbf8; }
table.history code { font-size: 12px; }
table.history .dim { color: var(--muted); font-size: 12px; }
table.history .thumb-cell { width: 84px; }
table.history .thumb-cell img { width: 72px; height: auto; display: block; border: 1px solid var(--line); border-radius: 5px; }
table.history .row-actions { display: flex; gap: 10px; align-items: center; justify-content: flex-end; white-space: nowrap; }
table.history .row-actions a:not(.kit) { font-size: 12px; font-weight: 600; color: var(--muted); text-decoration: none; }
table.history .row-actions a:not(.kit):hover { color: #111; }
table.history a.kit {
  display: inline-block; white-space: nowrap; font-weight: 600; font-size: 12px; text-decoration: none;
  background: #111; color: #fff; border-radius: 7px; padding: 7px 11px;
}
table.history a.kit:hover { background: #000; }
.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; text-transform: capitalize; }
.pill-issued { background: #e6f0ff; color: #1256b8; }
.pill-pending { background: #fff2d6; color: #9a6700; }
.pill-sent { background: #dff5e6; color: #17663a; }
.pill-rejected { background: #f2f2f2; color: #888; text-decoration: line-through; }
