/* B&B Order Desk - professional UI */
:root {
  --accent: #a01e4c;
  --accent-dark: #841840;
  --accent-bg: #fbe9f0;
  --ink: #1c2128;
  --ink-2: #55606e;
  --ink-3: #8b95a3;
  --line: #e6e8ec;
  --line-2: #d4d8de;
  --surface: #ffffff;
  --surface-1: #f7f8fa;
  --surface-0: #f0f2f5;
  --ok: #1a7f4b; --ok-bg: #e5f4ec;
  --warn: #9a6700; --warn-bg: #fdf3d7;
  --bad: #c1362f; --bad-bg: #fbeae9;
  --info: #3730a3; --info-bg: #e7e7fb;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(20,25,35,.06), 0 4px 16px rgba(20,25,35,.06);
  --shadow-pop: 0 8px 30px rgba(20,25,35,.16);
  --sidebar: 64px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font: 14.5px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--ink); background: var(--surface-0); -webkit-font-smoothing: antialiased; }
button { font: inherit; cursor: pointer; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
h1,h2,h3,h4 { font-weight: 600; margin: 0; }
a { color: var(--accent); text-decoration: none; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid transparent; border-radius: var(--radius); padding: 9px 15px; background: var(--accent); color: #fff; font-weight: 600; font-size: 14px; line-height: 1; transition: background .12s, box-shadow .12s; }
.btn:hover { background: var(--accent-dark); }
.btn.secondary { background: #fff; color: var(--ink); border-color: var(--line-2); }
.btn.secondary:hover { background: var(--surface-1); }
.btn.ghost { background: transparent; color: var(--accent); padding: 7px 10px; }
.btn.ghost:hover { background: var(--accent-bg); }
.btn.danger { background: var(--bad); }
.btn.danger:hover { background: #a82c26; }
.btn.big { padding: 12px 20px; font-size: 15px; }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn .ti { font-size: 18px; }

/* form fields */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.inp, .field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line-2); border-radius: var(--radius);
  padding: 9px 11px; background: #fff; transition: border-color .12s, box-shadow .12s;
}
.field input:focus, .field select:focus, .field textarea:focus, .inp:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg);
}
.field textarea { resize: vertical; }
.row { display: flex; gap: 12px; } .row > * { flex: 1; min-width: 0; }
@media (max-width: 620px) { .row { flex-direction: column; gap: 0; } }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; text-transform: capitalize; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.pending { background: var(--warn-bg); color: var(--warn); }
.badge.confirmed { background: var(--ok-bg); color: var(--ok); }
.badge.completed { background: var(--info-bg); color: var(--info); }
.badge.cancelled { background: var(--bad-bg); color: var(--bad); }
.badge.unpaid { background: var(--bad-bg); color: var(--bad); }
.badge.deposit { background: var(--warn-bg); color: var(--warn); }
.badge.paid { background: var(--ok-bg); color: var(--ok); }
.badge.refunded { background: var(--surface-0); color: var(--ink-2); }
.badge.plain { background: var(--surface-0); color: var(--ink-2); } .badge.plain::before { display:none; }

/* ===== login ===== */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--surface-0); }
.login-card { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: 36px; width: 380px; max-width: 100%; }
.login-card .logo { width: 240px; max-width: 90%; height: auto; display: block; margin: 0 auto 8px; }
.login-card .sub { color: var(--ink-3); margin: 2px 0 24px; text-align: center; font-size: 15px; }

