:root {
  --bg: #f6f1e8;
  --panel: #ffffff;
  --text: #171b18;
  --muted: #6d746e;
  --line: #d9d1c4;
  --green: #176b45;
  --green-dark: #0e4c31;
  --amber: #e8ac2f;
  --blue: #245b9f;
  --danger: #b83b35;
  --shadow: 0 12px 26px rgba(39, 31, 20, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
  line-height: 1.4;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--green-dark);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.kiosk-body {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.52), rgba(255, 255, 255, 0)),
    var(--bg);
}

.kiosk-shell {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: 54px minmax(0, 1fr) 72px;
  gap: 8px;
  padding: 8px;
}

.kiosk-header,
.admin-header,
.settings-strip,
.checkout-bar,
.login-panel {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.kiosk-header,
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 8px 12px;
  box-shadow: 0 6px 18px rgba(39, 31, 20, 0.08);
}

.kiosk-header h1,
.admin-header h1,
.login-panel h1 {
  margin: 0;
  font-size: 1.42rem;
  line-height: 1.05;
  text-transform: uppercase;
}

.status-pill {
  flex: 0 0 auto;
  min-width: 96px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #e9f5df;
  color: var(--green-dark);
  font-size: 0.88rem;
  font-weight: 800;
  text-align: center;
}

.product-board {
  min-height: 0;
  display: grid;
  gap: 8px;
  overflow: hidden;
}

.product-tile {
  --accent: #176b45;
  --accent-soft: #e9f5df;
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #fffdf8;
  border: 1px solid #191919;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(40, 32, 18, 0.08);
}

.product-tile.is-selected {
  border-color: var(--accent);
  box-shadow: 0 10px 22px rgba(40, 32, 18, 0.16);
}

.product-tile.just-added {
  animation: tileAdd 260ms ease-out;
}

.product-tile.just-removed {
  animation: tileRemove 220ms ease-out;
}

.slot-box {
  display: grid;
  place-items: center;
  align-content: center;
  background: var(--accent-soft);
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 6px;
}

.slot-box span {
  color: #29312c;
  font-size: 0.68rem;
  line-height: 1;
}

.slot-box strong {
  color: var(--accent);
  font-size: 1.52rem;
  line-height: 1;
}

.media-box {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.24);
  border-radius: 6px;
  background: var(--accent-soft);
}

.product-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.grain-art {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.12)),
    var(--accent-soft);
}

.grain-art strong {
  position: relative;
  z-index: 2;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #ffffff;
  border: 2px solid var(--accent);
  color: var(--accent);
  font-size: 1rem;
  font-weight: 900;
}

.grain-dot {
  position: absolute;
  width: 22px;
  height: 30px;
  border-radius: 58% 42% 56% 44%;
  background: var(--accent);
  opacity: 0.78;
  transform: rotate(20deg);
}

.dot-a {
  left: 14%;
  top: 22%;
}

.dot-b {
  right: 16%;
  top: 16%;
  transform: rotate(-24deg);
}

.dot-c {
  left: 23%;
  bottom: 14%;
  transform: rotate(-10deg);
}

.dot-d {
  right: 22%;
  bottom: 18%;
  transform: rotate(34deg);
}

.portion-panel {
  min-width: 0;
}

.count-label {
  color: #101010;
  font-size: 0.7rem;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.portion-count {
  color: #111111;
  font-size: 1.72rem;
  font-weight: 500;
  line-height: 1;
}

.portion-buttons button {
  min-width: 0;
  min-height: 0;
  border: 0;
  background: transparent;
  color: #151515;
  font-size: 2rem;
  font-weight: 500;
  line-height: 1;
}

.portion-buttons button:active {
  color: var(--accent);
  transform: translateY(1px);
}

.product-copy {
  min-width: 0;
}

.product-copy h2 {
  margin: 0;
  color: #151515;
  font-size: 0.86rem;
  font-weight: 900;
  line-height: 1.05;
  text-transform: uppercase;
}

.product-copy p {
  margin: 2px 0 0;
  color: #5f625f;
  font-size: 0.78rem;
  line-height: 1.08;
}

.price-stack {
  display: grid;
  gap: 1px;
  margin-top: 4px;
  color: #6b6f6a;
  font-size: 0.66rem;
  line-height: 1.12;
}

.price-stack span,
.price-stack small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.checkout-bar {
  display: grid;
  grid-template-columns: minmax(150px, 0.36fr) minmax(260px, 1fr);
  gap: 8px;
  padding: 6px;
  box-shadow: 0 -8px 20px rgba(39, 31, 20, 0.08);
}

.primary-action,
.secondary-action {
  min-height: 48px;
  border-radius: 6px;
  padding: 0 16px;
  font-weight: 900;
  text-transform: uppercase;
}

.primary-action {
  border: 0;
  background: var(--green);
  color: #ffffff;
}

.secondary-action {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--text);
}

