:root {
  --bg: #efe6d6;
  --ink: #1b1612;
  --muted: #6a5f53;
  --card: #fffaf1;
  --line: #d8ccb8;
  --accent: #9d3b14;
  --accent-ink: #fff7ee;
  --ok: #2a5a3a;
  --ok-bg: #e4efe6;
  --warn: #6a4a12;
  --warn-bg: #efe6d0;
  --danger-bg: #f3e0d6;
  --site: 64px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 "Avenir Next", "Segoe UI", sans-serif;
}

a {
  color: var(--accent);
}

.site {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--site);
  padding: 0 28px;
  background: #f7f0e4;
  border-bottom: 1px solid var(--line);
}

.brand {
  color: var(--ink);
  text-decoration: none;
  font: 700 18px/1 "Iowan Old Style", Palatino, serif;
  letter-spacing: -0.02em;
}

.brand span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font: 600 11px/1 "Avenir Next", "Segoe UI", sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.account {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
}

.account a,
.account button {
  font-size: 13px;
}

.who {
  color: var(--muted);
  padding-right: 6px;
}

.wrap {
  width: min(1120px, calc(100% - 40px));
  margin: 28px auto 72px;
}

.wrap-wide {
  width: min(1280px, calc(100% - 40px));
}

.page-head {
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 700;
}

h1 {
  margin: 0;
  max-width: 22ch;
  font: 700 36px/1.12 "Iowan Old Style", "Palatino Linotype", Palatino, serif;
}

.lede {
  margin: 10px 0 0;
  max-width: 52ch;
  color: var(--muted);
  font-size: 15px;
}

h2 {
  margin: 0;
  font-size: 16px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 14px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.wide {
  grid-column: 1 / -1;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

input,
select {
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: 400 15px/1.3 "Avenir Next", "Segoe UI", sans-serif;
}

input:focus,
select:focus,
button:focus-visible,
.btn:focus-visible {
  outline: 2px solid #c56a3a;
  outline-offset: 1px;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  max-width: 52ch;
}

.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin: 14px 0 0;
  color: var(--ink);
  font-weight: 400;
}

.check input {
  width: 16px;
  height: 16px;
}

.callout {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f6efe3;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

.callout strong {
  display: block;
  margin-bottom: 4px;
}

.callout code {
  font: 600 12px/1.4 ui-monospace, Menlo, monospace;
  background: #efe6d6;
  padding: 1px 5px;
  border-radius: 4px;
}

.callout-warn {
  background: var(--warn-bg);
  border-color: #e0d0a8;
  color: var(--warn);
}

.callout-ok {
  background: var(--ok-bg);
  border-color: #c7d9cb;
  color: var(--ok);
}

.advanced {
  margin-top: 14px;
}

.advanced summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.advanced .check {
  margin-top: 10px;
}

.status-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.eyebrow.tight {
  margin-bottom: 4px;
}

.run-title {
  margin: 0;
  font: 700 22px/1.15 "Iowan Old Style", Palatino, serif;
  letter-spacing: -0.02em;
}

.progress-block {
  margin-bottom: 14px;
}

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: #e8ddcc;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #9d3b14, #c45a2a);
  transition: width 0.4s ease;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.yield-summary {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  min-height: 1.2em;
}

.fix-panel {
  margin-top: 14px;
  padding: 14px;
  border-radius: 8px;
  background: var(--danger-bg);
  border: 1px solid #e4c4b4;
}

.fix-panel strong {
  display: block;
  margin-bottom: 6px;
  color: #7a2e12;
}

.fix-panel p {
  margin: 0 0 12px;
  color: #5c3a2a;
  font-size: 14px;
}

.log-wrap {
  margin-top: 14px;
}

.log-wrap summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  margin-bottom: 8px;
}

.results-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px 12px;
  margin: 0 0 14px;
}

.results-toolbar .grow {
  flex: 1 1 220px;
  min-width: 180px;
}

.toolbar-check {
  margin: 0 0 8px;
}

.email-cell {
  word-break: break-word;
}

.muted-cell {
  color: var(--muted);
}

.form-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  padding: 10px 16px;
  font: 650 14px/1 "Avenir Next", "Segoe UI", sans-serif;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
}

#start,
#submit,
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

#stop {
  background: #2b2622;
  color: #fff;
}

#stop:disabled,
#start:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.ghost:hover,
tr.pick:hover td {
  background: #f6efe3;
}