/* ===== app shell ===== */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; padding: 14px 0; position: sticky; top: 0; height: 100vh; gap: 4px; }
.sidebar .brandmark { width: 40px; height: 40px; border-radius: 10px; background: #fff; border: 1px solid var(--line); object-fit: contain; padding: 3px; margin-bottom: 14px; }
.sidebar .navbtn { width: 44px; height: 44px; border: 0; background: none; border-radius: 10px; color: var(--ink-3); display: flex; align-items: center; justify-content: center; position: relative; }
.sidebar .navbtn .ti { font-size: 22px; }
.sidebar .navbtn:hover { background: var(--surface-1); color: var(--ink-2); }
.sidebar .navbtn.active { background: var(--accent-bg); color: var(--accent); }
.sidebar .navbtn .tip { position: absolute; left: 52px; background: var(--ink); color: #fff; font-size: 12px; padding: 5px 9px; border-radius: 6px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 60; }
.sidebar .navbtn:hover .tip { opacity: 1; }
.sidebar .spacer { flex: 1; }

.content { min-width: 0; display: flex; flex-direction: column; }
.pagehead { background: var(--surface); border-bottom: 1px solid var(--line); padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: 0; z-index: 40; }
.pagehead h1 { font-size: 18px; }
.pagehead .sub { font-size: 12.5px; color: var(--ink-3); margin-top: 1px; }
.pagehead .who { display: flex; align-items: center; gap: 9px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 600; }
.page { padding: 22px 24px 80px; max-width: 1240px; width: 100%; margin: 0 auto; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card h2 { font-size: 16px; margin-bottom: 4px; }
.card .cardsub { color: var(--ink-3); font-size: 13px; margin-bottom: 14px; }
.eyebrow { font-size: 11.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--ink-3); margin: 18px 0 8px; }

/* metric cards */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 15px 16px; box-shadow: var(--shadow); }
.metric .ml { font-size: 12.5px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.metric .mv { font-size: 26px; font-weight: 700; margin-top: 6px; }
.metric .ms { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

/* steps */
.steps { display: flex; gap: 7px; margin-bottom: 18px; flex-wrap: wrap; }
.steps .step { font-size: 12.5px; padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--ink-3); font-weight: 600; background: #fff; }
.steps .step.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.steps .step.done { background: var(--accent-bg); border-color: transparent; color: var(--accent); cursor: pointer; }

/* builder layout */
.builder { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
@media (max-width: 940px) { .builder { grid-template-columns: 1fr; } }
.sticky-side { position: sticky; top: 78px; }

/* typeahead */
.ta-wrap { position: relative; }
.search-inp { position: relative; }
.search-inp .ti { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-size: 19px; pointer-events: none; }
.search-inp input { padding-left: 38px; }
.ta-results { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-pop); z-index: 50; overflow: hidden; max-height: 340px; overflow-y: auto; }
.ta-item { display: flex; align-items: center; gap: 11px; padding: 10px 13px; cursor: pointer; border-top: 1px solid var(--line); }
.ta-item:first-child { border-top: 0; }
.ta-item:hover { background: var(--surface-1); }
.ta-item .nm { font-weight: 600; font-size: 14px; }
.ta-item .dt { font-size: 12.5px; color: var(--ink-3); }
.ta-new { display: flex; align-items: center; gap: 8px; padding: 11px 13px; color: var(--accent); font-weight: 600; cursor: pointer; border-top: 1px solid var(--line); }
.ta-new:hover { background: var(--accent-bg); }

/* customer chosen block */
.person { display: flex; align-items: center; gap: 12px; }
.person .avatar { width: 40px; height: 40px; font-size: 14px; }
.person .pname { font-size: 16px; font-weight: 600; }
.person .pmeta { font-size: 13px; color: var(--ink-2); }

.household { border: 1px solid var(--warn-bg); background: #fffdf5; border-radius: 12px; overflow: hidden; margin: 12px 0; }
.household .hh-head { font-size: 12.5px; font-weight: 600; color: var(--warn); padding: 9px 13px; background: var(--warn-bg); display: flex; align-items: center; gap: 7px; }
.hh-row { display: flex; align-items: center; gap: 10px; padding: 9px 13px; border-top: 1px solid var(--line); }
.hh-row .why { font-size: 12px; color: var(--ink-3); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.chip { background: var(--accent-bg); color: var(--accent-dark); padding: 4px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600; cursor: pointer; border: 0; }

.addr-opt { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 10px; margin-bottom: 8px; cursor: pointer; }
.addr-opt.sel { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.addr-opt .ti { color: var(--ink-3); font-size: 19px; }
.addr-opt.sel .ti { color: var(--accent); }

/* ===== items step ===== */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.cat-card { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; cursor: pointer; background: #fff; transition: box-shadow .12s, border-color .12s; }
.cat-card:hover { box-shadow: var(--shadow); border-color: var(--line-2); }
.cat-card .cc-img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--surface-0); display: block; }
.cat-card .cc-img.ph { display: flex; align-items: center; justify-content: center; color: var(--ink-3); }
.cat-card .cc-img.ph .ti { font-size: 34px; }
.cat-card .cc-body { padding: 10px 12px; }
.cat-card .cc-name { font-weight: 600; font-size: 14px; line-height: 1.25; }
.cat-card .cc-count { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.cathead { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.cathead .backbtn { display: inline-flex; align-items: center; gap: 5px; border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 13.5px; padding: 4px 6px; border-radius: 6px; }
.cathead .backbtn:hover { background: var(--accent-bg); }
.cathead h3 { font-size: 15px; }
.subcat { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-3); padding: 14px 8px 4px; margin-top: 6px; border-top: 1px solid var(--line); }
.picker-main > .subcat:first-of-type, .card > .subcat:first-of-type { border-top: 0; margin-top: 0; }
.item-row { display: flex; align-items: center; gap: 13px; padding: 9px 8px; border-radius: 10px; }
.item-row:hover { background: var(--surface-1); }
.item-row.has { background: var(--accent-bg); }
.thumb { width: 52px; height: 52px; border-radius: 9px; object-fit: contain; background: #fff; flex: none; border: 1px solid var(--line); padding: 2px; }
.thumb.sm { width: 36px; height: 36px; border-radius: 7px; }
.thumb.ph { display: flex; align-items: center; justify-content: center; color: var(--ink-3); object-fit: none; }
.thumb.ph .ti { font-size: 24px; }
.clickimg { cursor: zoom-in; transition: box-shadow .12s, transform .12s; }
.clickimg:hover { box-shadow: 0 0 0 2px var(--accent); }
.item-row .thumb { width: 52px; height: 52px; }

/* lightbox */
.lb-back { position: fixed; inset: 0; background: rgba(15,18,25,.82); z-index: 300; display: flex; align-items: center; justify-content: center; padding: 24px; }
.lb-box { position: relative; max-width: 90vw; max-height: 90vh; display: flex; flex-direction: column; align-items: center; }
.lb-img { max-width: 90vw; max-height: 82vh; object-fit: contain; border-radius: 12px; background: #fff; box-shadow: 0 12px 50px rgba(0,0,0,.4); }
.lb-cap { color: #fff; font-size: 15px; font-weight: 600; margin-top: 12px; text-align: center; }
.lb-close { position: absolute; top: -14px; right: -14px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: #fff; color: var(--ink); display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-pop); }
.lb-close .ti { font-size: 20px; }
.item-row .info { flex: 1; min-width: 0; }
.item-row .iname { font-size: 14px; font-weight: 500; }
.item-row .imeta { font-size: 12.5px; color: var(--ink-2); }
.stepper { display: flex; align-items: center; gap: 8px; flex: none; }
.stepper button { width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--line-2); background: #fff; display: flex; align-items: center; justify-content: center; color: var(--ink-2); }
.stepper button.plus { background: var(--accent); border-color: var(--accent); color: #fff; }
.stepper button:disabled { opacity: .4; }
.stepper .q { min-width: 26px; text-align: center; font-size: 14px; font-weight: 600; }
.stepper .ti { font-size: 16px; }

/* cart */
.cart-item { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.cart-item:first-of-type { border-top: 0; }
.cart-item .ci-name { flex: 1; min-width: 0; font-size: 13.5px; }
.cart-item .ci-name .vn { color: var(--ink-3); font-size: 12px; }
.cart-item .ci-name .cn { color: var(--warn); font-size: 12px; font-style: italic; }
.cart-item .ci-line { font-weight: 600; font-size: 13.5px; white-space: nowrap; }
.cart-item .rm { background: none; border: 0; color: var(--ink-3); padding: 2px; display: flex; }
.cart-item .rm:hover { color: var(--bad); }
.cart-item .rm .ti { font-size: 17px; }
.empty-cart { text-align: center; color: var(--ink-3); padding: 26px 10px; font-size: 13px; }
.empty-cart .ti { font-size: 30px; display: block; margin-bottom: 8px; opacity: .5; }

.totals { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13.5px; }
.totals div { display: flex; justify-content: space-between; padding: 3px 0; color: var(--ink-2); }
.totals .grand { font-size: 18px; font-weight: 700; color: var(--ink); border-top: 1px solid var(--line); margin-top: 6px; padding-top: 9px; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(20,25,35,.4); backdrop-filter: blur(1px); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: #fff; border-radius: 14px; padding: 22px; width: 560px; max-width: 100%; max-height: 92vh; overflow: auto; box-shadow: var(--shadow-pop); }
.modal { position: relative; }
.modal-x { position: absolute; top: 14px; right: 14px; width: 30px; height: 30px; border: 0; background: var(--surface-1); border-radius: 8px; color: var(--ink-2); display: flex; align-items: center; justify-content: center; }
.modal-x:hover { background: var(--surface-0); color: var(--ink); }
.modal-x .ti { font-size: 18px; }
.modal h2 { font-size: 17px; margin-bottom: 4px; padding-right: 34px; }
.ta-head { padding: 8px 13px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-3); }
.avail { font-weight: 600; color: var(--ok); }
.avail.low { color: var(--warn); }
.avail.over { color: var(--bad); }
.vopt .avail { font-size: 11px; margin-top: 2px; }
.modal .msub { color: var(--ink-3); font-size: 13px; margin-bottom: 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.variant-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; margin: 8px 0 4px; }
.vopt { border: 1px solid var(--line-2); border-radius: 10px; padding: 7px; text-align: center; cursor: pointer; font-size: 12.5px; font-weight: 500; }
.vopt img { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 7px; background: #fff; margin-bottom: 5px; border: 1px solid var(--line); }
.vopt .vp { color: var(--ink-3); font-weight: 400; }
.vopt.sel { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }

/* tables */
.tablewrap { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-3); font-weight: 700; padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--surface-1); }
table.list td { padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
table.list tbody tr:last-child td { border-bottom: 0; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: var(--surface-1); }
.right { text-align: right; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .inp, .toolbar input, .toolbar select { width: auto; }
.toolbar .grow { flex: 1; min-width: 180px; }

.muted { color: var(--ink-3); }
.mt { margin-top: 14px; }
.err { background: var(--bad-bg); color: var(--bad); border-radius: var(--radius); padding: 10px 13px; margin: 10px 0; font-weight: 500; font-size: 13.5px; }
.okmsg { background: var(--ok-bg); color: var(--ok); border-radius: var(--radius); padding: 10px 13px; margin: 10px 0; font-weight: 500; font-size: 13.5px; }
.empty { text-align: center; color: var(--ink-3); padding: 40px 20px; }
.empty .ti { font-size: 38px; opacity: .4; display: block; margin-bottom: 10px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 10px; font-weight: 500; font-size: 13.5px; z-index: 200; box-shadow: var(--shadow-pop); display: flex; align-items: center; gap: 9px; }
.toast .ti { font-size: 18px; color: #7ee2a8; }

/* catalog admin */
.cat-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.cat-tabs .pill { border: 1px solid var(--line-2); background: #fff; border-radius: 999px; padding: 6px 14px; font-weight: 600; font-size: 13px; color: var(--ink-2); }
.cat-tabs .pill:hover { background: var(--surface-1); }
.cat-tabs .pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.edcell { display: inline-flex; align-items: center; gap: 3px; border-radius: var(--radius); transition: background .3s; padding: 2px; }
.edcell.saved { background: var(--ok-bg); }
.edcell input { padding: 6px 8px; }

.detail-grid { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
@media (max-width: 940px) { .detail-grid { grid-template-columns: 1fr; } }
.kv { display: flex; gap: 8px; font-size: 13.5px; padding: 4px 0; }
.kv .k { color: var(--ink-3); min-width: 110px; }
.timeline { font-size: 12.5px; color: var(--ink-2); }
.timeline .ev { display: flex; gap: 8px; padding: 5px 0; border-top: 1px solid var(--line); }
.timeline .ev:first-child { border-top: 0; }
