/* Pensado para una Raspberry Pi 3B: nada de sombras, blur ni animaciones.
   Pantalla objetivo: ELO 15" táctil (1024x768 o 1366x768). */
:root {
  --bg: #15120f;
  --surface: #231e19;
  --surface-2: #2f2922;
  --line: #453c32;
  --text: #f5eee3;
  --muted: #b9ab98;
  --accent: #eba83a;
  --accent-ink: #231703;
  --busy: #7a4a12;
  --busy-line: #eba83a;
  --ok: #57c27d;
  --danger: #e5604d;
  --danger-ink: #2a0905;
  --tap: 64px;
}

* {
  box-sizing: border-box;
  margin: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 18px/1.25 Roboto, 'Liberation Sans', 'Segoe UI', system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}
button:disabled {
  cursor: default;
  opacity: 0.4;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Barra superior */
.bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.bar h1 {
  font-size: 24px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar .who {
  color: var(--muted);
  font-size: 16px;
  white-space: nowrap;
}
.bar .spacer {
  flex: 1;
}
.clock {
  font-size: 22px;
  font-weight: 700;
}

.btn {
  min-height: var(--tap);
  padding: 8px 20px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-weight: 700;
}
.btn:active {
  background: var(--line);
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--danger-ink);
}
.btn.small {
  min-height: 52px;
  padding: 6px 16px;
}

.pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 15px;
  white-space: nowrap;
}
.pill::before {
  content: '';
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ok);
}
.pill.warn::before {
  background: var(--accent);
}
.pill.bad {
  background: var(--danger);
  color: var(--danger-ink);
  font-weight: 700;
}
.pill.bad::before {
  background: var(--danger-ink);
}

