/*
 * Layout: tablet landscape = menu (left) + live check (right, mirrored in Arabic).
 * Phone = menu only, the check opens as a full sheet from a bottom bar.
 * Every colour comes from a token; categories tint their tiles through --h (hue).
 */
:root {
  --bg: #e9eef0;
  --surface: #ffffff;
  --surface-2: #f3f6f7;
  --line: #d2dadd;
  --fg: #12232b;
  --muted: #566a73;
  --accent: #0b6b66;
  --accent-fg: #ffffff;
  --accent-soft: #d6ede9;
  --good: #1b7a49;
  --bad: #b3261e;
  --bad-soft: #fbe3e1;
  --scrim: rgba(10, 22, 28, 0.55);
  --tile-s: 42%;
  --tile-l: 93%;
  --tile-line-l: 82%;
  --shadow: 0 8px 28px rgba(10, 22, 28, 0.22);

  --font-body: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, system-ui, sans-serif;
  --font-display: 'Readex Pro', 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --r: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0d151a;
    --surface: #16222a;
    --surface-2: #1c2b34;
    --line: #2b3d47;
    --fg: #e5eef1;
    --muted: #93a7b0;
    --accent: #4cc4b9;
    --accent-fg: #052724;
    --accent-soft: #163b3b;
    --good: #5ccb8d;
    --bad: #ff8a80;
    --bad-soft: #3c1c1b;
    --scrim: rgba(0, 0, 0, 0.62);
    --tile-s: 24%;
    --tile-l: 19%;
    --tile-line-l: 28%;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --bg: #0d151a;
  --surface: #16222a;
  --surface-2: #1c2b34;
  --line: #2b3d47;
  --fg: #e5eef1;
  --muted: #93a7b0;
  --accent: #4cc4b9;
  --accent-fg: #052724;
  --accent-soft: #163b3b;
  --good: #5ccb8d;
  --bad: #ff8a80;
  --bad-soft: #3c1c1b;
  --scrim: rgba(0, 0, 0, 0.62);
  --tile-s: 24%;
  --tile-l: 19%;
  --tile-line-l: 28%;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#app {
  height: 100%;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.num,
.money {
  font-variant-numeric: tabular-nums;
}

/* ---------- buttons & fields ---------- */
.btn {
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}
.btn:hover {
  background: var(--surface-2);
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
  font-family: var(--font-display);
  font-weight: 600;
}
.btn.primary:hover {
  filter: brightness(1.06);
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
}
.btn.ghost:hover {
  background: var(--surface-2);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}
.btn.big {
  min-height: 56px;
  font-size: 17px;
}

.field {
  display: grid;
  gap: 6px;
  align-content: start;
}
.field label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}
.input {
  min-height: 44px;
  width: 100%;
  padding: 0 12px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface);
}
.input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

.badge {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 12px;
  font-weight: 600;
  display: inline-grid;
  place-items: center;
}

/* ---------- login ---------- */
.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 16px;
  padding: 24px 16px;
}
.copyright {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
}
.login-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  display: grid;
  gap: 16px;
  box-shadow: var(--shadow);
}
.login-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.login-card h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  text-wrap: balance;
}
.login-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}
.hint {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
}
.err {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--r);
  background: var(--bad-soft);
  color: var(--bad);
  font-size: 14px;
}