.clear-action {
  border-color: #1c1c1c;
  background: #fffdf8;
  font-size: 1rem;
}

.checkout-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid #0d0d0d;
  background:
    linear-gradient(90deg, var(--green-dark), var(--green)),
    var(--green);
  font-size: 1.08rem;
}

.checkout-action strong {
  font-size: 1.26rem;
  white-space: nowrap;
}

.checkout-action.is-processing {
  animation: checkoutGlow 850ms ease-in-out infinite;
}

.total-pulse {
  animation: totalPulse 260ms ease-out;
}

.full {
  width: 100%;
}

.secret-hotspot {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 20;
  width: 72px;
  height: 72px;
  border: 0;
  background: transparent;
}

.modal {
  width: min(760px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.modal::backdrop {
  background: rgba(23, 32, 27, 0.45);
}

.modal.compact {
  width: min(520px, calc(100vw - 28px));
}

.flow-modal {
  width: min(760px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  overflow: hidden;
  background: #fffdf8;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-header h2 {
  margin: 0;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  font-size: 1.5rem;
}

.qr-panel {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 18px;
  align-items: center;
}

.qr-panel img {
  width: 220px;
  height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.field input {
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #ffffff;
}

.field.small {
  max-width: 180px;
}

.admin-url {
  overflow-wrap: anywhere;
  color: var(--blue);
  font-weight: 700;
}

.receipt-preview {
  max-height: 260px;
  overflow: auto;
  padding: 12px;
  border-radius: 6px;
  background: #111815;
  color: #e6f1e9;
}

.flow-stage {
  min-height: min(560px, calc(100vh - 24px));
  display: grid;
}

.flow-card {
  display: grid;
  align-content: center;
  gap: 14px;
  min-height: 100%;
  padding: 26px;
}

.flow-card h2 {
  margin: 0;
  font-size: clamp(1.7rem, 5vw, 2.8rem);
  line-height: 1;
  text-transform: uppercase;
}

.checkout-summary {
  display: grid;
  gap: 6px;
  max-height: 160px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.checkout-summary li {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffaf0;
}

.checkout-summary strong {
  color: var(--green);
}

.checkout-summary span {
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.checkout-summary em {
  color: var(--muted);
  font-size: 0.86rem;
  font-style: normal;
  font-weight: 700;
}

.flow-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 8px;
  background: #102f21;
  color: #ffffff;
}

.flow-total span {
  font-size: 0.9rem;
  font-weight: 800;
  text-transform: uppercase;
}

.flow-total strong {
  font-size: clamp(1.4rem, 4vw, 2.15rem);
}

.compact-total {
  margin-top: 12px;
}

.payment-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.payment-options button {
  display: grid;
  gap: 6px;
  min-height: 112px;
  padding: 14px;
  border: 1px solid #0f281d;
  border-radius: 8px;
  background: linear-gradient(145deg, #ffffff, #ecf7e9);
  color: var(--text);
  text-align: left;
}

.payment-options button:active {
  transform: scale(0.98);
}

.payment-options span {
  font-size: 1.6rem;
  font-weight: 900;
  text-transform: uppercase;
}

.payment-options small {
  color: var(--muted);
  font-weight: 700;
}

.ghost-action {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
}

.pix-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.sim-qr {
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  gap: 4px;
  width: 220px;
  height: 220px;
  padding: 14px;
  border: 6px solid #ffffff;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px var(--line), 0 10px 20px rgba(15, 40, 29, 0.16);
}

.sim-qr span {
  border-radius: 2px;
  background: #eef3ea;
}

.sim-qr .filled {
  background: #111111;
}

.loader-line {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--green-dark);
  font-weight: 900;
  text-transform: uppercase;
}

.loader-line span {
  width: 24px;
  height: 24px;
  border: 4px solid #d8ead5;
  border-top-color: var(--green);
  border-radius: 999px;
  animation: spin 760ms linear infinite;
}

.card-terminal {
  width: min(300px, 100%);
  margin: 0 auto;
  padding: 18px;
  border-radius: 18px;
  background: #202623;
  box-shadow: 0 18px 36px rgba(15, 25, 18, 0.2);
}

.terminal-screen {
  display: grid;
  gap: 8px;
  min-height: 150px;
  padding: 18px;
  border-radius: 12px;
  background: #dff4e3;
  color: #0d4028;
}

.terminal-screen span {
  font-weight: 900;
}

.terminal-screen strong {
  align-self: end;
  font-size: 2rem;
}

.terminal-light {
  width: 70px;
  height: 8px;
  margin: 16px auto 0;
  border-radius: 999px;
  background: #42e27c;
  animation: checkoutGlow 700ms ease-in-out infinite;
}

.approved-card,
.final-card {
  justify-items: center;
  text-align: center;
  background: linear-gradient(145deg, #0f5c38, #1d8a56);
  color: #ffffff;
}

.approved-card p,
.final-card p {
  margin: 0;
  font-size: 1.2rem;
}

.approved-mark {
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  border: 4px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 3.4rem;
  font-weight: 900;
  animation: tileAdd 360ms ease-out;
}

.dispensing-card {
  justify-items: center;
  text-align: center;
}

.dispense-product {
  margin: 0;
  color: var(--green-dark);
  font-size: 1.2rem;
  font-weight: 900;
  text-transform: uppercase;
}

.dispense-progress {
  width: min(420px, 100%);
  height: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6eadf;
}

.dispense-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--amber), var(--green));
  transition: width 250ms ease;
}

.receipt-shell {
  width: min(420px, 100%);
  overflow: hidden;
  border-radius: 8px;
  background: #fffdf8;
  color: var(--text);
  text-align: left;
  box-shadow: 0 16px 34px rgba(12, 38, 24, 0.24);
}

.receipt-header {
  padding: 10px 12px;
  border-bottom: 1px dashed #c9c0b2;
  color: var(--green-dark);
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.final-card .receipt-preview {
  max-height: 230px;
  margin: 0;
  border-radius: 0;
  background: #fffdf8;
  color: var(--text);
}

.final-card .muted {
  color: rgba(255, 255, 255, 0.82);
}

.error-card {
  text-align: center;
}

@media (orientation: landscape) and (min-width: 760px) {
  /* NOTA: a grade do board e o layout do card agora sao 100% dirigidos pelo
     fit-to-tela (.product-board.grade-auto + .grade-auto .pg-* em
     totem-okoie.css). As antigas regras de grade fixa 5x2, o grid do
     .product-tile e os .product-tile:nth-child(8/9){grid-column} foram
     REMOVIDOS daqui — eles forcavam colunas e quebravam a grade calculada
     (causa de amontoamento). Sobrou so o ajuste de chrome/legado abaixo,
     inofensivo (mira classes do card antigo que nao existem mais). */

  .slot-box {
    display: none;
  }

  .portion-panel {
    display: grid;
    grid-template-rows: auto auto 60px;
    justify-items: center;
    align-items: center;
    padding: 2px 6px 0;
  }

  .portion-count {
    font-size: 1.7rem;
  }

  .media-box {
    margin: 6px 10px 3px;
  }

  /* Botões +/- maiores (feedback Bryan) - alvo de toque confortável */
  .portion-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    width: 100%;
    padding: 0 4px;
  }

  .portion-buttons button {
    min-height: 58px;
    font-size: 2.5rem;
    font-weight: 800;
    border: 2px solid var(--green-dark, #1f3d2b);
    border-radius: 12px;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
  }

  .minus-button { background: rgba(220, 95, 48, 0.18); }
  .plus-button { background: rgba(181, 204, 58, 0.5); }

  .product-copy {
    display: grid;
    align-content: center;
    min-height: 0;
    padding: 5px 8px 7px;
    text-align: center;
  }

  .product-copy h2 {
    font-size: 0.78rem;
  }

  .product-copy p {
    font-size: 0.68rem;
  }

  .price-stack {
    font-size: 0.56rem;
  }
}

@media (orientation: portrait), (max-width: 759px) {
  .kiosk-shell {
    grid-template-rows: 54px minmax(0, 1fr) 72px;
    gap: 7px;
    padding: 7px;
  }

  .kiosk-header h1 {
    font-size: 1.12rem;
  }

  .status-pill {
    min-width: 82px;
    font-size: 0.78rem;
  }

  /* NOTA: a antiga regra .product-board {grid-template-columns:1fr; overflow-y:auto}
     (coluna unica + rolagem) foi REMOVIDA — rolagem e proibida no totem
     (autoatendimento). A grade agora e sempre o fit-to-tela .grade-auto, que
     cabe na tela sem rolar em retrato e paisagem. As regras .product-tile/.slot-box
     abaixo miram o card antigo (inertes; sobrescritas por .grade-auto). */

  .product-tile {
    display: grid;
    grid-template-columns: 44px 60px minmax(0, 1fr) 132px;
    grid-template-areas: "slot media copy portion";
    align-items: center;
    gap: 8px;
    padding: 7px;
    min-height: 96px;
  }

  .slot-box {
    grid-area: slot;
    width: 44px;
    height: 100%;
  }

  .media-box {
    grid-area: media;
    width: 60px;
    height: 64px;
  }

  .grain-art strong {
    width: 30px;
    height: 30px;
    font-size: 0.78rem;
  }

  .grain-dot {
    width: 15px;
    height: 21px;
  }

  .product-copy {
    grid-area: copy;
    overflow: hidden;
  }

  /* Textos maiores (feedback Bryan): nome, descricao 2 linhas, preco, estoque */
  .product-copy h2 {
    font-size: 0.98rem;
    line-height: 1.12;
  }

  .product-copy p {
    font-size: 0.8rem;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .price-stack {
    font-size: 0.8rem;
    margin-top: 2px;
  }
  .price-stack span { font-weight: 800; }
  .price-stack small { font-size: 0.72rem; opacity: 0.85; }

  .portion-panel {
    grid-area: portion;
    display: grid;
    grid-template-columns: 46px 40px 46px;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "label label label"
      "minus count plus";
    align-items: center;
    justify-content: end;
    gap: 4px;
    min-height: 64px;
  }

  .count-label {
    grid-area: label;
    justify-self: center;
    font-size: 0.62rem;
    margin-bottom: 2px;
  }

  .portion-count {
    grid-area: count;
    justify-self: center;
    font-size: 1.5rem;
    font-weight: 800;
  }

  .portion-buttons {
    display: contents;
  }

  .minus-button {
    grid-area: minus;
  }

  .plus-button {
    grid-area: plus;
  }

  /* Botoes +/- maiores e mais separados, alvo de toque confortavel */
  .portion-buttons button {
    height: 48px;
    width: 46px;
    font-size: 2rem;
    font-weight: 800;
    border-radius: 12px;
    touch-action: manipulation;
    user-select: none;
  }
  .plus-button { background: var(--lime, #B5CC3A); }
  .minus-button { background: rgba(220, 95, 48, 0.18); }

  .checkout-bar {
    grid-template-columns: 0.78fr 1fr;
    gap: 6px;
  }

  .clear-action {
    font-size: 0.92rem;
  }

  .checkout-action {
    grid-template-columns: 1fr;
    gap: 2px;
    font-size: 0.92rem;
    text-align: center;
  }

  .checkout-action strong {
    font-size: 1rem;
  }
}

.admin-body {
  min-height: 100vh;
  padding: 16px;
  background: var(--bg);
}

.admin-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.login-panel {
  width: min(420px, 100%);
  margin: 12vh auto 0;
  padding: 22px;
  box-shadow: var(--shadow);
}

.login-panel .primary-action {
  margin-top: 14px;
}

.form-message {
  min-height: 22px;
  color: var(--danger);
  font-weight: 700;
}

.admin-dashboard {
  display: grid;
  gap: 14px;
}

.settings-strip {
  display: grid;
  grid-template-columns: 1fr 180px auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
}

.admin-products {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.admin-product {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.admin-product-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.admin-product-header strong {
  font-size: 1.12rem;
}

.product-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.product-form-grid .wide {
  grid-column: 1 / -1;
}

.image-admin-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  align-items: center;
}

.image-admin-row img,
.image-admin-placeholder {
  width: 72px;
  height: 72px;
  border: 1px solid var(--line);
  border-radius: 6px;
  object-fit: cover;
  background: #e7eadf;
}

.image-admin-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

@keyframes tileAdd {
  0% {
    transform: scale(1);
  }
  42% {
    transform: scale(1.035);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes tileRemove {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(0.985);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes totalPulse {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes checkoutGlow {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.16);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 720px) {
  .qr-panel,
  .settings-strip,
  .product-form-grid {
    grid-template-columns: 1fr;
  }

  .qr-panel img {
    width: min(240px, 100%);
    height: auto;
    margin: 0 auto;
  }

  .flow-modal {
    width: calc(100vw - 16px);
  }

  .flow-card {
    padding: 18px;
  }

  .payment-options,
  .pix-layout {
    grid-template-columns: 1fr;
  }

  .sim-qr {
    width: min(220px, 100%);
    height: auto;
    aspect-ratio: 1;
    margin: 0 auto;
  }

  .checkout-summary li {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .checkout-summary em {
    grid-column: 2;
  }
}
