/* EasyRote — tema laranja de logística (claro/escuro), sem build.
 * --brand / --brand-contrast / --brand-secondary vêm da marca da empresa (white label) no <head>.
 * --accent é o laranja do produto (logo, gráficos, destaques); não substitui a marca da empresa. */
:root {
  --brand: #c2410c;
  --brand-contrast: #ffffff;
  --brand-secondary: #fde7d6;
  --accent: #f97316;
  --accent-2: #fb923c;
  --accent-3: #fdba74;
  --accent-soft: rgba(249, 115, 22, .12);
  --accent-text: #9a3412; /* texto laranja com contraste AA sobre fundos claros */
  --accent-strong: linear-gradient(135deg, #c2410c, #9a3412); /* fundo com texto branco (AA) */
  --bg: #f7f4f0;
  --surface: #ffffff;
  --surface-2: #fbf8f5;
  --text: #1c1714;
  --muted: #6b6058;
  --border: #ebe4dd;
  --link: color-mix(in srgb, var(--brand) 85%, #000);
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #1a7f37;
  --ok-soft: #e9f7ee;
  --warn: #a15c07;
  --warn-soft: #fff4e0;
  --sidebar-bg: #16110d;
  --sidebar-bg-2: #1f1813;
  --sidebar-text: #d9cfc6;
  --sidebar-muted: #8d8077;
  --shadow: 0 1px 2px rgba(28, 23, 20, .05), 0 6px 20px -8px rgba(28, 23, 20, .12);
  --shadow-lg: 0 20px 40px -18px rgba(28, 23, 20, .28);
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar-w: 264px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  color-scheme: light;
}
:root[data-theme=dark] {
  --bg: #0e0b09;
  --surface: #191411;
  --surface-2: #211b17;
  --text: #f4ede6;
  --muted: #a89a8e;
  --border: #2f2722;
  --link: color-mix(in srgb, var(--brand) 55%, #fff);
  --danger: #f97066;
  --danger-soft: rgba(240, 68, 56, .14);
  --ok: #47cd89;
  --ok-soft: rgba(71, 205, 137, .12);
  --warn: #fdb022;
  --warn-soft: rgba(253, 176, 34, .12);
  --sidebar-bg: #0a0807;
  --sidebar-bg-2: #141010;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -10px rgba(0, 0, 0, .6);
  --shadow-lg: 0 24px 48px -20px rgba(0, 0, 0, .8);
  --brand-secondary: #2a211b;
  --accent-text: #fb923c;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.55; font-size: 15px; transition: background .3s var(--ease), color .3s var(--ease); }
a { color: var(--link); text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Shell: menu lateral + barra superior ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%); color: var(--sidebar-text); padding: 18px 14px 24px; display: flex; flex-direction: column; gap: 6px; scrollbar-width: thin; scrollbar-color: #3a302a transparent; z-index: 40; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; color: #fff; text-decoration: none; }
.sidebar-brand img { max-height: 34px; max-width: 150px; border-radius: 6px; }
.sidebar-brand .brand-name { font-weight: 700; font-size: 1.02rem; line-height: 1.2; }
.sidebar-brand small { display: block; color: var(--sidebar-muted); font-weight: 500; font-size: .74rem; }
.nav-group { border-radius: var(--radius-sm); }
.nav-group > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 10px 10px 6px; font-size: .7rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--sidebar-muted); border-radius: 8px; user-select: none; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary .chev { margin-left: auto; transition: transform .25s var(--ease); }
.nav-group[open] > summary .chev { transform: rotate(90deg); }
.nav-group > summary:hover { color: var(--sidebar-text); }
.nav-links { display: flex; flex-direction: column; gap: 2px; padding-bottom: 6px; }
.nav-group[open] .nav-links { animation: slide-down .28s var(--ease); }
.nav-link { position: relative; display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--sidebar-text); text-decoration: none; font-size: .92rem; font-weight: 500; transition: background .2s, color .2s, transform .2s var(--ease); }
.nav-link svg { flex-shrink: 0; opacity: .8; }
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; transform: translateX(2px); }
.nav-link.active { background: linear-gradient(90deg, rgba(249, 115, 22, .24), rgba(249, 115, 22, .06)); color: #fff; }
.nav-link.active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--accent); }
.nav-link.active svg { color: var(--accent-2); opacity: 1; }
.sidebar-foot { margin-top: auto; padding: 14px 8px 0; font-size: .75rem; color: var(--sidebar-muted); display: flex; align-items: center; gap: 8px; }
.sidebar-foot .er-mark { width: 20px; height: 20px; }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(160%) blur(12px); -webkit-backdrop-filter: saturate(160%) blur(12px); border-bottom: 1px solid var(--border); }
.topbar-title { font-weight: 650; font-size: 1.02rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-title small { display: block; color: var(--muted); font-weight: 500; font-size: .76rem; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; transition: transform .2s var(--ease), border-color .2s, background .2s; position: relative; }
.icon-btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.icon-btn .dot { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--surface); }
.menu-toggle { display: none; }
.theme-toggle .i-sun { display: none; }
:root[data-theme=dark] .theme-toggle .i-sun { display: block; }
:root[data-theme=dark] .theme-toggle .i-moon { display: none; }

