body.dark {
  background: var(--char);
  color: var(--steam);
  min-height: 100dvh;
  overflow-x: hidden;
}

.kds {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: 100dvh;
}

/* ---------- top bar ---------- */
.kds-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--char-line);
  background: var(--char);
  flex-wrap: wrap;
}
.kds-brand {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-right: auto;
}
.kds-brand b {
  font-family: var(--condensed);
  font-weight: 700;
  font-size: 1.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.kds-brand span {
  color: #a5978a;
  font-size: 0.9rem;
}
.kds-clock {
  font-family: var(--condensed);
  font-size: 1.6rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}
.kds-conn {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #6fbf73;
  box-shadow: 0 0 0 4px rgba(111, 191, 115, 0.15);
}
.kds-conn.off {
  background: var(--paprika);
  box-shadow: 0 0 0 4px rgba(194, 70, 43, 0.25);
  animation: blink 1s steps(2) infinite;
}
@keyframes blink {
  50% {
    opacity: 0.3;
  }
}
.kds-tools {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.kbtn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--char-line);
  background: var(--char-2);
  color: var(--steam);
  padding: 0.5rem 0.8rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.15s, border-color 0.15s;
}
.kbtn:hover {
  background: var(--char-3);
}
.kbtn.on {
  border-color: var(--saffron);
  color: var(--saffron);
}
.kbtn.warn {
  border-color: var(--paprika);
  background: rgba(194, 70, 43, 0.15);
  animation: blink 1.4s steps(2) infinite;
}
.waiter-calls {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 0.6rem 1.25rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--char-line);
  background: var(--char-2);
}
.waiter-calls.pending {
  border-color: #77562d;
  background: #2e2419;
}
.waiter-heading h2 {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  font: 700 1.2rem var(--condensed);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.waiter-calls.pending h2 {
  color: var(--saffron);
}
.waiter-heading span {
  color: #cbbfb2;
  font-size: 0.85rem;
}
.waiter-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
  gap: 0.5rem;
  max-height: min(11rem, 32dvh);
  overflow-y: auto;
}
.waiter-list:empty {
  display: none;
}
.waiter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.65rem;
  background: var(--char);
  border: 1px solid #77562d;
  border-radius: 8px;
}
.waiter-row b {
  font: 700 1.3rem/1.1 var(--condensed);
  overflow-wrap: anywhere;
}
.waiter-row small {
  display: block;
  color: #cbbfb2;
}
.waiter-row .kbtn {
  flex-shrink: 0;
}

/* ---------- lanes ---------- */
.lanes {
  display: grid;
  grid-template-columns: 1fr 1.25fr 0.9fr;
  min-height: 0;
}
.lane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--char-line);
}
.lane:last-child {
  border-right: 0;
}
.lane-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1rem;
  font-family: var(--condensed);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #cbbfb2;
}
.lane-head .dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}
.lane[data-lane="new"] .dot {
  background: var(--steam);
}
.lane[data-lane="preparing"] .dot {
  background: var(--saffron);
}
.lane[data-lane="ready"] .dot {
  background: #6fbf73;
}
.lane-head .n {
  margin-left: auto;
  background: var(--char-3);
  border-radius: 999px;
  padding: 0 0.6rem;
  font-size: 1rem;
  color: var(--steam);
}
.lane-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.25rem 0.8rem 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  align-content: start;
  gap: 0.8rem;
}
.lane-empty {
  grid-column: 1 / -1;
  border: 1.5px dashed var(--char-line);
  border-radius: 14px;
  padding: 2rem 1rem;
  text-align: center;
  color: #8a7d71;
  font-size: 0.95rem;
}

