/* Painel Don Corleone — ferramenta de trabalho com a identidade do site (fundo quente escuro + latão).
   Design system: tokens em :root; componentes abaixo usam só tokens (nada de cor solta). */
:root {
  color-scheme: dark;

  /* Superfícies */
  --bg: #0E0B09;
  --bg-sidebar: #130F0C;
  --surface: #1A1512;
  --surface-2: #221B17;
  --surface-3: #2B231D;
  --border: rgba(243, 235, 221, 0.10);
  --border-strong: rgba(243, 235, 221, 0.18);
  --overlay: rgba(0, 0, 0, 0.55);

  /* Texto */
  --text: #F5EFE6;
  --text-2: #D8CEBE;
  --muted: #9A8E7F;

  /* Marca */
  --gold: #F7BA2A;
  --gold-dark: #C48416;
  --gold-soft: rgba(247, 186, 42, 0.12);
  --gold-gradient: linear-gradient(180deg, #FCCB4E 0%, #EBAA24 100%);
  --gold-gradient-hover: linear-gradient(180deg, #FFD66B 0%, #F2B636 100%);
  --on-gold: #1A1200;

  /* Estados (cor de destaque, fundo suave e texto legível sobre fundo escuro) */
  --amber: #E26D2B;
  --amber-soft: rgba(226, 109, 43, 0.14);
  --amber-text: #F3A272;
  --red: #E05252;
  --red-soft: rgba(224, 82, 82, 0.14);
  --red-text: #F08A8A;
  --green: #2EB872;
  --green-soft: rgba(46, 184, 114, 0.14);
  --green-text: #6FD9A2;
  --blue: #5B9BD5;
  --blue-soft: rgba(91, 155, 213, 0.14);
  --blue-text: #9CC3E8;
  --violet: #A98BDB;
  --violet-soft: rgba(169, 139, 219, 0.14);

  --t-novo: var(--gold);
  --t-confirmado: var(--blue);
  --t-preparo: var(--amber);
  --t-rota: var(--violet);
  --t-concluido: var(--green);
  --t-cancelado: var(--red);

  /* Tipografia */
  --font-serif: 'Cinzel', 'Playfair Display', Georgia, serif;
  --font-sans: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-md: 0.875rem;
  --fs-base: 0.9375rem;

  /* Espaçamento (escala de 4px) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;

  /* Forma e profundidade */
  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --focus-ring: 0 0 0 3px rgba(247, 186, 42, 0.28);

  /* Controles: mesma altura para botões, campos e selects */
  --control-h: 40px;
  --control-h-sm: 32px;

  /* Layout */
  --sidebar-w: 236px;
  --topbar-h: 64px;
  --content-max: 1440px;
  --content-pad: 28px;
}
/* Telas de toque: alvos maiores (WCAG 2.2, área mínima confortável) */
@media (pointer: coarse) {
  :root { --control-h: 44px; --control-h-sm: 38px; }
  input[type=checkbox], input[type=radio] { width: 24px !important; height: 24px !important; }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.5;
}
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-family: var(--font-serif); font-size: 1.55rem; letter-spacing: 0.02em; color: var(--text); }
h2 { font-size: 1.05rem; font-weight: 700; }
h3 { font-size: 0.95rem; font-weight: 700; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
code { font-size: 0.88em; padding: 1px 6px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: var(--sp-5) var(--sp-3);
  display: flex; flex-direction: column; gap: var(--sp-5);
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 var(--sp-2); color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { width: 38px; height: 38px; }
.brand-name { font-family: var(--font-serif); font-size: 1.05rem; letter-spacing: 0.04em; color: var(--gold); line-height: 1.1; }
.brand-sub { font-size: 0.72rem; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: var(--sp-3); min-height: 40px;
  padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 600; font-size: var(--fs-md);
  transition: background 0.15s, color 0.15s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--gold-soft); color: var(--gold); box-shadow: inset 3px 0 0 var(--gold); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav-badge {
  margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: var(--radius-pill);
  background: var(--gold); color: var(--on-gold); font-size: var(--fs-xs); font-weight: 800; text-align: center;
}
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-3) var(--sp-2) 0; border-top: 1px solid var(--border); }
.sidebar-foot .user { font-size: var(--fs-sm); color: var(--text-2); padding: var(--sp-1) 0; }

.main { min-width: 0; display: flex; flex-direction: column; }

/* Barra do topo: uma linha só (título + som + status da loja). As ações da página ficam na faixa .page-toolbar */
.topbar {
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: var(--topbar-h);
  padding: var(--sp-3) max(var(--content-pad), calc((100% - var(--content-max)) / 2 + var(--content-pad)));
  border-bottom: 1px solid var(--border);
  background: rgba(14, 11, 9, 0.92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 30;
}
.topbar h1 { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .menu-toggle { display: none; }
.topbar-status { display: flex; align-items: center; gap: var(--sp-2); flex: none; }
.content {
  width: 100%; max-width: var(--content-max); margin-inline: auto;
  padding: var(--sp-6) var(--content-pad) 48px;
  display: flex; flex-direction: column; gap: var(--sp-5);
}
/* Links com #âncora (ex.: Configurações#campainha) não ficam escondidos atrás da barra fixa */
.content [id] { scroll-margin-top: calc(var(--topbar-h) + var(--sp-3)); }
.page-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3); }
.page-toolbar:empty { display: none; }
.page-toolbar > .btn-primary:last-child { margin-left: auto; }
.page-toolbar .store-pill { display: none; }
.page-toolbar:not(:has(> :not(.store-pill))) { display: none; }

/* ---------- Store status pill ---------- */
.store-pill {
  display: inline-flex; align-items: center; gap: var(--sp-2); min-height: var(--control-h-sm);
  padding: 0 var(--sp-3); border-radius: var(--radius-pill); font-size: var(--fs-md); font-weight: 700; white-space: nowrap;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
}
.store-pill:hover { text-decoration: none; border-color: var(--gold); }
.store-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--red); flex: none; }
.store-pill.is-open { color: var(--gold); }
.store-pill.is-open::before { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }

