/* ============================================================================
   OficinaOS — app.css
   Reset/base + biblioteca de componentes (DESIGN.md §7).
   Usa exclusivamente tokens de tokens.css. NUNCA redefine cor/tipografia.
   ============================================================================ */

/* ---------------------------------------------------------------- reset/base */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: var(--lh-tight);
  letter-spacing: -0.02em;
  font-weight: 600;
  color: var(--ink);
  text-wrap: balance;
}
h1 { font-size: var(--fs-3xl); letter-spacing: -0.04em; }
h2 { font-size: var(--fs-2xl); letter-spacing: -0.03em; }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }

p { line-height: var(--lh-body); }
a { color: inherit; text-decoration: none; }
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
ul, ol { list-style: none; padding: 0; }

::selection { background: color-mix(in oklch, var(--primary) 40%, transparent); color: var(--ink); }

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--r-sm);
}

/* dados em mono tabular — utilitário base usado em VIN/OEM/preço/prazo */
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.num  { font-variant-numeric: tabular-nums; }

/* scrollbar discreta */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-pill); border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ============================================================================
   APP SHELL — .app / .sidebar / .topbar / .content
   ============================================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w, 248px) 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas: "sidebar topbar" "sidebar content";
  min-height: 100dvh;
  transition: grid-template-columns var(--dur-base) var(--ease-out-expo);
}
.app.is-collapsed { --sidebar-w: 72px; }

/* ---- sidebar ---- */
.sidebar {
  grid-area: sidebar;
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-3);
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
}
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-2) var(--sp-4);
  min-height: 44px;
}
.sidebar__logo {
  width: 30px; height: 30px;
  flex: none;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  background: radial-gradient(120% 120% at 30% 20%, color-mix(in oklch, var(--primary) 30%, var(--surface-3)), var(--surface-3));
  box-shadow: inset 0 0 0 1px var(--border-strong), 0 0 14px -4px color-mix(in oklch, var(--primary) 50%, transparent);
  color: var(--primary);
}
.sidebar__wordmark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-md);
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.sidebar__wordmark b { color: var(--primary); font-weight: 600; }
.app.is-collapsed .sidebar__wordmark,
.app.is-collapsed .nav-item__label,
.app.is-collapsed .nav-section,
.app.is-collapsed .nav-item__badge { display: none; }
.app.is-collapsed .sidebar { padding-inline: var(--sp-2); }
.app.is-collapsed .sidebar__brand { justify-content: center; }

.nav-section {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  padding: var(--sp-4) var(--sp-3) var(--sp-1);
  font-weight: 500;
}

/* ---- nav-item ---- */
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  min-height: 42px;
  border-radius: var(--r-md);
  color: var(--ink-2);
  font-size: var(--fs-sm);
  font-weight: 450;
  transition: background var(--dur-micro) var(--ease-out-expo),
              color var(--dur-micro) var(--ease-out-expo);
}
.nav-item svg, .nav-item__icon { flex: none; width: 19px; height: 19px; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.is-active {
  color: var(--ink);
  background: var(--primary-soft);
  font-weight: 500;
}
/* leitor verdigris do item ativo */
.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: calc(var(--sp-3) * -1 + 2px);
  top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 18px;
  border-radius: var(--r-pill);
  background: var(--primary);
  box-shadow: 0 0 10px color-mix(in oklch, var(--primary) 70%, transparent);
}
.nav-item.is-active svg, .nav-item.is-active .nav-item__icon { color: var(--primary); }
.nav-item--hero.is-active { background: var(--primary-soft); }
.nav-item__label { white-space: nowrap; flex: 1; }
.nav-item__badge {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  padding: 1px 7px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--ink-2);
}
.nav-item--hero .nav-item__badge { background: var(--accent-soft); color: var(--accent); }
.sidebar__spacer { flex: 1; }

