:root {
  --bg: #e8edf2;
  --bg-2: #f7f9fb;
  --ink: #14181f;
  --muted: #5b6573;
  --line: #c9d2dc;
  --accent: #0b6e4f;
  --accent-ink: #063d2c;
  --bad: #9b1d2e;
  --warn: #8a5a00;
  --ok: #0b6e4f;
  --shadow: 0 18px 50px rgba(20, 24, 31, 0.08);
  --font-display: "Syne", sans-serif;
  --font-body: "Source Sans 3", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--ink);
  font-family: var(--font-body);
  background:
    linear-gradient(180deg, rgba(232,237,242,0.92), rgba(232,237,242,0.96)),
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent 47px,
      rgba(20,24,31,0.04) 47px,
      rgba(20,24,31,0.04) 48px
    ),
    repeating-linear-gradient(
      0deg,
      transparent 0,
      transparent 47px,
      rgba(20,24,31,0.04) 47px,
      rgba(20,24,31,0.04) 48px
    );
}

a { color: var(--accent-ink); }
.shell { max-width: 1120px; margin: 0 auto; padding: 28px 20px 64px; }
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}
.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.45rem;
  letter-spacing: -0.03em;
  text-decoration: none;
  color: var(--ink);
}
.brand span { color: var(--accent); margin-left: 0.15rem; }
.top-meta { display: flex; gap: 14px; align-items: center; }
.who { color: var(--muted); font-size: 0.95rem; }
.ghost {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}
.ghost:hover { color: var(--ink); }

.panel {
  background: var(--bg-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 22px 22px 26px;
  margin-bottom: 22px;
}
.panel-head h1, .panel-head h2 {
  font-family: var(--font-display);
  letter-spacing: -0.03em;
  margin: 0 0 6px;
}
.panel-head p { margin: 0; color: var(--muted); }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0 0 8px;
}
.lede { font-size: 1.05rem; color: var(--muted); max-width: 42rem; }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.muted { color: var(--muted); }
.empty { color: var(--muted); }

.login-stage {
  min-height: 70vh;
  display: grid;
  align-items: center;
}
.login-copy {
  max-width: 34rem;
  background: var(--bg-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 36px 32px;
}
.login-copy h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 2.8rem);
  letter-spacing: -0.04em;
  line-height: 1.05;
  margin: 0 0 12px;
}
.fine { margin-top: 18px; color: var(--muted); font-size: 0.9rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: #f4fff9;
  border: 0;
  padding: 0.85rem 1.2rem;
  font: 600 1rem var(--font-body);
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: 0.55; cursor: wait; }
.btn.google { margin-top: 0; }
.banner.ok {
  background: #d8f3e8;
  color: var(--ok);
  border: 1px solid #b7e4d0;
  padding: 0.75rem 0.9rem;
  margin: 14px 0;
}
.auth-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}
.auth-form label,
.invite-form label {
  display: grid;
  gap: 6px;
  font-weight: 600;
  font-size: 0.92rem;
}
.auth-form input,
.invite-form input,
.invite-form select {
  font: 500 1rem var(--font-body);
  padding: 0.75rem 0.8rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}
