:root {
  --bg: #0b0e14;
  --panel: #141927;
  --panel-border: #232c42;
  --text: #e8ecf4;
  --muted: #8b94ab;
  --accent: #e8b339;
  --accent-dark: #c9962a;
  --error: #ff7a7a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #1a2138 0%, var(--bg) 55%) fixed;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 48px;
}

header { text-align: center; max-width: 640px; }
h1 { margin: 8px 0 4px; font-size: 2rem; letter-spacing: 0.5px; }
.logo { border-radius: 9px; vertical-align: -7px; margin-right: 8px; }
.tagline { color: var(--muted); margin: 0 0 24px; line-height: 1.5; }

main {
  display: grid;
  grid-template-columns: minmax(320px, 440px) minmax(300px, 380px);
  gap: 20px;
  width: 100%;
  max-width: 860px;
}

@media (max-width: 760px) {
  main { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 18px;
}

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.tabs button {
  flex: 1 1 auto;
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s ease;
}
.tabs button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #10131c;
  font-weight: 600;
}

label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 12px; }
input[type="text"], input[type="tel"], textarea, select {
  width: 100%;
  margin-top: 4px;
  background: #0e1220;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 10px;
  font-size: 0.95rem;
  font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-dark); outline-offset: 1px; }
textarea { resize: vertical; }

.row { display: flex; gap: 12px; }
.row > label { flex: 1; }
.check { display: flex; align-items: center; gap: 8px; align-self: end; padding-bottom: 10px; }
.check input { width: auto; }

input[type="color"] {
  width: 100%; height: 38px; margin-top: 4px;
  border: 1px solid var(--panel-border); border-radius: 8px;
  background: #0e1220; padding: 3px;
}
input[type="range"] { width: 100%; margin-top: 8px; accent-color: var(--accent); }
.range-value { color: var(--accent); font-weight: 600; }

.tuning { margin-top: 4px; }
.tuning summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; margin-bottom: 12px; }

.hidden { display: none; }
.error { color: var(--error); font-size: 0.85rem; margin: 4px 0 0; }

.preview-panel { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.preview {
  width: 100%;
  max-width: 300px;
  aspect-ratio: 1;
  border-radius: 10px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: padding 0.1s ease;
}
.preview svg { width: 100%; height: 100%; display: block; }
.preview.empty { opacity: 0.25; }

.payload-preview {
  font-family: ui-monospace, "Cascadia Mono", monospace;
  font-size: 0.7rem;
  color: var(--muted);
  word-break: break-all;
  max-width: 100%;
  max-height: 3.2em;
  overflow: hidden;
  margin: 0;
  text-align: center;
}

.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.actions button {
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--text);
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.15s ease;
}
.actions button.primary { background: var(--accent); border-color: var(--accent); color: #10131c; font-weight: 600; }
.actions button:hover { filter: brightness(1.12); }

.export-size { margin: 0; display: flex; align-items: center; gap: 8px; }
.export-size select { width: auto; margin: 0; }

footer { margin-top: 40px; color: var(--muted); font-size: 0.85rem; text-align: center; }
footer a { color: var(--accent); }

/* Barcode preview keeps natural width */
.preview svg { max-width: 100%; height: auto; }

/* Print: only the print area */
#print-area { display: none; }
@media print {
  body { background: #fff; padding: 0; }
  header, main, footer { display: none; }
  #print-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px;
  }
  #print-area svg { max-width: 90vw; max-height: 70vh; }
  #print-area p {
    font-family: ui-monospace, monospace;
    font-size: 10px;
    color: #333;
    word-break: break-all;
    max-width: 90vw;
    margin: 0;
  }
}