/* ---- topbar ---- */
.topbar {
  grid-area: topbar;
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-6);
  min-height: 64px;
  background: color-mix(in oklch, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  backdrop-filter: blur(12px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
.topbar__left { display: flex; align-items: center; gap: var(--sp-3); }
.topbar__spacer { flex: 1; }
.topbar__right { display: flex; align-items: center; gap: var(--sp-3); }

/* ---- content ---- */
.content { grid-area: content; padding: var(--sp-8) var(--sp-8) var(--sp-16); max-width: 1640px; width: 100%; }
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--sp-8);
}
.page-head__eyebrow { color: var(--ink-3); font-size: var(--fs-sm); }
.page-head__title { margin-top: var(--sp-1); }
.page-head__actions { display: flex; gap: var(--sp-3); align-items: center; }

/* ============================================================================
   BOTÕES — .btn / .btn-primary / .btn-accent / .btn-ghost / .btn-icon
   ============================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-4);
  min-height: 40px;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid transparent;
  color: var(--ink);
  background: var(--surface-2);
  transition: transform var(--dur-micro) var(--ease-out-expo),
              background var(--dur-micro) var(--ease-out-expo),
              box-shadow var(--dur-base) var(--ease-out-expo),
              border-color var(--dur-micro) var(--ease-out-expo);
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; flex: none; }

.btn-primary {
  background: var(--primary-strong);
  color: var(--primary-ink);
  font-weight: 600;
}
.btn-primary:hover { background: var(--primary); box-shadow: var(--glow-primary); }

.btn-accent {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
.btn-accent:hover { background: var(--accent-strong); box-shadow: var(--glow-accent); }

.btn-ghost {
  background: transparent;
  color: var(--ink-2);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); border-color: var(--border-strong); }

.btn-icon {
  width: 40px; min-height: 40px; padding: 0;
  background: transparent;
  color: var(--ink-2);
  border-radius: var(--r-md);
}
.btn-icon:hover { background: var(--surface-2); color: var(--ink); }
.btn-icon svg { width: 19px; height: 19px; }

.btn-sm { min-height: 32px; padding: 0 var(--sp-3); font-size: var(--fs-xs); border-radius: var(--r-sm); }
.btn-lg { min-height: 48px; padding: 0 var(--sp-6); font-size: var(--fs-md); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }

/* notif dot no btn-icon */
.btn-icon[data-count]::after {
  content: attr(data-count);
  position: absolute;
  transform: translate(11px, -11px);
  font-family: var(--font-mono);
  font-size: 0.625rem;
  min-width: 16px; height: 16px; padding: 0 4px;
  display: grid; place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--r-pill);
  border: 2px solid var(--bg);
}
.btn-icon { position: relative; }

/* ---- toggle / segmented ---- */
.toggle {
  --w: 44px;
  position: relative;
  width: var(--w); height: 24px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  border: 1px solid var(--border);
  transition: background var(--dur-base) var(--ease-out-expo);
}
.toggle::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--ink-2);
  transition: transform var(--dur-base) var(--ease-out-expo), background var(--dur-base);
}
.toggle[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); }
.toggle[aria-pressed="true"]::after { transform: translateX(20px); background: var(--primary); }

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.segmented button {
  padding: var(--sp-1) var(--sp-3);
  min-height: 32px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  color: var(--ink-2);
  transition: background var(--dur-micro), color var(--dur-micro);
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-selected="true"], .segmented button.is-active {
  background: var(--surface-3);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}

/* ============================================================================
   ENTRADAS — .input / .field / .search / .select / .textarea / .dropzone / .voice
   ============================================================================ */
.input, .select, .textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 0 var(--sp-3);
  min-height: 40px;
  color: var(--ink);
  font-size: var(--fs-sm);
  transition: border-color var(--dur-micro), box-shadow var(--dur-base), background var(--dur-micro);
}
.textarea { padding: var(--sp-3); min-height: 84px; resize: vertical; line-height: var(--lh-body); }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  background: var(--surface-3);
}
.select { appearance: none; padding-right: var(--sp-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2399a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right var(--sp-3) center;
}

.field { display: flex; flex-direction: column; gap: var(--sp-2); }
.field__label { font-size: var(--fs-sm); color: var(--ink-2); font-weight: 500; }
.field__hint { font-size: var(--fs-xs); color: var(--ink-3); }

/* ---- search (topbar global / ⌘K trigger) ---- */
.search {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: min(420px, 42vw);
  padding: 0 var(--sp-3);
  min-height: 40px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--ink-3);
  font-size: var(--fs-sm);
  transition: border-color var(--dur-micro), background var(--dur-micro);
}
.search:hover { border-color: var(--border-strong); }
.search svg { width: 17px; height: 17px; flex: none; }
.search__placeholder { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kbd {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--ink-2);
  line-height: 1;
}

