/* Counter POS. Three layouts from the Figma file:
   desktop/tablet landscape (rail | menu | bill), tablet portrait (menu over bill),
   phone / handheld terminal (menu, bill as a full screen). */
#app { height: 100%; }
.pos { display: grid; grid-template-columns: 88px 1fr 392px; height: 100vh; height: 100dvh; overflow: hidden; }

.rail { background: var(--ink); color: #fff; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px 10px; }
.rail img { width: 48px; margin-bottom: 12px; }
.rail button { width: 68px; padding: 10px 4px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: #fff; opacity: .75; }
.rail button.on { background: var(--red); opacity: 1; }
.rail button svg { width: 22px; height: 22px; }
.rail .spacer { flex: 1; }

.menu { display: flex; flex-direction: column; gap: 14px; padding: 18px 24px; overflow: hidden; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 10px; }
.topbar .who { flex: 1; min-width: 0; }
.topbar .who h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tools { display: flex; align-items: center; gap: 10px; }
.search { display: flex; align-items: center; gap: 8px; width: 300px; flex-shrink: 0; border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 0 12px; }
.search input { border: 0; outline: 0; background: none; padding: 10px 0; flex: 1; min-width: 0; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); grid-auto-rows: max-content; gap: 12px; overflow-y: auto; align-content: start; padding-bottom: 12px; }
.tile { position: relative; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.tile .ph { height: 64px; display: flex; align-items: center; justify-content: center; font-family: var(--font-head); font-size: 26px; font-weight: 800; color: rgba(31,26,22,.55); background-size: cover; background-position: center; }
.tile .bd { padding: 8px 10px; display: flex; flex-direction: column; gap: 1px; }
.tile .n1 { font-weight: 600; line-height: 1.25; }
.tile .n2 { font-size: 12px; color: var(--ink-2); }
.tile .pr { display: flex; align-items: center; justify-content: space-between; padding-top: 4px; }
.tile .pr .price { font-size: 19px; }
.tile .code { font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 0 6px; }
.tile .qty { min-width: 26px; height: 26px; border-radius: 999px; background: var(--red); color: #fff; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; padding: 0 6px; }
.tile.sel { border: 2px solid var(--red); }
.tile.out { opacity: .55; }
.tile.out .price { color: var(--muted); }
.tile:active { transform: scale(.98); }
.cat-0 .ph { background-color: #F6E3C4; } .cat-1 .ph { background-color: #F7D9CF; } .cat-2 .ph { background-color: #E5EEDC; }
.cat-3 .ph { background-color: #F3E6D0; } .cat-4 .ph { background-color: #E8E1F0; } .cat-5 .ph { background-color: #DCEAF2; }

.bill { background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; padding: 16px 20px; min-height: 0; overflow-y: auto; }
.bill .seg button { padding: 6px 12px; white-space: nowrap; }
.btn-sm { min-height: 38px; padding: 6px 12px; font-size: 14px; }
.bill .lines { flex: 1; overflow-y: auto; min-height: 60px; }
.line { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.line .nm { flex: 1; min-width: 0; }
.stepper { display: flex; align-items: center; gap: 4px; border: 1px solid var(--border); border-radius: 999px; padding: 2px; }
.stepper button { width: 30px; height: 30px; border-radius: 999px; font-size: 18px; font-weight: 700; }
.stepper button:hover { background: var(--subtle); }
.stepper span { min-width: 18px; text-align: center; font-weight: 700; }
.line .lt { width: 56px; text-align: right; font-weight: 600; }
.totals { border-top: 1px solid var(--border); padding-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.totals .grand { font-family: var(--font-head); font-weight: 800; font-size: 28px; }
.paym { display: flex; gap: 8px; }
.paym button { flex: 1; border: 1px solid var(--border); border-radius: 12px; padding: 10px 6px; display: flex; align-items: center; justify-content: center; gap: 6px; font-weight: 600; color: var(--ink-2); }
.paym button.on { border: 2px solid var(--green); background: var(--green-subtle); color: var(--green); }
.quick { display: flex; gap: 6px; }
.quick button { flex: 1; background: var(--subtle); border-radius: 10px; padding: 9px 4px; font-weight: 600; }
.quick button.on { background: var(--ink); color: #fff; }
.change { display: flex; align-items: center; justify-content: space-between; background: var(--green-subtle); color: var(--green); border-radius: 12px; padding: 10px 14px; font-weight: 600; }
.change.short { background: var(--red-subtle); color: var(--red); }
.change b { font-family: var(--font-head); font-size: 24px; }
.empty { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted); padding: 24px; }
.billbar { display: none; }
.phone-back { display: none; }

/* pages other than billing */
.page { grid-column: 2 / 4; overflow-y: auto; padding: 24px 32px; display: flex; flex-direction: column; gap: 16px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
.table th { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.den { display: grid; grid-template-columns: 70px 20px 90px 1fr; align-items: center; gap: 10px; }
.den input { text-align: center; }
.diff { display: flex; justify-content: space-between; align-items: center; border-radius: 12px; padding: 12px 14px; font-weight: 600; }
.diff b { font-family: var(--font-head); font-size: 24px; }

/* tablet portrait: menu on top, bill docked at the bottom */
@media (max-width: 1100px) and (min-width: 700px) and (orientation: portrait) {
  .pos { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .rail { flex-direction: row; padding: 10px 16px; gap: 6px; }
  .rail img { width: 36px; margin: 0 8px 0 0; }
  .rail button { width: auto; flex-direction: row; padding: 8px 12px; }
  .rail .spacer { display: block; }
  .bill { border-left: 0; border-top: 1px solid var(--border); max-height: 46vh; display: grid; grid-template-columns: 1fr 320px; grid-template-rows: auto 1fr auto; column-gap: 20px; box-shadow: 0 -6px 20px rgba(0,0,0,.06); }
  .bill > .bh { grid-column: 1; } .bill > .lines { grid-column: 1; grid-row: 2 / 4; }
  .bill > .pay { grid-column: 2; grid-row: 1 / 4; }
  .page { grid-column: 1; }
}
/* small landscape tablets */
@media (max-width: 1180px) and (orientation: landscape) {
  .pos { grid-template-columns: 76px 1fr 340px; }
  .rail button { width: 60px; }
  .search { width: 220px; }
}
/* phone / handheld smart POS */
@media (max-width: 699px) {
  .pos { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .rail { flex-direction: row; padding: 8px 12px; gap: 4px; overflow-x: auto; }
  .rail img { width: 32px; margin: 0 6px 0 0; }
  .rail button { width: auto; flex-direction: row; padding: 6px 10px; font-size: 13px; }
  .rail button svg { width: 18px; height: 18px; }
  .menu { padding: 10px 12px; gap: 10px; }
  .topbar .stat { display: none; }
  .tools { flex-direction: column; align-items: stretch; }
  .search { width: auto; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .bill { display: none; position: fixed; inset: 0; z-index: 30; border: 0; padding: 0 16px 16px; overflow-y: auto; }
  .pos.show-bill .bill { display: flex; }
  .bill .lines { flex: none; overflow: visible; }
  .bill .bh h3 { display: none; }
  .bill .bh .seg { flex: 1 !important; }
  .phone-back { display: flex; align-items: center; gap: 10px; background: var(--ink); color: #fff; margin: 0 -16px; padding: 12px 16px; }
  .billbar { display: flex; align-items: center; gap: 12px; background: var(--red); color: #fff; padding: 12px 16px; font-weight: 600; }
  .billbar b { font-family: var(--font-head); font-size: 20px; }
  .page { grid-column: 1; padding: 14px; }
  .den { grid-template-columns: 60px 14px 70px 1fr; }
}
