:root {
  --ink: #17191c;
  --ink-soft: #292d32;
  --surface: #f5f6f8;
  --panel: #ffffff;
  --rule: #d8dce2;
  --rule-soft: #e9ebef;
  --text: #24282e;
  --muted: #66707c;
  --faint: #87909b;
  --go: #1b7f5a;
  --halt: #b3261e;
  --hold: #9a6700;
  --accent: #e12b23;
  --accent-dark: #bd211b;

  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------------------------------------------------- dispatch bar (the hero) */

.dispatch {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #c8201a;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 18px rgba(200, 32, 26, 0.25);
}

.dispatch__inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.dispatch__mailbox {
  font-size: 16px;
  font-weight: 600;
}

.dispatch__mailbox::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 15px;
  margin-right: 10px;
  vertical-align: -2px;
  background: var(--go);
}

.dispatch__mode {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.17);
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 5px;
}

.dispatch__mode--send {
  background: var(--halt);
  border-color: var(--halt);
}

.dispatch__state {
  margin-left: auto;
  font-size: 13px;
  color: #fff;
  background: var(--go);
  border-radius: 999px;
  padding: 5px 12px;
  font-weight: 600;
}

.dispatch__state strong {
  font-family: var(--mono);
  color: #fff;
  font-weight: 500;
}

/* LIVE SEND changes the whole bar's character, not just a badge. */
.dispatch.is-live {
  background: #2a1113;
  border-bottom-color: var(--halt);
}

.dispatch.is-live .dispatch__mailbox::before {
  background: var(--halt);
}

/* ------------------------------------------------------------------ structure */

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 36px 28px 96px;
}

.intro {
  margin: 0 0 40px;
  padding: 28px 32px;
  max-width: none;
  display: flex;
  align-items: center;
  gap: 28px;
  background: var(--panel);
  border: 1px solid var(--rule-soft);
  border-left: 5px solid var(--accent);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(23, 25, 28, 0.045);
}

.intro__logo {
  display: block;
  width: min(36%, 280px);
  height: auto;
  flex: 0 0 auto;
  object-fit: contain;
}

.intro__copy {
  max-width: 56ch;
}

.intro__eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.intro h1 {
  margin: 0 0 6px;
  font-size: 30px;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.intro p {
  margin: 0;
  color: var(--muted);
}

.intro .intro__eyebrow {
  color: var(--accent);
}

.cc-panel {
  margin: -18px 0 24px;
  padding: 20px 24px;
  background: var(--panel);
  border: 1px solid var(--rule-soft);
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(23, 25, 28, 0.035);
}

.cc-panel__heading h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 680;
}

.cc-panel__heading h2 span {
  margin-left: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.cc-panel__heading p,
.cc-panel__help {
  margin: 4px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.cc-panel label {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  font-weight: 600;
}

.cc-panel input {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.cc-panel input:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(225, 43, 35, 0.14);
  outline-offset: 1px;
}

.cc-panel__help {
  margin: 7px 0 0;
  font-size: 12px;
}

.sig-panel {
  margin-top: 0;
}

.sig-panel textarea {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  resize: vertical;
}

.sig-panel textarea:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(225, 43, 35, 0.14);
  outline-offset: 1px;
}

.sig-panel__actions {
  margin: 12px 0 0;
}

.sig-panel__status {
  color: var(--muted);
  font-size: 13px;
}

.stage {
  margin-bottom: 20px;
  padding: 24px 28px 26px 76px;
  position: relative;
  background: var(--panel);
  border: 1px solid var(--rule-soft);
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(23, 25, 28, 0.035);
}

.stage[hidden] {
  display: none;
}

.stage--active {
  border-color: #efc7c4;
  box-shadow: 0 8px 22px rgba(23, 25, 28, 0.055);
}

.stage__num {
  position: absolute;
  left: 0;
  top: 24px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--muted);
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #f8f8f9;
}

.stage--active .stage__num {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.stage__title {
  margin: 0 0 4px;
  font-size: 19px;
  font-weight: 680;
  letter-spacing: -0.01em;
}

.stage__hint {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
  max-width: 66ch;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--rule);
  padding: 22px;
}

/* ---------------------------------------------------------------- drop target */

.drop {
  border: 1px dashed #c9cdd4;
  border-radius: 9px;
  background: #fafafb;
  padding: 38px 22px;
  text-align: center;
  cursor: pointer;
}