/* ---- dropzone (foto) ---- */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  text-align: center;
  padding: var(--sp-6);
  min-height: 120px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-lg);
  color: var(--ink-3);
  background: color-mix(in oklch, var(--surface-2) 60%, transparent);
  transition: border-color var(--dur-base), background var(--dur-base), color var(--dur-base);
}
.dropzone:hover, .dropzone.is-dragover {
  border-color: var(--primary);
  color: var(--ink-2);
  background: var(--primary-soft);
}
.dropzone svg { width: 26px; height: 26px; color: var(--ink-2); }

/* ---- voice (captura por voz com waveform) ---- */
.voice {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
}
.voice__btn {
  width: 38px; height: 38px;
  flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  transition: transform var(--dur-micro) var(--ease-out-expo), box-shadow var(--dur-base);
}
.voice__btn:hover { box-shadow: var(--glow-accent); }
.voice__btn.is-recording { animation: voice-pulse 1.6s var(--ease-in-out) infinite; }
.waveform { display: flex; align-items: center; gap: 3px; height: 24px; flex: 1; }
.waveform span {
  flex: 1;
  min-width: 2px;
  max-width: 4px;
  border-radius: var(--r-pill);
  background: var(--accent);
  height: 30%;
  animation: wave 1.1s var(--ease-in-out) infinite;
}
.waveform span:nth-child(odd) { background: color-mix(in oklch, var(--accent) 70%, var(--ink-3)); }
.voice__hint { font-size: var(--fs-xs); color: var(--ink-3); white-space: nowrap; }

@keyframes wave { 0%,100% { height: 25%; } 50% { height: 90%; } }
@keyframes voice-pulse {
  0%,100% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--accent) 50%, transparent); }
  50%     { box-shadow: 0 0 0 8px color-mix(in oklch, var(--accent) 0%, transparent); }
}

/* ============================================================================
   BADGES / CHIPS / TAGS / CONFIDENCE
   ============================================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px var(--sp-2);
  min-height: 22px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 500;
  background: var(--surface-3);
  color: var(--ink-2);
  border: 1px solid transparent;
  line-height: 1;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge--neutral { color: var(--ink-2); }
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--danger  { background: var(--danger-soft);  color: var(--danger); }
.badge--whats   { background: var(--whats-soft);   color: var(--whats); }
.badge--primary { background: var(--primary-soft); color: var(--primary); }
.badge--no-dot::before { display: none; }

/* badge "ao vivo" — pulso cobre */
.badge--live { background: var(--accent-soft); color: var(--accent); }
.badge--live::before { animation: live-blink 1.4s var(--ease-in-out) infinite; }
@keyframes live-blink { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.8); } }

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-3);
  min-height: 30px;
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--ink-2);
  transition: background var(--dur-micro), border-color var(--dur-micro), color var(--dur-micro);
}
.chip:hover { border-color: var(--border-strong); color: var(--ink); }
.chip.is-active { background: var(--primary-soft); border-color: var(--primary); color: var(--ink); }
.chip__close { color: var(--ink-3); display: inline-grid; place-items: center; }
.chip__close:hover { color: var(--ink); }

/* tag OEM — código em mono */
.tag-oem {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 2px var(--sp-2);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-xs);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--ink);
  letter-spacing: -0.01em;
}
.tag-oem--confirmed { border-color: color-mix(in oklch, var(--primary) 45%, var(--border)); color: var(--primary); }

/* placa Mercosul */
.plate {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  padding: 3px var(--sp-2);
  border-radius: var(--r-sm);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  color: var(--ink);
  font-size: var(--fs-sm);
}

