:root{
  --bg:#f6f7fb; --card:#fff; --text:#1a2333; --muted:#5b6577; --soft-muted:#7a8296;
  --border:#e4e7ef; --line:#eef0f6; --input-bg:#fff; --input-border:#d4d9e6;
  --chip:#e8ebf4; --soft:#fbfcff; --shadow:rgba(20,30,60,.05); --footer:#9aa2b4;
}
body.dark{
  --bg:#10141f; --card:#1a2130; --text:#e8ecf5; --muted:#9aa4b8; --soft-muted:#8590a6;
  --border:#2a3245; --line:#232b3d; --input-bg:#121826; --input-border:#39425a;
  --chip:#262f44; --soft:#151b2a; --shadow:rgba(0,0,0,.3); --footer:#5d6880;
}
body.warm{
  --bg:#faf7f1; --card:#fdfbf7; --text:#23303a; --muted:#7a7264; --soft-muted:#8a8275;
  --border:#e7e0d3; --line:#efe9dd; --input-bg:#fdfbf7; --input-border:#d8d1c4;
  --chip:#efe9dd; --soft:#f5f1e8; --shadow:rgba(60,50,30,.06); --footer:#a39a89;
}
*{box-sizing:border-box}
body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif;background:var(--bg);color:var(--text);line-height:1.5}
h1,h2,h3{line-height:1.2}
a{color:var(--accent)}
main{max-width:980px;margin:0 auto;padding:24px 20px 60px}