.auth-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  margin: 18px 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  background: var(--line);
}
.invite-form { margin-top: 18px; }
.invite-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.7fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
@media (max-width: 800px) {
  .invite-grid { grid-template-columns: 1fr; }
}
.inline-form { display: inline; margin: 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.danger-btn { color: var(--bad); border-color: #e2b4bc; }
.pill.invited { background: #fff1cc; color: var(--warn); }
.pill.active { background: #d8f3e8; color: var(--ok); }
.pill.revoked { background: #f6d6dc; color: var(--bad); }

.upload-form { display: grid; gap: 16px; margin-top: 18px; }
.drop {
  display: grid;
  gap: 6px;
  place-items: start;
  border: 1.5px dashed #8ea0b3;
  background: #eef3f7;
  padding: 28px 22px;
  cursor: pointer;
}
.drop input { display: none; }
.drop strong { font-size: 1.05rem; }
.drop span { color: var(--muted); font-size: 0.92rem; }
.drop.drag { border-color: var(--accent); background: #e4f5ee; }
.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 720px) { .row { grid-template-columns: 1fr; } }
label { display: grid; gap: 6px; font-weight: 600; font-size: 0.92rem; }
label em { font-weight: 400; color: var(--muted); }
input[type="text"] {
  font: 500 1rem var(--font-mono);
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}
.status { margin: 0; color: var(--muted); }
.banner {
  margin: 14px 0 0;
  padding: 10px 12px;
  background: #e7f1ec;
  border-left: 3px solid var(--accent);
}
.banner.bad {
  background: #f8e8eb;
  border-left-color: var(--bad);
  color: #6e1522;
}

.table-wrap { overflow: auto; margin-top: 14px; border: 1px solid var(--line); }
.table-wrap.wide { max-height: 480px; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  background: #fff;
}
table.data th, table.data td {
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data thead th {
  position: sticky;
  top: 0;
  background: #f0f4f8;
  font-weight: 600;
  z-index: 1;
}
table.dense { font-family: var(--font-mono); font-size: 0.78rem; }

.pill {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #e6ebf0;
}
.pill.queued, .pill.running { background: #fff1cc; color: var(--warn); }
.pill.succeeded { background: #d8f3e8; color: var(--ok); }
.pill.failed { background: #f6d6dc; color: var(--bad); }

.run-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.download-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.download-strip a {
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid var(--accent);
}
.download-strip a:hover { color: var(--accent); }

.call-review .call-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.call-card {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: #fff;
  text-decoration: none;
  color: inherit;
}
.call-card:hover {
  border-color: var(--accent);
}
.call-card strong {
  font-family: var(--font-display);
  font-size: 1.05rem;
}
.call-card .mono { font-size: 0.85rem; }

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0 0;
}
.toolbar input[type="search"],
.toolbar select {
  flex: 1;
  min-width: 180px;
  font: 500 1rem var(--font-body);
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.btn.ghost-btn {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
}

.anno-page { margin-top: 22px; }
.anno-page h3 {
  font-family: var(--font-display);
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}
.anno-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.anno-card {
  display: grid;
  gap: 8px;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  padding: 8px;
  cursor: zoom-in;
  font: inherit;
  color: inherit;
}
.anno-card:hover { border-color: var(--accent); }
.anno-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background:
    linear-gradient(45deg, #e6ebf0 25%, transparent 25%) 0 0 / 16px 16px,
    linear-gradient(-45deg, #e6ebf0 25%, transparent 25%) 0 8px / 16px 16px,
    #f7f9fb;
}
.anno-meta { display: grid; gap: 2px; }
.anno-meta strong {
  font-size: 0.86rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.anno-meta em { color: var(--muted); font-style: normal; font-size: 0.8rem; }

.viewer {
  border: 0;
  padding: 0;
  width: min(1200px, 96vw);
  max-width: 96vw;
  height: min(900px, 92vh);
  background: #10141a;
  color: #f2efe8;
  box-shadow: 0 30px 80px rgba(0,0,0,0.45);
}
.viewer::backdrop { background: rgba(10, 12, 16, 0.72); }
.viewer-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid #2a3340;
  background: #161b22;
}
.viewer-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.viewer-body {
  display: grid;
  grid-template-columns: 1fr 240px;
  height: calc(100% - 58px);
}
@media (max-width: 860px) {
  .viewer-body { grid-template-columns: 1fr; }
  .viewer-side { display: none; }
}
.viewer-stage {
  overflow: hidden;
  position: relative;
  background:
    linear-gradient(45deg, #1a222c 25%, transparent 25%) 0 0 / 24px 24px,
    linear-gradient(-45deg, #1a222c 25%, transparent 25%) 0 12px / 24px 24px,
    #0f1318;
  cursor: grab;
  touch-action: none;
}
.viewer-stage.dragging { cursor: grabbing; }
.viewer-stage img {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1);
  transform-origin: center center;
  max-width: none;
  user-select: none;
  pointer-events: none;
}
.viewer-side {
  border-left: 1px solid #2a3340;
  padding: 12px;
  overflow: auto;
  background: #141a21;
}
.viewer-side h4 { margin: 0 0 10px; font-family: var(--font-display); }
.viewer-side ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.viewer-side li {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 0.82rem;
  border-bottom: 1px solid #243040;
  padding-bottom: 6px;
}
.tok-kind {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.68rem;
  color: #8fd6b5;
  min-width: 3.2rem;
}
.viewer .btn.ghost-btn {
  background: #222a35;
  color: #f2efe8;
  border-color: #3a4656;
}
.viewer .muted { color: #9aa7b8; }

.progress-panel.is-running .progress-fill {
  background: linear-gradient(90deg, #0b6e4f, #1ea57a, #0b6e4f);
  background-size: 200% 100%;
  animation: progress-shine 1.4s linear infinite;
}
.progress-panel.is-failed .progress-fill { background: var(--bad); }
.progress-pct {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--accent-ink);
}
.progress-track {
  height: 12px;
  background: #d7dee6;
  border: 1px solid var(--line);
  overflow: hidden;
  margin-top: 12px;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.35s ease;
}
@keyframes progress-shine {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}
.progress-meta {
  margin-top: 8px;
  min-height: 1.2em;
  font-family: var(--font-mono);
  font-size: 0.86rem;
}
.progress-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 18px;
  margin-top: 18px;
}
@media (max-width: 820px) {
  .progress-grid { grid-template-columns: 1fr; }
}
.progress-grid h3 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 1rem;
}
.step-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.step {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  align-items: start;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #fff;
}
.step strong { display: block; }
.step em {
  display: block;
  font-style: normal;
  color: var(--muted);
  font-size: 0.86rem;
  margin-top: 2px;
}
.step-mark {
  width: 12px;
  height: 12px;
  margin-top: 4px;
  border-radius: 50%;
  background: #c5ced8;
  box-shadow: inset 0 0 0 2px #fff;
}
.step.done .step-mark { background: var(--ok); }
.step.active .step-mark {
  background: #e0a800;
  box-shadow: 0 0 0 3px rgba(224, 168, 0, 0.25);
}
.step.error .step-mark { background: var(--bad); }
.step.active {
  border-color: #e0a800;
  background: #fffaf0;
}
.page-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.page-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--line);
  background: #fff;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}
.page-chip small { color: var(--muted); }
.page-chip.active {
  border-color: #e0a800;
  background: #fff6df;
  box-shadow: 0 0 0 2px rgba(224, 168, 0, 0.18);
}
.page-chip.done { border-color: #8fd6b5; background: #e8f7f0; }
.page-chip.skipped { opacity: 0.55; }
.page-chip.error { border-color: #e7a0ab; background: #fbeaed; }
