/* ============================================================
   AAA Catering — Ponto de Venda
   Palette: warm cream / deep espresso / caramel accent
   ============================================================ */

:root {
  --cream: #f6f1e8;
  --cream-2: #efe7d8;
  --paper: #fffdfa;
  --espresso: #2c1e14;
  --espresso-2: #46311f;
  --espresso-3: #5d4531;
  --caramel: #c68a49;
  --caramel-dark: #a06a33;
  --caramel-soft: rgba(198, 138, 73, 0.14);
  --latte: #e7dac6;
  --ink: #2b1e14;
  --muted: #8f7e6d;
  --green: #59825c;
  --red: #bf5a4b;
  --radius: 18px;
  --radius-sm: 11px;
  --shadow: 0 10px 30px rgba(44, 30, 20, 0.12);
  --shadow-sm: 0 2px 10px rgba(44, 30, 20, 0.08);
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.9rem; }
.right { text-align: right; }

/* ---------- Icons ---------- */
.ic { display: inline-flex; width: 20px; height: 20px; flex-shrink: 0; vertical-align: middle; }
.ic svg { width: 100%; height: 100%; }
.ic-sm { width: 16px; height: 16px; }
.ic-lg { width: 26px; height: 26px; }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.7rem 1.2rem;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.15s ease, color 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.97); }

.btn-primary {
  background: linear-gradient(160deg, var(--espresso-2), var(--espresso));
  color: var(--cream);
  box-shadow: 0 4px 14px rgba(44, 30, 20, 0.25);
}
.btn-primary:hover { background: linear-gradient(160deg, var(--espresso-3), var(--espresso-2)); box-shadow: 0 6px 18px rgba(44, 30, 20, 0.3); }

.btn-secondary { background: var(--latte); color: var(--espresso); }
.btn-secondary:hover { background: #ddcbaf; }

.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--red); background: rgba(191, 90, 75, 0.09); }

.btn-danger { background: rgba(191, 90, 75, 0.12); color: var(--red); }
.btn-danger:hover { background: rgba(191, 90, 75, 0.22); }

.btn-block { width: 100%; padding: 0.9rem; }
.btn-sm { padding: 0.42rem 0.8rem; font-size: 0.82rem; }