/* confidence — score IA (anel + barra) */
.confidence { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-xs); color: var(--ink-2); }
.confidence__ring {
  --pct: 88;
  --c: var(--success);
  width: 26px; height: 26px;
  border-radius: 50%;
  flex: none;
  background:
    conic-gradient(var(--c) calc(var(--pct) * 1%), color-mix(in oklch, var(--c) 14%, transparent) 0);
  display: grid; place-items: center;
  transition: background var(--dur-panel) var(--ease-out-expo);
}
.confidence__ring::after {
  content: "";
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--surface-2);
}
.confidence--high   { --c: var(--success); }
.confidence--mid    { --c: var(--warning); }
.confidence--low    { --c: var(--danger); }
.confidence__val { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--ink); }

/* confidence em barra (alternativo) */
.confidence-bar { width: 100%; height: 5px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.confidence-bar > i {
  display: block; height: 100%;
  border-radius: inherit;
  background: var(--success);
  width: 0;
  transition: width var(--dur-panel) var(--ease-out-expo);
}

/* ============================================================================
   KPI / STAT / SPARKLINE
   ============================================================================ */
.kpi {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  min-height: 112px;
}
.kpi__label { font-size: var(--fs-xs); color: var(--ink-3); display: flex; align-items: center; gap: var(--sp-2); }
.kpi__value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-2xl);
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.03em;
  line-height: 1;
}
.kpi__foot { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-xs); color: var(--ink-3); margin-top: auto; }
.kpi__delta { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 500; }
.kpi__delta--up { color: var(--success); }
.kpi__delta--down { color: var(--danger); }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat__value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--fs-lg); font-weight: 500; color: var(--ink); }
.stat__label { font-size: var(--fs-xs); color: var(--ink-3); }

.sparkline { display: block; width: 100%; height: 36px; overflow: visible; }
.sparkline path { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.sparkline .area { fill: var(--primary-soft); stroke: none; }
/* draw-in animation */
.sparkline[data-animate] path:not(.area) {
  stroke-dasharray: var(--len, 300);
  stroke-dashoffset: var(--len, 300);
  animation: draw 1.2s var(--ease-out-expo) forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ============================================================================
   PANEL (preferir a card) / GENÉRICO
   ============================================================================ */
.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: clip;
}
.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
}
.panel__title { font-family: var(--font-display); font-size: var(--fs-md); font-weight: 600; letter-spacing: -0.01em; }
.panel__sub { font-size: var(--fs-xs); color: var(--ink-3); }
.panel__body { padding: var(--sp-5); }
.panel__body--flush { padding: 0; }
.panel__foot { padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border); }

/* ============================================================================
   TABLE (zebra sutil, tabular-nums)
   ============================================================================ */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th {
  text-align: left;
  font-weight: 500;
  font-size: var(--fs-xs);
  color: var(--ink-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky; top: 0;
  background: var(--surface-1);
}
.table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid color-mix(in oklch, var(--border) 60%, transparent);
  color: var(--ink-2);
  vertical-align: middle;
}
.table td.is-strong { color: var(--ink); font-weight: 500; }
.table tbody tr { transition: background var(--dur-micro); }
.table tbody tr:nth-child(even) td { background: color-mix(in oklch, var(--surface-2) 40%, transparent); }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num, .table .mono { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.table .num--left { text-align: left; }

/* ============================================================================
   TIMELINE
   ============================================================================ */
.timeline { display: flex; flex-direction: column; }
.timeline__item {
  position: relative;
  padding: 0 0 var(--sp-5) var(--sp-6);
  border-left: 1px solid var(--border);
}
.timeline__item:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline__dot {
  position: absolute;
  left: -5px; top: 2px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
}
.timeline__item.is-done .timeline__dot { background: var(--success); border-color: var(--success); }
.timeline__item.is-current .timeline__dot { background: var(--primary); border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.timeline__title { font-size: var(--fs-sm); font-weight: 500; color: var(--ink); }
.timeline__meta { font-size: var(--fs-xs); color: var(--ink-3); margin-top: 2px; }
.timeline__meta .mono { color: var(--ink-2); }

/* ============================================================================
   KANBAN / OS-CARD
   ============================================================================ */
.kanban {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(270px, 1fr);
  gap: var(--sp-4);
  overflow-x: auto;
  padding-bottom: var(--sp-4);
  align-items: start;
}
.kanban-col {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  min-height: 120px;
  transition: box-shadow var(--dur-base) var(--ease-out-expo), border-color var(--dur-base);
}
.kanban-col.is-drop-target { border-color: var(--primary); box-shadow: var(--glow-primary); }
.kanban-col__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.kanban-col__title { font-size: var(--fs-sm); font-weight: 500; color: var(--ink); display: flex; align-items: center; gap: var(--sp-2); }
.kanban-col__count { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ink-3); }
.kanban-col__body { display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-3); }