.user-menu { position: relative; }
.user-menu > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 4px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); transition: border-color .2s; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary:hover { border-color: var(--accent); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; color: #fff; background: var(--accent-strong); flex-shrink: 0; }
.avatar.lg { width: 64px; height: 64px; font-size: 1.4rem; }
.user-menu .who { font-size: .85rem; font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 8px; animation: pop .2s var(--ease); z-index: 50; }
.dropdown .dd-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; font-size: .85rem; }
.dropdown a, .dropdown button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 8px; color: var(--text); text-decoration: none; background: none; border: 0; font: inherit; font-size: .9rem; cursor: pointer; text-align: left; }
.dropdown a:hover, .dropdown button:hover { background: var(--accent-soft); }

.container { width: 100%; max-width: 1240px; margin: 0 auto; padding: 24px; }
.narrow { max-width: 440px; }

/* ---------- Componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; box-shadow: var(--shadow); transition: box-shadow .3s var(--ease), transform .3s var(--ease), border-color .3s; }
.card-hover:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.card-title { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-title h2 { margin: 0; flex: 1; }
.card-icon { width: 38px; height: 38px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); flex-shrink: 0; }
label { display: block; font-weight: 600; font-size: .9rem; margin: 14px 0 6px; }
input[type=email], input[type=password], input[type=text], input[type=tel], input[type=search], input[type=color], select, input[type=date], input[type=number], input[type=file], textarea {
  width: 100%; padding: 11px 13px; font-size: 15px; font-family: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; transition: border-color .2s, box-shadow .2s, background .2s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--surface); }
input[type=color] { padding: 4px; height: 44px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; margin-top: 16px; padding: 11px 18px; min-height: 44px; background: var(--brand); color: var(--brand-contrast); border: 0; border-radius: 11px; font-size: 15px; font-weight: 600; font-family: inherit; cursor: pointer; text-decoration: none; box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--brand) 80%, transparent); transition: transform .2s var(--ease), box-shadow .2s, filter .2s; }
.btn:hover { transform: translateY(-1px); filter: brightness(1.06); box-shadow: 0 10px 22px -10px color-mix(in srgb, var(--brand) 90%, transparent); }
.btn:active { transform: translateY(0) scale(.98); }
.btn[disabled] { opacity: .6; cursor: progress; transform: none; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.btn-secondary:hover { border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text); box-shadow: none; border: 1px solid var(--border); }
.btn-small { margin-top: 0; padding: 7px 12px; min-height: 36px; font-size: 13.5px; border-radius: 9px; }
.errors { color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); border-left: 4px solid var(--danger); padding: 10px 14px; background: var(--danger-soft); border-radius: 10px; margin-bottom: 14px; animation: fade-up .35s var(--ease); }
.status { color: var(--ok); border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent); border-left: 4px solid var(--ok); padding: 10px 14px; background: var(--ok-soft); border-radius: 10px; margin-bottom: 14px; animation: fade-up .35s var(--ease); }
.warn { color: var(--text); border-left: 4px solid var(--warn); background: var(--warn-soft); padding: 10px 14px; border-radius: 10px; }
.muted { color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; padding: 10px; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; border-bottom: 1px solid var(--border); background: var(--surface-2); }
td { text-align: left; padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: var(--accent-soft); }
.table-wrap { overflow-x: auto; border-radius: 10px; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; background: var(--brand-secondary); color: var(--text); font-size: 12px; font-weight: 600; margin: 0 4px 4px 0; border: 1px solid var(--border); }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.login-logo { max-width: 100%; max-height: 80px; display: block; margin-bottom: 8px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.check input { width: auto; accent-color: var(--accent); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 18px; }
.secret { font-family: ui-monospace, monospace; word-break: break-all; background: var(--surface-2); padding: 10px; border: 1px dashed var(--border); border-radius: 8px; }
fieldset { border: 1px solid var(--border); border-radius: 12px; margin: 16px 0; padding: 8px 16px 16px; }
legend { font-weight: 700; padding: 0 6px; }
.swatch { display: inline-block; width: 18px; height: 18px; border: 1px solid var(--border); border-radius: 5px; vertical-align: middle; }
ul { padding-left: 1.2rem; }

/* Acordeão (details/summary nativo, acessível por teclado) */
.accordion { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 10px; overflow: hidden; box-shadow: var(--shadow); }
.accordion > summary { list-style: none; cursor: pointer; padding: 15px 18px; font-weight: 650; display: flex; align-items: center; gap: 10px; transition: background .2s; }
.accordion > summary::-webkit-details-marker { display: none; }
.accordion > summary:hover { background: var(--surface-2); }
.accordion > summary::after { content: ""; margin-left: auto; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .3s var(--ease); }
.accordion[open] > summary::after { transform: rotate(-135deg); }
.accordion[open] > summary { border-bottom: 1px solid var(--border); }
.accordion-body { padding: 4px 18px 16px; animation: slide-down .3s var(--ease); }