/* ---------- Buttons ----------
   .btn (secundário) · .btn-primary · .btn-ghost (terciário, contorno discreto) · .btn-plain (sem borda: ícones, fechar)
   · .btn-success · .btn-warning · .btn-danger
   Tamanhos: padrão, .btn-sm, .btn-icon (só ícone, precisa de aria-label) · .btn-block
   Estados: :hover, :active, :focus-visible, :disabled / [aria-disabled], [aria-busy="true"] (enviando) */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--control-h); padding: 0 var(--sp-4);
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 700; font-size: var(--fs-md); line-height: 1.2; text-align: center;
  cursor: pointer; white-space: nowrap; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.06s;
}
.btn:hover { background: var(--surface-3); border-color: rgba(243, 235, 221, 0.26); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: var(--radius-sm); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; flex: none; }

.btn-primary { background: var(--gold-gradient); color: var(--on-gold); border-color: transparent; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--gold-gradient-hover); border-color: transparent; }
.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-plain { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-plain:hover { background: var(--surface-2); border-color: transparent; color: var(--text); }
.btn-success { background: var(--green-soft); color: var(--green-text); border-color: rgba(46, 184, 114, 0.4); }
.btn-success:hover { background: rgba(46, 184, 114, 0.22); border-color: rgba(46, 184, 114, 0.55); }
.btn-warning { background: var(--amber-soft); color: var(--amber-text); border-color: rgba(226, 109, 43, 0.4); }
.btn-warning:hover { background: rgba(226, 109, 43, 0.22); border-color: rgba(226, 109, 43, 0.55); }
.btn-danger { color: var(--red-text); border-color: rgba(224, 82, 82, 0.4); background: transparent; }
.btn-danger:hover { background: var(--red-soft); border-color: rgba(224, 82, 82, 0.6); }

.btn-sm { min-height: var(--control-h-sm); padding: 0 var(--sp-3); font-size: var(--fs-sm); gap: 6px; }
.btn-icon { padding: 0; width: var(--control-h); }
.btn-icon.btn-sm { width: var(--control-h-sm); }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }

/* Enviando: o texto some e aparece um indicador; volta sozinho se a página não trocar */
.btn[aria-busy="true"] { position: relative; color: transparent !important; pointer-events: none; }
.btn[aria-busy="true"]::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--text-2); border-right-color: transparent; animation: girar 0.7s linear infinite;
}
.btn-primary[aria-busy="true"]::after { border-color: var(--on-gold); border-right-color: transparent; }
@keyframes girar { to { transform: rotate(360deg); } }