.hidden {
  display: none !important;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.stats.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stats.six {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.stats.seven {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.stats div {
  background: #f6efe3;
  border-radius: 8px;
  padding: 12px 14px;
}

.stats span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 700 22px/1.1 "Iowan Old Style", Palatino, serif;
}

.stats small,
.current,
.meta {
  color: var(--muted);
  font-size: 13px;
}

.current {
  margin: 14px 0 8px;
  min-height: 1.2em;
}

.log {
  margin: 0;
  max-height: 200px;
  overflow: auto;
  padding: 12px 14px;
  background: #1b1612;
  color: #efe6d6;
  font: 12px/1.5 ui-monospace, Menlo, monospace;
  border-radius: 8px;
}

.log-tall {
  max-height: 420px;
  margin-top: 14px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin: 0 0 14px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: 600 13px/1 "Avenir Next", "Segoe UI", sans-serif;
  cursor: pointer;
}

.chip.is-on {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--accent-ink);
}

.inline {
  min-width: 180px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.detail-grid div {
  background: #f6efe3;
  border-radius: 8px;
  padding: 10px 12px;
}

.detail-grid small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.detail-grid span {
  display: block;
  margin-top: 4px;
  font-size: 14px;
}

.cell-note {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.badge-yp {
  background: #efe0d0;
  color: #7a3b16;
}

.badge-yahoo {
  background: #e4e8f3;
  color: #2a3a6a;
}

.badge-yelp {
  background: #f3e4e4;
  color: #8a1f1f;
}

.table-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}

.table-wrap {
  overflow: auto;
  max-height: 520px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  text-align: left;
  padding: 10px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: var(--card);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

td a {
  color: var(--accent);
}

td.clip {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

td.num {
  white-space: nowrap;
}

.empty td {
  color: var(--muted);
  padding: 22px 10px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.plain {
  margin: 0;
  padding: 0;
  list-style: none;
}

.plain li {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.plain li:last-child {
  border-bottom: 0;
}

.plain:empty::before {
  content: "Nothing waiting.";
  color: var(--muted);
}

.queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.queue-item div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.queue-item strong {
  font-size: 13px;
}

.queue-item span {
  font-size: 14px;
}

.queue-item small {
  color: var(--muted);
  font-size: 12px;
}

.results-tip {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f6efe3;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.outcome-blocked .cell-note {
  color: var(--accent);
}

tr.has-email td:first-child {
  font-weight: 650;
}

#form-error:not([hidden]) {
  display: block;
  margin: 12px 0 0;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.2;
  background: #eee8dc;
  color: var(--muted);
}

.badge-done {
  background: var(--ok-bg);
  color: var(--ok);
}

.badge-error {
  background: var(--danger-bg);
  color: var(--accent);
}

.badge-queued {
  background: #eee8dc;
  color: var(--muted);
}

.badge-running,
.badge-stopping {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge-stopped {
  background: #eee8dc;
  color: var(--muted);
}

.badge-admin {
  background: var(--danger-bg);
  color: var(--accent);
}

tr.pick {
  cursor: pointer;
}

tr.pick.is-on td {
  background: #f3e8d8;
}

.error {
  min-height: 1.2em;
  margin: 8px 0 0;
  color: var(--accent);
  font-size: 13px;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.auth {
  width: min(420px, 100%);
  margin: 0;
}

.auth h1 {
  max-width: none;
  font-size: 32px;
}

.auth .panel {
  margin-bottom: 0;
}

.auth .panel label + label {
  margin-top: 14px;
}

.auth .actions {
  margin-top: 16px;
}

.auth .btn-primary {
  min-width: 120px;
}

@media (max-width: 1100px) {
  .stats.six,
  .stats.seven,
  .detail-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .grid,
  .grid-2,
  .stats,
  .stats.four,
  .stats.six,
  .stats.seven,
  .detail-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .site {
    padding: 10px 16px;
    align-items: flex-start;
    flex-direction: column;
  }

  .wrap {
    width: calc(100% - 28px);
    margin-top: 20px;
  }

  h1,
  .auth h1 {
    font-size: 28px;
  }

  .grid,
  .grid-2,
  .stats,
  .stats.four,
  .stats.six,
  .stats.seven,
  .detail-grid,
  .form-foot {
    grid-template-columns: 1fr;
    display: grid;
  }

  .status-head,
  .table-head,
  .queue-item,
  .progress-meta,
  .results-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .run-title {
    font-size: 18px;
  }

  .results-table-wrap {
    max-height: 360px;
  }

  .log {
    max-height: 140px;
  }

  .row-actions {
    flex-direction: column;
    align-items: stretch;
  }
}
