/* App do Dealer — base e shell (menu lateral + cabeçalho + conteúdo). */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { min-height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 var(--fs-md)/1.5 var(--font-body);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 { font-family: var(--font-title); color: var(--ink); line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: var(--fs-xl); font-weight: 600; margin: 0 0 .4rem; }
h2 { font-size: var(--fs-lg); font-weight: 600; margin: 0 0 .5rem; }
h3 { font-size: var(--fs-md); font-weight: 600; margin: 0 0 .4rem; }
p { margin: 0 0 .75rem; }
a { color: var(--brand-fg); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
img, svg { max-width: 100%; }
:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 2px; border-radius: var(--radius-xs); }
::selection { background: var(--brand-soft); }
.muted { color: var(--muted); }
.inline { display: inline; }
[hidden] { display: none !important; }

.skip-link { position: absolute; left: 8px; top: -80px; z-index: 100; background: var(--surface); color: var(--ink);
  padding: 6px 10px; border-radius: var(--radius-md); box-shadow: var(--shadow-md); }
.skip-link:focus { top: 8px; }

/* exibição por tema */
:root[data-theme="dark"] .only-light { display: none !important; }
:root:not([data-theme="dark"]) .only-dark { display: none !important; }

/* ícone por máscara: herda a cor do texto */
.ico { display: inline-block; flex: none; width: 16px; height: 16px; background: currentColor;
  -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }

/* ============================ SHELL ============================ */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; flex: 0 0 var(--sidebar-w); width: var(--sidebar-w);
  display: flex; flex-direction: column; background: var(--sidebar-bg); color: var(--sidebar-ink);
  border-right: 1px solid var(--sidebar-line); z-index: 40; transition: width .18s ease, flex-basis .18s ease;
}
.sb-brand { display: flex; align-items: center; height: var(--topbar-h); padding: 0 16px; flex: none;
  border-bottom: 1px solid var(--sidebar-line); color: var(--ink); text-decoration: none !important; overflow: hidden; }
.sb-logo { display: flex; align-items: center; flex: none; max-width: 100%; }
.sb-logo-img { display: block; height: 28px; width: auto; max-width: 196px; object-fit: contain; object-position: left center; }
.ctx-tenant .sb-logo-img { height: 32px; }
.sb-symbol { display: none; }
.sb-symbol .sym { width: 28px; height: 28px; display: block; }
.monogram { display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--radius-md);
  background: var(--brand); color: var(--brand-contrast); font: 600 13px var(--font-title); }
