:root {
  --bg: #f2f2f2;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7f7f7;
  --ink: #222222;
  --muted: #6b6b6b;
  --line: #e6e6e6;
  --line-soft: #d4d4d4;
  --brand: #b91c1c;
  --brand-deep: #8f1414;
  --brand-soft: #dc2626;
  --ok: #1f7a45;
  --ok-bg: #e8f6ee;
  --warn: #b45309;
  --warn-bg: #fff7ed;
  --danger: #b42318;
  --danger-bg: #fef2f2;
  --info: #1d4ed8;
  --info-bg: #eff6ff;
  --purple-bg: #fee2e2;
  --font: "Manrope", system-ui, sans-serif;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--muted);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, strong { color: var(--ink); }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(185, 28, 28, 0.08), transparent 42%),
    var(--bg);
}

.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-card h1 { margin: 0 0 6px; font-size: 1.35rem; font-weight: 800; }
.login-card p { margin: 0 0 18px; color: var(--muted); }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field span { font-size: .82rem; font-weight: 700; color: var(--muted); }

.field input,
.field select,
.field textarea,
.pay-row input,
.pay-row select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--ink);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.pay-row input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.16);
}

.field input::placeholder,
.field textarea::placeholder {
  color: #9ca3af;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: .92rem;
  cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}

.btn:hover { background: var(--brand-soft); }
.btn:active { transform: translateY(1px); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-secondary:hover {
  background: #eeeeee;
}

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #c53030; }
.btn-block { width: 100%; }

.alert {
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  background: var(--danger-bg);
  color: var(--danger);
  font-weight: 700;
  border: 1px solid #fecaca;
}

.alert-ok {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: #bbf7d0;
}

.shell {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--brand);
  border-right: 0;
  color: rgba(255, 255, 255, 0.82);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  color: #fff;
  margin: 4px 8px 22px;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.sidebar__brand::before {
  content: "PL";
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #fff;
  color: var(--brand);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  flex: 0 0 auto;
}

.sidebar nav { display: grid; gap: 4px; }

.sidebar a {
  padding: 10px 12px;
  border-radius: var(--radius);
  color: rgba(255, 255, 255, 0.84);
  font-weight: 600;
  font-size: .92rem;
  transition: background .15s ease, color .15s ease;
}

.sidebar a.is-active,
.sidebar a:hover {
  background: #fff;
  color: var(--brand);
}

.sidebar a[href*="logout"],
.sidebar a[target="_blank"] {
  margin-top: 4px;
}

.sidebar__foot {
  margin-top: 24px;
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  font-size: .8rem;
  color: rgba(255, 255, 255, 0.72);
}

.content {
  padding: 28px 28px 40px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}

.topbar h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
}

.stat-link {
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
  color: inherit;
}

.stat-link:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--brand);
}

.stat-link small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}

.stat-link--alert {
  border-color: var(--brand);
  background: #fff5f5;
}

.stat-link--alert strong {
  color: var(--brand);
}