/* ---------- Auth view ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background:
    radial-gradient(1000px 520px at 85% -10%, rgba(198, 138, 73, 0.30), transparent 60%),
    radial-gradient(800px 480px at -8% 108%, rgba(44, 30, 20, 0.22), transparent 55%),
    linear-gradient(170deg, #f9f4eb, #efe5d3);
}

.auth-card {
  width: 100%;
  max-width: 410px;
  background: var(--paper);
  border: 1px solid rgba(198, 138, 73, 0.18);
  border-radius: 26px;
  box-shadow: 0 24px 60px rgba(44, 30, 20, 0.16);
  padding: 2.6rem 2.4rem;
  animation: pop-in 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.auth-brand { text-align: center; margin-bottom: 1.9rem; }
.auth-logo {
  display: inline-flex;
  width: 64px; height: 64px;
  color: var(--cream);
  background: linear-gradient(150deg, var(--espresso-2), var(--espresso));
  border-radius: 20px;
  box-shadow: 0 8px 20px rgba(44, 30, 20, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  padding: 13px;
}
.auth-logo svg { width: 100%; height: 100%; }
.auth-brand h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  letter-spacing: 0.01em;
  color: var(--espresso);
  margin-top: 0.7rem;
}
.auth-brand p { color: var(--muted); margin-top: 0.3rem; }

.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-form label { font-size: 0.85rem; font-weight: 600; color: var(--espresso-2); display: flex; flex-direction: column; gap: 0.35rem; }

.auth-form input, .inline-form input, .modal input, .modal select {
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 0.75rem 0.95rem;
  border: 1.5px solid var(--latte);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.auth-form input:focus, .inline-form input:focus, .modal input:focus, .modal select:focus {
  border-color: var(--caramel);
  box-shadow: 0 0 0 4px rgba(198, 138, 73, 0.18);
}

.setup-banner {
  background: var(--caramel-soft);
  border: 1px solid rgba(198, 138, 73, 0.35);
  color: var(--caramel-dark);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.95rem;
  font-size: 0.88rem;
  font-weight: 500;
}

.auth-error { color: var(--red); text-align: center; margin-top: 1rem; min-height: 1.2em; font-size: 0.9rem; font-weight: 500; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--espresso-2), var(--espresso) 40%);
  color: var(--cream);
  display: flex;
  flex-direction: column;
  padding: 1.35rem 0.95rem;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.55rem 1.3rem;
  border-bottom: 1px solid rgba(246, 241, 232, 0.12);
  margin-bottom: 1.1rem;
}
.sidebar-logo {
  display: inline-flex;
  width: 42px; height: 42px;
  color: var(--espresso);
  background: linear-gradient(150deg, #dcb57f, var(--caramel));
  border-radius: 13px;
  padding: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
}
.sidebar-logo svg { width: 100%; height: 100%; }
.sidebar-title { font-family: var(--font-display); font-weight: 600; font-size: 1.12rem; letter-spacing: 0.01em; }
.sidebar-sub { font-size: 0.75rem; color: var(--latte); opacity: 0.75; margin-top: 0.1rem; }

.nav { display: flex; flex-direction: column; gap: 0.35rem; flex: 1; }

.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.8rem 0.9rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--latte);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
}
.nav-btn:hover { background: rgba(246, 241, 232, 0.09); color: var(--cream); }
.nav-btn:active { transform: scale(0.98); }
.nav-btn.active {
  background: linear-gradient(150deg, #d8ab6e, var(--caramel));
  color: var(--espresso);
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.nav-btn.logout { margin-top: auto; }
.nav-btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label-short { display: none; }
.nav-btn.logout:hover { background: rgba(191, 90, 75, 0.25); color: #f2cbc4; }

.main { flex: 1; padding: 1.6rem 2.1rem; min-width: 0; }

.page { display: none; animation: fade-up 0.3s ease both; }
.page.active { display: block; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  margin-bottom: 1.3rem;
}
.page-header h2 { font-family: var(--font-display); font-size: 1.7rem; color: var(--espresso); }

/* ---------- Register ---------- */
.register-layout { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 1.3rem; align-items: start; }

.category-tabs { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.05rem; }
.tab {
  border: 1px solid rgba(198, 138, 73, 0.2);
  background: var(--paper);
  color: var(--espresso-2);
  border-radius: 999px;
  padding: 0.55rem 1.15rem;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.tab:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.tab.active {
  background: linear-gradient(150deg, #d8ab6e, var(--caramel));
  border-color: transparent;
  color: var(--espresso);
  box-shadow: 0 4px 12px rgba(160, 106, 51, 0.35);
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 0.8rem;
}

.product-tile {
  min-height: 108px;
  border: 1px solid rgba(198, 138, 73, 0.16);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.7rem 0.5rem;
  cursor: pointer;
  font-family: var(--font-body);
  transition: transform 0.14s ease, box-shadow 0.2s ease, border-color 0.15s;
}
.product-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: rgba(198, 138, 73, 0.4); }
.product-tile:active { transform: scale(0.95); box-shadow: var(--shadow-sm); }

.tile-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  border-radius: 14px;
  color: var(--espresso-2);
  background: linear-gradient(150deg, var(--cream-2), var(--latte));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  padding: 9px;
}
.tile-icon svg { width: 100%; height: 100%; }
.product-tile .name { font-weight: 600; font-size: 0.86rem; color: var(--ink); text-align: center; line-height: 1.15; }
.product-tile .price { font-size: 0.82rem; color: var(--caramel-dark); font-weight: 700; }

/* ---------- Ticket ---------- */
.ticket {
  background: var(--paper);
  border: 1px solid rgba(198, 138, 73, 0.16);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 3.2rem);
  max-height: calc(100dvh - 3.2rem);
  position: sticky;
  top: 1.6rem;
}

.ticket-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.05rem 1.2rem;
  border-bottom: 2px dashed var(--latte);
}
.ticket-header h2 { font-family: var(--font-display); font-size: 1.2rem; color: var(--espresso); }