/* ---------- POS shell ---------- */
.pos {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  grid-template-rows: auto minmax(0, 1fr);
}
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  flex-wrap: wrap;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.brand strong {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
}
.brand span {
  font-size: 12px;
  color: var(--muted);
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.top-actions .btn {
  min-height: 40px;
  padding: 0 12px;
}
.who {
  color: var(--muted);
  font-size: 13px;
}

.menu {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.toolbar {
  display: grid;
  gap: 10px;
  padding: 12px 16px 4px;
}
.cats {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
}
.chip {
  flex: none;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 22px;
  border: 1px solid var(--chip-line, var(--line));
  background: var(--chip, var(--surface));
  color: var(--chip-fg, inherit);
  font-weight: 500;
}
.chip[aria-pressed='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

.items {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 16px 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  grid-auto-rows: min-content;
  gap: 10px;
  align-content: start;
}
.tile {
  min-height: 92px;
  padding: 10px 12px;
  border-radius: var(--r);
  border: 1px solid hsl(var(--h) 30% var(--tile-line-l));
  background: hsl(var(--h) var(--tile-s) var(--tile-l));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  text-align: start;
}
.tile:active {
  transform: scale(0.98);
}
.tile-name {
  font-weight: 500;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.tile-price {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}
.empty {
  grid-column: 1 / -1;
  padding: 32px 8px;
  color: var(--muted);
  text-align: center;
}

/* ---------- check panel ---------- */
.check {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-inline-start: 1px solid var(--line);
}
.check-head {
  display: grid;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.check-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.check-title h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.check-no {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 18px;
}
.head-actions {
  display: flex;
  gap: 4px;
}
.head-actions .btn {
  min-height: 40px;
  padding: 0 12px;
}
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  gap: 3px;
  border-radius: var(--r);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.seg button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-weight: 500;
}
.seg button[aria-pressed='true'] {
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--accent) inset;
  color: var(--accent);
}
.lines {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}
.line {
  display: grid;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.line-top,
.line-bot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.line-name {
  font-weight: 500;
  min-width: 0;
  overflow-wrap: anywhere;
}
.line-total {
  font-family: var(--font-display);
  font-weight: 500;
}
.line-unit {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.stepper {
  display: flex;
  align-items: center;
  gap: 4px;
}
.sq {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 20px;
  line-height: 1;
  display: grid;
  place-items: center;
}
.sq:hover {
  background: var(--surface-2);
}
.sq.danger {
  color: var(--bad);
  margin-inline-start: 8px;
}
.qty {
  min-width: 32px;
  text-align: center;
  font-weight: 600;
}
.check-empty {
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
}
.totals {
  padding: 12px 16px 0;
  display: grid;
  gap: 4px;
  border-top: 1px solid var(--line);
}
.totals .row {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 14px;
}
.totals .row.grand {
  color: var(--fg);
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  padding-top: 4px;
}
.check-foot {
  padding: 12px 16px;
}
.check-foot .btn {
  width: 100%;
}

.cartbar {
  display: none;
}

/* ---------- modal, toast, loader ---------- */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px));
  background: var(--scrim);
}
.modal {
  width: min(480px, 100%);
  max-height: 100%;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  display: grid;
  gap: 16px;
  box-shadow: var(--shadow);
}
.modal h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.due {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r);
  background: var(--accent-soft);
}
.due strong {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
}
.quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.quick .chip {
  min-height: 40px;
  border-radius: var(--r);
}
.change {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-family: var(--font-display);
}
.change strong {
  font-size: 22px;
  font-weight: 600;
}
.change strong.ok {
  color: var(--good);
}
.change strong.low {
  color: var(--bad);
}
.note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.modal-actions {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 8px;
}
.modal-actions.single {
  grid-template-columns: 1fr;
}
.done-mark {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--good);
  display: grid;
  place-items: center;
  font-size: 30px;
}
.kv {
  display: grid;
  gap: 8px;
  margin: 0;
}
.kv div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.kv dt {
  color: var(--muted);
}
.kv dd {
  margin: 0;
  font-weight: 500;
}
.oc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.oc {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}
.oc-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.oc-main strong {
  font-family: var(--font-mono);
  font-weight: 500;
}
.oc-meta {
  font-size: 13px;
  color: var(--muted);
}
.oc-side {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast {
  position: fixed;
  inset-inline: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  margin-inline: auto;
  width: fit-content;
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border-radius: var(--r);
  background: var(--fg);
  color: var(--bg);
  box-shadow: var(--shadow);
  font-weight: 500;
}
.toast.bad {
  background: var(--bad);
  color: #fff;
}

.loader {
  position: fixed;
  inset: 0 0 auto 0;
  height: 3px;
  z-index: 70;
  background: var(--accent);
  transform-origin: left;
  opacity: 0;
}
body[data-busy='1'] .loader {
  opacity: 1;
  animation: load 1s ease-in-out infinite;
}
@keyframes load {
  0% {
    transform: scaleX(0.05);
  }
  60% {
    transform: scaleX(0.8);
  }
  100% {
    transform: scaleX(1);
    opacity: 0.2;
  }
}

/* ---------- phone ---------- */
@media (max-width: 899px) {
  .pos {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
  }
  .who {
    display: none;
  }
  .check {
    position: fixed;
    inset: 0;
    z-index: 30;
    padding-top: env(safe-area-inset-top, 0px);
    border-inline-start: 0;
    transform: translateY(100%);
    visibility: hidden;
    transition: transform 0.22s ease, visibility 0.22s;
  }
  .check.open {
    transform: none;
    visibility: visible;
  }
  .cartbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 60px;
    margin: 0;
    padding: 8px 16px calc(8px + env(safe-area-inset-bottom, 0px));
    border: 0;
    border-top: 1px solid var(--line);
    background: var(--accent);
    color: var(--accent-fg);
    font-weight: 600;
    text-align: start;
  }
  .cartbar .money {
    font-family: var(--font-display);
    font-size: 18px;
  }
  .items {
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  }
  .modal-actions {
    grid-template-columns: 1fr;
  }
  .modal-actions .btn.primary {
    order: -1;
  }
}