/* ---------- Cards & panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); min-width: 0; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2) var(--sp-3); flex-wrap: wrap;
  padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border);
}
.panel-body { padding: var(--sp-4) var(--sp-5); }
.grid { display: grid; gap: var(--sp-4); grid-template-columns: minmax(0, 1fr); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { display: grid; gap: var(--sp-4); grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { padding: var(--sp-4) var(--sp-5); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); min-width: 0; }
.kpi-label { color: var(--muted); font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.kpi-value { font-size: 1.7rem; font-weight: 800; margin-top: var(--sp-1); font-variant-numeric: tabular-nums; line-height: 1.2; overflow-wrap: anywhere; }
.kpi-note { color: var(--muted); font-size: var(--fs-sm); margin-top: 2px; }
.kpi.is-gold .kpi-value { color: var(--gold); }

/* Abas / filtros segmentados: nunca quebram o texto; se faltar espaço, rolam para o lado */
.segmented {
  display: inline-flex; max-width: 100%; padding: 3px; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-pill);
  overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented a {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  min-height: calc(var(--control-h-sm) - 6px); padding: 0 var(--sp-3); border-radius: var(--radius-pill);
  color: var(--text-2); font-size: var(--fs-md); font-weight: 700; white-space: nowrap;
}
.segmented a[href]:hover { text-decoration: none; color: var(--text); background: var(--surface-2); }
.segmented a[aria-current="true"] { background: var(--gold-soft); color: var(--gold); }

/* ---------- Alerts / messages ---------- */
.alerts { display: flex; flex-direction: column; gap: var(--sp-2); }
/* Bloco (não flex): texto com <strong> e links corre como parágrafo normal */
.alert {
  position: relative; display: block;
  padding: 11px var(--sp-4) 11px calc(var(--sp-4) + 10px);
  border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--surface);
  font-size: var(--fs-md); line-height: 1.5; color: var(--text); overflow-wrap: anywhere;
}
.alert::before { content: ""; position: absolute; left: 10px; top: 10px; bottom: 10px; width: 4px; border-radius: 4px; background: var(--muted); }
.alert a { font-weight: 700; white-space: nowrap; margin-left: var(--sp-1); }
.alert-perigo, .alert-error { border-color: rgba(224, 82, 82, 0.35); }
.alert-perigo::before, .alert-error::before { background: var(--red); }
.alert-aviso, .alert-warning { border-color: rgba(226, 109, 43, 0.35); }
.alert-aviso::before, .alert-warning::before { background: var(--amber); }
.alert-info::before { background: var(--blue); }
.alert-success { border-color: rgba(46, 184, 114, 0.35); }
.alert-success::before { background: var(--green); }
.messages { position: fixed; right: var(--sp-5); top: calc(var(--topbar-h) + var(--sp-3)); z-index: 60; display: flex; flex-direction: column; gap: var(--sp-2); max-width: min(420px, calc(100vw - 32px)); }
.messages .alert { box-shadow: var(--shadow); background: var(--surface-2); }

/* ---------- Status badges / tags ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: 800; white-space: nowrap; line-height: 1.6;
  color: var(--tone, var(--text-2)); background: color-mix(in srgb, var(--tone, var(--muted)) 15%, transparent);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tone-novo { --tone: var(--t-novo); }
.tone-confirmado { --tone: var(--t-confirmado); }
.tone-preparo { --tone: var(--t-preparo); }
.tone-rota { --tone: var(--t-rota); }
.tone-concluido { --tone: var(--t-concluido); }
.tone-cancelado { --tone: var(--t-cancelado); }
.tag {
  display: inline-flex; align-items: center; padding: 2px var(--sp-2); border-radius: 6px;
  font-size: var(--fs-xs); font-weight: 700; line-height: 1.5; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
a.tag:hover { text-decoration: none; filter: brightness(1.15); }
.tag-warn { background: var(--amber-soft); color: var(--amber-text); }
.tag-gold { background: var(--gold-soft); color: var(--gold); }
.tag-red { background: var(--red-soft); color: var(--red-text); }
.tag-green { background: var(--green-soft); color: var(--green-text); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
th {
  text-align: left; padding: 10px var(--sp-4); color: var(--muted); font-size: var(--fs-xs); font-weight: 800;
  letter-spacing: 0.05em; text-transform: uppercase; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
th.right, td.right { text-align: right; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s; }
tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }
tr.is-off td { opacity: 0.55; }
.row-link { color: var(--text); font-weight: 700; white-space: nowrap; }
tfoot td { border-top: 1px solid var(--border-strong); }

/* Tabelas de listagem viram cartões no celular: <table class="table-cards"> com data-label em cada <td>.
   A primeira célula vira o título do cartão; as demais, linhas "rótulo · valor". Nada é escondido. */