/* Mapa de mesas */
.tables {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  grid-auto-rows: minmax(136px, auto);
  gap: 12px;
  align-content: start;
}
.table {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px 14px;
  text-align: left;
  border-radius: 10px;
  background: var(--surface);
  border: 2px solid var(--line);
}
.table:active {
  background: var(--surface-2);
}
.table .name {
  font-size: 34px;
  font-weight: 700;
  line-height: 1.05;
}
.table .free {
  color: var(--muted);
  font-size: 16px;
}
.table.busy {
  background: var(--busy);
  border-color: var(--busy-line);
}
.table.busy:active {
  background: #8f5817;
}
.table .total {
  font-size: 22px;
  font-weight: 700;
}
.table .meta {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 15px;
}
.table .meta span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Plano del salón: coordenadas en %, así se adapta a cualquier resolución */
.tables.with-plan {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 8px;
  overflow: hidden;
}
.plan {
  position: relative;
  flex: none;
  width: min(100%, calc((100vh - 86px) * 1000 / 680));
  aspect-ratio: 1000 / 680;
  border-radius: 8px;
  background: #1b1714;
}
.plan-el {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--muted);
  font-size: 15px;
}
.plan-walls {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.plan-walls line {
  stroke: #6b5d4d;
  stroke-linecap: round;
}
.plan-el.bar {
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-weight: 700;
}
.plan-el.zone {
  align-items: flex-start;
  justify-content: flex-start;
  padding: 4px 8px;
  border: 1px dashed var(--line);
}
.table.placed {
  position: absolute;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 4px 6px;
  overflow: hidden;
  text-align: center;
}
.table.placed.round {
  border-radius: 50%;
}
.table.placed .name {
  font-size: 24px;
}
.table.placed .free {
  font-size: 14px;
}
.table.placed .total {
  font-size: 16px;
}
.table.placed .meta {
  justify-content: center;
  font-size: 12px;
}
.table.placed .meta span:last-child {
  flex: none;
}

/* Pantalla de pedido */
.order {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 370px 1fr;
}
.ticket {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.lines {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 8px;
}
.lines .section {
  padding: 10px 6px 4px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.lines .empty {
  padding: 32px 12px;
  color: var(--muted);
  text-align: center;
}
.line {
  width: 100%;
  min-height: 52px;
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 6px;
  align-items: center;
  padding: 6px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 17px;
}
button.line:active {
  background: var(--surface-2);
}
.line.voided {
  color: var(--muted);
  text-decoration: line-through;
  font-size: 15px;
  min-height: 40px;
}
.line .q {
  font-weight: 700;
}
.draft-line {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 6px;
  border-bottom: 1px solid var(--line);
  font-size: 17px;
}
.stepper {
  display: flex;
  align-items: center;
}
.stepper button {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 26px;
  font-weight: 700;
}
.stepper button:active {
  background: var(--line);
}
.stepper span {
  min-width: 36px;
  text-align: center;
  font-weight: 700;
}
.draft-line .amount {
  min-width: 62px;
  text-align: right;
}
.sum {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 14px;
  border-top: 2px solid var(--line);
  font-size: 20px;
  font-weight: 700;
}
.sum strong {
  font-size: 30px;
  color: var(--accent);
}
.actions {
  flex: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 10px 10px;
}

.catalog {
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.cats {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}
.cat {
  min-height: 56px;
  padding: 6px 18px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-weight: 700;
}
.cat.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.products {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  grid-auto-rows: minmax(104px, auto);
  gap: 10px;
  align-content: start;
}
.product {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px 12px;
  text-align: left;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.product:active {
  background: var(--surface-2);
}
.product .pname {
  font-weight: 700;
  padding-right: 34px;
}
.product .price {
  color: var(--muted);
}
.product .badge {
  position: absolute;
  top: 8px;
  right: 8px;
  min-width: 34px;
  height: 34px;
  padding: 0 6px;
  line-height: 34px;
  text-align: center;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}
.product .badge:empty {
  display: none;
}

/* Cuentas cerradas */
.closed-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}
.closed-row {
  width: 100%;
  min-height: var(--tap);
  display: grid;
  grid-template-columns: 90px 1fr 110px 110px;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.closed-row:active {
  background: var(--surface);
}
.closed-row .t {
  text-align: right;
  font-weight: 700;
}
.muted {
  color: var(--muted);
}

/* Ventanas */
#modal:empty {
  display: none;
}
#modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(0, 0, 0, 0.72);
  z-index: 10;
}
.dialog {
  width: 100%;
  max-width: 480px;
  max-height: 100%;
  overflow-y: auto;
  padding: 18px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.dialog h2 {
  font-size: 24px;
  margin-bottom: 6px;
}
.dialog p {
  color: var(--muted);
  margin-bottom: 12px;
}
.dialog .buttons {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 8px;
  margin-top: 12px;
}
.dialog .amount-big {
  font-size: 34px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 12px;
}
.dialog .detail {
  max-height: 300px;
  overflow-y: auto;
}
.dialog .reasons {
  display: grid;
  gap: 8px;
}
.dialog .reasons .btn.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.dialog .qty-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.pinpad {
  max-width: 340px;
  text-align: center;
}
.dots {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 12px 0;
}
.dots i {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--muted);
}
.dots i.on {
  background: var(--accent);
  border-color: var(--accent);
}
.pinpad .err {
  min-height: 24px;
  color: var(--danger);
  font-weight: 700;
}
.keys {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 6px;
}
.keys button {
  height: 76px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 30px;
  font-weight: 700;
}
.keys button:active {
  background: var(--line);
}
.keys button.txt {
  font-size: 18px;
}

/* Activación */
.activate {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.activate form {
  width: 100%;
  max-width: 420px;
  display: grid;
  gap: 12px;
}
.activate input {
  min-height: var(--tap);
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  user-select: text;
  -webkit-user-select: text;
}

#toast:empty {
  display: none;
}
#toast {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 14px 22px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
  z-index: 20;
}
#toast.bad {
  background: var(--danger);
  color: var(--danger-ink);
}

@media (max-width: 760px) {
  .order {
    grid-template-columns: 1fr;
    grid-template-rows: 45% 55%;
  }
  .ticket {
    order: 2;
    border-right: 0;
    border-top: 1px solid var(--line);
  }
  .closed-row {
    grid-template-columns: 70px 1fr 90px;
  }
  .closed-row .who-col {
    display: none;
  }
  .bar .who,
  .clock {
    display: none;
  }
}