@media (min-width: 900px) {
  .head-actions .mobile-only {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .check {
    transition: none;
  }
  body[data-busy='1'] .loader {
    animation: none;
  }
  .tile:active {
    transform: none;
  }
}

/* ---------- real-POS states: sent lines, send + pay ---------- */
.sent-tag {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}
.check-foot.two {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 8px;
}
.seg button:disabled,
.input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---------- admin ---------- */
.admin-link {
  justify-self: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 6px 10px;
}
.admin-link:hover {
  color: var(--accent);
}
.admin {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}
.adm-top {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.adm-title strong {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
}
.adm-tabs {
  display: flex;
  gap: 4px;
  padding: 3px;
  border-radius: var(--r);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.adm-tabs button {
  min-height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-weight: 500;
}
.adm-tabs button[aria-selected='true'] {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.adm-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.adm-actions .btn {
  min-height: 40px;
  padding: 0 12px;
}
.adm-demo {
  margin: 0;
  padding: 8px 16px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  text-align: center;
}
.adm-auth {
  flex: 1;
}
.adm-form {
  width: min(880px, 100%);
  margin: 0 auto;
  padding: 16px 16px 8px;
  display: grid;
  gap: 14px;
}
.adm-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  display: grid;
  gap: 14px;
  min-width: 0;
}
.adm-card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
}
.grid2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.hint-line {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
}
.row-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.row-inline select {
  flex: 1;
  min-width: 0;
}
select.input {
  padding-inline-end: 8px;
}
.test-line {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  min-width: 0;
  overflow-wrap: anywhere;
}
.test-line.ok {
  color: var(--good);
}
.test-line.bad {
  color: var(--bad);
}
.tender-list {
  display: grid;
  gap: 6px;
}
.tender {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}
.tender .chip {
  min-height: 34px;
  padding: 0 12px;
  margin-inline-start: 6px;
  font-size: 13px;
}
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}
.check-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}
.emp-wrap {
  position: relative;
  overflow-x: auto;
  min-width: 0;
  max-width: 100%;
}
.adm-card > * {
  min-width: 0;
}
.emp {
  width: 100%;
  min-width: 620px;
  border-collapse: separate;
  border-spacing: 0 6px;
}
.emp th {
  text-align: start;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  padding: 0 4px;
}
.emp td {
  padding: 0 4px;
}
.emp td:first-child .input,
.emp td:nth-child(4) .input,
.emp td:nth-child(5) .input {
  max-width: 120px;
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.adm-save {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
}
.adm-save-in {
  width: min(880px, 100%);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 6px 16px;
  flex-wrap: wrap;
}
.adm-save-in .btn {
  margin-inline-start: auto;
}
#admDirty {
  font-weight: 600;
  font-size: 14px;
  color: var(--good);
}
#admDirty.warn {
  color: var(--bad);
}

/* logs */
.adm-logs {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 12px;
}
.log-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.log-bar .input {
  flex: 1;
  min-width: 180px;
}
.seg3 {
  grid-template-columns: repeat(3, auto);
}
.seg3 button {
  padding: 0 14px;
}
.danger-btn {
  border-color: var(--bad);
  color: var(--bad);
}
.log-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}
.log + .log {
  border-top: 1px solid var(--line);
}
.log-row {
  width: 100%;
  display: grid;
  grid-template-columns: auto auto auto minmax(0, 1fr);
  align-items: baseline;
  gap: 10px;
  padding: 9px 12px;
  border: 0;
  background: transparent;
  text-align: start;
  font-size: 13px;
}
.log-row:disabled {
  cursor: default;
  opacity: 1;
}
.log-row:not(:disabled):hover {
  background: var(--surface-2);
}
.log-row time {
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 12px;
}
.log .lv {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
}
.log.warn .lv {
  background: hsl(40 90% 50% / 0.18);
  color: hsl(32 80% 38%);
}
.log.error .lv {
  background: var(--bad-soft);
  color: var(--bad);
}
.log .src {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
}
.log .msg {
  overflow-wrap: anywhere;
  text-align: left;
}
.log-details {
  margin: 0;
  padding: 10px 12px;
  background: var(--surface-2);
  border-top: 1px dashed var(--line);
  font-family: var(--font-mono);
  font-size: 12px;
  overflow-x: auto;
  white-space: pre;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .log.warn .lv {
    color: hsl(40 90% 65%);
  }
}
:root[data-theme='dark'] .log.warn .lv {
  color: hsl(40 90% 65%);
}