.wordmark { font: 600 14px/1.2 var(--font-title); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wordmark.on-dark { color: #fff; }
/* logo do cliente sem versão escura: placa clara no tema escuro */
.logo-plate { display: inline-flex; align-items: center; border-radius: var(--radius-md); }
:root[data-theme="dark"] .logo-plate, .logo-plate.is-on { background: #fff; padding: 4px 8px; }

.sb-nav { flex: 1; overflow-y: auto; padding: 10px 10px 16px; scrollbar-width: thin; }
.sb-group { margin-top: 8px; }
.sb-group:first-child { margin-top: 2px; }
.sb-label { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 10px 4px;
  font-size: var(--fs-2xs); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--sidebar-muted); }
.sb-nav a, .sb-nav .soon {
  position: relative; display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px; margin: 1px 0;
  border-radius: var(--radius-md); color: var(--sidebar-ink); font-size: var(--fs-md); font-weight: 500;
  text-decoration: none; white-space: nowrap;
}
.sb-nav a .ico, .sb-nav .soon .ico { width: 16px; height: 16px; opacity: .8; }
.sb-nav a:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.sb-nav a.active { background: var(--brand-soft); color: var(--brand-fg); font-weight: 600; }
.sb-nav a.active .ico { opacity: 1; }
.sb-nav a.active::before { content: ""; position: absolute; left: -10px; top: 7px; bottom: 7px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--brand-accent); }
.sb-nav .soon { color: var(--sidebar-muted); cursor: default; }
.lbl { overflow: hidden; text-overflow: ellipsis; }
.sb-soon summary { cursor: pointer; list-style: none; border-radius: var(--radius-md); }
.sb-soon summary::-webkit-details-marker { display: none; }
.sb-soon summary::after { content: ""; width: 6px; height: 6px; margin-left: auto; border: solid currentColor;
  border-width: 0 1.5px 1.5px 0; transform: rotate(-45deg); transition: transform .15s; }
.sb-soon[open] summary::after { transform: rotate(45deg); }
.sb-soon summary:hover { color: var(--sidebar-ink); }
.sb-count { font-size: var(--fs-2xs); font-weight: 500; letter-spacing: 0; text-transform: none; padding: 0 6px;
  border-radius: 999px; background: var(--surface-3); color: var(--muted); margin-left: 4px; }
.sb-foot { flex: none; padding: 10px 16px; border-top: 1px solid var(--sidebar-line); font-size: var(--fs-xs); color: var(--sidebar-muted); }

.powered { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: var(--fs-2xs);
  text-decoration: none !important; opacity: .85; white-space: nowrap; }
.powered:hover { opacity: 1; }
.powered img { width: 13px; height: 13px; }
.powered strong { font-weight: 600; color: var(--ink-2); }

/* menu recolhido (desktop) */
@media (min-width: 901px) {
  :root[data-sidebar="collapsed"] .sidebar { flex-basis: var(--sidebar-w-collapsed); width: var(--sidebar-w-collapsed); }
  :root[data-sidebar="collapsed"] .sb-brand { justify-content: center; padding: 0; }
  :root[data-sidebar="collapsed"] .sb-logo { display: none; }
  :root[data-sidebar="collapsed"] .sb-symbol { display: block; }
  :root[data-sidebar="collapsed"] .sb-nav { padding-inline: 10px; }
  :root[data-sidebar="collapsed"] .sb-label, :root[data-sidebar="collapsed"] .sb-soon,
  :root[data-sidebar="collapsed"] .lbl, :root[data-sidebar="collapsed"] .sb-foot { display: none; }
  :root[data-sidebar="collapsed"] .sb-nav a { justify-content: center; padding: 0; }
  :root[data-sidebar="collapsed"] .sb-group + .sb-group { border-top: 1px solid var(--sidebar-line); padding-top: 6px; }
}

/* ============================ ÁREA PRINCIPAL ============================ */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 10px;
  padding: 0 20px 0 12px; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px); -webkit-backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.crumb { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: var(--fs-md); white-space: nowrap; }
.crumb-ctx { color: var(--muted); overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.crumb-sep { color: var(--line-strong); }
.crumb strong { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; }
.tb-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }

.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; flex: none;
  border: 1px solid transparent; border-radius: var(--radius-md); background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:root[data-theme="dark"] .icon-btn .i-moon, :root:not([data-theme="dark"]) .icon-btn .i-sun { display: none; }

/* busca rápida no menu */
.quick { position: relative; margin-left: 12px; width: min(300px, 32vw); }
.quick-ico { position: absolute; left: 9px; top: 50%; width: 15px; height: 15px; transform: translateY(-50%);
  fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.quick-input { height: 30px; padding: 0 56px 0 30px !important; background: var(--surface-2) !important; font-size: var(--fs-sm) !important; }
.quick-input::-webkit-search-cancel-button { display: none; }
.quick-kbd { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); font: 500 var(--fs-2xs) var(--font-body);
  color: var(--muted); border: 1px solid var(--line); border-radius: var(--radius-xs); padding: 1px 5px; background: var(--surface); }
.quick-list { position: absolute; left: 0; right: 0; top: calc(100% + 6px); margin: 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); max-height: 320px; overflow: auto; }
.quick-list li { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: var(--radius-md); cursor: pointer; color: var(--ink-2); }
.quick-list li[aria-selected="true"] { background: var(--brand-soft); color: var(--brand-fg); }
.quick-list .empty-q { color: var(--muted); cursor: default; }

