/* Light by default; follow the OS and only go dark when the system asks. */
:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --panel-2: #f6f7f9;
  --line: #e3e5ea;
  --text: #1b1f27;
  --muted: #687085;
  --accent: #2f6df6;
  --ok: #1f9d4e;
  --warn: #c4760a;
  --err: #e02e24;
  --off: #9aa1ad;
  --input-bg: #ffffff;
  --ghost: #eceef2;
  --ghost-hover: #e2e5ec;
  --log-bg: #f7f8fa;
  --log-ts: #98a0b0;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --panel: #171a21;
    --panel-2: #1f232c;
    --line: #2a2f3a;
    --text: #e7e9ee;
    --muted: #9aa3b2;
    --accent: #4f8cff;
    --ok: #34c759;
    --warn: #ff9f0a;
    --err: #ff453a;
    --off: #8e8e93;
    --input-bg: #11141a;
    --ghost: #262b35;
    --ghost-hover: #2f3542;
    --log-bg: #0c0e12;
    --log-ts: #56607a;
  }
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font:
    14px/1.45 -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    Roboto,
    sans-serif;
}
.app {
  display: grid;
  grid-template-columns: 360px 1fr;
  grid-template-rows: auto 1fr;
  height: 100%;
}
header {
  grid-column: 1 / 3;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
header h1 {
  font-size: 15px;
  margin: 0;
  font-weight: 650;
  letter-spacing: 0.2px;
}
header .target {
  color: var(--muted);
  font-size: 12px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
}
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--off);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
  transition: background 0.2s;
}
.dot.live {
  background: var(--ok);
}
.dot.err {
  background: var(--err);
}
.spacer {
  flex: 1;
}
.pill {
  font-size: 12px;
  color: var(--muted);
}

aside {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.group {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
}
.group h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin: 0 0 10px;
  font-weight: 600;
}
label.field {
  display: block;
  margin-bottom: 10px;
}
label.field:last-child {
  margin-bottom: 0;
}
label.field > span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
input,
select,
textarea {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
  outline: none;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
}
input.mono {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
}
.row {
  display: flex;
  gap: 8px;
}
.row > * {
  flex: 1;
}
button {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 9px 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button.ghost {
  background: var(--ghost);
  color: var(--text);
}
button.ghost:hover {
  background: var(--ghost-hover);
}
button:active {
  transform: translateY(1px);
}
.hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
}
.seg {
  display: flex;
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.seg button {
  flex: 1;
  background: transparent;
  color: var(--muted);
  border-radius: 0;
  font-weight: 500;
  padding: 7px;
}
.seg button.on {
  background: var(--accent);
  color: #fff;
}
.log {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 11px;
  line-height: 1.5;
  background: var(--log-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  height: 150px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.log .ts {
  color: var(--log-ts);
}
.log .ok {
  color: var(--ok);
}
.log .er {
  color: var(--err);
}
.log .wa {
  color: var(--warn);
}

main {
  position: relative;
  overflow-y: auto;
  padding: 22px;
}
/* The Epson editor is only a render engine — kept off-screen (still lays out and
   rasterizes to canvas), never shown. Fixed size so a full receipt renders. */
#editor {
  position: absolute;
  left: -10000px;
  top: 0;
  width: 620px;
  height: 2400px;
  border: 0;
}
.empty {
  color: var(--muted);
  text-align: center;
  margin: 80px auto 0;
  max-width: 380px;
}
.empty b {
  color: var(--text);
}

/* Receipt grid — one card per job, as many as come in. */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
  align-items: start;
}
.card {
  background: #fbfbf7;
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  animation: pop 0.35s ease-out;
}
@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.card img {
  display: block;
  width: 100%;
  height: auto;
}
.card .cap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-family: -apple-system, sans-serif;
  font-size: 12px;
  color: #333;
  border-top: 1px dashed #ddd;
}
.card .cap .jid {
  flex: 1;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  color: #666;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card .badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.badge.ok {
  background: #d5f6dd;
  color: #14823a;
}
.badge.pending {
  background: #ffe9c7;
  color: #9a5b00;
}
.badge.fail {
  background: #ffd9d6;
  color: #b3261e;
}
.card .acts {
  display: flex;
  gap: 6px;
  padding: 0 10px 9px;
}
.card .acts button {
  flex: 1;
  padding: 5px;
  font-size: 12px;
}