.drop.is-over {
  border-color: var(--accent);
  border-style: solid;
  background: #fff8f7;
}

.drop__primary {
  font-weight: 560;
  margin: 0 0 4px;
}

.drop__secondary {
  margin: 0;
  font-size: 13px;
  color: var(--faint);
}

.drop input[type="file"] {
  display: none;
}

.filerow {
  display: flex;
  align-items: flex-end;
  gap: 26px;
  margin-top: 14px;
  font-size: 14px;
  flex-wrap: wrap;
}

.filerow__slot {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* The optional slot reads as an aside, not a second required step. */
.filerow__slot--optional {
  flex-direction: row;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}

.filerow__label {
  font-size: 12px;
  color: var(--muted);
}

.filerow__slot--optional .filerow__label {
  color: var(--faint);
}

.filerow__name {
  font-family: var(--mono);
  font-size: 13px;
}

.filerow__slot--optional .filerow__name {
  color: var(--faint);
}

.filerow__pick {
  padding: 4px 10px;
  font-size: 13px;
}

/* A simulated row must never be mistaken for a delivered one. */
.simulated {
  color: var(--hold);
}

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

/* -------------------------------------------------------------------- buttons */

.btn {
  font: inherit;
  font-weight: 540;
  padding: 9px 18px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  background: var(--ink-soft);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--quiet {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule);
}

.btn--quiet:hover:not(:disabled) {
  background: var(--surface);
}

.btn--go {
  background: var(--accent);
  border-color: var(--accent);
}

.btn--go:hover:not(:disabled) {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.btn--halt {
  background: var(--halt);
  border-color: var(--halt);
}

.btn--halt:hover:not(:disabled) {
  background: #8f1e18;
}

/* ------------------------------------------------------------------- counters */

.counters {
  display: flex;
  border: 1px solid var(--rule);
  background: var(--panel);
  margin-bottom: 20px;
  border-radius: 8px;
  overflow: hidden;
}

.counter {
  padding: 16px 22px;
  border-right: 1px solid var(--rule-soft);
  flex: 1;
  min-width: 0;
}

.counter:last-child {
  border-right: 0;
}

.counter__value {
  font-family: var(--mono);
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.counter__label {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.stats-panel__counters {
  margin: 14px 0 0;
}

.counter--ready .counter__value {
  color: var(--go);
}

.counter--rejected .counter__value {
  color: var(--halt);
}

/* --------------------------------------------------------------------- ledger */

.ledger {
  border: 1px solid var(--rule);
  background: var(--panel);
  max-height: 300px;
  overflow: auto;
}

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

.ledger th {
  position: sticky;
  top: 0;
  background: var(--surface);
  text-align: left;
  font-size: 12px;
  font-weight: 620;
  color: var(--muted);
  padding: 9px 14px;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}

.ledger td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--rule-soft);
  vertical-align: top;
}

.ledger tr:last-child td {
  border-bottom: 0;
}

.ledger .num,
.ledger .addr {
  font-family: var(--mono);
  font-size: 13px;
  white-space: nowrap;
}

.ledger .num {
  color: var(--faint);
  text-align: right;
}

.ledger .reason {
  color: var(--halt);
}

.ledger .ok {
  color: var(--go);
}

.section-label {
  margin: 24px 0 10px;
  font-size: 14px;
  font-weight: 620;
}

/* -------------------------------------------------------------------- preview */

.preview {
  border: 1px solid var(--rule);
  background: var(--panel);
  border-radius: 8px;
  overflow: hidden;
}

.preview__tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
}

.preview__tab {
  font: inherit;
  font-family: var(--mono);
  font-size: 13px;
  padding: 10px 16px;
  border: 0;
  border-right: 1px solid var(--rule);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.preview__tab[aria-selected="true"] {
  background: var(--panel);
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.preview__meta {
  padding: 14px 18px;
  border-bottom: 1px solid var(--rule-soft);
  font-size: 14px;
}

.preview__meta div {
  display: flex;
  gap: 10px;
  padding: 2px 0;
}

.preview__meta dt {
  color: var(--muted);
  min-width: 62px;
}

.preview__meta dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-word;
}

.preview iframe {
  display: block;
  width: 100%;
  height: 620px;
  border: 0;
  background: #f2f4f7;
}

/* ------------------------------------------------------------------- dispatch */

.modes {
  display: grid;
  gap: 12px;
  margin-bottom: 22px;
}

.mode {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
}

.mode:has(input:checked) {
  border-color: var(--ink);
  box-shadow: inset 3px 0 0 var(--ink);
}

.mode:has(input:checked[value="send"]) {
  border-color: var(--halt);
  box-shadow: inset 3px 0 0 var(--halt);
}

.mode__body strong {
  display: block;
  font-weight: 600;
}

.mode__body span {
  font-size: 13px;
  color: var(--muted);
}

.confirm {
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--panel);
  padding: 20px;
}

.confirm__statement {
  margin: 0 0 16px;
  font-size: 15px;
  line-height: 1.6;
}

.confirm__statement b {
  font-family: var(--mono);
  font-weight: 500;
}

.confirm__row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.confirm input[type="text"] {
  font-family: var(--mono);
  font-size: 15px;
  padding: 9px 12px;
  border: 1px solid var(--rule);
  background: var(--panel);
  width: 150px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ------------------------------------------------------------------- progress */

.progress {
  height: 6px;
  background: var(--rule-soft);
  border: 1px solid var(--rule);
  margin: 4px 0 16px;
  overflow: hidden;
}

.progress__fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.4s ease;
}

.progress__fill.is-done {
  background: var(--go);
}

.runstate {
  display: flex;
  gap: 20px;
  align-items: baseline;
  flex-wrap: wrap;
  font-size: 14px;
  margin-bottom: 6px;
}

.runstate__count {
  font-family: var(--mono);
  font-size: 20px;
  letter-spacing: -0.02em;
}

.runstate__event {
  color: var(--muted);
  font-size: 13px;
}

/* --------------------------------------------------------------------- notice */

.notice {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--muted);
  background: var(--panel);
  padding: 14px 18px;
  margin-bottom: 18px;
  font-size: 14px;
}