@media (max-width: 640px) {
  .table-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-cards, .table-cards tbody, .table-cards tfoot { display: block; width: 100%; }
  .table-cards tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border);
  }
  .table-cards tbody tr:last-child { border-bottom: none; }
  .table-cards tfoot tr { border-top: 1px solid var(--border-strong); border-bottom: none; }
  .table-cards td, .table-cards td.right {
    grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
    padding: 3px 0; border: 0; text-align: right; min-height: 28px; min-width: 0;
  }
  .table-cards td::before { content: attr(data-label); color: var(--muted); font-size: var(--fs-sm); font-weight: 600; text-align: left; flex: none; }
  .table-cards td:not([data-label])::before { content: none; }
  .table-cards td:empty, .table-cards td.is-empty-mobile { display: none; }
  .table-cards td.hide-mobile { display: flex; }
  .table-cards td.card-title { grid-column: 1; grid-row: 1; justify-content: flex-start; flex-wrap: wrap; gap: 4px var(--sp-2); text-align: left; font-size: 1rem; padding-bottom: 6px; }
  .table-cards td.card-badge { grid-column: 2; grid-row: 1; justify-content: flex-end; padding-bottom: 6px; }
  .table-cards td.card-title::before, .table-cards td.card-badge::before { content: none; }
  .table-cards td.card-actions { justify-content: flex-end; padding-top: var(--sp-2); flex-wrap: wrap; }
  .table-cards td.card-actions::before { content: none; }
  .table-cards tbody tr:hover td { background: none; }
}

