:root { --ink: #1f2328; --muted: #5f6368; --line: #e2e3e3; --head: #f8f9fa; --green: #188038; --green-bg: #e6f4ea; --blue: #1a73e8; --sel: #e8f0fe; --red: #c5221f; font-family: Arial, Helvetica, sans-serif; color: var(--ink); }
* { box-sizing: border-box; }
body { margin: 0; background: #fff; font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid #dadce0; background: #fff; border-radius: 6px; padding: 7px 12px; font-weight: 600; }
button:hover { background: #f1f3f4; }
button.primary { background: var(--green); border-color: var(--green); color: #fff; }
button.primary:hover { background: #137333; }
button.link { border: none; background: none; padding: 0; color: var(--blue); font-weight: 500; }
input, select, textarea { border: 1px solid #dadce0; border-radius: 6px; padding: 7px 10px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(26,115,232,.25); border-color: var(--blue); }
.loading, .empty { padding: 60px 20px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* header + toolbar */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.biz { display: flex; align-items: center; gap: 10px; }
.biz .logo { width: 34px; height: 34px; border-radius: 8px; background: var(--green); display: grid; place-items: center; color: #fff; font-weight: 800; }
.biz h1 { font-size: 18px; margin: 0; font-weight: 700; }
.biz .contact { font-size: 12px; color: var(--muted); }
.top-right { display: flex; align-items: center; gap: 10px; }
.live { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: #34a853; box-shadow: 0 0 0 3px #e6f4ea; }
.cart-btn { background: var(--green); color: #fff; border-color: var(--green); padding: 8px 14px; }
.cart-btn:hover { background: #137333; }
.cart-btn .n { background: #fff; color: var(--green); border-radius: 999px; padding: 0 8px; margin-left: 6px; font-weight: 800; }
.note { background: #fef7e0; border-bottom: 1px solid #f6e3a5; padding: 8px 18px; font-size: 13px; }
.tools { display: flex; gap: 8px; align-items: center; padding: 10px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; background: #fff; position: sticky; top: 0; z-index: 5; }
.tools input[type=search] { flex: 1; min-width: 200px; }
.tools select { max-width: 170px; }
.seg { display: inline-flex; border: 1px solid #dadce0; border-radius: 6px; overflow: hidden; }
.seg button { border: none; border-radius: 0; padding: 7px 12px; }
.seg button.on { background: #e8f0fe; color: var(--blue); }
.count { font-size: 12px; color: var(--muted); margin-left: auto; white-space: nowrap; }

/* ---------- Sheet view (spreadsheet look) ---------- */
.fx { display: flex; align-items: center; border-bottom: 1px solid var(--line); font-size: 13px; height: 30px; }
.fx .ref { width: 70px; text-align: center; border-right: 1px solid var(--line); color: var(--muted); height: 100%; display: grid; place-items: center; }
.fx .fx-i { width: 36px; text-align: center; color: var(--muted); font-style: italic; font-family: Georgia, serif; border-right: 1px solid var(--line); height: 100%; display: grid; place-items: center; }
.fx .val { padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-wrap { overflow: auto; height: calc(100vh - 210px); min-height: 300px; }
table.sheet { border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 100%; }
table.sheet th, table.sheet td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0 8px; height: 26px; white-space: nowrap; }
table.sheet thead th { position: sticky; background: var(--head); z-index: 2; font-weight: 400; color: var(--muted); }
table.sheet thead tr.letters th { top: 0; height: 22px; font-size: 11px; text-align: center; }
table.sheet thead tr.hdr th { top: 22px; color: var(--ink); font-weight: 700; text-align: left; cursor: pointer; user-select: none; background: #f1f3f4; }
table.sheet thead tr.hdr th:hover { background: #e8eaed; }
table.sheet .rn { position: sticky; left: 0; background: var(--head); color: var(--muted); text-align: center; width: 46px; min-width: 46px; font-size: 11px; z-index: 1; }
table.sheet thead .rn { z-index: 3; }
table.sheet td.c, table.sheet th.c { text-align: center; width: 54px; }
table.sheet td.num, table.sheet th.num { text-align: right; }
table.sheet td.mono { font-family: "Roboto Mono", Consolas, monospace; font-size: 12.5px; }
table.sheet tbody tr:hover td { background: #f8fbff; }
table.sheet tbody tr.in td { background: var(--green-bg); }
table.sheet tbody tr.in td.rn { background: #ceead6; color: var(--green); font-weight: 700; }
table.sheet td.cell-sel { outline: 2px solid var(--blue); outline-offset: -2px; }
table.sheet input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--green); }
.sort { font-size: 10px; color: var(--blue); }
.tabs { display: flex; align-items: center; gap: 2px; background: var(--head); border-top: 1px solid var(--line); padding: 0 10px; height: 34px; font-size: 13px; }
.tabs .tab { background: #fff; padding: 6px 14px; border-radius: 0 0 6px 6px; color: var(--green); font-weight: 700; border-top: 2px solid var(--green); }

/* ---------- Grouped view ---------- */
.groups { padding: 14px 18px 40px; display: flex; flex-direction: column; gap: 10px; max-width: 1100px; margin: 0 auto; }
.g { border: 1px solid var(--line); border-radius: 10px; }
.g-head { display: grid; grid-template-columns: 1fr auto auto auto; gap: 16px; align-items: center; padding: 12px 14px; }
.g-title { font-size: 15px; font-weight: 700; }
.g-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.pill { font-size: 12px; border-radius: 999px; padding: 2px 9px; background: #f1f3f4; }
.pill.ok { background: var(--green-bg); color: var(--green); font-weight: 700; }
.g-avail { text-align: center; }
.g-avail b { font-size: 20px; display: block; }
.g-price { font-size: 17px; font-weight: 800; text-align: right; min-width: 90px; }
.g-add { display: flex; gap: 6px; align-items: center; }
.g-add input { width: 64px; text-align: center; }
.g-foot { display: flex; justify-content: space-between; align-items: center; padding: 0 14px 10px; font-size: 12px; }
.g-list { border-top: 1px solid var(--line); padding: 6px 14px 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 4px 16px; }
.g-list label { display: flex; gap: 8px; align-items: center; font-size: 13px; padding: 3px 0; cursor: pointer; }
.g-list .mono { font-family: Consolas, monospace; }
.in-cart { color: var(--green); font-weight: 700; }

/* ---------- Cards view: one card per phone ---------- */
.sec { margin-bottom: 8px; }
.sec-h { font-size: 15px; margin: 10px 0 8px; font-weight: 700; }
.sec-h .muted { font-weight: 400; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 10px; }
.card { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 6px; background: #fff; }
.card.on { border-color: var(--green); background: #f6fbf7; box-shadow: inset 0 0 0 1px var(--green); }
.card-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.card-title { font-weight: 700; font-size: 15px; }
.card-price { font-weight: 800; font-size: 17px; white-space: nowrap; }
.card-sub { color: var(--muted); font-size: 13px; margin-top: -4px; }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 2px; }
.card-foot .mono { font-family: Consolas, monospace; color: var(--muted); }
.card-foot button { padding: 6px 12px; white-space: nowrap; flex: none; }
.card-foot .mono { font-size: 11.5px; min-width: 0; overflow-wrap: anywhere; }
button.incart { background: var(--green-bg); color: var(--green); border-color: #ceead6; }

/* ---------- Rows view: one line per phone ---------- */
.rows { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.r { display: grid; grid-template-columns: minmax(200px, 1fr) 130px 100px 90px 100px 100px; gap: 10px; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--line); background: #fff; }
.r:last-child { border-bottom: none; }
.r:hover { background: #fafbfc; }
.r.on { background: #f6fbf7; box-shadow: inset 3px 0 0 var(--green); }
.r-imei { font-family: Consolas, monospace; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.r-break { display: none; }
.r-price { font-weight: 800; font-size: 15px; text-align: right; white-space: nowrap; }
.r button { white-space: nowrap; padding: 6px 10px; }
@media (max-width: 720px) {
  .r { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
  .r-main { flex-basis: 100%; }
  .r .r-c:empty { display: none; }
  .r-break { display: block; flex-basis: 100%; height: 0; }
  .r-price { margin-left: auto; }
}

/* ---------- Categories (cards + rows) ---------- */
.pill.warn { background: #fef7e0; color: #b06000; font-weight: 700; }
.pill.strong { background: #202124; color: #fff; font-weight: 700; }
.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.cat { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 7px; background: #fff; }
.cat.on { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); background: #f8fcf9; }
.cat.open { grid-column: 1 / -1; }
.cat-mid { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 2px; }
.cat-avail b { font-size: 20px; }
.cat .see, .cr .see { align-self: flex-start; font-size: 13px; white-space: nowrap; }
.ph-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 2px 14px; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 2px; }
.ph { display: grid; grid-template-columns: 20px 140px 1fr 70px auto; gap: 8px; align-items: center; font-size: 13px; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.ph:hover { background: #f1f3f4; }
.ph.on { background: var(--green-bg); }
.ph .mono { font-family: Consolas, monospace; font-size: 12px; }
.ph input { accent-color: var(--green); width: 16px; height: 16px; }
.crs { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.cr-head, .cr-line { display: grid; grid-template-columns: minmax(220px, 1fr) 90px 120px 100px 130px 160px; gap: 10px; align-items: center; padding: 9px 12px; }
.cr-head { background: #f8f9fa; font-size: 12px; color: var(--muted); font-weight: 700; border-bottom: 1px solid var(--line); }
.cr { border-bottom: 1px solid var(--line); background: #fff; }
.cr:last-child { border-bottom: none; }
.cr.on .cr-line { background: #f6fbf7; box-shadow: inset 3px 0 0 var(--green); }
.cr .ph-list { margin: 0 12px 10px; }
.cr-carriers { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.cr-carriers .pill { font-size: 11px; padding: 1px 7px; }
.cr-avail b { font-size: 16px; }
.cr-price { font-weight: 800; text-align: right; white-space: nowrap; }
@media (max-width: 900px) {
  .cr-head { display: none; }
  .cr-line { display: flex; flex-wrap: wrap; gap: 8px; }
  .cr-title { flex-basis: 100%; }
  .cr-price { margin-left: auto; }
  .ph { grid-template-columns: 20px 1fr auto; }
  .ph span:nth-of-type(2), .ph span:nth-of-type(3) { display: none; }
}

/* ---------- cart drawer ---------- */
.back { position: fixed; inset: 0; background: rgba(32,33,36,.4); z-index: 20; display: flex; justify-content: flex-end; }
.drawer { background: #fff; width: min(560px, 100%); height: 100%; display: flex; flex-direction: column; box-shadow: -8px 0 24px rgba(0,0,0,.2); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 18px; }
.drawer-body { flex: 1; overflow: auto; padding: 12px 18px; }
.cg { display: grid; grid-template-columns: 1fr auto 110px 24px; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid #f1f3f4; font-size: 13px; }
.cg .why { color: var(--red); font-weight: 700; font-size: 12px; margin-top: 3px; }
.cg-qty { display: flex; align-items: center; gap: 8px; }
.cg-qty b { min-width: 22px; text-align: center; font-size: 15px; }
.cg-qty button { width: 30px; height: 30px; padding: 0; font-size: 17px; line-height: 1; border-radius: 50%; }
.cg-price { text-align: right; font-size: 12px; color: var(--muted); }
.cg-price b { color: var(--ink); font-size: 14px; }
.c-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid #f1f3f4; font-size: 13px; }
.c-row .mono { font-family: Consolas, monospace; font-size: 12px; color: var(--muted); }
.c-row.gone { opacity: .55; }
.c-row.gone .why { color: var(--red); font-weight: 700; font-size: 12px; }
.totals { display: flex; justify-content: space-between; padding: 10px 0; font-size: 15px; border-top: 2px solid var(--ink); margin-top: 6px; }
.buyer { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.buyer .full { grid-column: 1 / -1; }
.buyer label { font-size: 12px; font-weight: 700; display: flex; flex-direction: column; gap: 3px; }
.drawer-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; }
.drawer-foot .primary { flex: 1; }

/* login */
.login { max-width: 360px; margin: 12vh auto; padding: 24px; border: 1px solid var(--line); border-radius: 12px; }
.login h1 { font-size: 20px; margin: 0 0 6px; }

#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 40; }
.toast { background: #202124; color: #fff; padding: 9px 14px; border-radius: 6px; font-size: 13px; }

/* print: order sheet */
#print-area { display: none; }
@media print {
  @page { size: letter; margin: .5in; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; }
}
.order { font-size: 11pt; color: #000; }
.order h1 { font-size: 18pt; margin: 0; }
.order .meta { display: flex; justify-content: space-between; margin: 12px 0 14px; gap: 20px; }
.order table { width: 100%; border-collapse: collapse; font-size: 9.5pt; }
.order th { text-align: left; border-bottom: 2px solid #000; padding: 4px 5px; }
.order td { border-bottom: 1px solid #ccc; padding: 4px 5px; }
.order .num { text-align: right; }
.order .mono { font-family: "Courier New", monospace; }
.order .tot { margin-top: 10px; text-align: right; font-size: 12pt; }

@media (max-width: 720px) {
  .g-head { grid-template-columns: 1fr auto; }
  .g-price { text-align: left; }
  .tools select { max-width: 46%; }
  .sheet-wrap { height: calc(100vh - 260px); }
}