@media (max-width: 700px) {
  .grid2 {
    grid-template-columns: minmax(0, 1fr);
  }
  .log-row {
    grid-template-columns: auto auto minmax(0, 1fr);
  }
  .log-row .msg {
    grid-column: 1 / -1;
  }
  .adm-save-in .btn {
    width: 100%;
  }
}

/* ---------- admin pickers (property / RVC) ---------- */
.pick-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.pick-title {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}
.pick-current {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--r);
  background: var(--accent-soft);
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}
.pick-current.none {
  background: var(--surface-2);
  color: var(--muted);
}
.pick-label {
  font-size: 13px;
  color: var(--muted);
}
.pick-current strong {
  overflow-wrap: anywhere;
}
.pick-ref {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}
.pick-list {
  display: grid;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
  padding: 2px;
}
.pick-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 22px;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  text-align: start;
}
.pick-row:hover {
  background: var(--surface-2);
}
.pick-row[aria-selected='true'] {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.pick-name {
  font-weight: 500;
  overflow-wrap: anywhere;
}
.pick-mark {
  color: var(--accent);
  font-weight: 700;
  text-align: center;
}
.test-line.demo {
  color: var(--bad);
}
.adm-top .adm-demo {
  flex-basis: 100%;
  margin: 0 -16px -8px;
  border-radius: 0;
}
.tender .chip[aria-pressed='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}
/* iOS zooms into inputs under 16px */
@media (max-width: 899px) {
  .input,
  select.input {
    font-size: 16px;
  }
}
.pick-manual {
  display: grid;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px dashed var(--line);
}
.pick-manual label {
  font-size: 12.5px;
  color: var(--muted);
}
.mode-pill {
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
}
.mode-pill.real {
  background: var(--accent-soft);
  color: var(--accent);
}
.mode-pill.mock {
  background: var(--bad-soft);
  color: var(--bad);
}
.mode-warn {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--r);
  background: var(--bad-soft);
  color: var(--bad);
  font-size: 14px;
  font-weight: 500;
}

/* ---------- combo meals ---------- */
.tile.combo {
  position: relative;
}
.combo-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-fg);
}
.line-details {
  margin: 0;
  padding-inline-start: 18px;
  color: var(--muted);
  font-size: 13px;
  display: grid;
  gap: 2px;
}
.combo-modal {
  width: min(640px, 100%);
}
.cg {
  display: grid;
  gap: 8px;
}
.cg-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.cg-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
}
.cg-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--bad);
}
.cg-count.done {
  color: var(--good);
}
.cg-opts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
.cg-opt {
  min-height: 52px;
  padding: 8px 12px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  text-align: start;
  font-weight: 500;
}
.cg-opt .money {
  font-size: 12px;
  color: var(--muted);
}
.cg-opt[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.tender-type {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
}
.cg-times {
  color: var(--accent);
  font-weight: 700;
}
.list-table {
  min-width: 520px;
}
.list-table td.center {
  text-align: center;
}
.list-table input[type='checkbox'] {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

/* ---------- order types & payment buttons ---------- */
.ot-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ot-chip {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 19px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-weight: 500;
}
.ot-chip[aria-pressed='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}
.ot-chip:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.ot-grid,
.tender-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.ot-big,
.tender-btn {
  min-height: 64px;
  padding: 10px 14px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
}
.ot-big:hover,
.tender-btn:hover {
  border-color: var(--accent);
}
.tender-btn[aria-pressed='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}
.sq.cond-btn {
  font-size: 16px;
  color: var(--accent);
  margin-inline-end: 6px;
}
.cg-opt[hidden] {
  display: none !important;
}
.act-code {
  font-family: var(--font-mono);
  font-size: 22px;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
}

/* ---------- admin security ---------- */
.sec-state {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--r);
  font-weight: 600;
}
.sec-state.on {
  background: var(--accent-soft);
  color: var(--good);
}
.sec-state.off {
  background: var(--surface-2);
  color: var(--muted);
}
.steps,
.policy {
  margin: 0;
  padding-inline-start: 20px;
  display: grid;
  gap: 4px;
  font-size: 14px;
}
.qr-wrap {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}
.qr-box {
  width: 192px;
  height: 192px;
  padding: 8px;
  border-radius: var(--r);
  background: #ffffff;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
}
.qr-box.qr-fail {
  display: none;
}
.qr-side {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.secret {
  font-family: var(--font-mono);
  font-size: 15px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  overflow-wrap: anywhere;
}
.totp-in {
  max-width: 180px;
}
.new-code {
  display: grid;
  gap: 4px;
  padding: 14px;
  border-radius: var(--r);
  background: var(--accent-soft);
  text-align: center;
}
.new-code strong {
  font-family: var(--font-mono);
  font-size: 30px;
  letter-spacing: 0.12em;
  color: var(--accent);
}
.dev-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.dev {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}
.dev-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}
input[data-weak]::placeholder {
  color: var(--bad);
}

/* ---------- begin check by table / name, item comments ---------- */
.start-fields {
  display: grid;
  gap: 8px;
}
.start-fields.two {
  grid-template-columns: 1fr 1fr;
}
.modal .start-fields {
  margin-bottom: 4px;
}
.req {
  color: var(--bad);
}
.sub-h {
  margin: 6px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}
.line-comment {
  margin: 2px 0 0;
  padding-inline-start: 18px;
  font-size: 13px;
  font-style: italic;
  color: var(--accent);
  overflow-wrap: anywhere;
}
.sq.note-btn {
  font-size: 15px;
  margin-inline-end: 2px;
  filter: grayscale(1);
  opacity: 0.75;
}
.sq.note-btn[aria-pressed='true'] {
  filter: none;
  opacity: 1;
  border-color: var(--accent);
}
.seg4 {
  grid-template-columns: repeat(4, 1fr);
}
@media (max-width: 560px) {
  .seg4 {
    grid-template-columns: 1fr 1fr;
  }
}
.check-row input:disabled + span,
.check-row:has(input:disabled) {
  opacity: 0.55;
}

.check-no.draft {
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--muted);
}

/* ---------- reports ---------- */
.report-modal {
  width: min(920px, 100%);
  align-content: start;
}
.range-bar {
  display: grid;
  gap: 10px;
}
.range-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.range-chips .chip {
  min-height: 38px;
}
.range-dates {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
}
.range-dates label {
  display: grid;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}
.range-dates .input {
  min-width: 150px;
}
.report-body {
  min-height: 120px;
}
.rp {
  display: grid;
  gap: 16px;
}
.rp-head {
  display: grid;
  gap: 2px;
}
.rp-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 18px;
}
.rp-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}
.rp-head .rp-gen {
  font-size: 12px;
}
.rp-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}
.rp-tile {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}
.rp-tile span {
  font-size: 13px;
  color: var(--muted);
}
.rp-tile strong {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
}
.rp-tile.hero {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.rp-tile.hero strong {
  font-size: 24px;
}
.rp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.rp-sec {
  display: grid;
  gap: 8px;
  min-width: 0;
  align-content: start;
}
.rp-sec h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}
.rp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.rp-table th {
  text-align: start;
  font-weight: 500;
  font-size: 12px;
  color: var(--muted);
  padding: 4px 6px;
  border-bottom: 1px solid var(--line);
}
.rp-table td {
  padding: 7px 6px;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.rp-table .n {
  text-align: end;
  white-space: nowrap;
}
.rp-table .muted,
.muted {
  color: var(--muted);
  font-size: 12px;
}
.rp-bars {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}
.rp-bars li {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  padding: 2px 0;
}
.rp-bar {
  height: 14px;
  display: block;
}
.rp-bar i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-start-end-radius: 4px;
  border-end-end-radius: 4px;
}
#printRoot {
  display: none;
}
@media print {
  body.print-report > :not(#printRoot) {
    display: none !important;
  }
  body.print-report {
    background: #fff;
    color: #000;
  }
  body.print-report #printRoot {
    display: block;
    padding: 0 4mm;
    font-size: 12px;
  }
  #printRoot .rp-tile {
    background: #fff;
    border-color: #999;
  }
  #printRoot .rp-tile.hero {
    background: #fff;
  }
  #printRoot .rp-bar i {
    background: #555;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  #printRoot .rp-grid {
    grid-template-columns: 1fr 1fr;
  }
  #printRoot .rp-sec {
    break-inside: avoid;
  }
}
@media (max-width: 560px) {
  .adm-tabs {
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .adm-tabs button {
    flex: none;
    padding: 0 10px;
  }
}

/* ---------- home page (optional, Admin -> Home page) ---------- */
.home {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}
.home-main {
  overflow-y: auto;
  padding: 28px 16px 20px;
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 22px;
}
.home-hello {
  text-align: center;
  display: grid;
  gap: 4px;
}
.home-hello h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 26px;
}
.home-hello p {
  margin: 0;
  color: var(--muted);
}
.home-grid {
  width: min(880px, 100%);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.home-tile {
  min-height: 116px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 18px 20px;
  text-align: start;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 1px 0 var(--line);
  cursor: pointer;
}
.home-tile strong {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
}
.home-tile span {
  font-size: 14px;
  color: var(--muted);
}
.home-tile:hover,
.home-tile:focus-visible {
  border-color: var(--accent);
}
.home-tile[data-act='hstart'] {
  border-inline-start: 4px solid var(--accent);
}
.home-tile.quiet {
  min-height: 80px;
  background: var(--surface-2);
}
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 2px 12px;
}
#ocSearch {
  margin-bottom: -4px;
}
@media (max-width: 560px) {
  .home-main {
    padding-top: 18px;
  }
  .home-grid {
    grid-template-columns: 1fr;
  }
  .home-tile {
    min-height: 88px;
  }
}