/* ---------- Forms ---------- */
.filters { display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label { font-size: var(--fs-sm); font-weight: 700; color: var(--text-2); }
.field:has(> input:required, > select:required, > textarea:required) > label::after { content: " *"; color: var(--gold); }
.field .help { font-size: var(--fs-xs); color: var(--muted); line-height: 1.45; }
.field .errorlist, .errorlist { list-style: none; margin: 0; padding: 0; color: var(--red-text); font-size: var(--fs-sm); font-weight: 600; }
input[type=text], input[type=search], input[type=number], input[type=url], input[type=date], input[type=time],
input[type=datetime-local], input[type=month], input[type=password], input[type=tel], input[type=email], select, textarea {
  width: 100%; min-height: var(--control-h); padding: 0 var(--sp-3); border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg); color: var(--text);
  font: inherit; font-size: var(--fs-base); line-height: 1.4;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { padding: 10px var(--sp-3); min-height: 88px; resize: vertical; }
select { padding-right: var(--sp-8); cursor: pointer; }
input::placeholder, textarea::placeholder { color: #7D7266; }
input:hover:not(:disabled):not(:focus), select:hover:not(:disabled):not(:focus), textarea:hover:not(:disabled):not(:focus) { border-color: rgba(243, 235, 221, 0.28); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: var(--focus-ring); }
input:disabled, select:disabled, textarea:disabled { opacity: 0.55; cursor: not-allowed; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--red); }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--gold); cursor: pointer; }
input[type=file] { width: 100%; color: var(--text-2); font: inherit; font-size: var(--fs-sm); }
input[type=file]::file-selector-button {
  min-height: var(--control-h-sm); margin-right: var(--sp-3); padding: 0 var(--sp-3);
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 700; cursor: pointer;
}
input[type=file]::file-selector-button:hover { background: var(--surface-3); }
input[type=number] { font-variant-numeric: tabular-nums; }
.check { display: inline-flex; align-items: center; gap: 10px; min-height: var(--control-h-sm); font-weight: 600; font-size: var(--fs-md); cursor: pointer; }
.form-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding-top: 6px; }
.weekday-checks ul, .weekday-checks div { display: flex; gap: 6px; flex-wrap: wrap; list-style: none; margin: 0; padding: 0; }
.weekday-checks label { display: inline-flex; gap: var(--sp-2); align-items: center; min-height: var(--control-h-sm); padding: 0 var(--sp-3); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-size: var(--fs-md); cursor: pointer; }
.weekday-checks label:has(input:checked) { border-color: var(--gold); background: var(--gold-soft); }
.input-cell input { min-width: 80px; }
.sticky-actions {
  position: sticky; bottom: 0; z-index: 10; display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px;
  padding: var(--sp-3) var(--sp-5); padding-bottom: max(var(--sp-3), env(safe-area-inset-bottom));
  background: rgba(26, 21, 18, 0.96); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border-top: 1px solid var(--border); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.callout {
  padding: var(--sp-3) var(--sp-4); border-radius: var(--radius); background: var(--surface-2);
  border: 1px dashed var(--border-strong); color: var(--text-2); font-size: var(--fs-md); line-height: 1.55;
}

/* ---------- Orders board ---------- */
.board-meta { display: flex; gap: var(--sp-1) var(--sp-4); flex-wrap: wrap; align-items: center; color: var(--muted); font-size: var(--fs-sm); margin-bottom: var(--sp-3); }
.alert + .board-meta { margin-top: var(--sp-3); }
.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr)); gap: var(--sp-4); align-items: start; }
.column { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); display: flex; flex-direction: column; min-height: 200px; }
.column-head {
  display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border);
  font-weight: 800; font-size: var(--fs-md);
}
.column-head::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--tone); flex: none; }
.column-count {
  margin-left: auto; min-width: 26px; padding: 0 var(--sp-2); border-radius: var(--radius-pill); text-align: center;
  background: var(--surface-3); color: var(--text-2); font-size: var(--fs-sm); font-variant-numeric: tabular-nums;
}
.column-body { padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.column-empty { color: var(--muted); font-size: var(--fs-sm); text-align: center; padding: var(--sp-6) var(--sp-2); }
.order-card {
  background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--tone);
  border-radius: var(--radius); padding: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-2);
}
.order-card.is-late { border-color: rgba(224, 82, 82, 0.55); border-left-color: var(--red); }
.order-card.is-new-arrival { animation: arrive 1.6s ease-out; }
@keyframes arrive { 0% { box-shadow: 0 0 0 0 rgba(247, 186, 42, 0.7); } 100% { box-shadow: 0 0 0 14px rgba(247, 186, 42, 0); } }
.order-top { display: flex; align-items: baseline; gap: 6px var(--sp-2); flex-wrap: wrap; }
.order-code { font-weight: 800; font-size: 1rem; color: var(--text); letter-spacing: 0.02em; white-space: nowrap; }
.column, .order-card, .column-body { min-width: 0; }
.order-time { margin-left: auto; font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; }
.order-time.is-late { color: var(--red-text); font-weight: 800; }
.order-customer { font-weight: 700; font-size: var(--fs-base); }
.order-items { margin: 0; padding: 0; list-style: none; font-size: var(--fs-md); color: var(--text-2); }
.order-items li { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-foot { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.order-total { font-weight: 800; margin-left: auto; font-variant-numeric: tabular-nums; }
.order-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.order-actions form { display: contents; }
.order-actions .btn { flex: 1; }
.order-actions select { flex: 1 1 100%; min-height: var(--control-h-sm); font-size: var(--fs-md); }
.no-courier { flex: 1 1 100%; color: var(--amber-text); }
.inline-select { display: inline-flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); }
.inline-select select { width: auto; }
/* Taxa do entregador ao despachar (já vem com a taxa padrão; não soma no pedido) */
.courier-fee-field { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); white-space: nowrap; }
.courier-fee-field input { width: 84px; min-height: var(--control-h-sm); text-align: right; font-variant-numeric: tabular-nums; }
.order-actions .courier-fee-field { flex: 1 1 100%; justify-content: space-between; }
/* Correção da taxa na página do entregador */
.fee-edit { display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px; margin: 0; }
.fee-edit input { width: 76px; min-height: var(--control-h-sm); padding: 0 var(--sp-2); text-align: right; font-variant-numeric: tabular-nums; }

.filters .flex-1 { flex: 1 1 140px; }
.filters .flex-2 { flex: 2 1 220px; }