.stat strong {
  display: block;
  font-size: 1.45rem;
  margin-top: 8px;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.stat span {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.card h2 {
  margin-top: 0;
  font-size: 1.05rem;
  font-weight: 800;
}

.table-wrap { overflow: auto; }

table { width: 100%; border-collapse: collapse; }

th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: .9rem;
}

th {
  color: var(--muted);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 700;
}

td { color: var(--muted); }
td strong, td a strong { color: var(--ink); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid transparent;
}

.badge-novo { background: var(--warn-bg); color: var(--warn); }
.badge-confirmado,
.badge-preparando { background: var(--info-bg); color: var(--info); }
.badge-saiu_entrega { background: var(--purple-bg); color: var(--brand); }
.badge-concluido { background: var(--ok-bg); color: var(--ok); }
.badge-cancelado { background: var(--danger-bg); color: var(--danger); }
.badge-pago { background: var(--ok-bg); color: var(--ok); }
.badge-pendente { background: var(--warn-bg); color: var(--warn); }
.badge-reembolsado { background: var(--surface-2); color: var(--muted); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

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

.form-grid .full { grid-column: 1 / -1; }
.checks { display: flex; gap: 16px; flex-wrap: wrap; }
.checks label { color: var(--muted); font-size: .9rem; }
.muted { color: var(--muted); }

.hours-by-day {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.hours-day-row {
  display: grid;
  grid-template-columns: 150px 1fr 1fr;
  gap: 12px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.hours-day-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  color: var(--ink);
  font-size: .95rem;
}

.hours-day-row .field { margin-bottom: 0; }

@media (max-width: 720px) {
  .hours-day-row { grid-template-columns: 1fr; }
}

.pay-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.checkout-row {
  grid-template-columns: 140px 1fr auto;
}

.image-upload { display: grid; gap: 12px; }

.image-upload__preview {
  width: 88px;
  height: 110px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.image-upload__preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-upload__drop {
  display: grid;
  gap: 4px;
  padding: 18px;
  border: 1.5px dashed var(--line-soft);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  cursor: pointer;
}

.image-upload__drop input[type="file"] {
  width: 100%;
  margin-bottom: 6px;
}

.image-upload__drop strong {
  font-size: .95rem;
  color: var(--ink);
}

.image-upload__drop small { color: var(--muted); }

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--brand);
}

.logo-upload__label {
  display: block;
  font-size: .82rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 8px;
}

.logo-upload__row {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.logo-upload__preview {
  width: 88px;
  height: 88px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.4rem;
  flex: 0 0 auto;
}

.logo-upload__preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.logo-upload__controls input[type="file"] {
  display: block;
  margin-bottom: 4px;
}

.delivery-map-wrap {
  margin-bottom: 4px;
}

.delivery-map {
  width: 100%;
  height: 320px;
  border-radius: 14px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: #e5e7eb;
  z-index: 1;
}

@media (max-width: 1100px) {
  .stats { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  }
  .sidebar nav {
    display: flex;
    gap: 6px;
    overflow: auto;
    padding-bottom: 4px;
  }
  .sidebar a { white-space: nowrap; }
  .sidebar__foot { display: none; }
  .content { padding: 18px 16px 32px; }
  .form-grid { grid-template-columns: 1fr; }
  .pay-row,
  .checkout-row { grid-template-columns: 1fr; }
}

/* Notinha: oculta na tela, só aparece na impressão */
.print-ticket {
  display: none;
}

.print-hint {
  margin: 8px 0 0;
  font-size: 0.86rem;
}

/* Impressora térmica não fiscal 80mm (bobina) */
@media print {
  @page {
    size: 80mm auto;
    margin: 0;
  }

  html,
  body {
    width: 80mm !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    color: #000 !important;
  }

  .shell {
    display: block !important;
    width: 80mm !important;
    margin: 0 !important;
  }

  .sidebar,
  .topbar,
  .no-print,
  .alert {
    display: none !important;
  }

  .content {
    width: 80mm !important;
    max-width: 80mm !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .print-ticket {
    display: block !important;
    box-sizing: border-box;
    width: 72mm;
    max-width: 72mm;
    margin: 0 auto;
    padding: 2mm 0 4mm;
    font-family: "Courier New", Courier, monospace;
    font-size: 11px;
    line-height: 1.3;
    color: #000;
    overflow: hidden;
    page-break-after: avoid;
    page-break-inside: avoid;
  }

  .print-ticket__head {
    text-align: center;
    border-bottom: 1px dashed #000;
    padding-bottom: 6px;
    margin-bottom: 6px;
  }

  .print-ticket__logo {
    display: block;
    width: 22mm;
    height: 22mm;
    object-fit: contain;
    margin: 0 auto 4px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .print-ticket__head strong {
    display: block;
    font-size: 13px;
    margin-bottom: 2px;
    text-transform: uppercase;
  }

  .print-ticket__block {
    border-bottom: 1px dashed #000;
    padding-bottom: 6px;
    margin-bottom: 6px;
    word-break: break-word;
  }

  .print-ticket__block > div {
    margin: 0 0 3px;
  }

  .print-ticket__items {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    margin-bottom: 6px;
  }

  .print-ticket__items th:nth-child(1),
  .print-ticket__items td:nth-child(1) {
    width: 58%;
  }

  .print-ticket__items th:nth-child(2),
  .print-ticket__items td:nth-child(2) {
    width: 12%;
  }

  .print-ticket__items th:nth-child(3),
  .print-ticket__items td:nth-child(3) {
    width: 30%;
  }

  .print-ticket__items th,
  .print-ticket__items td {
    padding: 2px 0;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px dotted #666;
    word-break: break-word;
  }

  .print-ticket__items th:nth-child(2),
  .print-ticket__items td:nth-child(2),
  .print-ticket__items th:nth-child(3),
  .print-ticket__items td:nth-child(3) {
    text-align: right;
    white-space: nowrap;
  }

  .print-ticket__note {
    font-size: 10px;
    margin-top: 1px;
  }

  .print-ticket__totals {
    border-top: 1px dashed #000;
    padding-top: 6px;
  }

  .print-ticket__totals > div {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    margin: 0 0 3px;
  }

  .print-ticket__total {
    font-size: 13px;
    margin-top: 4px !important;
    border-top: 1px solid #000;
    padding-top: 4px;
  }

  .print-ticket__foot {
    text-align: center;
    margin-top: 8px;
    border-top: 1px dashed #000;
    padding-top: 6px;
    font-size: 10px;
  }
}

/* Alertas de novos pedidos */
.admin-alert-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--brand);
  cursor: pointer;
}

.admin-alert-bell__badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 0 0 2px #fff;
}

.admin-alert-banner {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(92, 16, 24, 0.55);
  backdrop-filter: blur(2px);
}

.admin-alert-banner[hidden] {
  display: none !important;
}

.admin-alert-banner__inner {
  position: relative;
  width: min(560px, 100%);
  padding: 22px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  border: 3px solid var(--brand);
  overflow: hidden;
  animation: admin-alert-pop 0.35s ease;
}

.admin-alert-banner__pulse {
  position: absolute;
  inset: -40%;
  background: radial-gradient(circle, rgba(185, 28, 28, 0.18), transparent 55%);
  animation: admin-alert-pulse 1.2s ease-in-out infinite;
  pointer-events: none;
}

.admin-alert-banner__content {
  position: relative;
  z-index: 1;
}

.admin-alert-banner__content strong {
  display: block;
  font-size: 1.45rem;
  color: var(--brand);
  margin-bottom: 10px;
}

.admin-alert-banner__content ul {
  margin: 0;
  padding-left: 18px;
  color: var(--ink);
  display: grid;
  gap: 6px;
}

.admin-alert-banner__actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

body.has-order-alert .shell {
  animation: admin-shell-glow 1.4s ease-in-out infinite;
}

body.has-order-alert .admin-alert-bell {
  animation: admin-bell-shake 0.7s ease-in-out infinite;
  background: #fff5f5;
  border-color: var(--brand);
}

[data-admin-sound-toggle].is-on {
  border-color: var(--brand);
  color: var(--brand);
}

@keyframes admin-alert-pop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes admin-alert-pulse {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}

@keyframes admin-shell-glow {
  0%, 100% { filter: none; }
  50% { filter: drop-shadow(0 0 0.5px rgba(185, 28, 28, 0.35)); }
}

@keyframes admin-bell-shake {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-10deg); }
  75% { transform: rotate(10deg); }
}