.ticket-items { flex: 1 1 auto; overflow-y: auto; padding: 0.5rem 1.2rem; min-height: 120px; }
.ticket-empty { color: var(--muted); text-align: center; padding: 2.2rem 0; font-size: 0.95rem; }

.ticket-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--cream-2);
  animation: fade-up 0.2s ease both;
}
.ticket-item .ti-name { flex: 1; min-width: 0; font-weight: 500; font-size: 0.9rem; }
.ticket-item .ti-price { font-size: 0.78rem; color: var(--muted); }
.qty-ctrl { display: flex; align-items: center; gap: 0.4rem; }
.qty-btn {
  width: 30px; height: 30px;
  border-radius: 9px;
  border: 1.5px solid var(--latte);
  background: #fff;
  color: var(--espresso);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  transition: background 0.12s, transform 0.1s;
}
.qty-btn svg { width: 100%; height: 100%; }
.qty-btn:hover { background: var(--cream-2); }
.qty-btn:active { transform: scale(0.9); }
.qty-num { min-width: 20px; text-align: center; font-weight: 700; }
.ti-total { width: 64px; flex-shrink: 0; text-align: right; font-weight: 600; font-size: 0.9rem; }
.ti-remove {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  width: 26px; height: 26px;
  padding: 4px;
  border-radius: 7px;
  transition: color 0.12s, background 0.12s;
}
.ti-remove svg { width: 100%; height: 100%; }
.ti-remove:hover { color: var(--red); background: rgba(191, 90, 75, 0.1); }

.ticket-footer { padding: 1.05rem 1.2rem; border-top: 2px dashed var(--latte); }
.ticket-total-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.9rem; font-weight: 600; color: var(--espresso-2); }
.ticket-total { font-family: var(--font-display); font-size: 1.7rem; color: var(--espresso); }

.ticket-footer { overflow-y: auto; max-height: 62vh; flex-shrink: 0; }
.order-number-row { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.65rem; font-weight: 600; font-size: 0.9rem; color: var(--espresso-2); }
.order-number-row input { width: 110px; text-align: right; font-weight: 700; }
.receipt-toggle { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.65rem; font-size: 0.9rem; font-weight: 600; color: var(--espresso-2); cursor: pointer; user-select: none; }
.receipt-toggle input { width: 18px; height: 18px; accent-color: var(--caramel-dark); cursor: pointer; }
.receipt-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem; margin-bottom: 0.8rem; }
.receipt-fields input:first-child, .receipt-fields input[type="email"] { grid-column: 1 / -1; }
.receipt-fields input[type="email"] { order: 1; }
.order-number-row input, .receipt-fields input {
  font-family: var(--font-body);
  font-size: 0.92rem;
  padding: 0.5rem 0.7rem;
  border: 1.5px solid var(--latte);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  outline: none;
  min-width: 0;
}
.order-number-row input:focus, .receipt-fields input:focus { border-color: var(--caramel); box-shadow: 0 0 0 3px rgba(198, 138, 73, 0.18); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -0.3rem; padding: 0 0.3rem; }
.table-scroll .table { min-width: 560px; }
.table td { white-space: nowrap; }
.checkout-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; }
.checkout-row .btn-cash { grid-column: 1 / -1; }
.checkout-row .btn { white-space: nowrap; min-width: 0; }

/* Talão estreito (tablets, telemóveis pequenos): nome do produto numa linha,
   controlos de quantidade na linha de baixo — nada se sobrepõe */
