/* CSS simples para a rota /m em WebViews antigos de maquininhas. */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

:root {
  --paper: #fbf7ef;
  --surface: #ffffff;
  --surface-2: #f4efe3;
  --ink-900: #1c2333;
  --ink-700: #454d63;
  --ink-500: #7a8094;
  --border: #e7e1d3;
  --border-strong: #d9d2c0;
  --amber-500: #e2861b;
  --amber-600: #c66e0c;
  --amber-tint: rgba(226, 134, 27, 0.14);
  --amber-ink: #2b1a06;
  --green-600: #12805b;
  --green-tint: rgba(18, 128, 91, 0.12);
  --red-600: #c6362e;
  --red-tint: rgba(198, 54, 46, 0.12);
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--paper);
}

/* O botao flutuante LOG foi movido para o menu ⋮ do cabecalho. Escondemos aqui. */
#dbg-btn {
  display: none !important;
}

/* Menu suspenso (kebab) do cabecalho */
.machine-menu-wrap { position: relative; display: inline-block; }
.machine-menu-btn {
  font-size: 22px !important;
  font-weight: 700;
  color: var(--ink-500) !important;
  touch-action: manipulation;
  transition: transform .08s ease;
}
.machine-menu-dropdown {
  display: none;
  position: absolute;
  top: 40px;
  right: 0;
  z-index: 500;
  min-width: 190px;
  background: var(--surface);
  color: var(--ink-900);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 16px 36px rgba(28, 35, 51, 0.16);
  overflow: hidden;
}
.machine-menu-wrap.open .machine-menu-dropdown { display: block; }
.machine-menu-item {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 12px 14px;
  border: 0;
  background: transparent;
  color: var(--ink-900);
  text-align: left;
  font: 500 14px 'Poppins', Arial, Helvetica, sans-serif;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  touch-action: manipulation;
}
.machine-menu-item:last-child { border-bottom: 0; }
.machine-menu-item:active { background: var(--surface-2); }
.machine-menu-danger { color: var(--red-600); }
.machine-header-spacer { width: 8px; }


.machine-login-screen,
.machine-screen,
.machine-modal-layer,
.machine-code-card,
.machine-code-card *,
.machine-screen *,
.machine-modal-panel,
.machine-modal-panel * {
  box-sizing: border-box;
}

.machine-login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  color: var(--ink-900);
  padding: 16px;
  font-family: 'Poppins', Arial, Helvetica, sans-serif;
}

.machine-code-card {
  width: 100%;
  max-width: 384px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 18px 44px rgba(28, 35, 51, 0.12);
}

.machine-code-wrap {
  width: 100%;
  max-width: 384px;
}

.machine-code-content {
  padding: 26px 24px;
}

.machine-version {
  margin-top: 12px;
  color: var(--ink-500);
  text-align: center;
  font-size: 11px;
  font-weight: 500;
}

.machine-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 22px;
  color: var(--ink-900);
  font-size: 17px;
  font-weight: 600;
}

.machine-brand-icon {
  color: var(--amber-600);
  font-size: 19px;
}

.machine-code-help {
  margin: 0 0 16px;
  color: var(--ink-500);
  font-size: 14px;
}

.machine-form > * + * {
  margin-top: 12px;
}

.machine-code-input,
.machine-cash-input {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink-900);
  text-align: center;
  font-family: 'Poppins', Arial, Helvetica, sans-serif;
  outline: none;
  transition: border-color .12s ease, box-shadow .12s ease;
}

.machine-code-input:focus,
.machine-cash-input:focus {
  border-color: var(--amber-500);
  box-shadow: 0 0 0 3px var(--amber-tint);
  background: var(--surface);
}

.machine-code-input {
  height: 56px;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 6px;
}

.machine-code-submit,
.machine-ok-button,
.machine-confirm-button,
.machine-secondary-button,
.machine-sync-button,
.machine-bluetooth-button,
.machine-payment-option,
.machine-icon-button,
.machine-cart-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Poppins', Arial, Helvetica, sans-serif;
  transition: transform .08s ease, background-color .12s ease, border-color .12s ease;
  touch-action: manipulation;
}

