/* PAYDAY — arcade chrome, bank-grade invoice preview */

@font-face { font-family: "Press Start 2P"; font-style: normal; font-weight: 400; font-display: swap; src: url("/press-start-2p.woff2") format("woff2"); }
@font-face { font-family: "Press Start 2P Fallback"; src: local("Courier New"); size-adjust: 166.64%; ascent-override: 60%; descent-override: 0%; line-gap-override: 0%; }

:root {
  --bg: #0a0a12;
  --surface: #12121d;
  --surface-2: #1a1a2a;
  --line: #28283c;
  --text: #e9e9f2;
  --dim: #9aa0b5;
  --cyan: #45f0ff;
  --magenta: #ff3d8b;
  --gold: #ffc857;
  --green: #41ff8b;
  --red: #ff5560;
  --control-line: #5e5e80;
  --pixel: "Press Start 2P", "Press Start 2P Fallback", "Courier New", monospace;
  --body: -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --glow-cyan: 0 0 14px rgba(69, 240, 255, 0.35);
  --space-gutter: clamp(16px, 4vw, 48px);
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(1200px 500px at 50% -10%, rgba(69, 240, 255, 0.05), transparent 70%), var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
::selection { background: rgba(69, 240, 255, 0.3); }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.skip-link {
  position: absolute;
  left: 12px; top: -48px;
  z-index: 200;
  background: var(--cyan);
  color: #05050d;
  padding: 10px 16px;
  border-radius: 6px;
  font-family: var(--mono);
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.2s var(--ease-out);
}
.skip-link:focus-visible { transform: translateY(60px); }
:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgba(69, 240, 255, 0.15);
}
a { color: var(--cyan); }

.site-header {
  padding: 26px var(--space-gutter) 10px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.lab-link {
  align-self: flex-start;
  font-family: var(--pixel);
  font-size: 10px;
  color: var(--dim);
  text-decoration: none;
  padding: 6px 2px;
  transition: color 0.15s, text-shadow 0.15s;
}
.lab-link:hover { color: var(--cyan); text-shadow: var(--glow-cyan); }
.level {
  margin: 0;
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--gold);
}
.wordmark {
  margin: 6px 0 4px;
  font-family: var(--pixel);
  font-size: clamp(22px, 4.5vw, 34px);
  letter-spacing: 3px;
  color: var(--text);
  text-shadow: 0 0 16px rgba(69, 240, 255, 0.55), 3px 3px 0 var(--magenta);
}
.tagline {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--dim);
}
.cursor { color: var(--cyan); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

main {
  flex: 1;
  width: 100%;
  max-width: 1460px;
  margin: 0 auto;
  padding: 20px var(--space-gutter) 72px;
}
.app-shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  align-items: start;
}
.tools, form { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.hero-panel, .panel-head, .preview-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}
.panel-title {
  margin: 0;
  font-family: var(--pixel);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(69, 240, 255, 0.4);
}
.note, .hint, .privacy-note {
  margin: 0;
  font-size: 12px;
  color: var(--dim);
  line-height: 1.5;
}
.privacy-note { text-align: center; }
.register {
  min-width: min(100%, 230px);
  border: 1px solid rgba(255, 200, 87, 0.45);
  background: #07070d;
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 6px;
  text-align: right;
  box-shadow: inset 0 0 18px rgba(255, 200, 87, 0.08);
}
.register span {
  font-family: var(--pixel);
  font-size: 8px;
  color: var(--gold);
}
.register output {
  font-family: var(--pixel);
  font-size: clamp(14px, 4vw, 20px);
  color: var(--green);
  overflow-wrap: anywhere;
}

label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dim);
}
input, textarea, select {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  background: var(--bg);
  border: 1px solid var(--control-line);
  color: var(--text);
  border-radius: 6px;
  padding: 9px 10px;
  font: 13px var(--mono);
  transition: border-color 0.12s, box-shadow 0.12s;
}
textarea { resize: vertical; line-height: 1.45; }
input:hover, textarea:hover, select:hover { border-color: #74749a; }
input[type="color"] { padding: 2px; height: 42px; cursor: pointer; }
.field-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.upload-row, .mini-actions, .action-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.btn, .file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  min-height: 40px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s var(--ease-out), border-color 0.12s, box-shadow 0.12s, color 0.12s;
}
.btn:hover, .file-btn:hover {
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(69, 240, 255, 0.22);
  transform: translateY(-1px);
}
.btn:active, .file-btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { background: var(--cyan); border-color: var(--cyan); color: #05050d; }
.btn-primary:hover { box-shadow: 0 0 18px rgba(69, 240, 255, 0.5); }
.btn-ghost { background: transparent; }
.btn-big { font-family: var(--pixel); font-size: 11px; padding: 14px 20px; }
.danger { color: var(--red); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--dim);
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 6px 10px;
  min-height: 40px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, box-shadow 0.12s;
}
.chip:hover { border-color: var(--cyan); color: var(--text); }

