* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0b;
  --panel: #121215;
  --panel-2: #17171b;
  --border: #232329;
  --text: #e6e6ea;
  --muted: #8a8a95;
  --green: #4ade80;
  --red: #f87171;
  --accent: #e6e6ea;
  --paper: #f4f1e8;
  --paper-ink: #1a1a1a;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--border); background: var(--panel); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn.small { width: 28px; height: 28px; }
.icon-btn.small svg { width: 14px; height: 14px; }

#refreshBtn { transition: transform .5s ease, color .15s, border-color .15s, background .15s; }

.counters { display: flex; gap: 10px; font-size: 13px; font-variant-numeric: tabular-nums; }
.counters .added { color: var(--green); }
.counters .deleted { color: var(--red); }

.ship-btn {
  margin-left: auto;
  padding: 8px 20px;
  background: var(--accent);
  color: #0a0a0b;
  border: none;
  border-radius: 6px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.ship-btn:hover { opacity: .88; }
.ship-btn:active { transform: scale(.96); }
.ship-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.deploy-list { display: flex; flex-direction: column; gap: 10px; }

.deploy-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
  transition: border-color .15s;
}
.deploy-block:hover { border-color: #33333c; }

.block-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
}
.block-header:hover { background: var(--panel-2); }

.chev {
  width: 12px;
  height: 12px;
  color: var(--muted);
  flex-shrink: 0;
  transition: transform .2s ease;
}
.deploy-block.open .chev { transform: rotate(90deg); }

.block-title {
  font-weight: 600;
  font-size: 13px;
  letter-spacing: .02em;
  white-space: nowrap;
}

.badge-new {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(74, 222, 128, .12);
  color: var(--green);
  font-weight: 700;
  letter-spacing: .05em;
}

.block-stats {
  margin-left: auto;
  display: flex;
  gap: 10px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.block-stats .added { color: var(--green); }
.block-stats .deleted { color: var(--red); }

.edit-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 3px 10px;
  border-radius: 4px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.edit-btn:hover { color: var(--text); border-color: var(--muted); }

.block-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease;
}
.deploy-block.open .block-body { max-height: 400px; }

.block-body-inner {
  padding: 12px 14px 14px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}
