:root {
  --bg: #0f1115; --panel: #171a21; --panel2: #1e222b; --line: #2a2f3a;
  --text: #e7e9ee; --muted: #9aa3b2; --brand: #ff5a1f; --brand-d: #e04a12;
  --radius: 12px; --shadow: 0 8px 30px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }

.topbar { position: sticky; top: 0; z-index: 20; background: rgba(15,17,21,.85);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1400px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; letter-spacing: .2px; display: flex; align-items: center; gap: 9px; }
.brand-mark { width: 22px; height: 22px; display: block; }
.topbar-actions { display: flex; gap: 10px; }

.btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--panel2);
  color: var(--text); padding: 9px 16px; border-radius: 10px; cursor: pointer; transition: .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.icon { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-sm .icon { width: 15px; height: 15px; }
.btn-icon { padding: 8px 10px; }
.btn:hover { border-color: #3a4150; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-d); border-color: var(--brand-d); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.layout { max-width: 1400px; margin: 0 auto; padding: 20px;
  display: grid; grid-template-columns: minmax(380px, 460px) 1fr; gap: 24px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.editor { display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card > summary { padding: 14px 16px; font-weight: 700; cursor: pointer; list-style: none;
  display: flex; align-items: center; justify-content: space-between; user-select: none; }
.card > summary::-webkit-details-marker { display: none; }
.card > summary::after { content: "▾"; color: var(--muted); transition: .2s; }
.card[open] > summary::after { transform: rotate(180deg); }
.card-body { padding: 0 16px 16px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.span2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label, .check { font-size: 12.5px; color: var(--muted); font-weight: 600; }
input, select, textarea { font: inherit; background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
textarea { resize: vertical; }
.check { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.check input { width: auto; }

.hint { font-size: 11.5px; color: var(--muted); line-height: 1.35; }
.cust-row { display: flex; gap: 8px; align-items: center; }
.cust-row select { flex: 1; }
.cust-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.lbl-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg-btn { font: inherit; font-size: 11px; font-weight: 700; padding: 3px 10px; background: transparent;
  color: var(--muted); border: none; cursor: pointer; transition: .12s; white-space: nowrap; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--brand); color: #fff; }
.logo-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.logo-preview { max-height: 52px; max-width: 160px; background: #fff; border-radius: 8px; padding: 4px; }

.swatches { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 12px;
  max-height: 230px; overflow: auto; padding-right: 4px; }
.swatch { display: flex; align-items: center; gap: 8px; text-align: left; padding: 7px 9px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; cursor: pointer; color: var(--text); }
.swatch:hover { border-color: #3a4150; }
.swatch.active { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.swatch-bar { width: 10px; height: 22px; border-radius: 3px; flex: none; }
.swatch-name { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.custom-panel { margin-top: 14px; padding: 14px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--panel2); }
.custom-title { font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 10px;
  text-transform: uppercase; letter-spacing: .04em; }
.color-row { display: flex; gap: 8px; align-items: center; }
.color-row input[type="color"] { width: 44px; height: 38px; padding: 2px; border-radius: 8px; cursor: pointer; flex: none; }
.color-row .hex { font-family: "SFMono-Regular", monospace; text-transform: uppercase; }

.rows-edit { width: 100%; border-collapse: collapse; }
.rows-edit th { text-align: left; font-size: 11px; color: var(--muted); font-weight: 600; padding: 4px 6px; }
.rows-edit td { padding: 3px 6px 3px 0; vertical-align: middle; }
.rows-edit td:first-child { padding-left: 0; }
.rows-edit input { padding: 7px 9px; }
.cell-sm { max-width: 92px; } .cell-xs { max-width: 64px; }
.row-del { background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 15px; padding: 6px; }
.row-del:hover { color: #ff6b6b; }

/* Preview — sticky, skalas så hela A4-sidan alltid syns */
.preview { position: sticky; top: 60px; align-self: start;
  height: calc(100vh - 80px);
  background: #2a2d35; border-radius: var(--radius); padding: 12px; overflow: auto;
  display: flex; justify-content: center; align-items: flex-start; }
.preview-scale { transform-origin: top center; }
@media (max-width: 900px) {
  .preview { position: static; height: auto; min-height: 50vh; }
}
/* Låg skärm: sticky stängs av, förhandsvisningen scrollar med sidan som vanligt */
@media (max-height: 700px) {
  .preview { position: static; height: auto; min-height: 60vh; }
}

.site-footer { display: flex; align-items: center; justify-content: center; gap: 9px;
  padding: 28px 20px 36px; color: var(--muted); font-size: 13px; }
.site-footer a { display: inline-flex; opacity: .75; transition: opacity .15s; }
.site-footer a:hover { opacity: 1; }
.site-footer img { height: 16px; width: auto; display: block; }

.print-only { display: none; }
@media print {
  .no-print { display: none !important; }
  .print-only { display: block; }
  html, body { background: #fff; }
}