/* ---------- Couriers ---------- */
.day-picker { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.day-picker input { width: auto; min-height: var(--control-h-sm); padding: 0 var(--sp-2); font-size: var(--fs-md); }
.bag-list { display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow-y: auto; }
.bag-item { align-items: flex-start; padding: var(--sp-2) 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-weight: 400; }
.bag-item:has(input:checked) { border-color: var(--gold); background: var(--gold-soft); }
.route-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.route-row:last-child { border-bottom: none; }
.copyable { word-break: break-all; font-size: 0.82rem; }
.qr-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--sp-4); }
.qr-card { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
/* QR sempre em fundo branco: leitores falham com cores invertidas */
.qr-box { width: 220px; max-width: 100%; aspect-ratio: 1; background: #fff; border-radius: var(--radius); padding: 6px; display: grid; place-items: center; color: var(--on-gold); font-size: var(--fs-sm); }
.qr-box svg { width: 100%; height: 100%; }
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--sp-4); align-items: start; }
.map-panel { overflow: hidden; }
.map { height: 72vh; min-height: 380px; background: var(--surface-2); }
.map-pin {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; flex: none;
  background: var(--surface-3); border: 3px solid var(--gold); color: var(--text); font-weight: 800; font-size: var(--fs-sm);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
.map-pin.is-route { border-color: var(--violet); background: #3A2D52; }
.map-pin.is-stale { opacity: 0.6; border-style: dashed; }
.map-pin-label {
  position: absolute; left: 50%; top: 40px; transform: translateX(-50%); white-space: nowrap;
  padding: 1px 6px; border-radius: 6px; background: rgba(14, 11, 9, 0.85); color: var(--text); font: 700 var(--fs-xs) var(--font-sans);
}
.map-list { display: flex; flex-direction: column; gap: var(--sp-1); }
.map-row { display: flex; align-items: center; gap: var(--sp-2); }
.map-focus {
  flex: 1; min-width: 0; display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center;
  padding: var(--sp-2); border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.map-focus:hover:not(:disabled) { background: var(--surface-2); }
.map-focus:disabled { cursor: default; opacity: 0.7; }
@media (max-width: 900px) {
  .map-layout { grid-template-columns: 1fr; }
  .map { height: 55vh; }
}
.sheet-wrap { overflow-x: auto; overscroll-behavior-x: contain; }
.sheet { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(270px, 1fr); }
.sheet-col { border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.sheet-col:last-child { border-right: none; }
.sheet-head { padding: 9px var(--sp-3); display: flex; align-items: center; justify-content: center; gap: var(--sp-2); flex-wrap: wrap; font-weight: 800; color: var(--text); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.sheet-head a { color: var(--text); }
.sheet-add { min-height: 26px; padding: 0 var(--sp-2); font-size: var(--fs-xs); }
.sheet-entry { display: flex; flex-direction: column; gap: 2px; padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--border); color: var(--text); font-size: var(--fs-md); }
.sheet-entry:hover { text-decoration: none; background: rgba(255, 255, 255, 0.03); }
.sheet-entry-top { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); }
.filters-bar { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.sheet-row { display: grid; grid-template-columns: 1fr 1.3fr 64px; gap: var(--sp-2); align-items: center; padding: 6px var(--sp-3); border-bottom: 1px solid var(--border); color: var(--text); text-align: center; font-size: var(--fs-md); }
a.sheet-row:hover { text-decoration: none; background: rgba(255, 255, 255, 0.03); }
.sheet-labels { color: var(--muted); font-size: var(--fs-xs); font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; }
.sheet-collect { color: var(--gold); font-weight: 800; }
.sheet-ok { color: var(--green-text); font-weight: 800; }
.sheet-foot { margin-top: auto; padding: 10px var(--sp-3); display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-sm); color: var(--text-2); background: var(--surface-2); }

/* ---------- Order detail ---------- */
.detail-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: var(--sp-4); align-items: start; }
.item-list { list-style: none; margin: 0; padding: 0; }
.item-list > li { padding: var(--sp-3) 0; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: 1fr auto; gap: var(--sp-1) var(--sp-3); }
.item-list > li:last-child { border-bottom: none; }
.item-sub { grid-column: 1 / -1; color: var(--text-2); font-size: var(--fs-md); }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 6px var(--sp-3); font-size: var(--fs-base); }
.totals .grand { font-size: 1.15rem; font-weight: 800; color: var(--gold); padding-top: 6px; border-top: 1px solid var(--border); }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.timeline li { display: grid; grid-template-columns: 12px 1fr; gap: 10px; font-size: var(--fs-md); }
.timeline li::before { content: ""; width: 10px; height: 10px; margin-top: 5px; border-radius: 50%; background: var(--tone, var(--muted)); }
.dl { display: grid; grid-template-columns: auto 1fr; gap: 6px var(--sp-4); font-size: var(--fs-base); margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.note-box { padding: 10px var(--sp-3); border-radius: var(--radius-sm); background: rgba(226, 109, 43, 0.1); border: 1px solid rgba(226, 109, 43, 0.3); font-size: var(--fs-md); }

/* ---------- Menu (cardápio) ---------- */
.product-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto auto; gap: 14px; align-items: center; padding: var(--sp-3) var(--sp-5); border-bottom: 1px solid var(--border); }
.product-row:last-child { border-bottom: none; }
.product-row.is-off { background: rgba(224, 82, 82, 0.04); }
.product-row.is-off .product-name { text-decoration: line-through; color: var(--muted); }
.thumb { width: 52px; height: 52px; border-radius: var(--radius-sm); object-fit: cover; background: var(--surface-3); }
.product-name { font-weight: 700; }
.product-prices { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.product-actions { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.price-chip { font-size: var(--fs-sm); padding: 2px var(--sp-2); border-radius: 6px; background: var(--surface-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.switch-form { margin: 0; }
.switch {
  display: inline-flex; align-items: center; gap: var(--sp-2); min-height: var(--control-h-sm); padding: 0 var(--sp-3) 0 6px; border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong); background: transparent; color: var(--text-2);
  font: inherit; font-size: var(--fs-sm); font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: border-color 0.15s, background 0.15s;
}
.switch:hover { background: var(--surface-2); }
.switch::before { content: ""; flex: none; width: 26px; height: 16px; border-radius: var(--radius-pill); background: var(--surface-3) radial-gradient(circle at 8px 8px, var(--muted) 5px, transparent 6px); }
.switch.is-on { color: var(--green-text); border-color: rgba(46, 184, 114, 0.4); }
.switch.is-on::before { background: var(--green-soft) radial-gradient(circle at 18px 8px, var(--green) 5px, transparent 6px); }

/* ---------- Empty states ---------- */
.empty { text-align: center; padding: 40px var(--sp-5); color: var(--muted); }
.empty strong { display: block; color: var(--text-2); font-size: 1rem; margin-bottom: var(--sp-1); }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: var(--sp-2); align-items: center; justify-content: center; flex-wrap: wrap; padding: 14px; font-size: var(--fs-md); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: var(--sp-6) var(--sp-4);
  background: radial-gradient(circle at 50% 0%, rgba(226, 109, 43, 0.14), transparent 55%), var(--bg); }
.login-card { width: 100%; max-width: 400px; padding: var(--sp-8) 28px; display: flex; flex-direction: column; gap: var(--sp-4); }
.login-card .brand { justify-content: center; flex-direction: column; text-align: center; }
.login-card .brand img { width: 64px; height: 64px; }

/* ---------- Som dos pedidos (topo) e aviso de pedido novo fora do quadro ---------- */
.sound-toggle.is-locked { color: var(--red-text); border-color: rgba(224, 82, 82, 0.6); background: var(--red-soft); animation: som-pulse 1.6s ease-in-out infinite; }
.sound-toggle.is-on { color: var(--green-text); border-color: rgba(46, 184, 114, 0.45); background: var(--green-soft); }
@keyframes som-pulse { 50% { box-shadow: 0 0 0 5px rgba(224, 82, 82, 0.18); } }
/* Campainha desligada neste aparelho (Configurações): sino cortado, discreto */
.sound-toggle .icon-bell-off { display: none; }
.sound-toggle.is-muted { color: var(--muted); border-color: var(--border-strong); background: transparent; }
.sound-toggle.is-muted .icon-bell { display: none; }
.sound-toggle.is-muted .icon-bell-off { display: block; }
/* Em telas médias e no celular o botão fica compacto: o texto completo continua para leitores de tela */
@media (max-width: 1279px) {
  .sound-toggle [data-som-texto] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .sound-toggle.is-locked::after { content: "Ativar som"; }
  .sound-toggle.is-on, .sound-toggle.is-muted { width: var(--control-h-sm); padding: 0; }
}
/* Na base da tela: chama atenção sem cobrir o título, os filtros nem as abas */
.order-toast {
  position: fixed; bottom: var(--sp-6); left: calc(50% + var(--sidebar-w) / 2); transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: var(--sp-1); max-width: calc(100vw - 32px);
  padding: 6px 6px 6px var(--sp-4); border-radius: var(--radius-lg); box-shadow: var(--shadow);
  background: var(--gold-gradient); color: var(--on-gold);
  animation: arrive 1.6s ease-out infinite;
}
.order-toast[hidden] { display: none; }
.order-toast a { color: inherit; font-weight: 800; font-size: 1rem; }
.order-toast .btn { color: inherit; font-size: 1.1rem; line-height: 1; }
.order-toast .btn:hover { background: rgba(0, 0, 0, 0.1); }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  :root { --content-pad: 16px; --topbar-h: 56px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(288px, 84vw); z-index: 50;
    transform: translateX(-100%); visibility: hidden; transition: transform 0.2s ease, visibility 0s linear 0.2s; box-shadow: var(--shadow);
  }
  .app.nav-open .sidebar { transform: none; visibility: visible; transition: transform 0.2s ease; }
  .app.nav-open::after { content: ""; position: fixed; inset: 0; background: var(--overlay); z-index: 40; }
  .topbar { gap: var(--sp-2); padding-block: var(--sp-2); }
  .topbar .menu-toggle { display: inline-flex; }
  /* Título longo quebra em até 2 linhas em vez de ser cortado */
  .topbar h1 {
    font-size: 1.05rem; line-height: 1.2; white-space: normal;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  }
  .topbar-status .store-pill { display: none; }
  .page-toolbar .store-pill { display: inline-flex; }
  .page-toolbar:not(:has(> :not(.store-pill))) { display: flex; }
  .content { padding-top: var(--sp-4); gap: var(--sp-4); }
  .panel-head, .panel-body { padding-inline: var(--sp-4); }
  .grid-2, .grid-3, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .product-row { grid-template-columns: 44px minmax(0, 1fr); padding-inline: var(--sp-4); }
  .product-row .product-prices, .product-row .product-actions { grid-column: 2; justify-content: flex-start; }
  .thumb { width: 44px; height: 44px; }
  .hide-mobile { display: none; }
  .form-actions { justify-content: stretch; }
  .form-actions .btn { flex: 1 1 auto; }
  .sticky-actions { padding-inline: var(--sp-4); }
  .messages { top: calc(var(--topbar-h) + var(--sp-2)); left: var(--sp-4); right: var(--sp-4); max-width: none; }
  /* Aviso de pedido novo vai para a base da tela, sem cobrir o topo nem os filtros */
  .order-toast {
    bottom: max(var(--sp-4), env(safe-area-inset-bottom)); left: var(--sp-4); right: var(--sp-4);
    transform: none; max-width: none; justify-content: space-between;
  }
}
@media (max-width: 520px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: var(--sp-3); }
  .kpi-value { font-size: 1.35rem; }
  .page-toolbar > .btn-primary:last-child { margin-left: 0; }
  .page-toolbar > .segmented { flex: 1 1 100%; }
}

/* WhatsApp (Evolution API) */
.wa-page { max-width: 760px; }
.wa-status { display: flex; align-items: center; gap: var(--sp-3); padding: 14px var(--sp-5); border-left: 4px solid var(--muted); }
.wa-status.is-open { border-left-color: var(--green); }
.wa-status.is-connecting { border-left-color: var(--amber); }
.wa-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); flex: none; }
.wa-status.is-open .wa-dot { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.wa-status.is-connecting .wa-dot { background: var(--amber); animation: wa-pulse 1.4s infinite; }
@keyframes wa-pulse { 50% { opacity: 0.35; } }
.wa-page code { font-size: 0.85em; color: var(--text-2); }
.wa-form { display: flex; gap: var(--sp-3); align-items: flex-end; flex-wrap: wrap; margin-top: 14px; }
.wa-form .field { flex: 1 1 260px; }
.wa-qr-body { display: flex; gap: var(--sp-6); align-items: center; flex-wrap: wrap; }
.wa-qr { background: #fff; padding: 10px; border-radius: var(--radius); max-width: 100%; height: auto; }
.wa-qr.is-stale { opacity: 0.35; }
.wa-passos { margin: 0; padding-left: 18px; display: grid; gap: var(--sp-2); flex: 1 1 240px; color: var(--text-2); font-size: var(--fs-base); }
.wa-lista { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.wa-seguranca { margin-top: var(--sp-3); }

/* Pedidos da bag no mapa ao vivo (ao clicar no entregador) */
.map-row.is-selected { background: var(--surface-2); border-radius: var(--radius-sm); box-shadow: inset 3px 0 0 var(--gold); }
.map-bag { display: inline-block; margin-top: 2px; font-size: var(--fs-xs); color: var(--text-2); }
.map-bag strong { color: var(--gold); }
.map-order {
  position: absolute; left: 0; top: 0; transform: translate(-50%, calc(-100% - 6px)); white-space: nowrap;
  padding: 3px var(--sp-2); border-radius: var(--radius-sm); background: var(--surface-3); border: 2px solid var(--violet);
  color: var(--text); font: 800 var(--fs-xs) var(--font-sans); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); cursor: pointer;
}
.map-order::after {
  content: ''; position: absolute; left: 50%; bottom: -8px; margin-left: -6px;
  border: 6px solid transparent; border-top-color: var(--violet); border-bottom: 0;
}
.map-order.is-target { border-color: var(--gold); background: #3B2E12; }
.map-order.is-target::after { border-top-color: var(--gold); }
.map-order.is-approx { border-style: dashed; opacity: 0.9; }
.map-door {
  position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--gold); border: 3px solid var(--bg); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.mini-map { height: 220px; margin-top: var(--sp-3); border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .btn[aria-busy="true"]::after { animation: girar 1.4s linear infinite !important; }
}