.os-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  cursor: grab;
  transition: transform var(--dur-base) var(--ease-out-expo),
              box-shadow var(--dur-base) var(--ease-out-expo),
              border-color var(--dur-micro);
}
.os-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--border-strong); }
.os-card:active { cursor: grabbing; }
.os-card__top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.os-card__model { font-size: var(--fs-sm); font-weight: 500; color: var(--ink); }
.os-card__client { font-size: var(--fs-xs); color: var(--ink-3); }
.os-card__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-top: var(--sp-1); }
.os-card__value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--fs-sm); color: var(--ink); }

/* avatar (mecânico/cliente/fornecedor) */
.avatar {
  width: 26px; height: 26px;
  flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-3);
  color: var(--ink);
  font-size: 0.6875rem;
  font-weight: 600;
  border: 1px solid var(--border);
}
.avatar--sm { width: 22px; height: 22px; font-size: 0.625rem; }
.avatar--lg { width: 40px; height: 40px; font-size: var(--fs-sm); }

/* ============================================================================
   QUOTE-STREAM (feed WhatsApp ao vivo)
   ============================================================================ */
.quote-stream { display: flex; flex-direction: column; gap: var(--sp-3); }
.quote-msg {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-3);
  padding: var(--sp-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  animation: feed-in var(--dur-feed) var(--ease-out-expo) both;
}
.quote-msg.is-new { box-shadow: var(--glow-accent); animation: feed-in var(--dur-feed) var(--ease-out-expo) both, new-pulse 1.8s var(--ease-in-out) 1; }
.quote-msg__head { display: flex; align-items: center; gap: var(--sp-2); }
.quote-msg__name { font-size: var(--fs-sm); font-weight: 500; color: var(--ink); }
.quote-msg__time { font-family: var(--font-mono); font-size: 0.6875rem; color: var(--ink-3); margin-left: auto; }
.quote-msg__bubble {
  font-size: var(--fs-sm);
  color: var(--ink-2);
  background: color-mix(in oklch, var(--whats-soft) 50%, var(--surface-1));
  border: 1px solid color-mix(in oklch, var(--whats) 20%, var(--border));
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  margin-top: var(--sp-2);
}
.quote-msg__items { display: flex; flex-direction: column; gap: var(--sp-1); margin-top: var(--sp-2); }
.quote-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2);
  border-radius: var(--r-sm);
  background: var(--surface-1);
  font-size: var(--fs-xs);
}
.quote-item__price { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 500; margin-left: auto; }

@keyframes feed-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes new-pulse { 0% { box-shadow: var(--glow-accent); } 100% { box-shadow: 0 0 0 0 transparent; } }

/* ============================================================================
   COMPARE (matriz fornecedor × preço × prazo × marca)
   ============================================================================ */
