:root { --accent:#1f6feb; --bg:#f6f8fa; --line:#d0d7de; --ink:#1f2328; }
* { box-sizing: border-box; }
body { margin:0; font-family:-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;
       background:var(--bg); color:var(--ink); }
.topbar { display:flex; justify-content:space-between; align-items:center;
          background:#fff; border-bottom:1px solid var(--line); padding:.7rem 1.2rem; }
.brand { font-weight:700; text-decoration:none; color:var(--ink); }
.logout { color:#666; text-decoration:none; font-size:.9rem; }
main { max-width:960px; margin:1.5rem auto; padding:0 1rem; }
h1 { font-size:1.4rem; }
.row.between { display:flex; justify-content:space-between; align-items:center; }
.card { background:#fff; border:1px solid var(--line); border-radius:10px; padding:1.2rem; }
.login { max-width:340px; margin:4rem auto; }
.login h1 { margin-top:0; }
label { display:block; margin:.6rem 0; font-size:.9rem; color:#444; }
input { width:100%; padding:.5rem .6rem; border:1px solid var(--line); border-radius:7px;
        font-size:1rem; margin-top:.25rem; }
.btn { display:inline-block; background:#eaeef2; color:var(--ink); border:1px solid var(--line);
       border-radius:7px; padding:.5rem .9rem; text-decoration:none; cursor:pointer; font-size:.9rem; }
.btn.primary { background:var(--accent); color:#fff; border-color:var(--accent); }
.btn.big { width:100%; padding:.8rem; font-size:1.1rem; margin-top:1rem; }
.btn.disabled { opacity:.5; cursor:not-allowed; }
button { font: inherit; }
button.btn, button[type=submit] { background:var(--accent); color:#fff; border:1px solid var(--accent);
       border-radius:7px; padding:.6rem 1rem; cursor:pointer; }
.flash { padding:.7rem 1rem; border-radius:8px; margin-bottom:1rem; }
.flash.ok { background:#e6ffed; border:1px solid #34d058; }
.flash.error { background:#ffeef0; border:1px solid #d73a49; }
.grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(240px,1fr)); gap:1rem; margin-top:1rem; }
.template { text-align:center; }
.thumb, .label-preview { width:100%; border:1px solid var(--line); border-radius:6px; background:#fff;
        image-rendering: pixelated; }
.tname { margin:.6rem 0; font-weight:600; font-size:.95rem; }
.print-layout { display:grid; grid-template-columns:1fr 1fr; gap:1.5rem; align-items:start; }
.preview-pane { position:sticky; top:1rem; }
.hint { color:#777; font-size:.8rem; text-align:center; }
.back { color:#666; text-decoration:none; font-size:.9rem; }
.copies input { width:90px; }
@media (max-width:640px){ .print-layout{grid-template-columns:1fr;} }

/* dashboard tweaks */
.row.gap { display:flex; gap:.5rem; justify-content:center; }
.row.gap2 { display:flex; gap:.6rem; }
.row.gap2 label { flex:1; }

/* editor */
.editor-head { margin:.5rem 0 1rem; gap:.6rem; flex-wrap:wrap; }
.tname-input { width:auto; flex:1; min-width:180px; font-size:1.05rem; font-weight:600; margin:0; }
.editor-layout { display:grid; grid-template-columns:1fr 280px; gap:1.2rem; align-items:start; }
.label-canvas { position:relative; background:#fff; border:1px solid #999;
  box-shadow:0 1px 6px rgba(0,0,0,.1); overflow:hidden; user-select:none; touch-action:none; }
.el { position:absolute; box-sizing:border-box; cursor:move; white-space:nowrap;
  line-height:1.05; color:#000; padding:0; overflow:visible; }
.el.sel { outline:1.5px solid var(--accent); outline-offset:1px; }
.el-barcode { background:repeating-linear-gradient(90deg,#000 0 2px,#fff 2px 4px);
  color:#0000; border:1px solid #bbb; }
.el-barcode.sel, .el-qr, .el-rect { color:#333; }
.el-qr { background:#eee; border:1px solid #999; display:flex; align-items:center;
  justify-content:center; font-size:11px; color:#555; }
.el-rect { border:1px solid #000; background:transparent; }
.el-field { color:#1f6feb; }
.resize { position:absolute; right:-5px; bottom:-5px; width:11px; height:11px;
  background:var(--accent); border:1px solid #fff; border-radius:2px; cursor:nwse-resize; display:none; }
.el.sel .resize { display:block; }
.props label { display:block; margin:.5rem 0; font-size:.82rem; color:#444; }
.props input, .props select { width:100%; }
.props .chk { display:flex; align-items:center; gap:.4rem; }
.props .chk input { width:auto; }
.btn.danger { background:#ffeef0; border-color:#d73a49; color:#d73a49; padding:.3rem .6rem; }
.muted { color:#888; font-size:.85rem; }
.preview-block { margin-top:1rem; max-width:540px; }
@media (max-width:760px){ .editor-layout{grid-template-columns:1fr;} }
