:root {
  /* Marca Panificadora Santana (alinhada ao app Android) */
  --santana-red: #8b1a1a;
  --santana-red-dark: #6b1212;
  --santana-gold: #c9a227;
  --santana-gold-light: #e8c547;
  --bg: #f3eee6;
  --sidebar: #3d1f0a;
  --surface: #ffffff;
  --text: #1c1410;
  --muted: #6b5b4f;
  --accent: #8b1a1a;
  --accent-soft: #f8ecec;
  --border: #e6ddd2;
  --ok: #2f7d4a;
  --warn: #b45309;
  --danger: #b91c1c;
  --radius: 14px;
  --font: "Nunito Sans", "Segoe UI", sans-serif;
  --font-display: "Fraunces", Georgia, serif;
  --shadow: 0 10px 30px rgba(61, 31, 10, 0.08);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(ellipse 70% 45% at 100% -10%, rgba(201, 162, 39, 0.18), transparent 50%),
    radial-gradient(ellipse 50% 40% at 0% 100%, rgba(139, 26, 26, 0.08), transparent 45%),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

.app-shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, #4a2610 0%, var(--sidebar) 55%, #2a1508 100%);
  color: #f5efe6;
  display: flex;
  flex-direction: column;
  padding: 1.35rem 1rem;
}
.brand strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: #fff;
  letter-spacing: -0.02em;
}
.brand span { font-size: 0.75rem; color: var(--santana-gold-light); }
.sidebar nav { display: flex; flex-direction: column; gap: 0.3rem; margin-top: 1.5rem; flex: 1; }
.sidebar nav a {
  color: #ecdcc8;
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  text-decoration: none;
  transition: background .18s ease, color .18s ease;
}
.sidebar nav a.active, .sidebar nav a:hover {
  background: rgba(139, 26, 26, 0.55);
  color: #fff;
  text-decoration: none;
}
.sidebar-foot { font-size: 0.85rem; border-top: 1px solid rgba(255,255,255,.12); padding-top: 0.85rem; }
.sidebar-foot a { color: var(--santana-gold-light); }
.sidebar-copy { margin: 0.75rem 0 0; font-size: 0.68rem; color: #a89888; line-height: 1.35; }

.site-footer {
  width: 100%;
  box-sizing: border-box;
  text-align: center;
  padding: 1.5rem 1rem 2rem;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}
.site-footer-inner { max-width: 720px; margin: 0 auto; }
.site-footer-copy, .site-footer-cnpj { margin: 0.15rem 0; }
.site-footer-links { margin: 0.5rem 0 0; }
.site-footer a { color: var(--santana-red); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
}
.topbar h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.45rem;
  letter-spacing: -0.02em;
  color: var(--santana-red-dark);
}
.subtitle { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.9rem; }
.content { padding: 1.25rem 1.5rem 2rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.85rem; margin-bottom: 1.25rem; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}
.kpi .v { font-size: 1.6rem; font-weight: 700; color: var(--santana-red); font-family: var(--font-display); }
.kpi .l { font-size: 0.82rem; color: var(--muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.65rem 0.5rem; border-bottom: 1px solid var(--border); }
th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; background: #ebe4da; }
.badge.pago, .badge.preparando { background: #f8ecec; color: var(--santana-red-dark); }
.badge.pronto { background: #fef3c7; color: #92400e; }
.badge.saiu_entrega { background: #e8f0fe; color: #1d4ed8; }
.badge.entregue { background: #e4f5ea; color: #166534; }
.badge.cancelado, .badge.aguardando_pagamento { background: #fee2e2; color: #991b1b; }

.btn {
  display: inline-block;
  border: 0;
  border-radius: 10px;
  padding: 0.6rem 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  background: #ebe4da;
  color: var(--text);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: linear-gradient(180deg, #9d2222 0%, var(--santana-red) 100%);
  color: #fff;
  box-shadow: 0 6px 16px rgba(139, 26, 26, 0.28);
}
.btn-primary:hover { background: var(--santana-red-dark); }
.btn-sm { padding: 0.3rem 0.55rem; font-size: 0.8rem; }

.order-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.25rem 0 0.5rem;
}
.order-filters .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.order-filters .order-filter-count {
  display: inline-block;
  min-width: 1.25rem;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  background: rgba(0,0,0,0.08);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
}
.order-filters .order-filter-active .order-filter-count,
.order-filters .btn-primary .order-filter-count {
  background: rgba(255,255,255,0.22);
  color: #fff;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.form-grid label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; font-weight: 600; }
.form-grid input, .form-grid select, .form-grid textarea {
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  font-weight: 400;
  background: #fff;
}
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus {
  outline: 2px solid rgba(139, 26, 26, 0.25);
  border-color: var(--santana-red);
}

.alert { padding: 0.75rem 1rem; border-radius: 10px; margin-bottom: 1rem; }
.alert-success { background: #e4f5ea; color: #166534; }
.alert-danger { background: #fee2e2; color: #991b1b; }

/* Login */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem 1rem;
  background:
    radial-gradient(ellipse 60% 50% at 80% 10%, rgba(201, 162, 39, 0.35), transparent 55%),
    linear-gradient(155deg, #2a1508 0%, #6b1212 48%, #3d1f0a 100%);
}
.login-card {
  width: min(420px, 94vw);
  background: #fffdf9;
  border-radius: 20px;
  padding: 1.85rem 1.6rem 1.5rem;
  box-shadow: 0 24px 48px rgba(0,0,0,.28);
  border: 1px solid rgba(201, 162, 39, 0.35);
  animation: loginIn .45s ease both;
}
@keyframes loginIn {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.login-brand {
  text-align: center;
  margin-bottom: 1.15rem;
}
.login-brand .mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 0.75rem;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--santana-gold-light), var(--santana-red));
  box-shadow: 0 8px 18px rgba(139, 26, 26, 0.35);
}
.login-card h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.65rem;
  color: var(--santana-red);
  letter-spacing: -0.03em;
}
.login-card .login-lead {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}
.login-form {
  margin-top: 1.15rem;
  display: grid;
  gap: 0.8rem;
}
.login-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: #3d1f0a;
}
.login-form input[type="email"],
.login-form .password-field input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  font-weight: 400;
  background: #fff;
}
.login-form .btn-primary { width: 100%; padding: 0.75rem; font-size: 1rem; }
.login-links { margin-top: 1rem; text-align: center; font-size: 0.9rem; }
.login-copy { margin: 1.15rem 0 0; font-size: 0.72rem; color: #9a8b7c; text-align: center; line-height: 1.4; }
.login-demo { font-size: 0.8rem; color: var(--muted); margin: 0.75rem 0 0; text-align: center; }

.map { height: 480px; border-radius: var(--radius); border: 1px solid var(--border); position: relative; z-index: 1; }
.map-store-pin { height: 420px; cursor: crosshair; touch-action: none; }
.map-toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.75rem; align-items: center; }
.map-toolbar .btn { font-size: 0.85rem; }
.track-meta { font-size: 0.88rem; color: var(--muted); margin: 0.5rem 0 0; line-height: 1.45; }
.map-pin {
  background: transparent !important;
  border: 0 !important;
  font-size: 1.35rem;
  line-height: 1;
  text-align: center;
}
.pin-hit {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: #fff;
  border: 2px solid var(--santana-red);
  border-radius: 50%;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.28);
  cursor: grab;
  user-select: none;
}
.leaflet-marker-dragging .pin-hit,
.leaflet-drag-target .pin-hit { cursor: grabbing; }
.leaflet-marker-draggable { cursor: grab; }
.map-legend {
  display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem;
  font-size: 0.82rem; color: var(--muted); margin-top: 0.65rem;
}
.map-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.inline { display: inline; }
.public-track-page {
  min-height: 100vh;
  padding: 1.5rem 1rem 2rem;
  background:
    radial-gradient(ellipse 70% 40% at 50% -10%, rgba(201, 162, 39, 0.2), transparent 55%),
    linear-gradient(160deg, #fff8ef 0%, #f3eee6 55%, #e8e0d4 100%);
}
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative;
  padding: 0.65rem 0 0.65rem 1rem;
  border-left: 3px solid #e0b85a;
  margin-left: 0.35rem;
}
.timeline li:last-child { border-left-color: transparent; }
.timeline-time { display: block; font-size: 0.75rem; color: var(--muted); }
.auto-refresh-hint { font-size: 0.8rem; color: var(--muted); }
.live-badge {
  display: inline-block;
  margin: 0 0.25rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: #ebe4da;
  color: #5c4a3c;
  font-weight: 700;
  font-size: 0.72rem;
}
.live-badge.on { background: #e4f5ea; color: #166534; }

.kpi-delay .v { color: #9a3412; }
.kpi-delay-on {
  border-color: #f59e0b;
  background: linear-gradient(180deg, #fff7ed 0%, #fff 70%);
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.25);
  animation: delay-pulse 1.8s ease-in-out infinite;
}
.delay-panel-on {
  border-color: #f59e0b;
  background: #fffbeb;
}
.delay-badge { background: #fed7aa; color: #9a3412; }
.delay-row.delay-warning { background: #fff7ed; }
.delay-row.delay-critical { background: #fef2f2; }
.delay-row.delay-critical td:first-child { box-shadow: inset 3px 0 0 #dc2626; }
.alert-delay {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  background: #fff7ed;
  border: 1px solid #f59e0b;
  color: #9a3412;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}
.alert-delay .btn { margin-left: auto; }
.order-row-delayed { background: #fff7ed; }
.order-row-delayed td:first-child { box-shadow: inset 3px 0 0 #f59e0b; }
@keyframes delay-pulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.25); }
  50% { box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.35); }
}

.chat-layout {
  display: grid;
  grid-template-columns: minmax(280px, 1.1fr) minmax(280px, 0.9fr);
  gap: 1rem;
  align-items: start;
}
@media (max-width: 960px) {
  .chat-layout { grid-template-columns: 1fr; }
}
.chat-thread-unread { background: #fff7ed; }
.chat-messages {
  height: 360px;
  overflow-y: auto;
  padding: 0.75rem;
  background: #f7f1e8;
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.chat-bubble {
  max-width: 85%;
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--border);
}
.chat-mine {
  align-self: flex-end;
  background: #f8ecec;
  border-color: #e8c4c4;
}
.chat-theirs { align-self: flex-start; }
.chat-meta { font-size: 0.72rem; color: var(--muted); margin-bottom: 0.2rem; }
.chat-body { white-space: pre-wrap; word-break: break-word; }
.chat-compose {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.chat-compose input { flex: 1; }

.perm-group {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 1rem 1rem;
  margin: 0.75rem 0;
  background: #fbf7f1;
}
.perm-group legend {
  padding: 0 0.35rem;
  font-weight: 700;
  color: var(--santana-red-dark);
}
.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.45rem 0.75rem;
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; gap: 0.5rem; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; margin-top: 0.5rem; }
  .form-grid { grid-template-columns: 1fr; }
}

.password-field {
  display: flex;
  gap: 0.4rem;
  align-items: stretch;
  margin-top: 0.25rem;
}
.password-field input { flex: 1; }
.password-toggle {
  border: 1px solid var(--border);
  background: #f7f1e8;
  border-radius: 10px;
  padding: 0 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: #5c4a3c;
  white-space: nowrap;
  font-family: inherit;
}
.password-toggle:hover { background: var(--accent-soft); color: var(--santana-red); }
.password-check {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  font-weight: 500 !important;
  color: var(--muted);
  cursor: pointer;
}
.password-check input { width: auto; margin: 0; }

/* Seletor de imagem do cardápio */
.product-image-field { display: grid; gap: 0.65rem; }
.product-image-preview-wrap {
  display: flex; align-items: center; gap: 0.85rem; flex-wrap: wrap;
}
.product-image-preview {
  width: 96px; height: 96px; object-fit: cover; border-radius: 12px;
  border: 1px solid var(--border); background: #fff;
}
.product-image-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.img-picker-modal {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(28, 20, 16, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.img-picker-modal[hidden] { display: none !important; }
.img-picker-dialog {
  width: min(960px, 100%);
  max-height: min(94vh, 920px);
  overflow: auto;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem 1.25rem;
}
.img-picker-dialog.is-cropping .img-picker-help,
.img-picker-dialog.is-cropping .img-picker-steps,
.img-picker-dialog.is-cropping .img-picker-search,
.img-picker-dialog.is-cropping .img-picker-alt {
  display: none;
}
.img-picker-crop-box {
  width: 100%;
  max-width: 520px;
  height: min(56vh, 520px);
  margin: 0.5rem auto 0.75rem;
  background: #1c1410;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}
.img-picker-crop-box img {
  display: block;
  max-width: 100%;
  max-height: min(56vh, 520px);
}
.img-picker-crop-tools {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: center;
  margin: 0 0 0.65rem;
}
.img-picker-crop-tools .btn { min-width: 2.4rem; }
.img-picker-crop-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  flex-wrap: wrap;
  position: sticky;
  bottom: 0;
  background: var(--surface);
  padding-top: 0.5rem;
}
.img-picker-preview-out {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: center;
  margin: 0.35rem 0 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.img-picker-preview-out img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
}
.img-picker-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.75rem;
}
.img-picker-help {
  margin: 0 0 0.75rem;
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.45;
}
.img-picker-steps {
  margin: 0.35rem 0 0.85rem 1.1rem;
  padding: 0;
  line-height: 1.55;
}
.img-picker-steps li { margin-bottom: 0.2rem; }
.img-picker-search, .img-picker-url-row {
  display: flex; gap: 0.5rem; margin-bottom: 0.5rem;
}
.img-picker-search input, .img-picker-url-row input { flex: 1; }
.img-picker-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.65rem;
  margin: 0.75rem 0 1rem;
}
.img-picker-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  background: #fff;
  cursor: pointer;
  overflow: hidden;
  text-align: left;
  font: inherit;
  color: inherit;
}
.img-picker-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.img-picker-card img {
  display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: #f3eee6;
}
.img-picker-card span {
  display: block; padding: 0.35rem 0.45rem; font-size: 0.72rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.img-picker-alt {
  border-top: 1px solid var(--border);
  margin-top: 0.75rem; padding-top: 0.75rem;
  display: grid; gap: 0.65rem;
}
.img-picker-file input { display: block; margin-top: 0.35rem; }
.table-thumb {
  width: 40px; height: 40px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--border); vertical-align: middle; margin-right: 0.4rem;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