.items-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.items-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}
.items-table th, .items-table td {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
.items-table th {
  font: 10px var(--pixel);
  color: var(--gold);
  background: var(--surface-2);
}
.items-table th:nth-child(2), .items-table th:nth-child(3), .items-table th:nth-child(4) { width: 110px; }
.row-total {
  font-family: var(--mono);
  color: var(--green);
  white-space: nowrap;
}
.row-actions {
  display: flex;
  gap: 5px;
  min-width: 136px;
}
.icon-btn {
  min-width: 40px;
  min-height: 40px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font: 16px var(--mono);
}
.icon-btn:hover:not(:disabled) { border-color: var(--cyan); color: var(--cyan); }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.totals {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  font-family: var(--mono);
}
.totals span, .totals strong {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.totals strong { color: var(--green); }
.validation {
  margin: 0;
  padding-left: 18px;
  color: var(--gold);
  font-size: 13px;
}
.validation:empty { display: none; }

.preview-pane {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.invoice-paper {
  --invoice-accent: #2453a6;
  width: min(100%, 794px);
  min-height: 1122px;
  margin: 0 auto;
  padding: clamp(22px, 4vw, 54px);
  background: #ffffff;
  color: #111827;
  border-radius: 2px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.invoice-top {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  padding-bottom: 24px;
  border-bottom: 1px solid #d9dee8;
}
.invoice-kicker {
  margin: 0 0 6px;
  color: var(--invoice-accent);
  font-weight: 800;
  letter-spacing: 0.14em;
  font-size: 13px;
}
.invoice-top h2 {
  margin: 0;
  color: #111827;
  font: 700 28px Georgia, "Times New Roman", serif;
}
#previewLogo {
  max-width: 160px;
  max-height: 76px;
  object-fit: contain;
}
.invoice-parties {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin: 28px 0;
}
.invoice-parties h3, .invoice-copy h3 {
  margin: 0 0 8px;
  color: var(--invoice-accent);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.invoice-parties p, .invoice-copy p, .invoice-parties dd {
  margin: 0;
  color: #1f2937;
  white-space: pre-wrap;
}
.invoice-parties > div > p:first-of-type {
  font-weight: 800;
  color: #111827;
}
.invoice-parties div div p {
  margin: 2px 0;
  color: #4b5563;
}
.invoice-meta {
  margin: 0;
  display: grid;
  gap: 8px;
  align-content: start;
}
.invoice-meta div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid #edf0f5;
  padding-bottom: 6px;
}
.invoice-meta dt { color: #6b7280; font-size: 12px; }
.invoice-meta dd { font-weight: 700; }
.preview-items {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
  font-size: 13px;
}
.preview-items th {
  background: var(--invoice-accent);
  color: #fff;
  text-align: left;
  padding: 11px 10px;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.preview-items td {
  padding: 11px 10px;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: top;
}
.preview-items td:nth-child(n+2), .preview-items th:nth-child(n+2) { text-align: right; }
.preview-summary {
  display: flex;
  justify-content: flex-end;
  margin: 24px 0;
}
.preview-summary dl {
  width: min(100%, 320px);
  margin: 0;
}
.preview-summary div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 8px 0;
  border-bottom: 1px solid #edf0f5;
}
.preview-summary dt, .preview-summary dd { margin: 0; }
.summary-total {
  margin-top: 6px;
  padding: 14px 12px !important;
  background: var(--invoice-accent);
  color: #fff;
  border-bottom: 0 !important;
  font-weight: 800;
}
.invoice-copy {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  border-top: 1px solid #d9dee8;
  padding-top: 22px;
  color: #4b5563;
}

.toasts {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(440px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.22s var(--ease-out) both;
}
.toast-info { border-left-color: var(--cyan); }
.toast-success { border-left-color: var(--green); }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity 0.25s, transform 0.25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

.site-footer {
  border-top: 1px solid var(--line);
  padding: 22px var(--space-gutter);
  text-align: center;
  color: var(--dim);
  font-size: 13px;
}
.site-footer p { margin: 0 0 6px; }
.site-footer p:last-child { margin-bottom: 0; }
.site-footer a { color: var(--cyan); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; text-shadow: var(--glow-cyan); }

@media (min-width: 700px) {
  .field-grid.two { grid-template-columns: repeat(2, 1fr); }
  .field-grid.three { grid-template-columns: repeat(3, 1fr); }
  .invoice-parties { grid-template-columns: 1fr 1fr 0.8fr; }
  .invoice-copy { grid-template-columns: 1fr 1fr; }
  .totals { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1120px) {
  .app-shell { grid-template-columns: minmax(420px, 0.9fr) minmax(560px, 1.1fr); }
  .preview-pane { position: sticky; top: 16px; }
}
@media (max-width: 520px) {
  .hero-panel, .panel-head, .preview-head { flex-direction: column; }
  .action-grid > * { width: 100%; }
  .wordmark { letter-spacing: 1px; }
  .invoice-paper { min-height: auto; }
  .invoice-top { flex-direction: column; }
}
@media (pointer: coarse) {
  .btn, .file-btn, .chip, .icon-btn { min-height: 44px; }
}
@media print {
  body { background: #fff; color: #111; display: block; }
  .site-header, .tools, .preview-head, .privacy-note, .site-footer, .toasts, .skip-link { display: none !important; }
  main { max-width: none; padding: 0; }
  .app-shell { display: block; }
  .invoice-paper {
    width: auto;
    min-height: auto;
    margin: 0;
    padding: 0;
    box-shadow: none;
    border-radius: 0;
  }
  @page { size: A4; margin: 14mm; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .cursor { animation: none; }
}