.compare { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.compare th, .compare td { padding: var(--sp-3) var(--sp-4); text-align: left; border-bottom: 1px solid var(--border); }
.compare th { font-size: var(--fs-xs); color: var(--ink-3); font-weight: 500; }
.compare td.num, .compare th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.compare tr.is-best td { background: var(--success-soft); }
.compare .cell-best { color: var(--success); font-weight: 600; }
.compare__tag-cheapest { font-size: 0.625rem; color: var(--success); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

/* ============================================================================
   MARGIN-DIAL (controle de margem)
   ============================================================================ */
.margin-dial {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.margin-dial__row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); }
.margin-dial__value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--fs-2xl); font-weight: 500; color: var(--primary); letter-spacing: -0.03em; }
.margin-dial__value.is-below { color: var(--danger); }
.margin-dial__slider { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: var(--r-pill); background: var(--surface-3); outline: none; }
.margin-dial__slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--primary); border: 3px solid var(--surface-2);
  box-shadow: var(--glow-primary); cursor: pointer;
}
.margin-dial__slider::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--primary); border: 3px solid var(--surface-2); cursor: pointer; }
.margin-dial__floor { font-size: var(--fs-xs); color: var(--ink-3); }
.margin-dial.is-below { box-shadow: 0 0 0 1px var(--danger); }

/* ============================================================================
   SIGNATURE (assinatura digital)
   ============================================================================ */
.signature {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  min-height: 130px;
  display: grid; place-items: center;
  color: var(--ink-3);
  position: relative;
}
.signature.is-signed { border-style: solid; border-color: color-mix(in oklch, var(--primary) 40%, var(--border)); }
.signature__meta { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ink-3); }

/* ============================================================================
   PHONE (moldura celular PWA)
   ============================================================================ */
.phone {
  width: 390px;
  max-width: 100%;
  aspect-ratio: 390 / 844;
  background: var(--bg);
  border: 10px solid oklch(0.12 0.006 215);
  border-radius: 46px;
  box-shadow: var(--shadow-3), inset 0 0 0 1px var(--border);
  overflow: hidden;
  position: relative;
}
.phone__notch {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  width: 120px; height: 26px; border-radius: var(--r-pill);
  background: oklch(0.12 0.006 215);
  z-index: var(--z-sticky);
}
.phone__screen { width: 100%; height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ============================================================================
   TOAST / EMPTY / SKELETON
   ============================================================================ */
.toast-stack { position: fixed; bottom: var(--sp-6); right: var(--sp-6); z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--sp-3); }
.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  min-width: 280px;
  max-width: 380px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
  animation: feed-in var(--dur-panel) var(--ease-out-expo) both;
}
.toast__icon { width: 22px; height: 22px; flex: none; display: grid; place-items: center; border-radius: 50%; }
.toast--success .toast__icon { background: var(--success-soft); color: var(--success); }
.toast--accent .toast__icon { background: var(--accent-soft); color: var(--accent); }
.toast__msg { font-size: var(--fs-sm); color: var(--ink); }
.toast__sub { font-size: var(--fs-xs); color: var(--ink-3); }

.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-3);
  text-align: center; padding: var(--sp-12) var(--sp-6); color: var(--ink-3);
}
.empty__icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--border); color: var(--ink-2); }
.empty__title { font-family: var(--font-display); font-size: var(--fs-md); color: var(--ink); font-weight: 600; }

.skeleton { background: var(--surface-2); border-radius: var(--r-sm); position: relative; overflow: hidden; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in oklch, var(--surface-3) 80%, transparent), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.4s var(--ease-in-out) infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* ============================================================================
   COMMAND BAR (⌘K)
   ============================================================================ */