.notice--error {
  border-left-color: var(--halt);
  background: #fdf6f5;
}

.notice--warn {
  border-left-color: var(--hold);
  background: #fdfaf3;
}

.notice--ok {
  border-left-color: var(--go);
  background: #f4faf7;
}

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

.notice ul {
  margin: 6px 0 0;
  padding-left: 20px;
}

.notice li {
  margin: 3px 0;
}

.notice code {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--surface);
  padding: 1px 5px;
}

.empty {
  padding: 26px 22px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  background: var(--panel);
  border: 1px solid var(--rule);
}

@media (max-width: 720px) {
  main {
    padding: 26px 16px 72px;
  }

  .intro {
    padding: 22px 20px;
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .cc-panel {
    margin-top: -18px;
    padding: 18px;
  }

  .stage {
    padding: 20px;
  }

  .intro__logo {
    width: min(72%, 260px);
  }

  .intro h1 {
    font-size: 26px;
  }

  .stage {
    padding: 20px;
  }

  .stage__num {
    position: static;
    margin-bottom: 10px;
  }

  .counters {
    flex-direction: column;
  }

  .counter {
    border-right: 0;
    border-bottom: 1px solid var(--rule-soft);
  }

  .dispatch__state {
    margin-left: 0;
  }
}

.preview__on {
  color: var(--go);
  font-weight: 600;
}

.preview__off {
  color: var(--faint);
}

/* ---- sign-in ---- */
[hidden] { display: none !important; }
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--surface); }
.login__card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; padding: 32px; display: flex; flex-direction: column; gap: 8px; }
.login__logo { height: 40px; width: auto; align-self: flex-start; margin-bottom: 8px; }
.login__card h1 { margin: 0; font-size: 22px; }
.login__card p { margin: 0 0 8px; color: var(--muted); font-size: 14px; }
.login__card label { font-size: 13px; font-weight: 600; margin-top: 8px; }
.login__card input { padding: 10px 12px; border: 1px solid var(--rule); border-radius: 6px; font: inherit; }
.login__card .btn { margin-top: 16px; }
.login__error { background: #fdecea; color: var(--halt); border: 1px solid #f3c0bb; border-radius: 6px; padding: 8px 12px; font-size: 13px; }
.login__card textarea { padding: 10px 12px; border: 1px solid var(--rule); border-radius: 6px; font: inherit; resize: vertical; }
.login__switch { background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; margin-top: 8px; text-decoration: underline; }
.login__error--ok { background: #e8f5ee; color: var(--go); border-color: #b7dfc9; }