.store-header{display:flex;justify-content:space-between;align-items:center;gap:16px;padding:16px 24px;background:var(--card);border-bottom:3px solid var(--accent);flex-wrap:wrap}
.brand{display:flex;align-items:center;gap:14px}
.brand h1{margin:0;font-size:22px}
.tagline{margin:2px 0 0;color:var(--muted);font-size:13px}
.logo{width:52px;height:52px;border-radius:10px;object-fit:contain}
.logo-fallback{display:flex;align-items:center;justify-content:center;background:var(--accent);color:#fff;font-size:26px;font-weight:700}
.store-header nav a{margin-left:14px;text-decoration:none;color:var(--muted);font-weight:600;font-size:14px}
.store-header nav a.active{color:var(--accent)}

.card{background:var(--card);border:1px solid var(--border);border-radius:14px;padding:22px;margin:18px 0;box-shadow:0 1px 3px var(--shadow)}
.card h2{margin-top:0;font-size:19px}
.muted{color:var(--muted);font-size:14px}
.small{font-size:12.5px;color:var(--soft-muted)}

.btn{display:inline-block;background:var(--accent);color:#fff;border:none;border-radius:9px;padding:11px 22px;font-size:15px;font-weight:650;cursor:pointer;text-decoration:none}
.pop-badge{display:inline-block;background:var(--accent);color:#fff;font-size:10.5px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;padding:2px 9px;border-radius:999px;vertical-align:middle;margin-left:6px}
.btn:disabled{opacity:.45;cursor:not-allowed}
.fld input:disabled{opacity:.45;cursor:not-allowed}
.btn.secondary{background:var(--chip);color:var(--text)}
.btn.sm{padding:6px 12px;font-size:13px}
.btn.danger{background:#c2410c}

.chip{display:inline-block;background:var(--chip);border-radius:999px;padding:4px 13px;font-size:13px;font-weight:600;margin:2px 4px 2px 0}

.drop{border:2px dashed var(--input-border);border-radius:12px;padding:26px;text-align:center;color:var(--muted);background:var(--soft)}

.spinner{width:34px;height:34px;border:4px solid var(--border);border-top-color:var(--accent);border-radius:50%;animation:spin 1s linear infinite;margin:0 auto 12px}
@keyframes spin{to{transform:rotate(360deg)}}
.center{text-align:center}

table{width:100%;border-collapse:collapse;font-size:14px}
th{text-align:left;color:var(--muted);font-size:12.5px;text-transform:uppercase;letter-spacing:.04em;padding:8px 10px;border-bottom:2px solid var(--border)}
td{padding:9px 10px;border-bottom:1px solid var(--line);vertical-align:middle}
td.num,th.num{text-align:right}
.scroll-box{max-height:420px;overflow-y:auto;border:1px solid var(--line);border-radius:10px}
.scroll-box table{margin:0}
.scroll-box th{position:sticky;top:0;background:var(--card);z-index:1}

.order-row{display:flex;gap:12px;align-items:center;padding:10px 0;border-bottom:1px solid var(--line);flex-wrap:wrap}
.order-row:last-child{border-bottom:none}
select,input[type=text],input[type=number],input[type=color],input[type=email],input[type=tel]{padding:8px 10px;border:1.5px solid var(--input-border);border-radius:8px;font-size:14px;background:var(--input-bg);color:var(--text)}
input[type=color]{padding:3px;height:44px;width:72px;cursor:pointer}
input[type=number].price{width:96px}
label.fld{display:block;margin:10px 0;font-size:14px;font-weight:600}
label.fld input,label.fld select{display:block;margin-top:4px;font-weight:400;width:100%;max-width:340px}
label.fld.check input[type=checkbox]{display:inline-block;width:auto;margin:0 7px 0 0;vertical-align:-2px}
form.inline{display:flex;gap:10px;flex-wrap:wrap;align-items:flex-end}
form.inline label{font-size:12.5px;font-weight:650;color:var(--muted);display:block}
form.inline label input{display:block;margin-top:3px}

.total-line{display:flex;justify-content:space-between;font-size:15px;padding:6px 0}
.total-line.grand{font-weight:750;font-size:18px;border-top:2px solid var(--border);margin-top:8px;padding-top:12px}

.badge{display:inline-block;padding:3px 10px;border-radius:999px;font-size:12px;font-weight:700}
.badge.ok{background:#dcfce7;color:#15803d}
.badge.pending{background:#fef3c7;color:#b45309}
.badge.sim{background:#e0e7ff;color:#4338ca}

.store-card{display:flex;justify-content:space-between;align-items:center;gap:12px}
.site-footer{text-align:center;color:var(--footer);font-size:12.5px;padding:26px 0 34px}
.hero{padding:34px 0 6px}
.hero h2{font-size:30px;margin:0 0 8px}
.step-num{display:inline-flex;width:26px;height:26px;border-radius:50%;background:var(--accent);color:#fff;font-size:14px;font-weight:700;align-items:center;justify-content:center;margin-right:8px}
.ok-text{color:#15803d;font-weight:650}
.err-text{color:#b91c1c;font-weight:650}
body.dark .ok-text{color:#4ade80}
body.dark .err-text{color:#f87171}

/* ---- prints: upload grid ---- */
.pgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:12px;margin-top:16px}
.pcard{position:relative;border:1px solid var(--border);border-radius:10px;overflow:hidden;background:var(--soft)}
.pthumb{position:relative;aspect-ratio:4/3;background:var(--chip);display:flex;align-items:center;justify-content:center}
.pthumb img{width:100%;height:100%;object-fit:cover;display:block}
.pth-fallback{display:none;font-size:30px}
.pthumb.undecodable img{display:none}
.pthumb.undecodable .pth-fallback{display:block}
.pmeta{display:flex;justify-content:space-between;gap:6px;align-items:baseline;padding:6px 9px 2px}
.pname{font-size:12px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.pstate{white-space:nowrap}
.pbar{height:4px;background:var(--line);margin:5px 9px 9px;border-radius:2px;overflow:hidden}
.pbar-fill{height:100%;width:0;background:var(--accent);transition:width .2s}
.pbar.done .pbar-fill{background:#15803d}
.premove{position:absolute;top:6px;right:6px;width:24px;height:24px;border:none;border-radius:50%;background:rgba(15,20,35,.55);color:#fff;font-size:15px;line-height:1;cursor:pointer}

/* ---- prints: order builder (photo grid + products panel) ---- */
.order-flex{display:flex;gap:20px;align-items:flex-start}
.order-flex .pgrid{flex:1;margin-top:0}
.products-panel{flex:0 0 235px;position:sticky;top:12px;border:1px solid var(--border);border-radius:12px;padding:14px 16px;background:var(--soft)}
.products-panel h3{font-size:15px}
.prod-row{display:flex;justify-content:space-between;align-items:center;gap:10px;padding:9px 0;border-bottom:1px solid var(--line)}
.prod-row:last-of-type{border-bottom:none}
.stepper{display:inline-flex;align-items:center;gap:2px;border:1.5px solid var(--input-border);border-radius:9px;background:var(--input-bg);overflow:hidden}
.stepper button{width:30px;height:30px;border:none;background:transparent;color:var(--text);font-size:17px;font-weight:700;cursor:pointer;line-height:1}
.stepper button:hover{background:var(--chip)}
.stepper b{min-width:26px;text-align:center;font-size:14px}
@media(max-width:760px){.order-flex{flex-direction:column}.products-panel{position:static;width:100%;flex:none}}

/* admin order-line thumbnails */
.mini-thumb{width:34px;height:34px;object-fit:cover;border-radius:5px;border:1px solid var(--input-border);background:var(--chip);flex:none}

/* photo selection + product tags */
.pthumb{cursor:pointer}
.sel-check{display:none;position:absolute;top:6px;left:6px;width:22px;height:22px;border-radius:50%;background:var(--accent);color:#fff;font-size:13px;font-weight:700;align-items:center;justify-content:center;box-shadow:0 1px 4px rgba(0,0,0,.35)}
.pcard.sel{border-color:var(--accent);box-shadow:0 0 0 2px var(--accent)}
.pcard.sel .sel-check{display:flex}
.chips{display:flex;flex-wrap:wrap;gap:5px;padding:0 9px 9px;min-height:8px}
.chip{display:inline-block;background:var(--chip);border-radius:999px;padding:3px 11px;font-size:12.5px;font-weight:650}
.chip-sel{border:1.5px solid var(--accent);background:color-mix(in srgb,var(--accent) 12%,var(--card));color:var(--text);border-radius:999px;padding:2px 9px;font-size:12px;font-weight:600;cursor:pointer}
.chip-sel b{font-weight:750}
.chip-sel.low{border-color:#b45309;background:#fef3c7;color:#7c3f06}
.chip-sel:hover{filter:brightness(1.05)}

/* crop preview modal (tab per chosen product) */
.modal-back{position:fixed;inset:0;background:rgba(10,14,25,.6);display:flex;align-items:center;justify-content:center;z-index:50;padding:18px}
.modal{background:var(--card);border:1px solid var(--border);border-radius:14px;padding:20px 22px;max-width:520px;width:100%;box-shadow:0 12px 40px rgba(0,0,0,.35)}
.cm-title{margin:0 0 10px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.cm-tabs{display:flex;flex-wrap:wrap;gap:6px;margin:0 0 10px}
.cm-tab{padding:5px 13px;border-radius:999px;border:1.5px solid var(--input-border);background:var(--input-bg);color:var(--text);font-size:13px;font-weight:600;cursor:pointer}
.cm-tab.active{border-color:var(--accent);background:color-mix(in srgb,var(--accent) 14%,var(--card));font-weight:750}
.cm-stage{text-align:center;margin-bottom:12px}
/* Pintura edit mode: the modal widens and the editor replaces the preview */
.modal.editing{max-width:940px}
#cm-editor{display:none}
.modal.editing #cm-editor{display:block;height:min(65vh,640px)}
.modal.editing .cm-stage,.modal.editing .cm-tabs,.modal.editing #cm-sub,.modal.editing #cm-controls{display:none}
.crop-box{display:inline-flex;align-items:center;justify-content:center;background:var(--chip);border-radius:6px;overflow:hidden;border:1px solid var(--input-border)}
.crop-box img{width:100%;height:100%;object-fit:cover;display:block}
/* #cm-box gets exact pixel width/height from JS — no CSS max clamps, they
   would silently break the print's aspect ratio once one of them kicks in */
