:root {
  --bg: #f3f5f6; --panel: #fff; --ink: #1b2228; --ink2: #4a5761; --muted: #7b8892; --line: #dfe4e8; --line2: #eef1f3;
  --accent: #0f5f6b; --accent-ink: #fff; --accent-soft: #e2f0f1; --danger: #b3261e; --warn: #9a6200; --ok: #1f7a3a;
  --radius: 7px; --mono: ui-monospace, "SF Mono", Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 28px 0 10px; }
h3 { font-size: 14px; margin: 18px 0 6px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .center { text-align: center; } .nowrap { white-space: nowrap; }
.r { text-align: right; } .ok-t { color: var(--ok); } .err-t { color: var(--danger); } .warn-t { color: var(--warn); font-weight: 600; }
.strike { text-decoration: line-through; }

/* header */
.top { display: flex; align-items: center; gap: 18px; padding: 0 20px; height: 54px; background: #182127; color: #dfe6ea; position: sticky; top: 0; z-index: 20; }
.top .brand { color: #fff; font-weight: 700; font-size: 15px; white-space: nowrap; }
.top nav.main { display: flex; gap: 2px; flex: 1; }
.top nav.main a { color: #b9c5cc; padding: 7px 12px; border-radius: 6px; white-space: nowrap; }
.top nav.main a:hover { background: #26323a; color: #fff; text-decoration: none; }
.top nav.main a.on { background: #2c3b44; color: #fff; }
.top .who { display: flex; gap: 14px; align-items: center; font-size: 13px; white-space: nowrap; }
.top .who a { color: #b9c5cc; }
.top .uname { color: #fff; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.langsw { display: inline-flex; gap: 6px; }
.langsw b { color: inherit; }
.top .langsw b { color: #fff; } .top .langsw a { color: #8fa0aa; }
.badge { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 9px; background: #e8a33d; color: #1b1300; font-size: 11px; font-weight: 700; text-align: center; line-height: 18px; }
.navtg, .navbtn { display: none; }
.imp-bar { background: #fff3cd; color: #5c4400; padding: 8px 20px; font-size: 13px; border-bottom: 1px solid #ead9a0; }

main.wrap { max-width: 1320px; margin: 0 auto; padding: 22px 20px 60px; }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.head-row h1 small { font-weight: 400; font-size: 15px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; margin: 0; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 13px; border: 1px solid #c9d1d7; background: #fff; color: var(--ink);
  border-radius: var(--radius); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; line-height: 1.3; }
.btn:hover { background: #f4f7f8; border-color: #aeb9c1; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #0c4f59; }
.btn.danger { color: var(--danger); border-color: #e4bcb9; }
.btn.danger:hover { background: #fdf1f0; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink2); }
.btn.ghost:hover { background: #e8ecee; }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn.big { padding: 11px 22px; font-size: 15px; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* forms */
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid #c9d1d7; border-radius: 6px; padding: 7px 9px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9fd0d6; outline-offset: 0; border-color: var(--accent); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
input[type=file] { padding: 6px; }
textarea { resize: vertical; }
label { display: block; font-size: 12.5px; color: var(--ink2); font-weight: 500; margin-bottom: 10px; }
label > input, label > select, label > textarea { margin-top: 4px; }
label.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink); }
fieldset { border: 1px solid var(--line); background: var(--panel); border-radius: 9px; padding: 14px 16px 6px; margin: 0 0 16px; min-width: 0; }
fieldset > .btn, fieldset > form > .btn { margin-bottom: 10px; }
legend { font-weight: 700; padding: 0 6px; font-size: 13px; }
.grid2, .grid3 { display: grid; gap: 0 12px; }
.grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.form-actions { display: flex; gap: 8px; align-items: center; margin: 4px 0 16px; flex-wrap: wrap; }
.sp { flex: 1; }
.narrow { max-width: 640px; }
.stack { display: grid; gap: 8px; margin-bottom: 10px; }
.preview { max-width: 100%; border-radius: 6px; border: 1px solid var(--line); display: block; margin-bottom: 8px; }
dl.meta { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 6px 0 12px; font-size: 13px; }
dl.meta dt { color: var(--muted); } dl.meta dd { margin: 0; }
.note { background: #fffbea; border: 1px solid #f0e2a6; padding: 10px 12px; border-radius: 7px; margin: 12px 0; }
.pw { font-size: 15px; background: #fff; padding: 2px 8px; border-radius: 4px; user-select: all; }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; background: var(--panel); padding: 10px; border: 1px solid var(--line); border-radius: 9px; }
.filters input, .filters select { width: auto; min-width: 0; }
.filters .grow { flex: 1 1 240px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 9px 14px; color: var(--ink2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs a small { color: var(--muted); font-weight: 400; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.bulk { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.portal-note { background: var(--accent-soft); border: 1px solid #bcdcdf; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }

/* tables */
.tbl-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 9px 10px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
.tbl th.r { text-align: right; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: #f8fafb; }
.tbl tfoot td { border-top: 1px solid var(--line); border-bottom: 0; padding: 6px 10px; }
.tbl tfoot .grand td { font-weight: 700; font-size: 15px; }
.tbl.compact td { padding: 4px 8px; }
.tbl .thumb { width: 54px; padding: 4px 6px; }
.tbl .thumb img { width: 46px; height: 46px; object-fit: cover; border-radius: 5px; border: 1px solid var(--line); display: block; background: #fff; }
.tbl input.num { width: 72px; text-align: right; padding: 4px 6px; }
.tbl input.price { width: 88px; }
.rowlink { cursor: pointer; }
.hidden-row td { color: var(--muted); }
.hidden-row td a { color: #5f8a91; }
tr.over td { background: #fff4f2; }
.catalog .specs { color: var(--ink2); margin-top: 3px; max-width: 520px; }
.addcart { display: flex; gap: 4px; justify-content: flex-end; margin: 0; }
.addcart input.num { width: 58px; }
label.del { display: inline-flex; gap: 3px; margin: 0; cursor: pointer; color: var(--danger); font-size: 13px; }
.addline { display: flex; gap: 8px; margin: 12px 0; }
.addline input.num { width: 80px; }
.tag { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 4px; background: #eef1f3; color: var(--ink2); }
.grade { display: inline-block; font-size: 11px; font-weight: 700; padding: 0 5px; border-radius: 4px; background: #e6f2e9; color: #1f6b35; }
.grade.gB { background: #fff2d6; color: #7a5400; } .grade.gC { background: #fbe5e3; color: #8c2a22; }

/* statuses */
.st { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 10px; vertical-align: middle; }
.st-new { background: #fff1d6; color: #8a5a00; }
.st-confirmed { background: #dff0f7; color: #145f80; }
.st-shipped { background: #e1f3e6; color: #1f6b35; }
.st-cancelled { background: #eceff1; color: #6b7780; }

/* cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-bottom: 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; color: var(--ink); }
a.card:hover { border-color: var(--accent); text-decoration: none; }
.card .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.card .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.card .v small { font-size: 13px; font-weight: 500; color: var(--muted); }
.card .s { font-size: 12.5px; color: var(--ink2); }

/* flash */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 10px; border: 1px solid; }
.flash.ok { background: #eaf6ee; border-color: #b9dfc4; color: #17552a; }
.flash.error { background: #fdefee; border-color: #f0c4c0; color: #8a1f18; }

/* pager */
.pager { display: flex; gap: 4px; flex-wrap: wrap; margin: 14px 0; }
.pager a, .pager b, .pager span { padding: 5px 10px; border-radius: 6px; border: 1px solid var(--line); background: #fff; font-size: 13px; }
.pager b { background: var(--accent); color: #fff; border-color: var(--accent); }
.pager span { border: 0; background: transparent; }

/* login */
body.guest { background: linear-gradient(160deg, #182127 0, #182127 320px, var(--bg) 320px); }
.login-box { max-width: 400px; margin: 60px auto 0; background: var(--panel); border-radius: 12px; padding: 26px 28px 16px; box-shadow: 0 10px 40px rgba(16,24,30,.18); }
.login-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.login-box h1 { font-size: 20px; }
.login-box .btn { margin-top: 6px; }

/* responsive */
@media (max-width: 980px) {
  .cols { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .top { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 8px; }
  .navbtn { display: block; margin-left: auto; font-size: 22px; cursor: pointer; color: #fff; padding: 0 4px; }
  .top nav.main, .top .who { display: none; width: 100%; }
  .navtg:checked ~ nav.main { display: flex; flex-direction: column; }
  .navtg:checked ~ .who { display: flex; flex-wrap: wrap; padding: 6px 0 4px; }
  main.wrap { padding: 16px 16px 50px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .filters .grow { flex-basis: 100%; }
  .filters select { flex: 1 1 45%; }
  .tbl th, .tbl td { padding: 7px 7px; }
  .catalog .specs { display: none; }
  .catalog thead { display: none; }
  .catalog tbody tr:not(.empty) { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 3px 10px; padding: 10px; border-bottom: 1px solid var(--line2); }
  .catalog tbody tr:not(.empty) td { border: 0; padding: 0; }
  .catalog td.thumb { grid-column: 1; grid-row: 1 / 4; width: auto; }
  .catalog td:nth-child(2) { grid-column: 2 / 4; grid-row: 1; }
  .catalog td:nth-child(3) { grid-column: 2; grid-row: 2; }
  .catalog td:nth-child(4) { grid-column: 3; grid-row: 2; text-align: right; }
  .catalog td.avail { grid-column: 2; grid-row: 3; text-align: left; color: var(--ink2); }
  .catalog td.avail::before { content: attr(data-label); }
  .catalog td:nth-child(6) { grid-column: 3; grid-row: 3; }
  .catalog td:nth-child(7) { grid-column: 1 / 4; grid-row: 4; padding-top: 4px; }
}

/* waiting customers */
.rq-waiting { background: #fff1d6; color: #8a5a00; }
.rq-building { background: #e8e4fb; color: #4a3a9a; }
.rq-ready { background: #d7f0e0; color: #11602d; box-shadow: inset 0 0 0 1px #8fd0a8; }
.rq-notified { background: #dff0f7; color: #145f80; }
.rq-done { background: #e1f3e6; color: #1f6b35; }
.rq-cancelled { background: #eceff1; color: #6b7780; }
.phl { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.btn.ph { padding: 3px 8px; font-size: 12px; font-weight: 600; color: var(--ink2); }
.btn.ph.call { color: var(--accent); }
.contact-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.contact-bar .btn.ph { padding: 8px 14px; font-size: 14px; }
.phwrap { margin-top: 4px; }
.match { display: inline-block; font-size: 12px; font-weight: 600; background: #d7f0e0; color: #11602d; padding: 1px 7px; border-radius: 9px; }
.clip { max-width: 520px; }
.assigned { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; background: var(--panel); border: 1px solid #8fd0a8; border-radius: 9px; padding: 10px 14px; }
ul.log { list-style: none; margin: 8px 0 10px; padding: 0; max-height: 460px; overflow: auto; }
ul.log li { display: flex; gap: 8px; padding: 7px 0; border-top: 1px solid var(--line2); font-size: 13px; }
ul.log .li { width: 18px; flex: none; text-align: center; }
#log .form-actions { margin: 6px 0 4px; }
@media (max-width: 760px) {
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tabs a { white-space: nowrap; padding: 9px 11px; }
  .reqs thead { display: none; }
  .reqs tbody tr { display: block; padding: 10px 12px; border-bottom: 1px solid var(--line2); }
  .reqs tbody td { display: inline-block; border: 0 !important; padding: 2px 8px 2px 0 !important; vertical-align: middle; }
  .reqs td:nth-child(1), .reqs td:nth-child(2) { display: block; }
  .reqs td.r { text-align: left; }
}

/* services in admin form */
.service-only { display: none; }
body.is-service .stock-only { display: none; }
body.is-service .service-only { display: block; }

/* admin photo list */
.imgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin-bottom: 10px; }
.imgbox { border: 1px solid var(--line); border-radius: 7px; padding: 5px; background: #fafbfc; }
.imgbox img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; display: block; }
.imgbox label { margin: 4px 0 0; font-size: 11.5px; gap: 4px; }
.imgbox label.del { color: var(--danger); }

/* catalogue rows open the item dialog */
.catalog tr.itemrow { cursor: pointer; }
.catalog .item-link { color: var(--ink); }
.catalog .item-link:hover { color: var(--accent); }
.catalog .thumb a { position: relative; display: block; }
.imgn { position: absolute; right: 2px; bottom: 2px; background: rgba(16,24,30,.75); color: #fff; font-size: 10px; font-weight: 700; padding: 0 4px; border-radius: 4px; line-height: 15px; }

/* item dialog */
.itemdlg { border: 0; padding: 0; border-radius: 12px; width: min(960px, calc(100vw - 32px)); max-height: calc(100vh - 32px); box-shadow: 0 20px 60px rgba(10,16,20,.35); background: var(--panel); color: var(--ink); overflow: auto; }
.itemdlg::backdrop { background: rgba(14,20,24,.6); }
.dlg-close { position: absolute; top: 10px; right: 10px; z-index: 3; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(255,255,255,.92); box-shadow: 0 1px 4px rgba(0,0,0,.2); font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink); }
.dlg-close:hover { background: #fff; }
.dlg-loading { padding: 80px; text-align: center; color: var(--muted); font-size: 24px; }
.item { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 0; }
.item.noimg { grid-template-columns: 1fr; }
.item-info { padding: 24px 26px; display: flex; flex-direction: column; gap: 4px; }
.item-title { font-size: 20px; margin: 2px 40px 8px 0; line-height: 1.3; }
.item-specs { white-space: normal; background: #f6f8f9; border-radius: 8px; padding: 10px 12px; font-size: 13.5px; margin: 6px 0 10px; }
.item-buy { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line2); display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.item-price b { font-size: 24px; letter-spacing: -.01em; }
.item-price .strike { margin-left: 6px; }
.item-buy .addcart { justify-content: flex-start; }
.item-buy .addcart input.num { width: 70px; }
.item-page { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }

/* gallery */
.gallery { background: #f1f3f5; display: flex; flex-direction: column; min-width: 0; }
.g-main { position: relative; aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.g-img { display: none; max-width: 100% !important; max-height: 100% !important; object-fit: contain; cursor: zoom-in; }
.g-img.on { display: block; }
.g-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255,255,255,.9); box-shadow: 0 1px 5px rgba(0,0,0,.2); font-size: 26px; line-height: 1; cursor: pointer; color: var(--ink); }
.g-prev { left: 10px; } .g-next { right: 10px; }
.g-nav:hover { background: #fff; }
.g-count { position: absolute; left: 10px; bottom: 10px; background: rgba(16,24,30,.7); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 10px; }
.g-zoom { position: absolute; right: 10px; bottom: 10px; width: 32px; height: 32px; border-radius: 6px; border: 0; background: rgba(255,255,255,.9); cursor: pointer; font-size: 16px; }
.g-thumbs { display: flex; gap: 6px; padding: 8px; overflow-x: auto; background: #e9ecef; }
.g-thumbs button { flex: none; width: 58px; height: 58px; padding: 0; border: 2px solid transparent; border-radius: 6px; overflow: hidden; cursor: pointer; background: #fff; }
.g-thumbs button.on { border-color: var(--accent); }
.g-thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* zoomed: photo fills the screen */
.gallery.zoomed { position: fixed; inset: 0; z-index: 50; background: #0d1215; }
.gallery.zoomed .g-main { aspect-ratio: auto; flex: 1; }
.gallery.zoomed .g-img { cursor: zoom-out; }
.gallery.zoomed .g-thumbs { background: #182127; justify-content: center; }

@media (max-width: 760px) {
  .itemdlg { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; }
  .item { grid-template-columns: 1fr; }
  .item-info { padding: 16px; }
  .dlg-close { position: fixed; }
}
