:root {
  --ink: #192e31;
  --muted: #6a7e80;
  --green: #126b58;
  --deep: #103f38;
  --bg: #f3f6f5;
  --line: #dce5e2;
  --red: #b33c35;
  --white: #fff;
  --amber: #a16d11;
  font-family:
    Inter,
    Segoe UI,
    system-ui,
    sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
.btn {
  cursor: pointer;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 10px 15px;
  border-radius: 8px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 600;
  min-height: 42px;
}
button:hover,
.btn:hover {
  filter: brightness(0.96);
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
button.primary,
.btn.primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
button.danger {
  color: var(--red);
  border-color: #e8bcb9;
}
button.small {
  min-height: 32px;
  padding: 5px 9px;
  font-size: 12px;
}
input,
select,
textarea {
  border: 1px solid #cbd9d4;
  border-radius: 7px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
  width: 100%;
  min-height: 42px;
}
textarea {
  min-height: 75px;
  resize: vertical;
}
input:focus,
select:focus,
textarea:focus {
  outline: 3px solid #bce1d7;
  outline-offset: 1px;
}
input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
}
label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  color: #536969;
}
label.check {
  flex-direction: row;
  align-items: center;
}
h1,
h2,
h3,
p {
  margin-top: 0;
}
h1 {
  font-size: 29px;
  letter-spacing: -1px;
  margin-bottom: 8px;
}
h2 {
  font-size: 19px;
}
h3 {
  font-size: 15px;
}
p {
  line-height: 1.6;
}
.muted,
.sub {
  color: var(--muted);
}
.sub {
  font-size: 12px;
}
.loading {
  padding: 80px;
  text-align: center;
}
.layout {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--deep);
  color: #d7e8e3;
  padding: 28px 18px;
  position: fixed;
  top: 0;
  bottom: 0;
  width: 232px;
  overflow: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin: 0 10px 28px;
}
.brandmark {
  background: #d5ef72;
  color: #173e31;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 23px;
  font-weight: 800;
}
.sidebar small {
  display: block;
  margin: 22px 12px 8px;
  font-size: 10px;
  color: #8cb3a9;
  letter-spacing: 1.8px;
  text-transform: uppercase;
}
.nav {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 11px 12px;
  background: none;
  border: none;
  color: #cae0d9;
  text-align: left;
  justify-content: flex-start;
  font-weight: 500;
  margin: 3px 0;
  min-height: 40px;
}
.nav.active {
  background: #286052;
  color: #fff;
}
.nav span {
  width: 22px;
  font-size: 16px;
}
.sidebar-foot {
  font-size: 11px;
  color: #9fbbb2;
  padding: 24px 12px;
}
.main {
  grid-column: 2;
  min-width: 0;
}
.topbar {
  height: 72px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  gap: 15px;
}
.topbar .business {
  font-weight: 600;
}
.userbox {
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 33px;
  height: 33px;
  background: #e5efeb;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--green);
}
.content {
  padding: 30px 32px 45px;
  max-width: 1600px;
  margin: 0 auto;
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 15px;
  margin-bottom: 23px;
}
.page-head p {
  margin: 0;
}
.actions,
.toolbar {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}
.toolbar {
  margin-bottom: 18px;
}
.toolbar input,
.toolbar select {
  width: auto;
  min-width: 140px;
}
.card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: 0 2px 3px #183b2903;
}
.card.flush {
  padding: 0;
  overflow: hidden;
}
.card-header {
  padding: 19px 21px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h2 {
  margin: 0;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 23px;
}
.stat {
  padding: 20px;
  border: 1px solid var(--line);
  background: white;
  border-radius: 11px;
}
.stat span {
  font-size: 12px;
  color: var(--muted);
}
.stat strong {
  display: block;
  font-size: 27px;
  margin: 10px 0 5px;
  letter-spacing: -1px;
}
.stat.green {
  background: #e9f3ed;
  border-color: #cfe1d5;
}
.stat small {
  font-size: 11px;
  color: var(--muted);
}
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.grid3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-grid .full {
  grid-column: 1/-1;
}
.form-actions {
  margin-top: 22px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.table-wrap {
  overflow: auto;
}
table {
  border-collapse: collapse;
  width: 100%;
  white-space: nowrap;
  text-align: left;
}
th {
  background: #f8faf9;
  color: #71817d;
  font-size: 10px;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  font-weight: 600;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
}
td {
  padding: 14px 18px;
  border-bottom: 1px solid #edf1ef;
  font-size: 13px;
}
tr:last-child td {
  border-bottom: none;
}
td strong {
  font-weight: 600;
}
td.num,
th.num {
  text-align: right;
}
.badge {
  border-radius: 5px;
  padding: 4px 7px;
  background: #eaf4ee;
  color: #247052;
  font-size: 11px;
  display: inline-block;
}
.badge.warn {
  color: var(--amber);
  background: #fff5d9;
}
.badge.bad {
  color: var(--red);
  background: #fcebea;
}
.badge.neutral {
  background: #edf1f3;
  color: #64757a;
}
.empty {
  text-align: center;
  padding: 45px 20px;
  color: var(--muted);
}
.notice {
  padding: 14px 16px;
  background: #edf5ef;
  border: 1px solid #cfe2d4;
  border-radius: 8px;
  color: #315b45;
  margin-bottom: 18px;
  font-size: 13px;
  line-height: 1.6;
}
.notice.error {
  background: #fcecea;
  color: #9e332c;
  border-color: #ecc4bf;
}
.notice.warn {
  background: #fff8e7;
  color: #826421;
  border-color: #eddfb6;
}
.pos {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 20px;
  align-items: start;
}
.scanbox {
  display: flex;
  gap: 10px;
  align-items: center;
}
.scanbox input {
  font-size: 18px;
  padding: 15px;
}
.scan-icon {
  font-size: 27px;
  color: var(--green);
}
.pos-summary {
  position: sticky;
  top: 20px;
}
.big-total {
  font-size: 42px;
  letter-spacing: -1.5px;
  font-weight: 700;
  margin: 10px 0 23px;
}
.summary-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 13px 0;
  color: var(--muted);
}
.wide {
  width: 100%;
}
.cart-qty {
  width: 90px;
}
.cart-discount {
  width: 90px;
}
.cart-warehouse {
  width: 135px;
}
.result-list {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 10px;
}
.result-list button {
  width: 100%;
  justify-content: space-between;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  font-weight: 400;
  text-align: left;
}
.result-list small {
  color: var(--muted);
}
.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.tabs button.active {
  background: var(--green);
  border-color: var(--green);
  color: white;
}
.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.login-intro {
  background: var(--deep);
  color: #fff;
  padding: 12vh 8vw;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login-intro h1 {
  font-size: 49px;
  line-height: 1.12;
  max-width: 480px;
  margin-top: 50px;
}
.login-intro p {
  color: #b9d3c9;
  font-size: 17px;
  max-width: 400px;
}
.login-main {
  display: grid;
  place-items: center;
  padding: 30px;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  padding: 35px;
  border: 1px solid var(--line);
  border-radius: 15px;
}
.login-card form {
  display: grid;
  gap: 17px;
}
.login-card h1 {
  margin-top: 25px;
}
.setup {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 30px;
}
.login-error {
  color: var(--red);
  font-size: 13px;
}
.mobile-toggle {
  display: none;
}
dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0;
  width: min(780px, 94vw);
  max-height: 91vh;
  color: var(--ink);
  box-shadow: 0 20px 70px #102b3240;
}
dialog::backdrop {
  background: #092e365c;
}
dialog > header {
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: white;
  z-index: 2;
}
dialog > header h2 {
  margin: 0;
}
#modal-body {
  padding: 24px;
}
.icon {
  border: none;
  font-size: 24px;
  padding: 0 8px;
  background: none;
  min-height: 30px;
}
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  max-width: 420px;
  padding: 15px 20px;
  background: var(--deep);
  color: white;
  border-radius: 9px;
  box-shadow: 0 6px 30px #173a3030;
  z-index: 100;
  display: none;
}
#toast.error {
  background: #9c3933;
}
.payment-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 35px;
  gap: 8px;
  align-items: end;
  margin-bottom: 10px;
}
.part-row {
  display: grid;
  grid-template-columns: 1fr 100px 35px;
  gap: 8px;
  margin-bottom: 10px;
}
.spacer {
  height: 15px;
}
.mono {
  font-family: ui-monospace, Consolas, monospace;
}
.inline {
  display: flex;
  gap: 10px;
  align-items: end;
}
.inline > * {
  flex: 1;
}
.kicker {
  font-size: 10px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--green);
  font-weight: 700;
  margin-bottom: 9px;
}
.link {
  border: none;
  color: var(--green);
  background: none;
  padding: 0;
  min-height: 25px;
}
.ticket {
  width: 54mm;
  margin: auto;
  font:
    11px ui-monospace,
    monospace;
  color: black;
}
.ticket h1 {
  font-size: 16px;
  text-align: center;
  letter-spacing: 0;
}
.ticket p {
  margin: 5px 0;
  line-height: 1.3;
}
.ticket hr {
  border: 0;
  border-top: 1px dashed #000;
}
.ticket .row {
  display: flex;
  justify-content: space-between;
  gap: 5px;
}
.ticket .center {
  text-align: center;
}
.label-sheet {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 20px;
}
.label-item {
  width: 56mm;
  min-height: 32mm;
  border: 1px dashed #aaa;
  padding: 6px;
  text-align: center;
  break-inside: avoid;
  color: black;
}
.label-item svg {
  width: 48mm;
  height: 19mm;
}
.label-item p {
  font: 11px sans-serif;
  margin: 2px;
}
.print-controls {
  padding: 20px;
  text-align: center;
}
.book-meta {
  font-size: 11px;
  color: var(--muted);
}
@media (max-width: 1150px) {
  .layout {
    grid-template-columns: 200px 1fr;
  }
  .sidebar {
    width: 200px;
  }
  .content {
    padding: 24px 20px;
  }
  .topbar {
    padding: 0 20px;
  }
  .pos {
    grid-template-columns: minmax(0, 1fr) 280px;
  }
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 850px) {
  .layout {
    display: block;
  }
  .sidebar {
    display: none;
    width: 240px;
    z-index: 20;
    box-shadow: 20px 0 60px #0003;
  }
  .sidebar.open {
    display: block;
  }
  .main {
    width: 100%;
  }
  .mobile-toggle {
    display: inline-flex;
  }
  .topbar {
    height: 62px;
    padding: 0 15px;
  }
  .content {
    padding: 22px 15px 35px;
  }
  .pos {
    grid-template-columns: 1fr;
  }
  .pos-summary {
    position: static;
  }
  .grid2,
  .grid3 {
    grid-template-columns: 1fr;
  }
  .page-head {
    flex-wrap: wrap;
  }
  .login {
    grid-template-columns: 1fr;
  }
  .login-intro {
    display: none;
  }
  .login-main {
    min-height: 100vh;
  }
  .userbox .sub {
    display: none;
  }
  .pos-summary .big-total {
    font-size: 35px;
  }
  .toolbar {
    align-items: stretch;
  }
  .toolbar input,
  .toolbar select {
    width: 100%;
  }
  h1 {
    font-size: 25px;
  }
}
@media (max-width: 500px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  .stats {
    gap: 10px;
  }
  .stat {
    padding: 14px;
  }
  .stat strong {
    font-size: 22px;
  }
  .card {
    padding: 16px;
  }
  .payment-row {
    grid-template-columns: 1fr 1fr 30px;
  }
  .payment-row label:nth-child(3) {
    grid-column: 1/3;
    grid-row: 2;
  }
  .payment-row button {
    grid-column: 3;
    grid-row: 1;
  }
  .topbar .business {
    max-width: 130px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .userbox {
    gap: 5px;
  }
  td,
  th {
    padding: 11px;
  }
  .big-total {
    font-size: 32px;
  }
  #modal-body {
    padding: 17px;
  }
}
@media print {
  @page {
    margin: 2mm;
  }
  body {
    background: white;
  }
  .print-controls {
    display: none !important;
  }
  .ticket {
    width: 54mm;
    margin: 0;
  }
  .label-sheet {
    padding: 0;
  }
  .label-item {
    border: none;
  }
  body:not(.print-page) .sidebar,
  body:not(.print-page) .topbar,
  body:not(.print-page) .toolbar,
  body:not(.print-page) .actions,
  body:not(.print-page) button {
    display: none !important;
  }
  .layout {
    display: block;
  }
  .content {
    padding: 0;
  }
  .card {
    border: 0;
    box-shadow: none;
  }
  table {
    white-space: normal;
  }
  th,
  td {
    padding: 5px;
    font-size: 9px;
  }
}

/* Keep grid/table content inside the available width on small devices. */
.card,
.grid2 > *,
.grid3 > *,
.pos > * {
  min-width: 0;
}
.topbar > .actions {
  min-width: 0;
  flex: 1;
  flex-wrap: nowrap;
}
.topbar .business {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.userbox,
.userbox > div {
  min-width: 0;
}
.userbox .avatar,
.userbox button {
  flex-shrink: 0;
}
.userbox strong {
  display: block;
  max-width: 180px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
@media (max-width: 500px) {
  .topbar {
    gap: 8px;
  }
  .topbar > .actions {
    gap: 5px;
  }
  .userbox strong {
    max-width: 85px;
  }
  .userbox .avatar {
    display: none;
  }
}

.mfa-qr {
  max-width: 100%;
  height: auto;
  margin: 0 auto 14px;
  image-rendering: pixelated;
}
.mfa-qr:not([hidden]) {
  display: block;
}
.mfa-key {
  overflow-wrap: anywhere;
  user-select: all;
}
.mfa-recovery-codes {
  list-style: none;
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 18px 0;
}
