:root {
  color-scheme: light;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  color: #172d3d;
  background: #f2f5f7;
  --navy: #18384d;
  --teal: #086953;
  --teal-dark: #064c3c;
  --line: #d4dfe5;
  --muted: #526775;
  --danger: #a1232d;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 2.75rem;
  padding: .55rem .85rem;
  background: #fff;
  color: var(--navy);
  border: 1px solid #adbeca;
  border-radius: .5rem;
  font-weight: 650;
  cursor: pointer;
}

button:hover { background: #edf3f7; }
button:disabled { opacity: .57; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid #1676a8;
  outline-offset: 3px;
}

button.primary { background: var(--teal); color: white; border-color: var(--teal); }
button.primary:hover { background: var(--teal-dark); border-color: var(--teal-dark); }
button.danger { color: var(--danger); }
button.text-button { color: var(--teal-dark); background: transparent; border-color: transparent; text-decoration: underline; text-underline-offset: .18em; }
button.text-button:hover { background: #edf3f7; }
input, select, textarea {
  width: 100%;
  min-width: 0;
  min-height: 2.75rem;
  padding: .5rem .65rem;
  border: 1px solid #a7bac9;
  border-radius: .5rem;
  background: #fff;
  color: inherit;
}

input::placeholder { color: #607684; opacity: 1; }
textarea { resize: vertical; }
label { font-weight: 600; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.55rem, 3vw, 1.95rem); letter-spacing: -.025em; line-height: 1.16; }
h2 { font-size: 1.15rem; letter-spacing: -.015em; }
h3 { font-size: 1rem; }
small, .subtle { color: var(--muted); font-size: .88rem; line-height: 1.45; }
.subtle:not(:empty) { margin-top: .3rem; }
.sr-only, .skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link:focus { position: absolute; z-index: 2; top: .5rem; left: .5rem; color: var(--navy); background: white; padding: .7rem; }

.shell { display: flex; align-items: center; gap: 1rem; padding: .6rem clamp(.75rem, 3vw, 2.25rem); min-height: 4.15rem; color: #fff; background: var(--navy); }
.brand { display: flex; align-items: center; gap: .6rem; flex-shrink: 0; margin-right: .65rem; }
.brand strong, .brand small { display: block; }
.brand small { color: #d2e2ec; font-size: .8rem; }
.brand-mark { position: relative; display: inline-block; width: 2.24rem; height: 2.24rem; border-radius: .55rem; background: #d7f2e7; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -50%); width: 1.17rem; height: .33rem; border-radius: .08rem; background: var(--teal); }
.brand-mark::after { transform: translate(-50%, -50%) rotate(90deg); }
.shell nav { display: flex; flex-wrap: wrap; gap: .2rem; }
.shell nav button, .account button { color: #fff; background: transparent; border-color: transparent; }
.shell nav button:hover, .account button:hover { background: #2c4d63; }
.shell nav button[aria-current=page] { background: #d7f2e7; color: #15483b; }
.shell button:focus-visible { outline-color: #7bd7bd; }
.account { margin-left: auto; display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: .3rem; font-size: .88rem; }
.account button { border-color: #7590a2; min-height: 2.3rem; }
.account span { overflow-wrap: anywhere; }

main { max-width: 106rem; padding: clamp(.85rem, 2.7vw, 2rem); margin: auto; }
.login-card { margin: min(11vh, 5rem) auto 0; padding: clamp(1rem, 4vw, 2rem); width: min(100%, 25rem); }
.login-card h1 { margin-bottom: 1.4rem; }
#login-switch { margin-top: .55rem; }
.section-heading, .toolbar, .basket-header, .sync-header, .dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: .75rem; }
.section-heading { margin-bottom: 1.25rem; align-items: flex-start; }
.toolbar { flex-wrap: wrap; justify-content: flex-end; }
.pill { display: inline-block; border-radius: 1rem; padding: .3rem .7rem; color: #415969; background: #e9eff3; font-size: .81rem; font-weight: 650; }
.pill.good { color: #14523b; background: #dcf2e7; }
.pill.warn { color: #674216; background: #fff0d9; }
.pill.bad { color: #81232b; background: #fce4e5; }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: .8rem; background: #fff; }
.panel-header { padding: 1rem 1.1rem; border-bottom: 1px solid var(--line); }
.notice { margin: 0 0 .9rem; padding: .65rem .85rem; border: 1px solid #bbdcca; border-radius: .45rem; background: #e6f5ed; color: #1b563b; overflow-wrap: anywhere; }
.notice.error { border-color: #e3a9ac; background: #fcebed; color: #84222b; }
.empty { padding: 1.1rem; color: var(--muted); }

.register-layout { display: grid; grid-template-columns: minmax(0, 1.28fr) minmax(22rem, 1fr); gap: 1rem; align-items: start; }
#search-form { display: flex; gap: .5rem; margin-top: .75rem; }
#catalog-search { min-height: 3.05rem; }
#viewer-search { margin-top: .4rem; }
.product-results { min-height: 13rem; }
.suggestions { display: flex; flex-wrap: wrap; gap: .35rem; padding: .65rem 1.1rem; background: #edf7f2; }
.suggestions button { min-height: 2.5rem; color: var(--teal-dark); }
.product, .basket-item, .hold-item { display: flex; align-items: center; justify-content: space-between; gap: .75rem; min-width: 0; padding: .76rem 1.1rem; border-bottom: 1px solid #e7edf1; }
.product:last-child, .basket-item:last-child, .hold-item:last-child { border-bottom: 0; border-radius: 0 0 .8rem .8rem; }
.product > div:first-child, .basket-item > div:first-child, .hold-item > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.product h3, .basket-item strong, .hold-item strong { line-height: 1.24; }
.product small, .basket-item small, .hold-item small { display: block; margin-top: .23rem; }
.product-price { font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 4.25rem; text-align: right; }
.product-action { display: flex; align-items: center; gap: .65rem; margin-left: auto; }
.product-action button { min-width: 3.3rem; color: var(--teal-dark); }
.stock-out { color: var(--danger); }
.basket { position: sticky; top: 1rem; }
.basket-items { min-height: 13rem; }
.basket-totals { padding: 1rem; background: #f8fafb; border-top: 1px solid var(--line); border-radius: 0 0 .8rem .8rem; }
.mobile-basket { display: none; }
.total-row, .summary-row { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: .4rem; }
.total-row strong, .amount { font-size: 1.7rem; letter-spacing: -.025em; font-variant-numeric: tabular-nums; font-weight: 750; }
.basket-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: .55rem; margin-top: .9rem; }
.basket-actions > button { min-height: 3.1rem; }
.quantity { display: flex; align-items: center; gap: .3rem; white-space: nowrap; }
.quantity button { min-width: 2.5rem; padding: .35rem; }
.quantity output { min-width: 1.5rem; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }

.filters { display: flex; align-items: flex-end; flex-wrap: wrap; gap: .8rem; border-bottom: 1px solid var(--line); padding: 1rem; }
.filters label, .field { display: grid; gap: .32rem; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; text-align: left; }
th, td { padding: .7rem .85rem; border-bottom: 1px solid #e7edf1; overflow-wrap: anywhere; vertical-align: middle; }
th { font-size: .87rem; font-weight: 650; background: #f6f9fb; }
tr:last-child td { border-bottom: 0; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.receipt-number { color: var(--teal-dark); text-decoration: underline; }
.sync-panel { margin-bottom: 1rem; }
.details-list { display: grid; grid-template-columns: minmax(8rem, .55fr) minmax(0, 1fr); gap: .65rem 1rem; margin: 0; padding: 1rem; }
.details-list dt { color: var(--muted); }
.details-list dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.sync-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.sync-card { padding: 1.1rem; }
.sync-card button { margin-top: .85rem; }
#terminal-setup:not(:empty) { margin-bottom: 1rem; }

dialog { color: inherit; width: min(calc(100% - 1.5rem), 36rem); max-height: min(calc(100% - 1.5rem), 50rem); overflow: auto; border: 1px solid var(--line); border-radius: .8rem; box-shadow: 0 1rem 4rem #17313c54; padding: 0; }
dialog::backdrop { background: #122b3d8c; }
.dialog-heading { border-bottom: 1px solid var(--line); padding: .65rem 1rem; }
.dialog-body { padding: 1rem; overflow-wrap: anywhere; }
.dialog-body h3 { margin: .9rem 0 .45rem; }
.dialog-body hr { border: 0; border-bottom: 1px solid var(--line); margin: .9rem 0; }
.dialog-body .details-list { padding: 0; }
.dialog-body .notice { margin: 0; }
.form-stack { display: grid; gap: .65rem; }
.form-stack > label { margin-top: .3rem; }
.form-stack > input { margin-top: -.35rem; }
.form-stack .primary { margin-top: .2rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .6rem; flex-wrap: wrap; margin-top: .65rem; }
.summary-list { margin: .4rem 0; padding: 0; }
.summary-list dd { margin: 0; }
.summary-list .summary-row { padding: .25rem 0; }
.payment-methods { display: flex; gap: .5rem; flex-wrap: wrap; margin: .4rem 0; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: .5rem; }
.payment-methods label { display: flex; align-items: center; min-height: 2.2rem; gap: .3rem; padding-right: .5rem; }
.payment-methods input { width: 1rem; min-height: auto; }

@media (max-width: 900px) {
  .shell { flex-wrap: wrap; gap: .45rem .7rem; }
  .shell nav { order: 3; width: 100%; }
  .shell nav button { flex: 1; }
  .section-heading { flex-wrap: wrap; }
  .toolbar { justify-content: flex-start; }
  .register-layout { grid-template-columns: minmax(0, 1fr) minmax(18rem, .8fr); }
}

@media (max-width: 670px) {
  .register-layout, .sync-actions { grid-template-columns: minmax(0, 1fr); }
  .basket { position: static; }
  .product-results, .basket-items { min-height: auto; }
  .section-heading, .toolbar { gap: .55rem; }
  .product, .basket-item, .hold-item, .panel-header { padding-left: .75rem; padding-right: .75rem; }
  .mobile-basket { position: fixed; z-index: 1; right: 0; bottom: 0; left: 0; display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .55rem .85rem max(.55rem, env(safe-area-inset-bottom)); background: white; box-shadow: 0 -.2rem 1.1rem #18384d1f; font-weight: 700; }
  .view:has(.mobile-basket:not([hidden])) { padding-bottom: 4.15rem; }
  .details-list { grid-template-columns: minmax(5rem, .55fr) minmax(0, 1fr); }
  .table-wrap table { min-width: 30rem; }
}

@media (max-width: 365px) {
  .toolbar button, .shell nav button { font-size: .85rem; }
  .product-action { align-items: flex-end; flex-direction: column; gap: .25rem; }
  .basket-actions { grid-template-columns: minmax(0, 1fr); }
}

@media print {
  body { background: white; }
  body > :not(dialog), .dialog-heading button, .no-print { display: none !important; }
  dialog[open] { position: static; inset: auto; display: block; width: 100%; max-height: none; padding: 0; border: 0; box-shadow: none; }
  dialog::backdrop { display: none; }
  .dialog-body, .dialog-heading { padding: .5rem 0; }
}