.machine-code-submit:active,
.machine-ok-button:active,
.machine-confirm-button:active,
.machine-secondary-button:active,
.machine-payment-option:active,
.machine-icon-button:active,
.machine-cart-control:active,
.machine-product-button:not(:disabled):active {
  transform: scale(0.95);
}

.machine-code-submit,
.machine-confirm-button {
  width: 100%;
  height: 48px;
  background: var(--amber-500);
  color: var(--amber-ink);
  font-size: 16px;
  font-weight: 600;
}

.machine-secondary-button {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--ink-700);
  font-weight: 500;
}

.machine-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink-900);
  font-family: 'Poppins', Arial, Helvetica, sans-serif;
}

.machine-header {
  position: relative;
  min-height: 52px;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.machine-title {
  min-width: 0;
  max-width: 100%;
  margin: 0;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-900);
  font-size: 17px;
  font-weight: 600;
}

.machine-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-self: end;
}

.machine-logout {
  justify-self: start;
}


.machine-icon-button,
.machine-cart-control {
  width: 36px;
  height: 36px;
  background: transparent;
  color: var(--ink-500);
}

.machine-cart-control {
  width: 28px;
  height: 28px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--ink-700);
}

.machine-remove-control {
  color: var(--red-600);
  border-color: rgba(198, 54, 46, 0.3);
}

.machine-sync-button {
  height: 32px;
  margin-right: 4px;
  padding: 0 8px;
  background: var(--amber-500);
  color: var(--amber-ink);
  font-size: 12px;
  font-weight: 700;
}

.machine-bluetooth-button {
  width: 36px;
  height: 32px;
  margin-right: 4px;
  background: #0e9e8e;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
}

.machine-cash-closed {
  margin: 12px 12px 0;
  padding: 10px;
  border: 1px solid rgba(198, 54, 46, 0.3);
  border-radius: 8px;
  background: var(--red-tint);
  color: var(--red-600);
  text-align: center;
  font-size: 12.5px;
  font-weight: 500;
}

.machine-products-area {
  flex: 1 1 auto;
  overflow: auto;
  padding: 12px;
}

.machine-empty {
  padding: 64px 0;
  color: var(--ink-500);
  text-align: center;
}

.machine-products-grid {
  display: flex;
  flex-wrap: wrap;
  margin: -4px;
}

.machine-product-button {
  position: relative;
  width: calc(33.333% - 8px);
  min-height: 96px;
  margin: 4px;
  padding: 18px 6px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink-900);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 2px rgba(28, 35, 51, 0.04);
}

.machine-product-disabled {
  background: var(--surface-2);
  color: var(--ink-500);
  box-shadow: none;
}

.machine-product-name {
  max-height: 48px;
  overflow: hidden;
  font-size: 13px;
  line-height: 16px;
  font-weight: 700;
  text-transform: uppercase;
}

.machine-product-price {
  margin-top: 4px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--amber-600);
}

.machine-product-disabled .machine-product-price {
  color: var(--ink-500);
}

.machine-stock-badge,
.machine-cart-badge {
  position: absolute;
  top: 4px;
  min-width: 18px;
  border-radius: 999px;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
}

.machine-stock-badge {
  right: 4px;
  background: var(--surface-2);
  color: var(--ink-500);
}

.machine-cart-badge {
  left: 4px;
  background: var(--amber-500);
  color: var(--amber-ink);
}

.machine-cart-panel,
.machine-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.machine-cart-panel {
  padding: 8px;
}

.machine-cart-list {
  max-height: 160px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.machine-cart-line {
  display: flex;
  align-items: center;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.machine-cart-line:last-child { border-bottom: 0; }

.machine-cart-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-900);
}

.machine-cart-price {
  margin: 0 8px;
  color: var(--ink-500);
}

.machine-cart-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.machine-cart-qty {
  width: 24px;
  text-align: center;
  font-weight: 700;
  color: var(--ink-900);
}

.machine-footer {
  padding: 12px;
}

.machine-footer-row {
  display: flex;
  align-items: center;
}

.machine-total {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  margin-right: 8px;
  padding: 8px 16px;
  border-radius: 10px;
  background: var(--amber-500);
  color: var(--amber-ink);
  box-shadow: 0 8px 20px rgba(226, 134, 27, 0.25);
}