/* Calendário */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-head { font-weight: 700; text-align: center; padding: 4px; font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.cal-day { display: flex; flex-direction: column; gap: 2px; min-height: 88px; padding: 7px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); background: var(--surface); text-decoration: none; font-size: 13px; overflow: hidden; transition: border-color .2s, transform .2s var(--ease), box-shadow .2s; }
.cal-day:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
@media (max-width: 600px) { .cal-day { min-height: 56px; font-size: 11px; padding: 3px; } .cal-day .badge { display: none; } }

/* KPIs e gráficos */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 16px 14px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow); text-decoration: none; color: var(--text); transition: transform .3s var(--ease), box-shadow .3s, border-color .3s; }
a.kpi:hover, .kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.kpi strong { font-size: 30px; line-height: 1.1; font-weight: 750; letter-spacing: -.02em; }
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-icon { width: 36px; height: 36px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); }
.kpi-bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 8px; border: 1px solid var(--border); }
.kpi-bar span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transform-origin: left; animation: grow-x 1s var(--ease) both; }
.kpi-alert { border-left: 4px solid var(--warn); }
.kpi-hero { background: linear-gradient(135deg, #1f1712 0%, #3b2213 55%, #c2410c 140%); color: #fff; border-color: transparent; }
.kpi-hero .kpi-label { color: #f3d9c6; }
.kpi-hero .kpi-icon { background: rgba(255, 255, 255, .12); color: #fff; }
.kpi-hero .kpi-bar { background: rgba(255, 255, 255, .12); border-color: transparent; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .bar { fill: url(#bar-grad); transform-box: fill-box; transform-origin: bottom; animation: grow-y .9s var(--ease) both; }
.chart .bar:hover { filter: brightness(1.15); }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .grid { stroke: var(--border); stroke-dasharray: 3 4; }
.chart .val { fill: var(--text); font-size: 11px; font-weight: 700; }
.donut-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut { width: 150px; height: 150px; flex-shrink: 0; }
.donut circle.seg { fill: none; stroke-width: 16; transform: rotate(-90deg); transform-origin: 50% 50%; animation: donut-in 1.1s var(--ease) both; }
.donut .center { font-size: 22px; font-weight: 750; fill: var(--text); }
.donut .center-sub { font-size: 10px; fill: var(--muted); }
.legend { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: .88rem; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; }
.progress-list { display: grid; gap: 12px; }
.progress-row { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto; gap: 10px; align-items: center; font-size: .88rem; }
.empty { text-align: center; padding: 26px 12px; color: var(--muted); }
.empty svg { color: var(--accent); opacity: .7; margin-bottom: 6px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; border-left: 2px solid var(--border); margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 3px solid var(--accent); }
.hello { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.hello h1 { margin: 0; font-size: 1.7rem; }
.hello .wave { display: inline-block; animation: wave 2.2s ease-in-out 1; transform-origin: 70% 70%; }

/* Login / telas sem sessão */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(1100px 500px at 10% -10%, rgba(249, 115, 22, .22), transparent 60%),
  radial-gradient(900px 500px at 110% 110%, rgba(194, 65, 12, .22), transparent 60%), var(--bg); }
.auth-wrap .container { padding: 0; }
.auth-card { padding: 30px; border-radius: 20px; animation: fade-up .5s var(--ease); }
.auth-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.auth-foot { text-align: center; font-size: .82rem; margin-top: 14px; }
.er-logo { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; font-size: 1.2rem; letter-spacing: -.02em; color: inherit; text-decoration: none; }
.er-logo .er-mark { width: 34px; height: 34px; }
.er-logo b { color: var(--accent-text); }

/* Animações (desligadas com prefers-reduced-motion) */
.container > .card, .container > .kpis, .container > .grid-2, .container > .grid-3, .container > .hello, .container > .accordion { animation: fade-up .5s var(--ease) both; }
.container > :nth-child(2) { animation-delay: .04s; } .container > :nth-child(3) { animation-delay: .08s; }
.container > :nth-child(4) { animation-delay: .12s; } .container > :nth-child(5) { animation-delay: .16s; }
.container > :nth-child(6) { animation-delay: .2s; } .container > :nth-child(n+7) { animation-delay: .24s; }
.kpis > * { animation: fade-up .55s var(--ease) both; }
.kpis > :nth-child(2) { animation-delay: .05s; } .kpis > :nth-child(3) { animation-delay: .1s; } .kpis > :nth-child(4) { animation-delay: .15s; }
.kpis > :nth-child(5) { animation-delay: .2s; } .kpis > :nth-child(n+6) { animation-delay: .25s; }
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes slide-down { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes grow-x { from { transform: scaleX(0); } }
@keyframes grow-y { from { transform: scaleY(0); } }
@keyframes donut-in { from { stroke-dasharray: 0 999; } }
@keyframes wave { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(14deg); } 20% { transform: rotate(-8deg); } 40% { transform: rotate(-4deg); } 50% { transform: rotate(10deg); } }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Responsivo: menu lateral vira gaveta */
.scrim { display: none; }
@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(86vw, var(--sidebar-w)); transform: translateX(-102%); transition: transform .35s var(--ease); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(10, 8, 6, .5); z-index: 35; animation: fade-in .25s; }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 10px 14px; }
  .container { padding: 16px; }
  .user-menu .who { display: none; }
}
@keyframes fade-in { from { opacity: 0; } }
@media print { .sidebar, .topbar { display: none; } .shell { display: block; } .card { box-shadow: none; } }
.er-mark { width: 32px; height: 32px; flex-shrink: 0; }
.sidebar-brand .er-mark { width: 40px; height: 40px; filter: drop-shadow(0 6px 14px rgba(249, 115, 22, .35)); }
.sidebar-foot .er-mark { width: 18px; height: 18px; }
@media (max-width: 600px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpis > .kpi-hero { grid-column: 1 / -1; }
  .kpi { padding: 13px; }
  .kpi strong { font-size: 24px; }
  .kpi-icon { width: 30px; height: 30px; }
  .hello h1 { font-size: 1.35rem; }
  .card { padding: 16px; }
}

/* Mapa de lojas (Leaflet hoje; adaptador pronto para outro provedor) */
.map-card { padding: 0; overflow: hidden; }
.map-filters { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, .7fr) minmax(0, 1fr); gap: 12px 16px; padding: 16px 20px 8px; align-items: end; }
.map-filters .map-status { grid-column: 1 / -1; }
.map-filters label { margin-top: 0; }
.map-status { margin: 0; padding: 6px 12px 10px; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.map-status .check { margin: 4px 0; font-size: .88rem; }
.map-status i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); }
.dot-covered { background: #16a34a; } .dot-partial { background: #f59e0b; } .dot-pending { background: #dc2626; } .dot-none { background: #94a3b8; }
.map-wrap { position: relative; }
.store-map { height: min(68vh, 640px); min-height: 380px; border-top: 1px solid var(--border); background: var(--surface-2); z-index: 0; }
.map-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; color: var(--muted); background: color-mix(in srgb, var(--surface) 70%, transparent); z-index: 500; }
.map-loading[hidden] { display: none; }
.map-loading svg { color: var(--accent); animation: float 1.4s ease-in-out infinite; }
.map-foot { padding: 10px 20px 14px; margin: 0; font-size: .85rem; }
.map-popup { display: grid; gap: 3px; font: 13px/1.45 system-ui, sans-serif; }
.map-popup-status { font-weight: 700; margin-top: 4px; }
.leaflet-container { font-family: inherit; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.leaflet-popup-content-wrapper { border-radius: 12px; }
:root[data-theme=dark] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.88) saturate(.7); }
:root[data-theme=dark] .leaflet-control-zoom a, :root[data-theme=dark] .leaflet-control-attribution { background: var(--surface); color: var(--text); border-color: var(--border); }
:root[data-theme=dark] .leaflet-control-attribution a { color: var(--accent-2); }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@media (max-width: 700px) { .map-filters { grid-template-columns: 1fr 1fr; } .map-filters > :first-child { grid-column: 1 / -1; } .store-map { height: 62vh; } }
/* Acessibilidade: o atalho "Ir para o conteúdo" aparece ao receber foco pelo teclado. */
.sr-only:focus, .sr-only:focus-visible { position: fixed; left: 12px; top: 12px; width: auto; height: auto; clip: auto; overflow: visible; white-space: normal; z-index: 1000; background: var(--surface); color: var(--text); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); }