/* ---------- admin: menu screens (SLU) ---------- */
.screens td.move {
  white-space: nowrap;
}
.screens td.move .sq {
  width: 34px;
  min-height: 34px;
  margin-inline-end: 4px;
}
.screens tr.off .cat-name {
  color: var(--muted);
  text-decoration: line-through;
}
.screens .hint-line {
  font-size: 12px;
}
.new-tag {
  background: var(--accent);
  color: var(--accent-fg);
}
.pick-head h2 {
  margin: 0;
}

/* ---------- discounts ---------- */
.check-tools {
  display: flex;
  gap: 6px;
  padding: 8px 16px 0;
}
.check-tools .btn {
  min-height: 38px;
  padding: 0 14px;
}
.totals .disc-row {
  color: var(--good);
}
.totals .disc-row span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sq.mini {
  width: 26px;
  height: 26px;
  min-height: 26px;
  font-size: 14px;
}
.disc-btn {
  display: grid;
  gap: 4px;
  align-content: center;
}
.disc-btn small {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}
.disc-btn[aria-pressed='true'] small {
  color: inherit;
}
.disc-btn:disabled {
  opacity: 0.55;
}
.disc-btn .lock {
  font-size: 13px;
  margin-inline-start: 4px;
}
.totals .approved {
  font-size: 11px;
  color: var(--muted);
}
.approve-box {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.approve-box strong {
  font-family: var(--font-display);
  font-size: 17px;
}
.approve-form {
  display: grid;
  gap: 12px;
}
.acc-select {
  min-width: 140px;
}
.over-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.over-row .input {
  width: 80px;
}
.over-row .hint-line {
  flex: 1 1 260px;
}

/* ---------- admin: setup steps ---------- */
.setup-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.step {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
}
.step-mark {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 600;
  border: 2px solid var(--line);
  color: var(--muted);
}
.step.done .step-mark {
  background: var(--good);
  border-color: var(--good);
  color: #fff;
}
.step.opt .step-mark {
  border-style: dashed;
}
.step-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.step.done .step-text strong {
  color: var(--muted);
}
.danger-card {
  border-color: var(--bad);
}
.danger-card h2 {
  color: var(--bad);
}

/* ---------- admin accounts ---------- */
.adm-user {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  margin-bottom: 10px;
}
.adm-user.off {
  opacity: 0.7;
}
.adm-user.new {
  border-style: dashed;
}
.adm-user-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.adm-who {
  margin-inline-start: 10px;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- design: groups of menu screens, tile sizes, category column ---------- */
.catbox {
  display: grid;
  gap: 8px;
  min-width: 0;
}
.chip.grp {
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.grp-count {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: color-mix(in srgb, currentColor 14%, transparent);
  font-size: 12px;
  display: inline-grid;
  place-items: center;
}
.chip.grp.tinted {
  background: var(--gc);
  border-color: var(--gc);
  color: var(--gc-fg);
}
.chip.grp.tinted[aria-pressed='true'] {
  background: var(--gc);
  border-color: var(--gc);
  color: var(--gc-fg);
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.cats.subcats {
  padding: 8px;
  border-radius: calc(var(--r) + 4px);
  background: color-mix(in srgb, var(--gc, var(--accent)) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--gc, var(--accent)) 30%, var(--surface));
  padding-bottom: 8px;
}
.chip.sub {
  min-height: 40px;
  border-radius: var(--r);
}
.cats.side .subs {
  display: contents;
}
.tile.gtint {
  background: color-mix(in srgb, var(--gc) 22%, var(--surface));
  border-color: color-mix(in srgb, var(--gc) 48%, var(--surface));
}
.tiles-color .tile {
  background: var(--tile-bg);
  border-color: var(--tile-line);
  color: var(--tile-fg);
}
.tiles-color .tile .tile-price {
  color: var(--tile-fg);
  opacity: 0.8;
}
.pos.tiles-s .items {
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 8px;
}
.pos.tiles-s .tile {
  min-height: 70px;
  padding: 8px 10px;
  font-size: 14px;
}
.pos.tiles-l .items {
  grid-template-columns: repeat(auto-fill, minmax(192px, 1fr));
  gap: 12px;
}
.pos.tiles-l .tile {
  min-height: 124px;
  padding: 14px 16px;
  font-size: 18px;
}
.pos.tiles-l .tile-price {
  font-size: 16px;
}
@media (min-width: 900px) {
  .pos.cats-side .menu {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }
  .pos.cats-side .toolbar {
    display: contents;
  }
  .pos.cats-side #search {
    grid-column: 1 / -1;
    width: auto;
    margin: 12px 16px 4px;
  }
  .pos.cats-side .catbox {
    grid-row: 2;
    min-height: 0;
    overflow-y: auto;
    padding: 8px 0 16px;
    padding-inline-start: 16px;
    align-content: start;
  }
  .pos.cats-side .cats.side {
    flex-direction: column;
    align-items: stretch;
    overflow: visible;
  }
  .pos.cats-side .cats.side .chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 48px;
    border-radius: var(--r);
    text-align: start;
  }
  .pos.cats-side .cats.side .subs {
    display: grid;
    gap: 6px;
    padding: 6px;
    margin-inline-start: 10px;
    border-inline-start: 3px solid var(--accent);
  }
  .pos.cats-side .cats.side .chip.sub {
    min-height: 42px;
  }
  .pos.cats-side .items {
    grid-row: 2;
    grid-column: 2;
  }
}

/* ---------- admin: design tab ---------- */
.seg.n3 {
  grid-template-columns: repeat(3, 1fr);
}
.presets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 8px;
}
.preset {
  display: grid;
  gap: 6px;
  justify-items: start;
  padding: 10px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 500;
  text-align: start;
}
.preset[aria-pressed='true'] {
  box-shadow: 0 0 0 2px var(--accent) inset;
}
.sw-row {
  display: flex;
  gap: 4px;
}
.sw {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.15);
}
.ds-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 16px;
  align-items: start;
}
.ds-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.color-in {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.color-in input[type='color'] {
  width: 52px;
  height: 40px;
  padding: 2px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
}
.color-in input[type='color']:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.color-in bdi {
  font-size: 13px;
  color: var(--muted);
}
.ds-preview {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  pointer-events: none;
  font-size: 14px;
}
.pv-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.pv-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
}
.pv-menu {
  display: grid;
  gap: 8px;
  padding: 10px;
  min-width: 0;
}
.pv-menu .chip {
  min-height: 34px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
}
.pv-menu .cats {
  padding-bottom: 0;
  overflow: hidden;
}
.pv-menu .cats.subcats {
  padding: 6px;
}
.pv-items {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.pv-items .tile {
  min-height: 60px;
  padding: 8px;
  font-size: 13px;
}
.pv-check {
  display: grid;
  align-content: end;
  gap: 8px;
  padding: 10px;
  background: var(--surface);
  border-inline-start: 1px solid var(--line);
}
.pv-check .btn {
  min-height: 38px;
}
.pv-total {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
}
.grp-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  border-inline-start: 6px solid var(--gc, var(--line));
  background: var(--surface-2);
}
.grp-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.grp-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gc, transparent);
  border: 1px solid var(--line);
}
.grp-title {
  flex: 1;
  min-width: 0;
  font-family: var(--font-display);
}
.grp-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}
.grp-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.grp-slus {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
  counter-reset: slu;
}
.grp-slus li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px;
  padding-inline-start: 12px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  counter-increment: slu;
}
.grp-slus li > span:first-child::before {
  content: counter(slu) '. ';
  color: var(--muted);
}
.grp-slus .sq {
  width: 34px;
  height: 34px;
  font-size: 16px;
}
.grp-slus .sq.danger {
  margin-inline-start: 0;
}
.grp-add {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.pill-btn {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 18px;
  border: 1px dashed var(--line);
  background: var(--surface);
  font-size: 13.5px;
}
.pill-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn.danger-text {
  color: var(--bad);
  min-height: 36px;
}
@media (max-width: 760px) {
  .ds-grid,
  .grp-fields {
    grid-template-columns: minmax(0, 1fr);
  }
}

.cats.subcats[style] .chip.sub[aria-pressed='true'],
.subs.tinted .chip.sub[aria-pressed='true'] {
  background: var(--gc);
  border-color: var(--gc);
  color: var(--gc-fg);
}
.pos.cats-side .cats.side .subs.tinted {
  border-inline-start-color: var(--gc);
}
@media (max-width: 600px) {
  .pos.tiles-l .items {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
  .pos.tiles-l .tile {
    min-height: 104px;
  }
}

/* ---------- design: groups on top, the chosen group's screens on the side ---------- */
.subside {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  margin: 4px 16px 0;
  padding: 8px;
  border-radius: calc(var(--r) + 4px);
  background: color-mix(in srgb, var(--gc, var(--accent)) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--gc, var(--accent)) 30%, var(--surface));
  scrollbar-width: thin;
}
.subside-title {
  margin: 0;
  padding-inline: 4px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.subside.tinted .chip.sub[aria-pressed='true'] {
  background: var(--gc);
  border-color: var(--gc);
  color: var(--gc-fg);
}
@media (min-width: 900px) {
  .pos.cats-split .menu.has-side {
    display: grid;
    grid-template-columns: 210px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }
  .pos.cats-split .menu.has-side .toolbar {
    grid-column: 1 / -1;
  }
  .pos.cats-split .menu.has-side .subside {
    grid-row: 2;
    grid-column: 1;
    align-self: start;
    flex-direction: column;
    align-items: stretch;
    max-height: calc(100% - 24px);
    overflow-x: visible;
    overflow-y: auto;
    margin: 8px 0 16px;
    margin-inline-start: 16px;
  }
  .pos.cats-split .menu.has-side .subside .chip.sub {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 48px;
    text-align: start;
  }
  .pos.cats-split .menu.has-side .items {
    grid-row: 2;
    grid-column: 2;
  }
}

/* ---------- design: check on a fixed side (left / right), whatever the language ---------- */
:root[dir='rtl'] {
  --pg-dir: rtl;
}
:root[dir='ltr'] {
  --pg-dir: ltr;
}
@media (min-width: 900px) {
  .pos.check-left,
  .pos.check-right {
    direction: ltr;
  }
  .pos.check-left > *,
  .pos.check-right > * {
    direction: var(--pg-dir, rtl);
  }
  .pos.check-left {
    grid-template-columns: 390px minmax(0, 1fr);
  }
  .pos.check-left .menu {
    grid-column: 2;
    grid-row: 2;
  }
  .pos.check-left .check {
    grid-column: 1;
    grid-row: 2;
    border-inline-start: 0;
    border-right: 1px solid var(--line);
  }
  .pos.check-right .check {
    border-inline-start: 0;
    border-left: 1px solid var(--line);
  }
  /* the side column of categories goes to the outer edge, away from the check */
  .pos.check-left.cats-side .menu,
  .pos.check-right.cats-side .menu,
  .pos.check-left.cats-split .menu.has-side,
  .pos.check-right.cats-split .menu.has-side {
    direction: ltr;
  }
  .pos.check-left.cats-side .menu > *,
  .pos.check-right.cats-side .menu > *,
  .pos.check-left.cats-split .menu.has-side > *,
  .pos.check-right.cats-split .menu.has-side > * {
    direction: var(--pg-dir, rtl);
  }
  .pos.check-left.cats-side .menu {
    grid-template-columns: minmax(0, 1fr) 220px;
  }
  .pos.check-left.cats-side .catbox {
    grid-column: 2;
    padding-inline-start: 0;
    padding-left: 0;
    padding-right: 16px;
  }
  .pos.check-left.cats-side .items {
    grid-column: 1;
  }
  .pos.check-right.cats-side .catbox {
    padding-inline-start: 0;
    padding-right: 0;
    padding-left: 16px;
  }
  .pos.check-left.cats-split .menu.has-side {
    grid-template-columns: minmax(0, 1fr) 210px;
  }
  .pos.check-left.cats-split .menu.has-side .subside {
    grid-column: 2;
    margin-inline-start: 0;
    margin-left: 0;
    margin-right: 16px;
  }
  .pos.check-left.cats-split .menu.has-side .items {
    grid-column: 1;
  }
  .pos.check-right.cats-split .menu.has-side .subside {
    margin-inline-start: 0;
    margin-right: 0;
    margin-left: 16px;
  }
}