.machine-total-label {
  font-size: 13px;
  font-weight: 600;
}

.machine-total-value {
  font-size: 24px;
  font-weight: 700;
}

.machine-ok-button {
  width: 76px;
  height: 56px;
  background: var(--green-600);
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
}

.machine-modal-layer {
  position: fixed;
  z-index: 9999;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(28, 35, 51, 0.55);
  font-family: 'Poppins', Arial, Helvetica, sans-serif;
}

.machine-modal-panel {
  position: relative;
  width: 100%;
  max-width: 448px;
  max-height: 92vh;
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink-900);
  box-shadow: 0 24px 60px rgba(28, 35, 51, 0.22);
}

.machine-modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 0;
  background: transparent;
  color: var(--ink-500);
  font-size: 28px;
  line-height: 28px;
  cursor: pointer;
}

.machine-modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 32px 16px 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink-900);
}

.machine-payment-total {
  margin-bottom: 12px;
  padding: 14px;
  border-radius: 10px;
  background: var(--surface-2);
  text-align: center;
}

.machine-payment-total-label {
  color: var(--ink-500);
  font-size: 12px;
  font-weight: 500;
}

.machine-payment-total-value {
  margin-top: 2px;
  font-size: 28px;
  font-weight: 700;
  color: var(--amber-600);
}

.machine-payment-grid {
  display: flex;
  flex-wrap: wrap;
  margin: -4px -4px 12px;
}

.machine-payment-option {
  width: calc(50% - 8px);
  height: 64px;
  margin: 4px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-700);
  flex-direction: column;
  font-weight: 600;
}

.machine-payment-selected {
  border-color: var(--amber-600);
  background: var(--amber-500);
  color: var(--amber-ink);
}

.machine-cash-form > * + * {
  margin-top: 8px;
}

.machine-cash-label {
  display: block;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-700);
}

.machine-cash-input {
  height: 48px;
  background: var(--surface);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0;
}

.machine-cash-preview { font-size: 14.5px; color: var(--ink-500); margin: 4px 0; text-align: right; }
.machine-cash-preview strong { color: var(--ink-900); font-size: 19px; }
.machine-change-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
}

.machine-change-negative {
  background: var(--red-tint);
  color: var(--red-600);
}

.machine-change-positive {
  background: var(--green-tint);
  color: var(--green-600);
}

.machine-pending {
  margin: 12px 0 0;
  color: var(--ink-500);
  text-align: center;
  font-size: 14px;
}

.machine-loading,
.machine-error {
  text-align: center;
}

.machine-toast {
  position: fixed;
  z-index: 10000;
  right: 16px;
  bottom: 16px;
  max-width: 320px;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--ink-900);
  color: var(--paper);
  font-family: 'Poppins', Arial, Helvetica, sans-serif;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 16px 36px rgba(28, 35, 51, 0.28);
}

.machine-error-text {
  color: var(--ink-900);
  font-size: 17px;
}

button:disabled,
.machine-product-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  .machine-code-submit,
  .machine-ok-button,
  .machine-confirm-button,
  .machine-secondary-button,
  .machine-payment-option,
  .machine-icon-button,
  .machine-cart-control,
  .machine-product-button {
    transition: none;
  }
  .machine-code-submit:active,
  .machine-ok-button:active,
  .machine-confirm-button:active,
  .machine-secondary-button:active,
  .machine-payment-option:active,
  .machine-icon-button:active,
  .machine-cart-control:active,
  .machine-product-button:not(:disabled):active {
    transform: none;
  }
}

@media (min-width: 640px) {
  .machine-product-button {
    width: calc(25% - 8px);
  }
}

@media (min-width: 768px) {
  .machine-product-button {
    width: calc(20% - 8px);
  }
}

@media (min-width: 1024px) {
  .machine-product-button {
    width: calc(16.666% - 8px);
  }
}

@media (max-width: 420px) {
  .machine-title {
    font-size: 15px;
  }


  .machine-total {
    padding-right: 10px;
    padding-left: 10px;
  }

  .machine-total-label {
    font-size: 12px;
  }

  .machine-total-value {
    font-size: 20px;
  }
}