/* empresa em uso */
.company-pill { display: inline-flex; align-items: center; gap: 6px; max-width: 240px; height: 28px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink-2) !important;
  font-size: var(--fs-sm); font-weight: 500; text-decoration: none !important; }
.company-pill:hover { border-color: var(--brand-accent); }
.company-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); flex: none; }
.company-pill .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* menu do usuário */
.menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 6px 0 3px; border: 1px solid transparent;
  border-radius: 999px; background: transparent; color: var(--ink); cursor: pointer; font: inherit; }
.user-btn:hover, .user-btn[aria-expanded="true"] { background: var(--surface-3); }
.avatar { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; flex: none;
  background: var(--brand-soft); color: var(--brand-fg); font: 600 11px var(--font-title); }
.user-txt { display: flex; flex-direction: column; line-height: 1.15; text-align: left; max-width: 160px; }
.user-txt strong { font-size: var(--fs-sm); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-txt small { font-size: var(--fs-2xs); color: var(--muted); }
.chev { width: 14px; height: 14px; fill: none; stroke: var(--muted); stroke-width: 2; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px; padding: 5px; z-index: 50;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.menu-head { padding: 8px 10px; display: flex; flex-direction: column; line-height: 1.3; }
.menu-head small { color: var(--muted); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; }
.menu-pop a, .menu-pop button[role="menuitem"] { display: flex; width: 100%; align-items: center; padding: 7px 10px;
  border: 0; border-radius: var(--radius-md); background: none; color: var(--ink-2); font: inherit; text-align: left; cursor: pointer; text-decoration: none; }
.menu-pop a:hover, .menu-pop button[role="menuitem"]:hover { background: var(--surface-3); color: var(--ink); }
.menu-pop form { margin: 0; }
.menu-danger { color: var(--danger-ink) !important; }
.menu-sep { height: 1px; margin: 4px 2px; background: var(--line); }
.menu-theme { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 10px; color: var(--muted); font-size: var(--fs-sm); }
.seg { display: inline-flex; padding: 2px; border-radius: var(--radius-md); background: var(--surface-3); }
.seg button { border: 0; background: none; padding: 3px 8px; border-radius: var(--radius-sm); font: 500 var(--fs-xs) var(--font-body);
  color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-xs); }

.content { flex: 1; width: 100%; max-width: 1440px; padding: 20px 24px 40px; }
.content:focus { outline: none; }

.only-mobile { display: none !important; }
.sb-backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 35; }

@media (max-width: 900px) {
  .only-mobile { display: inline-grid !important; }
  .only-desktop { display: none !important; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; height: auto; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .topbar { padding: 0 12px 0 8px; }
  .quick { display: none; }
  .crumb-ctx, .crumb-sep { display: none; }
  .user-txt, .chev { display: none; }
  .company-pill { max-width: 140px; }
  .content { padding: 16px 14px 32px; }
}
@media (max-width: 520px) {
  .company-pill { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
.sb-logo .wordmark { height: auto; max-width: 196px; font-size: 15px; }

/* assinatura App do Dealer (símbolo + nome em HTML, Poppins) */
.lockup.lockup { --lk-h: 28px; display: inline-flex; align-items: center; gap: calc(var(--lk-h) * .3); height: auto !important;
  max-width: none !important; color: var(--navy); white-space: nowrap; }
:root[data-theme="dark"] .lockup, .lockup.on-dark { color: #fff; }
.lk-sym { display: block; height: var(--lk-h); width: auto; }
.lk-txt { display: flex; flex-direction: column; font-family: var(--font-title); line-height: .98; }
.lk-txt small { font-size: calc(var(--lk-h) * .36); font-weight: 500; letter-spacing: -.01em; }
.lk-txt strong { font-size: calc(var(--lk-h) * .58); font-weight: 700; letter-spacing: -.03em; }
.sb-logo .lockup { --lk-h: 28px; }