/* ---------- ticket ---------- */
.ticket {
  background: var(--steam);
  color: var(--ink);
  border-radius: 6px 6px 4px 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 24px -14px rgba(0, 0, 0, 0.7);
  position: relative;
}
.ticket.enter {
  animation: drop-in 0.45s var(--ease) both;
}
@keyframes drop-in {
  from {
    opacity: 0;
    transform: translateY(-16px) rotate(-1deg);
  }
}
.ticket.fresh {
  animation: fresh 1s ease-in-out infinite;
}
@keyframes fresh {
  50% {
    box-shadow: 0 0 0 5px var(--saffron), 0 12px 24px -14px rgba(0, 0, 0, 0.7);
  }
}
.t-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  background: #d9cdb9;
  border-bottom: 2px dashed rgba(31, 26, 23, 0.25);
}
.ticket[data-age="warn"] .t-head {
  background: var(--saffron);
}
.ticket[data-age="late"] .t-head {
  background: var(--paprika);
  color: #fff;
}
.ticket[data-age="late"] {
  animation: late 2s ease-in-out infinite;
}
@keyframes late {
  50% {
    box-shadow: 0 0 0 3px rgba(194, 70, 43, 0.7), 0 12px 24px -14px rgba(0, 0, 0, 0.7);
  }
}
.t-no {
  font-family: var(--condensed);
  font-weight: 700;
  font-size: 2rem;
  line-height: 1;
}
.t-table {
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.t-table small {
  display: block;
  font-weight: 500;
  font-size: 0.78rem;
  opacity: 0.75;
}
.t-timer {
  font-family: var(--condensed);
  font-weight: 700;
  font-size: 1.45rem;
  font-variant-numeric: tabular-nums;
}
.t-note {
  margin: 0.6rem 0.75rem 0;
  padding: 0.45rem 0.6rem;
  border: 2px solid var(--ink);
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.t-items {
  list-style: none;
  margin: 0;
  padding: 0.35rem 0.4rem 0.5rem;
  flex: 1;
}
.t-item {
  display: grid;
  grid-template-columns: 2.4rem 1fr;
  gap: 0.2rem 0.4rem;
  padding: 0.45rem 0.35rem;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, opacity 0.15s;
}
.t-item:hover {
  background: rgba(31, 26, 23, 0.06);
}
.t-item .q {
  font-family: var(--condensed);
  font-weight: 700;
  font-size: 1.45rem;
  line-height: 1.1;
  text-align: right;
}
.t-item .nm {
  font-weight: 650;
  font-size: 1.12rem;
  line-height: 1.25;
  align-self: center;
}
.t-item .mod {
  grid-column: 2;
  font-weight: 700;
  color: var(--paprika-deep);
  font-size: 0.92rem;
}
.t-item.done {
  opacity: 0.38;
}
.t-item.done .nm {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}
.t-foot {
  display: flex;
  gap: 0.4rem;
  padding: 0.55rem;
  border-top: 1px solid rgba(31, 26, 23, 0.12);
}
.bump {
  flex: 1;
  border: 0;
  border-radius: 8px;
  padding: 0.85rem 0.6rem;
  font-family: var(--condensed);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--steam);
  transition: transform 0.1s, background 0.15s;
}
.bump:active {
  transform: scale(0.97);
}
.ticket[data-status="preparing"] .bump {
  background: var(--herb);
}
.ticket[data-status="ready"] .bump {
  background: var(--char-3);
}
.more {
  border: 0;
  width: 48px;
  border-radius: 8px;
  background: rgba(31, 26, 23, 0.08);
  display: grid;
  place-items: center;
}

/* ---------- dialogs ---------- */
.kds-dialog {
  border: 1px solid var(--char-line);
  border-radius: 18px;
  background: var(--char-2);
  color: var(--steam);
  padding: 0;
  width: min(92vw, 560px);
  max-height: 86dvh;
}
.kds-dialog[open] {
  display: flex;
  flex-direction: column;
  animation: pop 0.25s var(--ease);
}
.kds-dialog::backdrop {
  background: rgba(10, 8, 7, 0.7);
}
@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
}
.dlg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--char-line);
}
.dlg-head h2 {
  margin: 0;
  font-family: var(--condensed);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.dlg-body {
  padding: 0.6rem 1.2rem 1.2rem;
  overflow-y: auto;
}
.dlg-actions {
  display: grid;
  gap: 0.5rem;
  padding: 1rem 1.2rem 1.2rem;
}
.dlg-actions .kbtn {
  justify-content: center;
  padding: 0.9rem;
  font-size: 1rem;
}
.kbtn.danger {
  color: #f3a08c;
  border-color: rgba(194, 70, 43, 0.6);
}
.row86 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--char-line);
}
.row86.off .nm {
  text-decoration: line-through;
  color: #8a7d71;
}
.cat86 {
  font-family: var(--condensed);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #a5978a;
  margin: 1rem 0 0.2rem;
  font-weight: 700;
}
.switch {
  position: relative;
  width: 52px;
  height: 30px;
  flex: none;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--paprika);
  transition: background 0.2s;
}
.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s var(--ease);
}
.switch input:checked + span {
  background: var(--herb);
}
.switch input:checked + span::after {
  transform: translateX(22px);
}
.switch input:focus-visible + span {
  outline: 2px solid var(--saffron);
  outline-offset: 2px;
}
.hist {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.8rem;
  align-items: center;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--char-line);
}
.hist .t-no {
  font-size: 1.5rem;
}
.hist .sum {
  color: #a5978a;
  font-size: 0.88rem;
}

.sound-prompt {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  width: max-content;
  max-width: calc(100% - 2rem);
  transform: translateX(-50%);
  z-index: 50;
  background: var(--char-2);
  border: 1px solid var(--saffron);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  text-align: center;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
}
.sound-prompt p {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}

@media (max-width: 900px) {
  .kds {
    height: auto;
  }
  .lanes {
    grid-template-columns: 1fr;
  }
  .lane {
    border-right: 0;
    border-bottom: 1px solid var(--char-line);
  }
  .lane-body {
    overflow: visible;
  }
}
@media (max-width: 560px) {
  .waiter-calls {
    grid-template-columns: minmax(0, 1fr);
  }
}
.kbtn.bill-alert {
  text-decoration: none;
  color: #f3c2b5;
}
.kbtn.bill-alert[hidden] {
  display: none;
}