.cmd-backdrop {
  position: fixed; inset: 0; z-index: var(--z-modal-backdrop);
  background: color-mix(in oklch, var(--bg) 55%, transparent);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: grid; place-items: start center; padding-top: 14vh;
  animation: fade-in var(--dur-base) var(--ease-out-expo) both;
}
.cmd-backdrop[hidden] { display: none; }
.cmd {
  width: min(600px, 92vw);
  z-index: var(--z-modal);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  overflow: hidden;
  animation: cmd-in var(--dur-base) var(--ease-out-expo) both;
}
.cmd__input-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); }
.cmd__input-row svg { width: 20px; height: 20px; color: var(--ink-3); flex: none; }
.cmd__input { flex: 1; background: none; border: none; outline: none; font-size: var(--fs-md); color: var(--ink); }
.cmd__input::placeholder { color: var(--ink-3); }
.cmd__list { max-height: 50vh; overflow-y: auto; padding: var(--sp-2); }
.cmd__section { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); padding: var(--sp-3) var(--sp-3) var(--sp-1); }
.cmd__item {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; text-align: left;
  padding: var(--sp-2) var(--sp-3); min-height: 42px;
  border-radius: var(--r-md);
  color: var(--ink-2); font-size: var(--fs-sm);
}
.cmd__item svg { width: 17px; height: 17px; color: var(--ink-3); flex: none; }
.cmd__item:hover, .cmd__item.is-active { background: var(--primary-soft); color: var(--ink); }
.cmd__item:hover svg, .cmd__item.is-active svg { color: var(--primary); }
.cmd__item .kbd { margin-left: auto; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes cmd-in { from { opacity: 0; transform: scale(0.98) translateY(-6px); } to { opacity: 1; transform: none; } }

/* ============================================================================
   UTILITÁRIOS
   ============================================================================ */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); } .gap-5 { gap: var(--sp-5); } .gap-6 { gap: var(--sp-6); } .gap-8 { gap: var(--sp-8); }

.text-ink { color: var(--ink); }
.text-ink-2 { color: var(--ink-2); }
.text-ink-3 { color: var(--ink-3); }
.text-primary { color: var(--primary); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }

.text-xs { font-size: var(--fs-xs); }
.text-sm { font-size: var(--fs-sm); }
.text-lg { font-size: var(--fs-lg); }
.text-display { font-family: var(--font-display); letter-spacing: -0.02em; }
.fw-500 { font-weight: 500; } .fw-600 { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mt-1 { margin-top: var(--sp-1); } .mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); } .mt-6 { margin-top: var(--sp-6); } .mt-8 { margin-top: var(--sp-8); }
.mb-2 { margin-bottom: var(--sp-2); } .mb-4 { margin-bottom: var(--sp-4); } .mb-6 { margin-bottom: var(--sp-6); }

.divider { height: 1px; background: var(--border); border: none; }
.hairline { border-top: 1px solid var(--border); }

/* bento grid helper */
.bento { display: grid; gap: var(--sp-4); grid-template-columns: repeat(12, 1fr); }
.col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; } .col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; } .col-7 { grid-column: span 7; } .col-8 { grid-column: span 8; }
.col-9 { grid-column: span 9; } .col-12 { grid-column: span 12; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* entrada em stagger de blocos (dashboard) */
.stagger > * { animation: feed-in var(--dur-panel) var(--ease-out-expo) both; }
.stagger > *:nth-child(1) { animation-delay: 40ms; }
.stagger > *:nth-child(2) { animation-delay: 80ms; }
.stagger > *:nth-child(3) { animation-delay: 120ms; }
.stagger > *:nth-child(4) { animation-delay: 160ms; }
.stagger > *:nth-child(5) { animation-delay: 200ms; }
.stagger > *:nth-child(6) { animation-delay: 240ms; }
.stagger > *:nth-child(7) { animation-delay: 280ms; }
.stagger > *:nth-child(8) { animation-delay: 320ms; }

/* ============================================================================
   RESPONSIVO
   ============================================================================ */
@media (max-width: 1100px) {
  .col-3, .col-4, .col-5 { grid-column: span 6; }
  .col-7, .col-8, .col-9 { grid-column: span 12; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-areas: "topbar" "content"; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: var(--z-modal);
    transform: translateX(-100%);
    transition: transform var(--dur-base) var(--ease-out-expo);
    width: 248px;
  }
  .app.nav-open .sidebar { transform: none; box-shadow: var(--shadow-3); }
  .content { padding: var(--sp-5) var(--sp-4) var(--sp-12); }
  .bento [class*="col-"] { grid-column: span 12; }
  .search { width: 100%; }
}

/* ============================================================================
   REDUCED MOTION — conteúdo nunca depende de animação
   ============================================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .stagger > *, .quote-msg, .toast, .cmd, .cmd-backdrop { opacity: 1 !important; transform: none !important; }
  .sparkline[data-animate] path:not(.area) { stroke-dashoffset: 0 !important; }
}
