:root {
  --ink: #16181d;
  --ink-soft: #5b616e;
  --line: #d9dce3;
  --bg: #fbfbfc;
  --panel: #ffffff;
  --accent: #1f4ea8;
  --flag: #8a5a00;
  --flag-bg: #fdf4e3;
  --flag-line: #e8d5a8;
  --highlight: rgba(255, 214, 0, 0.34);
  --highlight-line: #c99a00;
  --radius: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

h2, h3 { font-weight: 600; letter-spacing: -0.01em; }
.state-label { font-size: 1.05rem; margin: 0 0 4px; }

.note { color: var(--ink-soft); font-size: 0.875rem; }
.note.subtle { color: #7b818e; font-size: 0.82rem; }

button {
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 15px;
  cursor: pointer;
}
button:hover { border-color: #b9bec9; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.linklike {
  border: none;
  background: none;
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.linklike:hover { border: none; }

/* ---------- State 1 ---------- */

#dropzone {
  border: 1.5px dashed #c3c8d2;
  border-radius: 10px;
  background: #fff;
  min-height: 46vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: border-color .12s, background .12s;
}
#dropzone.over { border-color: var(--accent); background: #f4f7fd; }
#dropzone:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.drop-title { font-size: 1.55rem; font-weight: 500; margin: 0 0 6px; }
.drop-sub { margin: 0; color: var(--ink-soft); font-size: 0.9rem; }

#samples {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 22px;
}

#privacy-note { margin: 0 0 4px; }
#limits-note { margin: 0; }

/* ---------- State 2 ---------- */

#log {
  list-style: none;
  margin: 14px 0 0;
  padding: 16px 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.83rem;
  color: #2c313b;
  min-height: 40vh;
}
#log li { padding: 3px 0; }
#log li::before { content: "\2192\00a0"; color: #a7adb9; }
#log li.final::before { content: "\2713\00a0"; color: #2f7d42; }

/* ---------- State 3 ---------- */

#results-head { margin-bottom: 14px; }
#results-head #again { margin-top: 6px; display: inline-block; }

.banner {
  border: 1px solid var(--flag-line);
  background: var(--flag-bg);
  color: var(--flag);
  border-radius: var(--radius);
  padding: 10px 13px;
  font-size: 0.875rem;
  margin-bottom: 14px;
}

/* The everything-was-queued heading. Same weight as the truncation banner:
   this is a statement about the result, not a warning about it. */
.banner.queued {
  font-weight: 500;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 0.9rem;
}
th, td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid #eceef2;
  vertical-align: top;
}
th {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  font-weight: 600;
  background: #f7f8fa;
}
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; width: 56px; }
td.field { width: 24%; }

tr.flagged { background: var(--flag-bg); }
tr.corrected td.value { font-weight: 600; }

.undetermined {
  color: var(--flag);
  font-weight: 600;
  letter-spacing: 0.02em;
  font-size: 0.82rem;
}

