/* NexaBook Office app. Tokens from the brand system (mint/teal);
   layout bands: phone < 768, tablet 768-1180, desktop > 1180. */
:root {
  --teal: #087F75; --teal-dark: #05665E; --navy: #081A32; --mint: #E8F7F2;
  --accent: #03C8B3; --bg: #F7FAF8; --surface: #FFFFFF; --ink: #102A35;
  --muted: #5C7268; --line: #D9E8E1; --focus: #03A896; --err: #B3261E;
  --err-bg: #FDECEA; --amber: #8A5A00; --amber-bg: #FFF4D6;
  --radius: 14px; --topbar-h: 60px;
  --ease-sheet: cubic-bezier(0.32, 0.72, 0, 1);
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; }
html { overscroll-behavior: none; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif; font-size: 16px;
  -webkit-text-size-adjust: 100%; }
button { touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  font: inherit; }
input, select, textarea { font-size: 16px; color: var(--ink); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1 { font-size: 22px; margin: 0 0 6px; }
h2 { font-size: 18px; margin: 0 0 8px; }
h3 { font-size: 16px; margin: 0 0 6px; }
.mut { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* ---------- shared controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; min-height: 48px; padding: 12px 20px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 600; cursor: pointer; user-select: none;
  -webkit-user-select: none; text-decoration: none; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.danger { background: var(--surface); border-color: var(--err); color: var(--err); }
.btn.big { width: 100%; min-height: 54px; font-size: 17px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:active { transform: translateY(1px); }
.linklike { background: none; border: 0; color: var(--teal); font-weight: 600;
  min-height: 44px; padding: 8px 6px; cursor: pointer; }
.iconbtn { display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; border-radius: 50%; border: 0; background: none;
  color: var(--ink); cursor: pointer; }
.iconbtn:active { background: var(--mint); }
.card { background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 18px; }
.chip { display: inline-flex; align-items: center; min-height: 48px;
  padding: 10px 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-weight: 600;
  cursor: pointer; user-select: none; -webkit-user-select: none; }
.chip.on { background: var(--teal); border-color: var(--teal); color: #fff; }
.chip:active { transform: scale(0.97); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
label.flabel { display: block; font-size: 14px; font-weight: 600; margin: 14px 0 6px; }
input[type="text"], input[type="email"], input[type="password"],
input[type="tel"], input[type="number"], input[type="date"],
input[type="time"], select, textarea {
  width: 100%; min-height: 50px; padding: 11px 13px; border: 1px solid var(--line);
  border-radius: 12px; background: #fff; }
textarea { min-height: 84px; }
.msg { margin-top: 12px; font-size: 15px; min-height: 20px; }
.msg.err { color: var(--err); }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.switch { position: relative; display: inline-flex; align-items: center;
  min-height: 44px; min-width: 60px; cursor: pointer; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; }
.switch .track { width: 56px; height: 32px; border-radius: 999px;
  background: #CBDAD2; transition: background 160ms; flex: none; }
.switch .thumb { display: block; width: 26px; height: 26px; margin: 3px;
  border-radius: 50%; background: #fff; transition: transform 160ms;
  box-shadow: 0 1px 3px rgba(8, 26, 50, 0.3); }
.switch input:checked + .track { background: var(--teal); }
.switch input:checked + .track .thumb { transform: translateX(24px); }
.switch input:focus-visible + .track { outline: 3px solid var(--focus); outline-offset: 2px; }
.switchrow { display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.switchrow p { margin: 2px 0 0; }

/* ---------- auth ---------- */
#authView { min-height: 100dvh; padding: calc(20px + var(--sat)) 16px 40px; }
.auth-wrap { max-width: 430px; margin: 0 auto; }
.auth-logo { width: 200px; max-width: 72%; display: block; margin: 10px auto 2px; }
.auth-tag { text-align: center; color: var(--muted); margin: 0 0 20px; }
#authView .card { margin-bottom: 16px; }
#authView label { display: block; font-size: 14px; font-weight: 600; margin: 14px 0 6px; }
#authView label:first-of-type { margin-top: 4px; }
#authView .btn.big { margin-top: 18px; }
.auth-links { display: flex; flex-wrap: wrap; justify-content: space-between; margin-top: 6px; }
.auth-foot { text-align: center; color: var(--muted); font-size: 14px; }
.auth-foot a { color: var(--teal); font-weight: 600; }

/* ---------- app frame ---------- */
#appView { display: flex; flex-direction: column; height: 100dvh; height: 100svh; }
#topbar { flex: none; min-height: var(--topbar-h);
  padding: var(--sat) calc(14px + var(--sar)) 0 calc(14px + var(--sal));
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg); border-bottom: 1px solid var(--line); z-index: 5; }
.tb-left { display: flex; align-items: center; gap: 10px; min-width: 0;
  flex: 1 1 auto; }
.tb-titles { min-width: 0; }
.tb-logo { width: 38px; height: 38px; border-radius: 10px; }
.tb-biz { font-weight: 700; font-size: 17px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.tb-role { font-size: 13px; color: var(--muted); }
.tb-right { display: flex; align-items: center; gap: 6px; flex: none; }
.syncdot { width: 11px; height: 11px; border-radius: 50%; background: var(--teal); flex: none; }
.syncdot.syncing { background: var(--accent); }
.syncdot.offline { background: var(--err); }
.syncdot.degraded { background: var(--amber); }
.syncword { font-size: 13px; color: var(--muted); }
#offlineBar { flex: none; background: var(--navy); color: #fff; font-size: 14px;
  padding: 10px calc(16px + var(--sar)) 10px calc(16px + var(--sal));
  display: flex; gap: 10px; flex-wrap: wrap; }
#outboxCount { font-weight: 700; }
#viewRoot { flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 16px calc(16px + var(--sar)) calc(108px + var(--sab)) calc(16px + var(--sal));
  max-width: 100%; }
.view-inner { max-width: 760px; margin: 0 auto; }
.view-head { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
#tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding: 4px calc(6px + var(--sar)) calc(4px + var(--sab)) calc(6px + var(--sal)); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 2px; min-height: 56px; padding: 6px 2px; border: 0; background: none;
  color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer;
  border-radius: 12px; }
.tab svg { width: 24px; height: 24px; }
.tab.on { color: var(--teal); }
.tab:active { background: var(--mint); }

/* ---------- overview ---------- */
.alertcard { background: var(--amber-bg); border: 1px solid #E8CF8A;
  border-radius: 16px; padding: 14px 16px; margin-bottom: 14px; }
.alertcard.err { background: var(--err-bg); border-color: #E5A49F; }
.alertrow { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 6px 0; }
.pair { display: grid; gap: 14px; }
.statrow { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 14px 0; }
.stat { background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 14px; }
.stat .num { font-size: 22px; font-weight: 800; }
.stat .lab { font-size: 13px; color: var(--muted); }
.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 2px;
  border-top: 1px solid var(--line); min-height: 56px; }
.row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; }
.row .sub { font-size: 13px; color: var(--muted); }
.pill { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  background: var(--mint); color: var(--teal-dark); white-space: nowrap; }
.pill.amber { background: var(--amber-bg); color: var(--amber); }
.pill.err { background: var(--err-bg); color: var(--err); }
.pill.grey { background: #EDF1EE; color: var(--muted); }

/* ---------- schedule ---------- */
.daynav { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.daynav .btn { min-height: 44px; padding: 8px 14px; }
.daynav input[type="date"] { width: auto; flex: 1; min-width: 150px; }
.weekwrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); }
.weekgrid { display: grid; min-width: 860px; }
.weekgrid .cell { border-top: 1px solid var(--line); border-left: 1px solid var(--line);
  padding: 8px; min-height: 74px; font-size: 13px; }
.weekgrid .cell.head { min-height: 0; font-weight: 700; background: var(--mint);
  position: sticky; top: 0; }
.weekgrid .cell.staff { position: sticky; left: 0; background: var(--surface);
  font-weight: 700; border-left: 0; z-index: 1; }
.weekgrid .cell.staff.head { background: var(--mint); z-index: 2; }
.shiftchip { display: block; width: 100%; text-align: left; border: 1px solid var(--line);
  background: var(--mint); border-radius: 8px; padding: 6px 8px; margin-bottom: 6px;
  font-size: 12px; cursor: pointer; min-height: 36px; }
.shiftchip.open { background: var(--amber-bg); border-color: #E8CF8A; }
.apptblock { display: block; width: 100%; text-align: left; border: 0;
  background: var(--navy); color: #fff; border-radius: 8px; padding: 6px 8px;
  margin-bottom: 6px; font-size: 12px; cursor: pointer; min-height: 36px; }
.addcell { display: block; width: 100%; border: 0; background: none; color: var(--teal);
  font-weight: 700; font-size: 18px; min-height: 36px; cursor: pointer; }

/* ---------- counter ---------- */
.counter-layout { display: grid; gap: 14px; }
.billpane .linetable { width: 100%; }
.linerow { display: flex; align-items: center; gap: 8px; padding: 10px 0;
  border-top: 1px solid var(--line); }
.stepper { display: inline-flex; align-items: center; gap: 2px; flex: none; }
.stepper button { width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); font-size: 20px;
  font-weight: 700; cursor: pointer; }
.stepper .qty { min-width: 30px; text-align: center; font-weight: 700; }
.totals { border-top: 2px solid var(--line); margin-top: 10px; padding-top: 10px; }
.totals .trow { display: flex; justify-content: space-between; padding: 3px 0; }
.totals .grand { font-size: 20px; font-weight: 800; }
.tenders { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.tenders .btn { min-height: 56px; }
.catalog { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.catbtn { border: 1px solid var(--line); background: var(--surface); border-radius: 12px;
  padding: 12px; text-align: left; cursor: pointer; min-height: 64px; }
.catbtn .nm { font-weight: 600; display: block; }
.catbtn .pr { color: var(--muted); font-size: 13px; }
.catbtn:disabled { opacity: 0.45; }
.receipt { background: var(--surface); border: 1px dashed var(--teal);
  border-radius: 14px; padding: 16px; }

/* ---------- customers ---------- */
.cust-layout { display: grid; gap: 14px; }
.searchbar { position: sticky; top: 0; background: var(--bg); padding-bottom: 10px; z-index: 2; }

/* ---------- settings ---------- */
.setsec { margin-bottom: 22px; }
.setsec > h2 { margin-bottom: 4px; }
.setsec .card { margin-top: 10px; }
.qrbox { text-align: center; }
.qrbox img { width: 210px; height: 210px; border: 1px solid var(--line); border-radius: 12px; }
code.codechip { font-size: 17px; font-weight: 800; letter-spacing: 2px;
  background: var(--mint); padding: 6px 12px; border-radius: 8px; }

/* ---------- dialog ---------- */
#dialogRoot .scrim { position: fixed; inset: 0; background: rgba(8, 26, 50, 0.45);
  z-index: 40; display: flex; align-items: flex-end; justify-content: center;
  animation: fadein 160ms ease; }
#dialogRoot .sheet { background: var(--surface); width: 100%; max-height: 88dvh;
  overflow-y: auto; border-radius: 20px 20px 0 0; padding: 8px 20px calc(20px + var(--sab));
  animation: sheetup 260ms var(--ease-sheet); }
#dialogRoot .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line);
  margin: 6px auto 10px; }
#dialogRoot .sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
#dialogRoot .sheet-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
#dialogRoot .sheet-actions .btn { flex: 1; }
@keyframes sheetup { from { transform: translateY(48px); opacity: 0.4; } to { transform: none; opacity: 1; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
#toast { position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(96px + var(--sab)); z-index: 60; background: var(--navy); color: #fff;
  padding: 12px 18px; border-radius: 999px; font-size: 15px; max-width: 92vw;
  box-shadow: 0 6px 24px rgba(8, 26, 50, 0.35); }

/* ---------- station mode: bigger targets on the counter device ---------- */
body.station .btn, body.station .chip { min-height: 60px; font-size: 18px; }
body.station .catbtn { min-height: 84px; }
body.station .tenders .btn { min-height: 72px; font-size: 19px; }
body.station .stepper button { width: 52px; height: 52px; }

/* ---------- tablet band ---------- */
@media (min-width: 768px) {
  #viewRoot { padding-bottom: 40px; }
  #tabbar { position: static; order: 3; border-top: 0; border-bottom: 1px solid var(--line);
    justify-content: center; gap: 4px; padding: 6px 16px; }
  .tab { flex: 0 1 auto; flex-direction: row; gap: 8px; min-height: 48px;
    padding: 8px 16px; font-size: 15px; }
  #offlineBar { order: 2; }
  #topbar { order: 1; }
  #viewRoot { order: 4; }
  .view-inner { max-width: 1060px; }
  .pair { grid-template-columns: 1fr 1fr; align-items: start; }
  .statrow { grid-template-columns: repeat(4, 1fr); }
  .counter-layout { grid-template-columns: 370px 1fr; align-items: start; }
  .counter-layout .tickets { position: sticky; top: 8px; }
  .cust-layout { grid-template-columns: 340px 1fr; align-items: start; }
  #dialogRoot .scrim { align-items: center; padding: 24px; }
  #dialogRoot .sheet { max-width: 560px; border-radius: 20px;
    padding: 8px 24px 24px; animation: fadein 160ms ease; }
  #toast { bottom: 28px; }
}

/* ---------- desktop ---------- */
@media (min-width: 1180px) {
  #appView { display: grid; grid-template-columns: 236px 1fr;
    grid-template-rows: auto auto 1fr; }
  #topbar { grid-column: 1 / -1; }
  #offlineBar { grid-column: 1 / -1; }
  #tabbar { grid-row: 3; flex-direction: column; justify-content: flex-start;
    align-items: stretch; border-bottom: 0; border-right: 1px solid var(--line);
    padding: 14px 10px; gap: 4px; }
  .tab { justify-content: flex-start; padding: 10px 14px; }
  #viewRoot { grid-row: 3; }
  .view-inner { max-width: 1180px; }
}

/* ---------- motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; scroll-behavior: auto !important; }
  .btn, .chip, .switch .track, .switch .thumb { transition: opacity 120ms ease; }
}