.block-body-inner code {
  display: block;
  padding: 3px 0;
  color: var(--text);
  font-family: inherit;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn .2s ease;
}
.overlay[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.confirm-dialog {
  width: min(420px, 100%);
  background: #2b2b2e;
  border-radius: 10px;
  padding: 20px 22px 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
  color: #e8e8e8;
  animation: dialogIn .18s ease;
}
@keyframes dialogIn { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.confirm-title { font-size: 13px; font-weight: 700; margin-bottom: 10px; color: #fff; }
.confirm-body { font-size: 13px; line-height: 1.5; color: #cfcfcf; margin-bottom: 20px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }
.confirm-actions button {
  padding: 7px 18px;
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: filter .15s, background .15s;
}
.btn-ghost { background: transparent; color: #cfcfcf; border-color: #4a4a4f; }
.btn-ghost:hover { background: #3a3a3e; }
.btn-primary { background: #4a8cff; color: #fff; }
.btn-primary:hover { filter: brightness(1.1); }

.receipt-overlay {
  align-items: flex-end;
  justify-items: center;
  background: rgba(0, 0, 0, .75);
  backdrop-filter: blur(2px);
  padding: 0;
}

.receipt-modal {
  width: min(440px, 100%);
  max-height: 92vh;
  background: var(--panel);
  border-radius: 14px 14px 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp .35s cubic-bezier(.2, .9, .3, 1);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.receipt-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  flex-shrink: 0;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  letter-spacing: .12em;
  font-weight: 700;
  color: var(--muted);
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fbbf24;
  animation: pulse 1s infinite;
}
.status.printed { color: var(--green); }
.status.printed .status-dot {
  background: var(--green);
  animation: none;
  box-shadow: 0 0 8px var(--green);
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

.toolbar-right { display: flex; align-items: center; gap: 8px; }
.branch-info { display: flex; gap: 6px; font-size: 11px; align-items: center; }
.branch {
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  background: var(--panel);
}
.hash { color: var(--muted); }

.sound-off { display: none; }
#soundToggle.muted .sound-on { display: none; }
#soundToggle.muted .sound-off { display: block; }

.receipt-scroll {
  overflow-y: auto;
  padding: 18px 18px 0;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.receipt-scroll::-webkit-scrollbar { width: 6px; }
.receipt-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.receipt-paper {
  background: var(--paper);
  color: var(--paper-ink);
  position: relative;
  font-family: "Courier New", Courier, monospace;
  font-size: 12px;
  line-height: 1.5;
  max-height: 2000px;
  overflow: hidden;
  filter: drop-shadow(0 10px 30px rgba(0, 0, 0, .35));
}
.receipt-paper.printing {
  max-height: 0;
  animation: printRoll 2.2s cubic-bezier(.35, 0, .15, 1) forwards;
}
@keyframes printRoll {
  0% { max-height: 0; }
  100% { max-height: 2000px; }
}

.receipt-inner { padding: 22px 22px 18px; }

.receipt-logo {
  text-align: center;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -1px;
  margin-bottom: 2px;
  font-family: ui-monospace, monospace;
}
.receipt-logo span { color: #888; }

.receipt-domain {
  text-align: center;
  font-size: 10px;
  letter-spacing: .2em;
  color: #777;
  margin-bottom: 16px;
  text-transform: lowercase;
}

.receipt-title {
  text-align: center;
  font-size: 12px;
  letter-spacing: .15em;
  font-weight: 700;
  padding: 8px 0;
  border-top: 2px solid var(--paper-ink);
  border-bottom: 2px solid var(--paper-ink);
  margin-bottom: 14px;
}

.meta { margin-bottom: 16px; }
.meta-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  gap: 10px;
  font-size: 11px;
}
.meta-row > span:first-child {
  color: #777;
  letter-spacing: .05em;
  flex-shrink: 0;
  font-weight: 600;
}
.meta-val {
  text-align: right;
  font-weight: 600;
  word-break: break-all;
}

.artifacts-head {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  letter-spacing: .1em;
  font-weight: 700;
  padding: 6px 0;
  border-top: 1px dashed #a5a297;
  border-bottom: 1px dashed #a5a297;
  margin-bottom: 6px;
  color: #555;
}

.artifacts { list-style: none; margin-bottom: 14px; }
.artifacts li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 11px;
  border-bottom: 1px dotted #d4d0c2;
}
.artifacts li:last-child { border-bottom: none; }
.file { font-weight: 600; color: var(--paper-ink); }
.badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .08em;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid currentColor;
}
.badge.new { color: #1a7a3e; }
.badge.iter { color: #8a5a00; }

.summary { border-top: 1px dashed #a5a297; padding-top: 10px; }
.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 11px;
  gap: 10px;
}
.summary-row > span:first-child {
  color: #777;
  letter-spacing: .05em;
  font-weight: 600;
  flex-shrink: 0;
}
.summary-row > span:last-child { font-weight: 700; }
.barcode {
  font-family: "Courier New", monospace;
  letter-spacing: 1px;
  font-size: 10px;
  word-break: break-all;
  text-align: right;
}

.receipt-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed #a5a297;
}
.link-icon {
  color: #666;
  transition: color .15s, transform .15s;
  display: grid;
  place-items: center;
}
.link-icon:hover { color: var(--paper-ink); transform: translateY(-1px); }
.link-icon svg { width: 18px; height: 18px; }

.receipt-edge {
  height: 12px;
  background: var(--paper);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M0 0 L6 12 L12 0 Z' fill='%23000'/%3E%3C/svg%3E");
  -webkit-mask-size: 12px 12px;
  -webkit-mask-repeat: repeat-x;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M0 0 L6 12 L12 0 Z' fill='%23000'/%3E%3C/svg%3E");
  mask-size: 12px 12px;
  mask-repeat: repeat-x;
}

@media (max-width: 480px) {
  .app { padding: 16px 14px 40px; }
  .receipt-inner { padding: 18px 16px 14px; }
  .receipt-scroll { padding: 12px 12px 0; }
  .branch-info .hash { display: none; }
}