.conf {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 6px;
  color: var(--ink-soft);
  white-space: nowrap;
}
.conf.high { color: #1d6b33; border-color: #bcdcc4; background: #f2f9f4; }
.conf.medium { color: #7a5c00; border-color: #e5d3a0; background: #fdf7e8; }
.conf.low { color: #8a3a12; border-color: #e8c3ad; background: #fdf1ea; }
.conf.none { color: #6a6f7a; }

.flag-note {
  display: block;
  font-size: 0.78rem;
  color: var(--flag);
  margin-top: 3px;
}

/* ---------- Exceptions ---------- */

#exceptions { margin-top: 26px; }
#exceptions-title { font-size: 0.95rem; margin: 0 0 10px; }

.exception {
  border: 1px solid var(--flag-line);
  background: #fff;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.exception h4 { margin: 0 0 2px; font-size: 0.92rem; font-weight: 600; }
.exception .why { font-size: 0.83rem; color: var(--flag); margin: 0 0 9px; }
.exception .controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.exception input[type=text] {
  font: inherit;
  font-size: 0.88rem;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 240px;
  flex: 1 1 240px;
}
.exception.resolved { border-color: #bcdcc4; background: #f7fcf8; }
.exception .resolved-note { font-size: 0.83rem; color: #1d6b33; margin: 8px 0 0; }

.empty-queue {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

/* ---------- Actions ---------- */

#actions {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
#action-status { flex-basis: 100%; }

.closing {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 0.86rem;
  color: var(--ink-soft);
  max-width: 62ch;
}

/* ---------- Provenance panel ---------- */

/* An author display rule beats the user-agent rule for [hidden], so the
   hidden state has to be restated here or the panel is visible on load. */
#panel[hidden] { display: none; }

#panel {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 27, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  overflow: auto;
  z-index: 40;
}
#panel-inner {
  background: var(--panel);
  border-radius: 8px;
  max-width: 860px;
  width: 100%;
  padding: 16px 18px 18px;
}
#panel-inner header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 12px;
}
#panel-field { margin: 0 0 2px; font-size: 1rem; }
#panel-where { margin: 0; }

#panel-figure {
  position: relative;
  line-height: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
}
#panel-image { width: 100%; height: auto; display: block; }
#panel-boxes { position: absolute; inset: 0; }
.hl {
  position: absolute;
  background: var(--highlight);
  border: 1.5px solid var(--highlight-line);
  border-radius: 2px;
}
#panel-sentence {
  margin: 12px 0 0;
  font-size: 0.86rem;
  color: #2c313b;
  background: #f7f8fa;
  border-left: 3px solid var(--highlight-line);
  padding: 9px 12px;
  line-height: 1.5;
}

/* ---------- Webhook ---------- */

#webhook {
  margin-top: 22px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
#webhook label {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 4px;
}
#webhook .note { margin: 0 0 10px; max-width: 70ch; }

.webhook-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.webhook-row input[type=url] {
  font: inherit;
  font-size: 0.9rem;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  flex: 1 1 320px;
  min-width: 0;
}
.webhook-row input[type=url]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

#webhook-status { margin: 9px 0 0; }
#webhook-status.posted { color: #1d6b33; }
#webhook-status.refused { color: var(--flag); }

#contained-note { margin: 0 0 4px; }

.contact {
  margin: 10px 0 0;
  font-size: 0.86rem;
  color: var(--ink-soft);
  max-width: 62ch;
}

.retention { color: var(--ink-soft); }

/* ---------- Narrow screens ----------
   A five-column table cannot fit a phone, and a sideways-scrolling table on a
   sales page reads as broken. Below this width each row becomes a stacked
   block with its own labels, so nothing overflows horizontally. */

@media (max-width: 600px) {
  #app { padding: 20px 16px 56px; }

  table, thead, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  table { border: none; background: none; }

  tbody tr {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 10px;
    padding: 10px 12px;
  }
  tbody tr.flagged { border-color: var(--flag-line); background: var(--flag-bg); }

  td { border: none; padding: 2px 0; }
  td.field {
    font-weight: 600;
    font-size: 0.95rem;
    padding-bottom: 6px;
  }
  td.num, th.num { text-align: left; width: auto; }

  /* Label every cell except the field name, which is the block's heading. */
  td[data-label]::before {
    content: attr(data-label) ": ";
    color: var(--ink-soft);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  .drop-title { font-size: 1.3rem; }
  #dropzone { min-height: 34vh; }
  #samples { flex-direction: column; align-items: stretch; }
  #samples button { width: 100%; text-align: left; }

  .exception input[type=text] { min-width: 0; flex: 1 1 100%; }
  .exception .controls { gap: 6px; }
  #actions button { flex: 1 1 100%; }

  #panel { padding: 0; align-items: stretch; }
  #panel-inner {
    border-radius: 0;
    min-height: 100%;
    padding: 12px 14px 20px;
  }
  #panel-inner header {
    position: sticky;
    top: 0;
    background: var(--panel);
    padding-bottom: 8px;
    z-index: 2;
  }
  #panel-close { flex: 0 0 auto; }
}