body.has-pending-new-orders .admin-alert-bell {
  animation: admin-bell-shake 0.7s ease-in-out infinite;
  background: #fff5f5;
  border-color: var(--brand);
}

/* Fila da cozinha */
.kitchen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.kitchen-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
}

.kitchen-card--novo {
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.18);
}

.kitchen-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.kitchen-card__code {
  display: inline-block;
  margin-right: 8px;
  font-size: 1.15rem;
}

.kitchen-card__customer {
  margin: 0;
  color: var(--ink);
  font-weight: 700;
}

.kitchen-card__items {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.kitchen-card__note {
  display: block;
  color: var(--warn);
  font-size: 0.86rem;
  font-weight: 600;
}

.kitchen-card__meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--ink);
  font-weight: 700;
}

.kitchen-card__address {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.kitchen-card__actions {
  display: grid;
  gap: 8px;
}

.kitchen-advance {
  display: grid;
  gap: 8px;
}

.kitchen-btn {
  min-height: 52px;
  font-size: 1.05rem;
  font-weight: 800;
}

.kitchen-btn--next {
  background: var(--brand);
}

.kitchen-btn--print {
  background: #111827;
}

.kitchen-btn-link {
  text-align: center;
}

.checkout-eta,
.success-eta {
  margin: 0 0 12px;
}