/* Ficha de dados (lista de fatos em grade) */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px 22px; margin: 18px 0 0; }
.facts > div { min-width: 0; }
.facts dt { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.facts dd { margin: 3px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.facts .span-2 { grid-column: span 2; }
.legacy-refs { margin-top: 16px; }
.legacy-refs summary { cursor: pointer; font-weight: 600; }
.current-value { margin: 0 0 4px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }

/* Formulários em seções */
.form-sections { display: grid; gap: 14px; }
.form-section { border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 16px 16px; margin: 0; background: var(--surface); }
.form-section legend { display: inline-flex; align-items: center; gap: 7px; padding: 0 6px; font-weight: 700; color: var(--accent-text); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.field-title { margin: 14px 0 6px; font-weight: 600; font-size: .9rem; }
.chip-checks { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-check { margin: 0; cursor: pointer; }
.chip-check input { position: absolute; opacity: 0; pointer-events: none; }
.chip-check span { display: inline-block; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); font-size: .85rem; font-weight: 600; transition: background .15s, border-color .15s, color .15s; }
.chip-check input:checked + span { background: var(--brand); color: var(--brand-contrast); border-color: var(--brand); }
.chip-check input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
[data-freq-only][hidden] { display: none; }

/* Modal (elemento <dialog>) */
.modal { width: min(860px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.modal[open] { display: flex; animation: pop .25s var(--ease); }
.modal::backdrop { background: rgba(10, 8, 6, .55); backdrop-filter: blur(3px); }
.modal-form { display: flex; flex-direction: column; width: 100%; max-height: inherit; }
.modal-head, .modal-foot { display: flex; align-items: center; gap: 10px; padding: 14px 20px; flex-shrink: 0; }
.modal-head { border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; flex: 1; font-size: 1.15rem; }
.modal-body { padding: 16px 20px; overflow-y: auto; background: var(--surface-2); }
.modal-foot { justify-content: flex-end; border-top: 1px solid var(--border); }
.modal-foot .btn { margin-top: 0; }
body.modal-open { overflow: hidden; }
@media (max-width: 600px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modal { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; }
  .modal-body { padding: 14px; }
}

/* Prévia da identidade visual (tela de login), atualizada ao vivo */
.brand-preview { border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: var(--surface-2); }
.bp-browser { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
.bp-dots { display: inline-flex; gap: 5px; } .bp-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--border); }
.bp-tab { display: inline-flex; align-items: center; gap: 7px; max-width: 75%; padding: 5px 12px; border-radius: 9px 9px 0 0; background: var(--surface-2); font-size: .78rem; font-weight: 600; }
.bp-tab img { width: 16px; height: 16px; object-fit: contain; flex-shrink: 0; }
.bp-tab span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bp-screen { display: grid; place-items: center; padding: 26px 16px; min-height: 360px;
  background: radial-gradient(500px 240px at 0% 0%, color-mix(in srgb, var(--pv-primary) 26%, transparent), transparent 70%),
              radial-gradient(400px 240px at 100% 100%, color-mix(in srgb, var(--pv-primary) 20%, transparent), transparent 70%), var(--bg); }
.bp-card { display: flex; flex-direction: column; width: min(300px, 100%); padding: 22px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.bp-logo { min-height: 34px; margin-bottom: 10px; }
.bp-logo img { max-width: 100%; max-height: 56px; display: block; }
.bp-title { font-size: 1.1rem; overflow-wrap: anywhere; }
.bp-sub { font-size: .76rem; color: var(--muted); margin: 4px 0 10px; }
.bp-label { font-size: .72rem; font-weight: 600; margin-top: 6px; }
.bp-input { height: 30px; margin-top: 4px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); }
.bp-btn { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 14px; min-height: 36px; border-radius: 9px; background: var(--pv-primary); color: var(--pv-text); font-weight: 700; font-size: .86rem; transition: background .2s, color .2s; }
.bp-link { text-align: center; font-size: .72rem; margin-top: 10px; color: color-mix(in srgb, var(--pv-primary) 80%, var(--text)); }
.bp-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-top: 1px solid var(--border); background: var(--surface); font-size: .8rem; }
.bp-badge { padding: 2px 10px; border-radius: 999px; background: var(--pv-secondary); color: var(--pv-secondary-text); font-weight: 700; font-size: .75rem; border: 1px solid var(--border); }
@media (min-width: 961px) { .brand-preview-card { position: sticky; top: 84px; align-self: start; } }
.back-link { display: inline-flex; align-items: center; gap: 6px; margin: 0 0 12px; font-weight: 600; text-decoration: none; color: var(--muted); }
.back-link:hover { color: var(--accent-text); }

/* Rodapé de navegação no celular (atalhos por perfil + "Menu" que abre a gaveta) */
.tabbar { display: none; }
@media (max-width: 960px) {
  .tabbar { display: flex; position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 30; max-width: 620px; margin: 0 auto; padding: 4px; gap: 2px;
    background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); }
  .tabbar a, .tabbar button { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 54px; padding: 6px 2px;
    color: var(--muted); text-decoration: none; background: none; border: 0; border-radius: 14px; font: inherit; font-size: 11px; font-weight: 600; cursor: pointer; transition: color .2s, background .2s; }
  .tabbar span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar a.active { color: var(--accent-text); background: var(--accent-soft); }
  .tabbar a:active, .tabbar button:active { transform: scale(.96); }
  .main-col { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
}
@media print { .tabbar { display: none !important; } }
.bp-logo [hidden], .brand-preview [hidden] { display: none !important; }

/* Tabelas adaptativas no celular: cada linha vira um cartão com "coluna: valor" (rótulos vindos do app.js) */
@media (max-width: 700px) {
  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  .table-wrap:has(table.stack) { overflow-x: visible; }
  table.stack tr { margin: 0 0 10px; padding: 4px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
  table.stack tbody tr:hover { background: var(--surface); }
  table.stack td { display: grid; grid-template-columns: minmax(84px, 36%) minmax(0, 1fr); gap: 4px 10px; align-items: start; padding: 8px 0; border-bottom: 1px dashed var(--border); overflow-wrap: anywhere; }
  table.stack td:last-child { border-bottom: 0; }
  table.stack td::before { content: attr(data-label); font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding-top: 2px; }
  table.stack td[data-label=""], table.stack td:not([data-label]) { grid-template-columns: minmax(0, 1fr); }
  table.stack td[data-label=""]::before, table.stack td:not([data-label])::before { display: none; }
  table.stack td > * { min-width: 0; }
  table.stack td .actions select, table.stack td .actions input[type=date] { max-width: 100% !important; flex: 1 1 140px; }
}

/* Visitas do plano no celular: cartão compacto (loja em destaque; data, promotor, ordem e distância numa linha) */
.st-store strong { display: block; }
.st-store .muted { font-size: .84rem; }
@media (max-width: 700px) {
  table.stops-table tr { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; padding: 10px 12px; }
  table.stops-table td { display: block; width: auto; padding: 0; border: 0; }
  table.stops-table td::before { display: none; }
  table.stops-table .st-seq { order: 0; }
  table.stops-table .st-seq-n { display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 6px; border-radius: 9px; background: var(--accent-strong); color: #fff; font-weight: 800; font-size: .85rem; }
  table.stops-table .st-store { order: 1; flex: 1 1 calc(100% - 44px); min-width: 0; } /* ocupa a linha; o resto quebra abaixo */
  table.stops-table .st-store .muted { display: block; }
  table.stops-table .st-date, table.stops-table .st-promoter, table.stops-table .st-dist { order: 2; font-size: .82rem; color: var(--muted); }
  table.stops-table .st-date { margin-left: 38px; }
  table.stops-table .st-promoter::before, table.stops-table .st-dist::before { content: "·"; display: inline; margin-right: 8px; font-size: inherit; text-transform: none; letter-spacing: 0; }
  table.stops-table .st-alerts { order: 3; flex-basis: 100%; margin-left: 38px; }
  table.stops-table .st-alerts:empty { display: none; }
  table.stops-table .st-edit { order: 4; flex-basis: 100%; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
}

/* Fotos: miniatura clicável e galeria em modal */
.photo-thumb { display: block; border-radius: 10px; overflow: hidden; cursor: zoom-in; position: relative; }
.photo-thumb img { display: block; transition: transform .25s var(--ease); }
.photo-thumb:hover img, .photo-thumb:focus-visible img { transform: scale(1.04); }
.lightbox { width: 100vw; height: 100dvh; max-width: 100vw; max-height: 100dvh; margin: 0; padding: 0; border: 0; background: rgba(8, 6, 5, .94); color: #fff; }
.lightbox[open] { display: flex; align-items: center; justify-content: center; animation: fade-in .2s; }
.lightbox::backdrop { background: rgba(8, 6, 5, .6); }
.lightbox figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 56px 12px 20px; max-width: 100%; max-height: 100%; }
.lightbox img { max-width: min(1100px, 100%); max-height: calc(100dvh - 120px); object-fit: contain; border-radius: 10px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); background: #111; }
.lightbox figcaption { font-size: .9rem; color: rgba(255, 255, 255, .8); }
.lb-close, .lb-nav { position: absolute; display: grid; place-items: center; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .14); color: #fff; cursor: pointer; transition: background .2s; }
.lb-close:hover, .lb-nav:hover { background: rgba(255, 255, 255, .28); }
.lb-close { top: calc(12px + env(safe-area-inset-top)); right: 12px; width: 44px; height: 44px; font-size: 20px; }
.lb-nav { top: 50%; transform: translateY(-50%); width: 48px; height: 48px; font-size: 30px; line-height: 1; }
.lb-prev { left: 12px; } .lb-next { right: 12px; }
.lightbox.single .lb-nav { display: none; }
@media (max-width: 600px) { .lb-nav { top: auto; bottom: calc(16px + env(safe-area-inset-bottom)); transform: none; } }

/* Backup */
.backup-layout .form-section { margin-top: 14px; }
.steps { padding-left: 20px; } .steps li { margin-bottom: 6px; }
.sha { display: block; font-size: .72rem; margin-top: 4px; font-family: ui-monospace, monospace; }
[data-backup-only][hidden] { display: none; }

/* Menu completo em painel (app de campo) */
.menu-sheet .sheet-group { margin: 14px 0 6px; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.menu-sheet .sheet-group:first-child { margin-top: 0; }
.menu-sheet .sheet-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.menu-sheet .sheet-links a, .menu-sheet .sheet-links button { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); text-decoration: none; font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; text-align: left; }
.menu-sheet .sheet-links a.active { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }
.menu-sheet .sheet-links form { margin: 0; }
@media (max-width: 600px) { .menu-sheet { height: fit-content; max-height: 85dvh; margin-top: auto; border-radius: 18px 18px 0 0; } }
.menu-sheet .modal-body { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