.ticket { container-type: inline-size; }
@container (max-width: 330px) {
  .ticket-item { flex-wrap: wrap; row-gap: 0.35rem; }
  .ticket-item .ti-name { flex: 1 1 100%; }
  .ticket-item .ti-total { flex: 1 1 auto; width: auto; }
  .checkout-row .btn { padding: 0.9rem 0.4rem; font-size: 0.98rem; }
}
.btn-cash { background: linear-gradient(160deg, #6a966b, var(--green)); color: #fff; padding: 1rem; font-size: 1.05rem; box-shadow: 0 4px 12px rgba(89, 130, 92, 0.35); }
.btn-cash:hover { background: linear-gradient(160deg, #7aa67c, #618765); }
.btn-card { background: linear-gradient(160deg, var(--espresso-2), var(--espresso)); color: var(--cream); padding: 1rem; font-size: 1.05rem; box-shadow: 0 4px 12px rgba(44, 30, 20, 0.3); }
.btn-card:hover { background: linear-gradient(160deg, var(--espresso-3), var(--espresso-2)); }
.btn-credit { background: linear-gradient(160deg, #d8ab6e, var(--caramel-dark)); color: #fff; padding: 1rem; font-size: 1.05rem; box-shadow: 0 4px 12px rgba(160, 106, 51, 0.35); }
.btn-credit:hover { background: linear-gradient(160deg, #e0b87e, var(--caramel)); }

/* ---------- Cards / dashboard ---------- */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); gap: 1rem; margin-bottom: 1.3rem; }

.stat-card {
  background: var(--paper);
  border: 1px solid rgba(198, 138, 73, 0.14);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.15rem 1.3rem;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 5px;
  background: linear-gradient(180deg, #d8ab6e, var(--caramel-dark));
}
.stat-card .label { font-size: 0.78rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.stat-card .value { font-family: var(--font-display); font-size: 1.8rem; color: var(--espresso); margin-top: 0.3rem; }

.dashboard-grid > .card { min-width: 0; }
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 1rem; }

.card {
  background: var(--paper);
  border: 1px solid rgba(198, 138, 73, 0.14);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.3rem 1.45rem;
  margin-bottom: 1rem;
}
.card h3 {
  font-family: var(--font-display);
  font-size: 1.08rem;
  color: var(--espresso);
  margin-bottom: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.card h3 .ic { color: var(--caramel-dark); }

.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 165px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar {
  width: 100%;
  max-width: 46px;
  background: linear-gradient(180deg, #d8ab6e, var(--caramel-dark));
  border-radius: 9px 9px 4px 4px;
  min-height: 4px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: height 0.5s ease, filter 0.15s;
}
.bar:hover { filter: brightness(1.1); }
.bar-col { min-width: 0; }
.bar-value { font-size: 0.7rem; color: var(--muted); font-weight: 700; white-space: nowrap; }
.bar-label { font-size: 0.72rem; color: var(--muted); font-weight: 500; white-space: nowrap; }
.bar-label .bl-short { display: none; }

.rank-row { display: flex; align-items: center; gap: 0.7rem; padding: 0.5rem 0; border-bottom: 1px solid var(--cream-2); font-size: 0.92rem; }
.rank-row:last-child { border-bottom: none; }
.rank-num {
  width: 24px; height: 24px;
  border-radius: 8px;
  background: linear-gradient(150deg, var(--cream-2), var(--latte));
  color: var(--espresso);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.rank-name { flex: 1; min-width: 0; font-weight: 500; overflow-wrap: anywhere; }
.rank-qty, .rank-amt { white-space: nowrap; }
.rank-qty { color: var(--muted); font-size: 0.85rem; }
.rank-amt { font-weight: 700; color: var(--caramel-dark); }

.meter-row { margin-bottom: 0.8rem; }
.meter-head { display: flex; justify-content: space-between; font-size: 0.88rem; margin-bottom: 0.3rem; }
.meter-head .amt { font-weight: 700; }
.meter-track { height: 9px; background: var(--cream-2); border-radius: 999px; overflow: hidden; }
.meter-fill {
  height: 100%;
  background: linear-gradient(90deg, #d8ab6e, var(--caramel-dark));
  border-radius: 999px;
  transition: width 0.5s ease;
}

.order-row { display: flex; align-items: center; gap: 0.7rem; padding: 0.55rem 0.4rem; border-bottom: 1px solid var(--cream-2); cursor: pointer; border-radius: 9px; transition: background 0.12s; }
.order-row:hover { background: var(--cream); }
.order-row:last-child { border-bottom: none; }
.order-time { font-size: 0.8rem; color: var(--muted); min-width: 62px; white-space: nowrap; flex-shrink: 0; }
.order-desc { flex: 1; font-size: 0.88rem; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-method { color: var(--muted); width: 20px; height: 20px; flex-shrink: 0; }
.order-method svg { width: 100%; height: 100%; }
.order-total { font-weight: 700; font-size: 0.9rem; white-space: nowrap; }

/* ---------- Payment summary / export ---------- */
.pay-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--cream-2);
  margin-bottom: 0.5rem;
}
.pay-row { gap: 0.6rem; }
.pay-amt { white-space: nowrap; }
.pay-label { display: inline-flex; align-items: center; gap: 0.55rem; font-weight: 600; font-size: 0.92rem; color: var(--espresso-2); }
.pay-label .ic { color: var(--caramel-dark); }
.pay-amt { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; color: var(--espresso); }
.pay-total {
  background: linear-gradient(150deg, #d8ab6e, var(--caramel));
  box-shadow: 0 4px 12px rgba(160, 106, 51, 0.3);
}
.pay-total .pay-label { color: var(--espresso); font-weight: 700; }
.pay-total .pay-label .ic { color: var(--espresso); }
.pay-total .pay-amt { font-size: 1.3rem; }

.export-period { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.export-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th { text-align: left; color: var(--muted); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.06em; padding: 0.4rem 0.6rem; border-bottom: 2px solid var(--cream-2); }
.table td { padding: 0.65rem 0.6rem; border-bottom: 1px solid var(--cream-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background 0.12s; }
.table tbody tr:hover { background: var(--cream); }
.table .actions { display: flex; gap: 0.4rem; justify-content: flex-end; }

.badge { display: inline-block; padding: 0.22rem 0.7rem; border-radius: 999px; font-size: 0.78rem; font-weight: 700; }
.badge-admin { background: var(--caramel-soft); color: var(--caramel-dark); }
.badge-cashier { background: rgba(89, 130, 92, 0.15); color: var(--green); }

.category-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.9rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.45rem;
  background: var(--cream-2);
  border: 1px solid rgba(198, 138, 73, 0.18);
  border-radius: 999px;
  padding: 0.35rem 0.5rem 0.35rem 0.9rem;
  font-size: 0.88rem;
  font-weight: 500;
}
.chip button {
  border: none; background: none; color: var(--muted); cursor: pointer;
  width: 20px; height: 20px; padding: 3px; border-radius: 50%;
  transition: color 0.12s, background 0.12s;
}
.chip button svg { width: 100%; height: 100%; }
.chip button:hover { color: var(--red); background: rgba(191, 90, 75, 0.12); }

.inline-form { display: flex; gap: 0.6rem; max-width: 440px; }
.inline-form input { flex: 1; }

.prod-icon {
  display: inline-flex;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(150deg, var(--cream-2), var(--latte));
  color: var(--espresso-2);
  padding: 7px;
}
.prod-icon svg { width: 100%; height: 100%; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(43, 30, 20, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  animation: fade-in 0.2s ease both;
  padding: 1rem;
}
.modal {
  background: var(--paper);
  border: 1px solid rgba(198, 138, 73, 0.18);
  border-radius: 22px;
  box-shadow: 0 24px 60px rgba(44, 30, 20, 0.28);
  width: 100%;
  max-width: 430px;
  padding: 1.7rem;
  animation: pop-in 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h3 { font-family: var(--font-display); color: var(--espresso); margin-bottom: 1.15rem; font-size: 1.3rem; }
.modal label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.85rem; font-weight: 600; color: var(--espresso-2); margin-bottom: 0.9rem; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: flex-end; margin-top: 1.25rem; }

.icon-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0.4rem; }
.icon-opt {
  border: 2px solid transparent;
  background: var(--cream-2);
  border-radius: 12px;
  color: var(--espresso-2);
  padding: 0.5rem;
  cursor: pointer;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, border-color 0.1s, background 0.1s;
}
.icon-opt svg { width: 100%; height: 100%; }
.icon-opt:hover { transform: scale(1.08); }
.icon-opt.selected { border-color: var(--caramel); background: #fff; }

.big-total { font-family: var(--font-display); font-size: 2.3rem; color: var(--espresso); text-align: center; margin: 0.4rem 0 1rem; }
.change-due { text-align: center; font-size: 1.15rem; font-weight: 700; color: var(--green); margin-top: 0.8rem; min-height: 1.4em; }
.quick-amounts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.45rem; margin-top: 0.6rem; }
.quick-amounts button { padding: 0.55rem; }

.order-detail-items { margin: 0.8rem 0; }
.order-detail-items .row { display: flex; justify-content: space-between; gap: 0.8rem; overflow-wrap: anywhere; padding: 0.4rem 0; border-bottom: 1px solid var(--cream-2); font-size: 0.92rem; }

/* Editar pedido (modal) */
.modal .receipt-toggle { flex-direction: row; }
.modal .receipt-toggle input { padding: 0; }
.modal .receipt-fields input { font-size: 0.92rem; padding: 0.6rem 0.8rem; }
.modal .modal-actions .btn-danger { margin-right: auto; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 1.6rem;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(150deg, var(--espresso-2), var(--espresso));
  color: var(--cream);
  padding: 0.8rem 1.5rem;
  border-radius: 999px;
  box-shadow: 0 12px 30px rgba(44, 30, 20, 0.35);
  font-weight: 500;
  z-index: 100;
  max-width: calc(100% - 2rem);
  width: max-content;
  text-align: center;
  animation: toast-in 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ---------- Animations ---------- */
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- Responsive ---------- */
/* Botão flutuante "Ver pedido" — só aparece em telemóveis */
.ticket-jump { display: none; }

/* Portáteis pequenos (≤ 1180px) */
@media (max-width: 1180px) {
  .sidebar { width: 200px; }
  .register-layout { grid-template-columns: minmax(0, 1fr) 320px; }
  .main { padding: 1.3rem 1.5rem; }
}

/* Tablets (≤ 960px): barra lateral só com ícones */
@media (max-width: 960px) {
  .sidebar { width: 76px; padding: 1.1rem 0.55rem; }
  .sidebar-title, .sidebar-sub, .nav-btn span { display: none; }
  .nav-btn { justify-content: center; padding: 0.8rem 0; }
  .sidebar-brand { justify-content: center; padding: 0 0 1rem; }
  .register-layout { grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; }
  .main { padding: 1.1rem 1.2rem; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 0.65rem; }
}

/* Ecrãs baixos (portáteis 768px de altura, telemóvel deitado):
   o talão deixa de ficar fixo para não cortar os botões de pagamento */
@media (max-height: 640px) and (min-width: 701px) {
  .ticket { position: static; max-height: none; }
  .ticket-items { max-height: 40vh; }
  .ticket-footer { max-height: none; overflow: visible; }
  .nav { gap: 0.15rem; }
  .nav-btn { padding-top: 0.55rem; padding-bottom: 0.55rem; }
  .sidebar-brand { margin-bottom: 0.6rem; padding-bottom: 0.6rem; }
}

/* Telemóveis (≤ 700px): navegação em barra inferior, uma coluna */
@media (max-width: 700px) {
  .app { flex-direction: column; }

  .sidebar {
    position: fixed;
    top: auto; bottom: 0; left: 0; right: 0;
    width: 100%;
    height: auto;
    flex-direction: row;
    padding: 0.35rem 0.35rem calc(0.35rem + env(safe-area-inset-bottom));
    z-index: 40;
    overflow: visible;
    box-shadow: 0 -6px 20px rgba(44, 30, 20, 0.25);
  }
  .sidebar-brand { display: none; }
  .nav { flex-direction: row; gap: 0.2rem; flex: 1; min-width: 0; }
  .nav-btn,
  .nav-btn.logout {
    flex: 1 1 0;
    min-width: 0;
    flex-direction: column;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.45rem 0.1rem;
    margin-top: 0;
    text-align: center;
  }
  .nav-btn.logout { flex: 0 0 auto; width: 58px; margin-left: 0.2rem; }
  .nav-btn span { display: block; max-width: 100%; font-size: 0.64rem; font-weight: 600; }
  .nav-btn .label-long { display: none; }
  .nav-btn .label-short { display: block; }
  .nav-btn .ic { width: 22px; height: 22px; }
}
@media (max-width: 380px) {
  .nav-btn span { font-size: 0.58rem; letter-spacing: -0.01em; }
  .nav-btn.logout { width: 48px; }
}
@media (max-width: 700px) {

  .main { padding: 0.9rem 0.85rem calc(5.2rem + env(safe-area-inset-bottom)); }
  .page-header { margin-bottom: 0.9rem; }
  .page-header h2 { font-size: 1.4rem; }
  .page-header .btn { flex: 1 1 auto; }

  /* Registo */
  .register-layout { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .category-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin: 0 -0.85rem 0.9rem;
    padding: 0.2rem 0.85rem 0.4rem;
    scrollbar-width: none;
  }
  .category-tabs::-webkit-scrollbar { display: none; }
  .tab { flex-shrink: 0; padding: 0.5rem 1rem; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 0.55rem; }
  .product-tile { min-height: 96px; padding: 0.6rem 0.35rem; }
  .tile-icon { width: 38px; height: 38px; padding: 8px; }
  .product-tile .name { font-size: 0.8rem; overflow-wrap: anywhere; }

  .ticket { position: static; max-height: none; scroll-margin-top: 0.8rem; }
  .ticket-items { min-height: 90px; padding: 0.4rem 0.9rem; }
  .ticket-header, .ticket-footer { padding-left: 0.9rem; padding-right: 0.9rem; }
  .ticket-footer { max-height: none; overflow: visible; }
  .ticket-item { gap: 0.45rem; }
  .ti-total { width: 58px; font-size: 0.85rem; }

  .ticket-jump {
    display: flex;
    position: fixed;
    left: 0.75rem; right: 0.75rem;
    bottom: calc(4.6rem + env(safe-area-inset-bottom));
    z-index: 35;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    padding: 0.85rem 1.1rem;
    border: none;
    border-radius: 14px;
    background: linear-gradient(160deg, #6a966b, var(--green));
    color: #fff;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    box-shadow: 0 8px 22px rgba(44, 30, 20, 0.3);
    cursor: pointer;
    animation: fade-up 0.2s ease both;
  }

  /* Painel */
  .stat-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; margin-bottom: 1rem; }
  .stat-card { padding: 0.85rem 0.95rem; }
  .stat-card .label { font-size: 0.68rem; }
  .stat-card .value { font-size: 1.35rem; overflow-wrap: anywhere; }
  .card { padding: 1rem 1rem; }
  .bar-chart { gap: 4px; height: 140px; }
  .bar-value { font-size: 0.58rem; }
  .bar-label .bl-long { display: none; }
  .bar-label .bl-short { display: inline; }
  .export-actions .btn { flex: 1 1 auto; }

  /* Formulários: 16px evita o zoom automático do iPhone ao tocar num campo */
  input, select, textarea,
  .order-number-row input, .receipt-fields input { font-size: 16px !important; }
  .inline-form { flex-wrap: wrap; max-width: none; }
  .inline-form input { min-width: 0; flex: 1 1 160px; }

  /* Modais */
  .modal { padding: 1.25rem; border-radius: 18px; max-height: calc(100dvh - 2rem); }
  .modal-actions .btn { flex: 1 1 auto; }
  .big-total { font-size: 2rem; }
  .icon-picker { grid-template-columns: repeat(5, 1fr); }

  .toast { bottom: calc(5rem + env(safe-area-inset-bottom)); border-radius: 16px; }
}

/* Telemóveis pequenos (≤ 380px) */
@media (max-width: 380px) {
  .auth-card { padding: 1.8rem 1.3rem; border-radius: 20px; }
  .auth-brand h1 { font-size: 1.7rem; }
  .bar-value { display: none; }
  .checkout-row .btn { font-size: 0.95rem; padding: 0.85rem 0.5rem; }
  .receipt-fields { grid-template-columns: 1fr; }
  .quick-amounts { grid-template-columns: repeat(2, 1fr); }
  .stat-card .value { font-size: 1.15rem; }
}

/* Ecrãs táteis: alvos de toque maiores e sem efeitos de hover "presos" */
@media (pointer: coarse) {
  .qty-btn { width: 36px; height: 36px; padding: 8px; }
  .ti-remove { width: 34px; height: 34px; padding: 7px; }
  .chip button { width: 28px; height: 28px; padding: 6px; }
  .product-tile:hover, .tab:hover, .btn:hover, .stat-card:hover { transform: none; }
}
