:root {
  --bg: #f6f5f2; --panel: #ffffff; --ink: #1f2328; --muted: #6b7280; --line: #e4e2dc;
  --accent: #d5541f; --accent-ink: #ffffff; --ok: #1f7a4d; --warn: #a15c00; --bad: #b42318;
  --shadow: 0 1px 2px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14161a; --panel: #1c1f24; --ink: #e8e8ea; --muted: #9aa0aa; --line: #2d3139;
    --accent: #f26b36; --ok: #4cc38a; --warn: #f0b34a; --bad: #ff7b72; --shadow: none; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px 48px; }
header.top { display: flex; align-items: center; gap: 12px; padding: 16px 0; flex-wrap: wrap; }
header.top h1 { font-size: 20px; margin: 0; flex: 1 1 auto; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab { background: none; border: 0; padding: 10px 14px; cursor: pointer; color: var(--muted); font: inherit; border-bottom: 2px solid transparent; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
button, .btn { font: inherit; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-block; }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
input, select { font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); min-width: 0; }
.banner { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; box-shadow: var(--shadow); }
.banner.error { border-color: var(--bad); }
.muted { color: var(--muted); font-size: 13px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters input[type="search"] { flex: 1 1 220px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr.row { cursor: pointer; }
tbody tr.row:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
td.num, th.num { text-align: right; white-space: nowrap; }
.items { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; border: 1px solid currentColor; white-space: nowrap; }
.pill.ok { color: var(--ok); } .pill.warn { color: var(--warn); } .pill.bad { color: var(--bad); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 14px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; box-shadow: var(--shadow); }
.tile .v { font-size: 24px; font-weight: 650; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; box-shadow: var(--shadow); margin-bottom: 16px; }
.panel h2 { font-size: 15px; margin: 0 0 10px; }
.chart { width: 100%; height: 220px; }
.chart rect { fill: var(--accent); }
.chart text { fill: var(--muted); font-size: 10px; }
.login { max-width: 340px; margin: 18vh auto 0; padding: 0 16px; }
.login form { display: grid; gap: 10px; }
.err { color: var(--bad); min-height: 1.2em; font-size: 14px; }
.detail { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .detail { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 4px 10px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.noprint-bar { display: flex; gap: 8px; margin: 16px 0; }
@media print {
  body { background: #fff; color: #000; font-size: 12pt; }
  .noprint-bar, header.top .btn, .tabs { display: none !important; }
  .panel, .card { border: 1px solid #999; box-shadow: none; }
}

.uploads { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.uploads figure { margin: 0; }
.uploads img { width: 100%; height: auto; max-height: 320px; object-fit: contain; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.uploads figcaption { margin-top: 4px; }
@media print { .uploads img { max-height: 240px; } .uploads { grid-template-columns: repeat(3, 1fr); } }

.noprint {}
@media print { .noprint, #banner, .pager { display: none !important; } #pick .card { border: 0; } th, td { padding: 4px 8px; } }
.thumb { width: 64px; height: 64px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; background: #fff; vertical-align: middle; }
.brandhead { font-size: 16px; margin: 20px 0 8px; }
@media print { .thumb { width: 90px; height: 90px; } }
.pf { margin-bottom: 8px; } .pfname { font-weight: 600; font-size: 13px; }
.ordercard { margin-bottom: 10px; } .orderhead { font-size: 12px; padding: 6px 12px 0; } .ordercard th, .ordercard td { padding-top: 4px; padding-bottom: 4px; }

.pfwrap { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.pf { width: 124px; }
.pf .pfname { margin-bottom: 4px; }
.pf .thumb { width: 124px; height: 124px; display: block; }
.pfrow { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 12px; }
.pfrow select.small { flex: 1; min-width: 0; }
.pfadd { width: 190px; display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px dashed var(--line); border-radius: 8px; }
select.small, button.small, input.small { font-size: 12px; padding: 3px 6px; border-radius: 6px; }
input.small { max-width: 100%; }
td .pfwrap { min-width: 270px; }
@media print { .pf .thumb { width: 150px; height: 150px; } }
input.sizein { width: 64px; }

.ordercard { padding: 0 0 4px; }
.orderhead { padding: 10px 16px 6px; font-size: 14px; border-bottom: 1px solid var(--line); }
.item { padding: 12px 16px; border-bottom: 1px solid var(--line); } .item:last-child { border-bottom: 0; }
.itemtop { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.specs { display: flex; flex-wrap: wrap; gap: 8px 28px; align-items: flex-end; }
.spec .k { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.spec .v { font-size: 17px; font-weight: 600; }
.qty { display: flex; align-items: baseline; gap: 2px; } .qty .n { font-size: 28px; font-weight: 700; line-height: 1; } .qty .x { color: var(--muted); }
.itemact { text-align: right; } .small { font-size: 12px; }
.pfwrap { gap: 16px; }
.pf { width: 150px; } .pf .thumb { width: 150px; height: 150px; }
.pfname { font-size: 13px; line-height: 1.3; min-height: 34px; }
details.pfedit, details.pfadd { font-size: 12px; margin-top: 4px; }
details summary { cursor: pointer; color: var(--muted); }
details.pfadd { width: 150px; min-height: 150px; border: 1px dashed var(--line); border-radius: 8px; padding: 10px; align-self: flex-start; }
details.pfadd[open] { width: 210px; }
.editgrid { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.editgrid label { display: flex; flex-direction: column; gap: 2px; color: var(--muted); }
.editgrid select, .editgrid input[type=number] { font-size: 13px; padding: 4px 6px; border-radius: 6px; width: 100%; }
.editgrid input[type=file] { font-size: 12px; max-width: 100%; }
.sizepair { display: flex; gap: 6px; } .sizepair select { width: 80px; flex: none; } .sizepair input { flex: 1; min-width: 0; }
button.linkbtn { background: none; border: 0; padding: 0; color: var(--bad); font-size: 12px; text-align: left; cursor: pointer; }
@media print { .pf, .pf .thumb { width: 160px; } .pf .thumb { height: 160px; } .item { break-inside: avoid; } }

.item { display: grid; grid-template-columns: 240px 1fr; gap: 20px; align-items: start; }
.itemleft { display: flex; flex-direction: column; gap: 10px; }
.specs { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.spec .v { font-size: 16px; font-weight: 600; word-break: break-word; }
.itemact { text-align: left; margin-top: 4px; } .itemact button { width: 100%; padding: 10px 14px; }
.pfwrap { margin: 0; }
@media (max-width: 700px) { .item { grid-template-columns: 1fr; } }

.orderhead { display: flex; justify-content: space-between; align-items: center; gap: 12px; position: relative; }
details.pfadd { width: auto; min-height: 0; border: 0; padding: 0; align-self: center; } details.pfadd[open] { width: auto; }
details.pfadd summary { color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; background: var(--panel); list-style: none; font-size: 13px; }
details.pfadd summary::-webkit-details-marker { display: none; }
.addpanel { position: absolute; right: 16px; top: 100%; z-index: 5; width: 230px; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.25); margin-top: 4px; }
.item { grid-template-columns: 200px 1fr 170px; }
.itemact { text-align: right; } .itemact button { width: 100%; }
@media (max-width: 800px) { .item { grid-template-columns: 1fr; } }
.ordercard { overflow: visible; }

.item { grid-template-columns: 1fr 2fr; }
.pfwrap { justify-content: flex-end; }
.headact { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.headact button { padding: 4px 12px; font-size: 13px; }
@media (max-width: 800px) { .item { grid-template-columns: 1fr; } .pfwrap { justify-content: flex-start; } }

.headname { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.custthumb { width: 30px; height: 30px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); background: #fff; display: block; margin-left: 2px; }

.neworder { padding: 16px; }
.formgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.formgrid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.formgrid label.wide { grid-column: 1 / -1; }
.formgrid input, .formgrid select, .formgrid textarea { font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
.itemform { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.pill.ready { color: #2f6fd0; }
@media (prefers-color-scheme: dark) { .pill.ready { color: #6aa5ff; } }

.bulkbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
select.stagesel { font-size: 13px; padding: 3px 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
select.stagesel.st-design { color: var(--warn); } select.stagesel.st-print { color: #2f6fd0; } select.stagesel.st-printed { color: #7b4fd0; } select.stagesel.st-ship { color: var(--ok); }
@media (prefers-color-scheme: dark) { select.stagesel.st-print { color: #6aa5ff; } select.stagesel.st-printed { color: #b79bff; } }
.bulkbar[hidden] { display: none; }
