:root {
  --bg: #f5f6f2;
  --surface: #ffffff;
  --soft: #f0f3ec;
  --dark: #153b2a;
  --dark-2: #0f2d20;
  --text: #13251d;
  --muted: #728078;
  --border: #dfe6dc;
  --accent: #b8ff12;
  --accent-2: #9be30c;
  --danger: #b64242;
  --danger-hover: #983232;
  --radius: 14px;
  --radius-sm: 8px;
  --font: "Inter", "Segoe UI", Tahoma, sans-serif;
  --shadow-sm: 0 1px 2px rgba(21, 59, 42, 0.07), 0 1px 1px rgba(21, 59, 42, 0.04);
  --shadow-md: 0 10px 26px rgba(21, 59, 42, 0.09), 0 2px 8px rgba(21, 59, 42, 0.05);
  --shadow-lg: 0 24px 50px rgba(15, 45, 32, 0.14), 0 6px 18px rgba(21, 59, 42, 0.07);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

::selection {
  background: var(--accent);
  color: var(--dark);
}

::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #c5d3bd;
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: #aebfa3;
  background-clip: padding-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background:
    radial-gradient(circle at 50% 18%, rgba(21, 59, 42, 0.08) 0 2px, transparent 3px) 0 0 / 18px 18px,
    var(--bg);
  animation: pageFadeIn 0.35s var(--ease);
}

@keyframes pageFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.container {
  width: min(1180px, calc(100vw - 64px));
  margin: 0 auto;
  padding: 38px 0 54px;
  display: grid;
  gap: 18px;
}

.top-strip {
  display: flex;
  justify-content: center;
  gap: 28px;
  flex-wrap: wrap;
  padding: 11px 18px;
  background: var(--dark);
  color: #d8e3dc;
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 0.82rem;
  font-weight: 700;
}

.title {
  min-height: 128px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 22px;
  flex-wrap: wrap;
  position: relative;
  overflow: hidden;
}

.title::after {
  content: "";
  position: absolute;
  width: 210px;
  height: 210px;
  right: 12%;
  top: -90px;
  background: radial-gradient(circle, rgba(184, 255, 18, 0.38) 0 3px, transparent 4px);
  background-size: 18px 18px;
  opacity: 0.45;
}

.title > * {
  position: relative;
  z-index: 1;
}

.title > div {
  min-width: 0;
}

.hero-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 390px);
  min-height: 360px;
  align-items: center;
}

.title h1 {
  margin: 10px 0 0;
  max-width: 580px;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1.08;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.title p {
  margin: 16px 0 0;
  max-width: 520px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--dark);
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0;
}

.eyebrow::before {
  content: "";
  width: 24px;
  height: 13px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) 0 52%, var(--dark) 52% 72%, var(--accent-2) 72%);
}

.hero-visual {
  width: 100%;
  min-height: 250px;
  position: relative;
}

.hero-visual img {
  width: 100%;
  height: 250px;
  object-fit: cover;
  filter: grayscale(1);
  border-radius: 8px 42px 8px 42px;
  display: block;
}

.hero-visual::after {
  content: "";
  position: absolute;
  width: 76px;
  height: 76px;
  right: 18px;
  bottom: 18px;
  background: var(--accent);
  clip-path: polygon(50% 0, 62% 36%, 100% 50%, 62% 64%, 50% 100%, 38% 64%, 0 50%, 38% 36%);
}

.hero-visual span {
  position: absolute;
  left: -18px;
  bottom: 28px;
  width: 88px;
  height: 88px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 10px solid var(--surface);
  background: var(--dark);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.home-link,
.button-link,
.text-link {
  text-decoration: none;
}

.marquee-strip {
  display: flex;
  gap: 42px;
  overflow: hidden;
  padding: 16px 24px;
  background: var(--dark);
  color: #f2f8f4;
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-weight: 800;
  white-space: nowrap;
}

.marquee-strip span::after {
  content: "*";
  margin-left: 42px;
  color: var(--accent);
  font-size: 1.7rem;
  vertical-align: middle;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.home-link {
  display: grid;
  gap: 6px;
  align-content: start;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-md);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
}

.home-link:hover {
  border-color: var(--accent-2);
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.home-link span {
  color: var(--dark);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.home-link strong {
  font-size: 1.55rem;
  overflow-wrap: anywhere;
}

.home-link small {
  max-width: 36rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-md);
  transition: box-shadow 0.2s var(--ease);
}

.quick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.popup-modal {
  width: min(560px, calc(100vw - 44px));
  max-height: calc(100vh - 44px);
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

.popup-modal[open] {
  animation: modalIn 0.2s var(--ease);
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.popup-modal::backdrop {
  background: rgba(15, 45, 32, 0.62);
  animation: backdropIn 0.2s var(--ease);
}

@keyframes backdropIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.popup-modal-medium {
  width: min(720px, calc(100vw - 44px));
}

.popup-modal-wide {
  width: min(980px, calc(100vw - 44px));
}

.modal-panel {
  max-height: calc(100vh - 44px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  padding: 18px;
  position: relative;
}

.modal-header {
  display: block;
  margin: 0 44px 12px 0;
}

.modal-header h2 {
  margin: 0;
}

.icon-button {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  line-height: 1;
}

body.modal-open {
  overflow: hidden;
}

.backup-card {
  background: linear-gradient(135deg, var(--surface), #f7faef);
}

h1, h2, h3, h4 {
  font-weight: 800;
  letter-spacing: -0.01em;
}

h2 {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 1.28rem;
}

h3 {
  margin: 0;
  color: var(--text);
  font-size: 1.05rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
}

.form-grid + .form-section-title {
  margin-top: 20px;
}

.form-section-title {
  margin: 0 0 12px;
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.col-12 { grid-column: span 12; }
.col-8 { grid-column: span 8; }
.col-6 { grid-column: span 6; }
.col-4 { grid-column: span 4; }
.col-3 { grid-column: span 3; }

label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 5px;
  font-weight: 900;
  text-transform: uppercase;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 11px;
  font-size: 0.92rem;
  background: #fbfcf9;
  color: var(--text);
  outline: none;
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease), background 0.16s var(--ease);
}

input:hover,
textarea:hover,
select:hover {
  border-color: #c7d3c1;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent-2);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(184, 255, 18, 0.32);
}

small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

.helper-text {
  margin: 0 0 10px;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 12px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.combo {
  position: relative;
}

.combo-menu {
  display: none;
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 150px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.combo-menu.open {
  display: block;
  animation: comboIn 0.15s var(--ease);
}

@keyframes comboIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.combo-option {
  width: 100%;
  border-radius: 0;
  padding: 9px 11px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  font-weight: 700;
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
}

.combo-option:hover {
  background: var(--soft);
  color: var(--dark);
}

.combo-phone {
  color: var(--muted);
  font-size: 0.82em;
  font-weight: 400;
}

.form-row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.client-list {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.client-list-empty {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 8px 0 0;
}

.client-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--soft);
  text-decoration: none;
  color: inherit;
  width: 100%;
  border: none;
  font: inherit;
  text-align: left;
}

.client-list-item.is-clickable {
  cursor: pointer;
  transition: background 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.client-list-item.is-clickable:hover {
  background: var(--border);
  box-shadow: var(--shadow-sm);
}

.client-list-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.client-list-info strong {
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.client-list-phone {
  font-size: 0.82rem;
  color: var(--muted);
}

.combo-empty {
  padding: 10px 11px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

button,
.button-label,
.button-link {
  border: 0;
  background: var(--dark);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-weight: 900;
  cursor: pointer;
  display: inline-block;
  font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
  transition: background 0.16s var(--ease), transform 0.16s var(--ease), box-shadow 0.16s var(--ease);
}

button:hover,
.button-label:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

button:active,
.button-label:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

button:disabled {
  cursor: default;
  opacity: 0.55;
  box-shadow: none;
}

button:focus-visible,
.button-label:focus-visible,
.button-link:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.button-link,
button:hover,
.button-label:hover {
  background: var(--dark-2);
}

.button-link:hover {
  background: var(--accent);
  color: var(--dark);
}

.text-link {
  color: var(--dark);
  font-weight: 900;
  border-bottom: 1px solid var(--dark);
  transition: opacity 0.15s var(--ease);
}

.text-link:hover {
  opacity: 0.75;
}

.hidden-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

button.ghost {
  background: #dce6d7;
  color: var(--dark);
  box-shadow: none;
}

button.ghost:hover {
  background: #cbd9c5;
}

button.danger {
  background: var(--danger);
}

button.danger:hover {
  background: var(--danger-hover);
}

.toolbar {
  margin-bottom: 10px;
}

.filters {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 220px;
  gap: 10px;
  margin-top: 12px;
}

.filter-field {
  min-width: 0;
}

.client-name {
  display: inline-block;
  color: var(--dark);
  line-height: 1.35;
}

.summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.summary-item {
  flex: 1 1 180px;
  max-width: 240px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: var(--soft);
}

.summary-item strong {
  display: block;
  color: var(--text);
  font-size: 1.28rem;
}

.summary-item span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.status {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.status-pendente { background: #ffe4e4; color: #9b1c1c; }
.status-em-aberto { background: #edf2f7; color: #334155; }
.status-em-correcao { background: #fff2c7; color: #8a5c00; }
.status-corrigido { background: #dcf7df; color: #15622b; }
.status-entregue { background: #e4f0ff; color: #254f8a; }
.status-em-andamento { background: #fff2c7; color: #8a5c00; }
.status-concluido { background: #dcf7df; color: #15622b; }
.status-cancelado { background: #ffe4e4; color: #9b1c1c; }

.status-alta { background: #ffe4e4; color: #9b1c1c; }
.status-media { background: #fff2c7; color: #8a5c00; }
.status-baixa { background: #edf2f7; color: #334155; }

.sped-badge-sim { background: #dcf7df; color: #15622b; }
.sped-badge-nao { background: #edf2f7; color: #334155; }

.clientes-table { min-width: 480px; }

.fv-table { min-width: 900px; }

.fv-table td { vertical-align: middle; }

.fv-doc-cell { white-space: nowrap; font-variant-numeric: tabular-nums; }

.fv-obs-cell {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.fv-badge-sim { background: #dcf7df; color: #15622b; white-space: nowrap; }
.fv-badge-nao { background: #edf2f7; color: #64748b; }

.fv-clear-field { align-self: end; }

.col-dias { width: 1%; white-space: nowrap; text-align: right; padding-right: 0.5rem; }
.dias-val { display: block; text-align: right; white-space: nowrap; }

.obs-btn {
  font-size: 0.75rem;
  padding: 2px 7px;
  background: #e8eeff;
  color: #2d45b0;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.obs-btn:hover { background: #d0d9ff; }

.proc-obs-content {
  padding: 1rem 1.25rem 1.5rem;
  white-space: pre-wrap;
  line-height: 1.6;
  color: var(--text);
  min-height: 3rem;
}

.badge-matriz { background: #e8eeff; color: #2d45b0; }
.badge-filial  { background: #f3e8ff; color: #6b21a8; }

.tree-filial td:first-child { padding-left: 0; }
.tree-branch { color: var(--muted); font-size: 0.9em; user-select: none; }
.client-name-cell { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }

.tree-ghost { opacity: 0.45; }
.tree-ghost td:last-child { pointer-events: none; }

.tree-toggle {
  all: unset;
  cursor: pointer;
  font-size: 0.65rem;
  color: var(--muted);
  padding: 2px 5px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.tree-toggle:hover { background: var(--border); color: var(--text); }

.filial-count {
  font-size: 0.72rem;
  color: var(--muted);
  margin-left: 0.35rem;
}

/* ── Timeline ───────────────────────────────────────────────────────────────── */
.timeline {
  position: relative;
  padding-left: 36px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: var(--border);
  border-radius: 2px;
}

.timeline-item {
  position: relative;
  margin-bottom: 12px;
}

.timeline-item:last-child {
  margin-bottom: 0;
}

.timeline-dot {
  position: absolute;
  left: -31px;
  top: 14px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.timeline-dot-diario { background: var(--dark); }
.timeline-dot-sped   { background: #6366f1; }
.timeline-dot-proc   { background: #f59e0b; }

.timeline-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.timeline-card:hover {
  background: var(--soft);
  border-color: var(--accent-2);
  box-shadow: var(--shadow-sm);
}

.timeline-card-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  min-width: 0;
}

.timeline-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.timeline-date {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.timeline-body {
  font-size: 0.9rem;
  color: var(--text);
}

.timeline-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.timeline-obs {
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
}

@media (max-width: 600px) {
  .timeline { padding-left: 28px; }
  .timeline-dot { left: -23px; width: 12px; height: 12px; }
  .timeline::before { left: 7px; }
  .timeline-card { flex-wrap: wrap; }
}

/* ── Diário — layout duas colunas ────────────────────────────────────────── */
.diario-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
  margin-top: 0.75rem;
}

.diario-timeline-col {
  min-width: 0;
}

.diario-estrutura-col {
  position: sticky;
  top: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--soft);
  min-height: 200px;
}

.estrutura-title {
  margin: 0 0 16px;
  font-size: 1rem;
  color: var(--dark);
}

.estrutura-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.estrutura-field:last-child {
  border-bottom: 0;
}

.estrutura-label {
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
  color: var(--muted);
}

.estrutura-value {
  font-size: 0.92rem;
  color: var(--text);
  font-weight: 600;
}

@media (max-width: 1024px) {
  .diario-layout {
    grid-template-columns: 1fr;
  }

  .diario-estrutura-col {
    position: static;
  }
}

/* ── Implantação — resumo somente-leitura ────────────────────────────────── */
.impl-summary-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 4px 24px;
  margin-bottom: 16px;
}

.impl-summary-estrutura {
  margin-bottom: 16px;
}

.impl-summary-estrutura p {
  margin: 4px 0 0;
  font-size: 0.92rem;
  color: var(--text);
  white-space: pre-wrap;
}

.impl-maquinas-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.impl-maquina-summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--soft);
  font-size: 0.9rem;
}

.impl-senha-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.impl-senha-value {
  font-family: monospace;
  letter-spacing: 1px;
}

.impl-maquinas-empty {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

/* ── Implantação — geração de PDF ────────────────────────────────────────── */
#implPdfArea {
  display: none;
}

.pdf-header {
  margin-bottom: 20px;
}

.pdf-header h1 {
  margin: 0 0 4px;
}

.pdf-header .pdf-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.pdf-section {
  margin-bottom: 20px;
}

.pdf-section-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.pdf-field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 6px 24px;
  margin-bottom: 10px;
}

.pdf-field strong {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.pdf-maquina-row {
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.92rem;
}

.pdf-maquina-row:last-child {
  border-bottom: none;
}

.pdf-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.pdf-table th,
.pdf-table td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
  overflow-wrap: break-word;
}

.pdf-empty {
  color: var(--muted);
  font-size: 0.9rem;
  font-style: italic;
  padding: 14px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

/* ── Força de Vendas — geração de PDF ────────────────────────────────────── */
.pdf-header--fv {
  padding-bottom: 14px;
  border-bottom: 3px solid var(--dark);
}

.pdf-subtitle {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.95rem;
}

.pdf-product-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

.pdf-product-header .pdf-section-title {
  border-bottom: none;
  margin: 0;
  padding: 0 0 4px;
}

.pdf-count-badge {
  flex: none;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--dark);
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  white-space: nowrap;
}

.pdf-product-section {
  border-left: 4px solid var(--border);
  padding-left: 14px;
}

.pdf-product-vem {
  border-left-color: var(--accent-2);
}

.pdf-product-automacao {
  border-left-color: var(--dark);
}

.pdf-table--fv thead th {
  background: var(--dark);
  color: #fff;
  border-color: var(--dark);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.pdf-table--fv tbody tr:nth-child(even) {
  background: var(--soft);
}

.pdf-table--fv tbody tr {
  break-inside: avoid;
}

.pdf-col-idx {
  width: 36px;
  text-align: center;
  color: var(--muted);
}

.pdf-table th.pdf-col-qtd,
.pdf-table td.pdf-col-qtd {
  width: 120px;
  text-align: center;
}

.pdf-qtd-pill {
  display: inline-block;
  min-width: 1.6em;
  font-weight: 700;
  color: var(--dark);
}

.pdf-table--fv tfoot td {
  border-top: 2px solid var(--dark);
  font-weight: 700;
  background: transparent;
}

@media print {
  body.impl-pdf-print > *:not(#implPdfArea) {
    display: none !important;
  }
  body.impl-pdf-print {
    background: none;
  }
  body.impl-pdf-print #implPdfArea {
    display: block !important;
    color: #000;
  }
  #implPdfArea .pdf-section {
    break-inside: avoid;
  }

  body.fv-pdf-print > *:not(#fvPdfArea) {
    display: none !important;
  }
  body.fv-pdf-print {
    background: none;
  }
  body.fv-pdf-print #fvPdfArea {
    display: block !important;
    color: #000;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  #fvPdfArea .pdf-product-header {
    break-after: avoid;
  }
  .pdf-table--fv thead {
    display: table-header-group;
  }
  .pdf-table--fv tfoot {
    display: table-footer-group;
  }
}

#fvPdfArea {
  display: none;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  text-transform: none;
  color: var(--text);
  cursor: pointer;
}

.checkbox-field input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 0;
}

.card-header-row h2 {
  margin: 0 0 12px;
}

.section-body.collapsed {
  display: none;
}

.collapsible-header {
  cursor: pointer;
  user-select: none;
}

.collapsible-header:hover h2 {
  opacity: 0.75;
}

.collapse-arrow {
  font-size: 0.75rem;
  opacity: 0.5;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.collapsible-header[aria-expanded="false"] .collapse-arrow {
  transform: rotate(-90deg);
}

.tab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.tab-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 18px;
  font-size: 0.84rem;
  font-weight: 900;
  cursor: pointer;
}

.tab-btn:hover {
  background: var(--soft);
  color: var(--dark);
}

.tab-btn.active {
  background: var(--dark);
  color: #fff;
  border-color: var(--dark);
}

.sped-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-top: 12px;
}

.sped-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--dark);
  color: #fff;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s var(--ease);
}

.sped-group-header:hover {
  background: var(--dark-2);
}

.sped-group-title {
  font-size: 0.95rem;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.sped-group-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sped-group-count {
  font-size: 0.78rem;
  font-weight: 700;
  opacity: 0.7;
  white-space: nowrap;
}

.sped-group-toggle {
  font-size: 0.85rem;
  opacity: 0.8;
}

.sped-group-items {
  display: flex;
  flex-direction: column;
}

.sped-group-items .table-wrap {
  min-width: 0;
}

.sped-group-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  transition: background 0.15s var(--ease);
}

.sped-group-item:last-child {
  border-bottom: 0;
}

.sped-group-item:hover {
  background: var(--soft);
}

.sped-group-item-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  flex: 1;
  min-width: 0;
}

.sped-group-item-chip {
  display: inline-block;
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.76rem;
  font-weight: 900;
  color: var(--dark);
  white-space: nowrap;
}

.sped-group-item-meta {
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
}

.sped-group-item-obs {
  font-size: 0.82rem;
  color: var(--muted);
  font-style: italic;
  flex-basis: 100%;
}

.table-wrap {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  background: var(--surface);
  width: 100%;
}

table {
  width: 100%;
  min-width: 1240px;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  border-bottom: 1px solid var(--border);
  text-align: center;
  vertical-align: middle;
  padding: 10px 9px;
}

th {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  background: var(--soft);
  white-space: nowrap;
}

td {
  color: #425149;
}

tbody tr {
  transition: background 0.14s var(--ease);
}

tbody tr:hover {
  background: var(--soft);
}

td:nth-child(1),
td:nth-child(3) {
  text-align: left;
}

th:nth-child(1),
td:nth-child(1) { min-width: 150px; }

th:nth-child(2),
td:nth-child(2) { min-width: 110px; }

th:nth-child(3),
td:nth-child(3) { min-width: 170px; }

th:nth-child(4),
td:nth-child(4) { min-width: 110px; }

th:nth-child(5),
td:nth-child(5) { min-width: 130px; }

th:nth-child(6),
td:nth-child(6),
th:nth-child(7),
td:nth-child(7),
th:nth-child(8),
td:nth-child(8) {
  min-width: 145px;
  white-space: nowrap;
}

th:nth-child(10),
td:nth-child(10) {
  min-width: 120px;
  white-space: nowrap;
}

.small-actions {
  display: inline-flex;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: nowrap;
  align-items: center;
}

.small-actions button {
  font-size: 0.78rem;
  padding: 6px 10px;
  white-space: nowrap;
  min-width: 58px;
  text-align: center;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 14px;
  font-weight: 700;
}

.compact-empty {
  padding: 10px 0 0;
}

.show-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 12px;
}

@media (min-width: 1440px) {
  .container {
    width: min(1280px, calc(100vw - 96px));
  }

  .hero-title {
    grid-template-columns: minmax(0, 1fr) minmax(380px, 460px);
  }

  .hero-visual img {
    height: 280px;
  }
}

@media (max-width: 1200px) {
  .container {
    width: min(1080px, calc(100vw - 48px));
  }

  .hero-title {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
    min-height: 320px;
  }

  .hero-visual img {
    height: 230px;
  }

  .hero-visual span {
    left: -10px;
    width: 78px;
    height: 78px;
    border-width: 8px;
  }
}

@media (max-width: 1024px) {
  .container {
    width: min(960px, calc(100vw - 36px));
    padding-top: 24px;
  }

  .title {
    padding: 20px;
  }

  .hero-title {
    grid-template-columns: minmax(0, 1fr) minmax(250px, 300px);
    gap: 18px;
  }

  .title h1 {
    font-size: clamp(2rem, 4.6vw, 3.1rem);
  }

  .title p {
    max-width: 460px;
  }

  .col-8,
  .col-4,
  .col-3 {
    grid-column: span 6;
  }

  .filters {
    grid-template-columns: minmax(180px, 260px) minmax(260px, 1fr);
  }

  .filters .filter-field:last-child {
    grid-column: span 2;
  }

  .summary-item {
    flex: 1 1 140px;
    max-width: 200px;
  }
}

@media (max-width: 900px) {
  .container {
    width: min(94vw, 680px);
    padding-top: 18px;
  }

  .top-strip {
    border-radius: var(--radius);
  }

  .title,
  .hero-title {
    min-height: auto;
  }

  .hero-title {
    grid-template-columns: 1fr;
  }

  .hero-visual {
    order: 3;
    width: min(420px, 100%);
  }

  .col-6,
  .col-8,
  .col-4,
  .col-3 {
    grid-column: span 12;
  }

  .filters,
  .home-grid,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .summary {
    justify-content: flex-start;
  }

  .summary-item {
    flex: 1 1 120px;
    max-width: 100%;
  }
}

/* ====== Tablets e celulares grandes (≤ 768px) ====== */
@media (max-width: 768px) {
  .sped-group-item {
    flex-wrap: wrap;
    gap: 8px 10px;
  }

  .tab-bar {
    flex-wrap: wrap;
  }

  .tab-btn {
    flex: 1;
    text-align: center;
  }

  .card-header-row {
    gap: 8px;
  }

  .filters .filter-field:last-child {
    grid-column: span 1;
  }
}

/* ====== Celulares (≤ 600px) ====== */
@media (max-width: 600px) {
  .container {
    width: calc(100vw - 16px);
    padding: 12px 0 28px;
  }

  .card {
    padding: 14px;
  }

  .title {
    padding: 16px;
  }

  .home-link strong {
    font-size: 1.35rem;
  }

  .quick-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .quick-actions button {
    width: 100%;
  }

  button:not(.icon-button),
  .button-label {
    min-height: 44px;
  }

  .form-row-actions {
    flex-wrap: wrap;
  }

  .form-row-actions button {
    flex: 1;
    min-width: 110px;
  }

  .popup-modal,
  .popup-modal-medium,
  .popup-modal-wide {
    width: calc(100vw - 16px);
  }

  .modal-panel {
    padding: 14px;
  }

  .sped-group-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .small-actions {
    flex-wrap: wrap;
    width: 100%;
  }

  .small-actions button {
    flex: 1;
  }

  .hero-visual span {
    left: 8px;
    width: 74px;
    height: 74px;
    font-size: 0.66rem;
    border-width: 8px;
  }
}

/* ====== Celulares pequenos (≤ 480px) ====== */
@media (max-width: 480px) {
  .card {
    padding: 12px;
  }

  .title {
    padding: 12px;
  }

  .modal-panel {
    padding: 12px;
  }

  .top-strip {
    flex-direction: column;
    gap: 6px;
    text-align: center;
  }

  .home-link strong {
    font-size: 1.2rem;
  }

  .summary-item strong {
    font-size: 1.1rem;
  }

  .sped-group-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .sped-group-header-right {
    width: 100%;
    justify-content: space-between;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .actions button {
    width: 100%;
  }

  .client-list-item {
    flex-wrap: wrap;
  }
}

/* ── Modal de IA ── */
.ai-modal {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(680px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 48px));
  border: 1px solid #333;
  border-radius: 20px;
  padding: 0;
  background: #1a1c1f;
  color: #f0f0f0;
  box-shadow: 0 32px 80px rgba(0,0,0,0.55);
  overflow: hidden;
}

.ai-modal[open] {
  display: flex;
  flex-direction: column;
}

.ai-modal::backdrop {
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
}

.ai-modal-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.ai-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 14px;
  border-bottom: 1px solid #2a2d30;
  flex-shrink: 0;
}

.ai-modal-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 0.97rem;
  color: #e8e8e8;
}

.ai-modal-icon {
  width: 22px;
  height: 22px;
  color: #b8ff12;
  flex-shrink: 0;
}

.ai-modal-close {
  background: #2a2d30;
  border: none;
  color: #aaa;
  cursor: pointer;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
  transition: background 0.15s, color 0.15s;
}

.ai-modal-close:hover {
  background: #363a3e;
  color: #fff;
  transform: none;
  box-shadow: none;
}

.ai-chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.ai-chat-history::-webkit-scrollbar { width: 5px; }
.ai-chat-history::-webkit-scrollbar-track { background: transparent; }
.ai-chat-history::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }

.ai-welcome {
  background: #22262b;
  border: 1px solid #2e3338;
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 0.9rem;
  color: #c8cfd8;
  line-height: 1.6;
}

.ai-welcome p { margin: 0; }

.ai-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: aiMsgIn 0.22s ease;
}

@keyframes aiMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ai-msg-user {
  align-items: flex-end;
}

.ai-msg-assistant {
  align-items: flex-start;
}

.ai-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-msg-user .ai-bubble {
  background: #b8ff12;
  color: #111;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}

.ai-msg-assistant .ai-bubble {
  background: #22262b;
  border: 1px solid #2e3338;
  color: #d8dfe8;
  border-bottom-left-radius: 4px;
}

.ai-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 14px;
  background: #22262b;
  border: 1px solid #2e3338;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.ai-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #666;
  animation: aiDot 1.2s infinite;
}

.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes aiDot {
  0%, 80%, 100% { transform: scale(0.8); background: #555; }
  40%            { transform: scale(1.1); background: #b8ff12; }
}

.ai-mode-tag {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 20px;
  width: fit-content;
  margin-bottom: 2px;
}

.ai-mode-tag.search { background: rgba(30,174,219,0.15); color: #1eaedb; }
.ai-mode-tag.think  { background: rgba(139,92,246,0.15); color: #8b5cf6; }

.ai-prompt-wrap {
  padding: 12px 14px 14px;
  flex-shrink: 0;
  border-top: 1px solid #2a2d30;
}

.ai-prompt-box {
  background: #22262b;
  border: 1px solid #363a3e;
  border-radius: 16px;
  padding: 10px 12px 8px;
  transition: border-color 0.18s;
}

.ai-prompt-box:focus-within {
  border-color: #4a4f55;
}

.ai-textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  color: #e8e8e8;
  font-family: var(--font);
  font-size: 0.93rem;
  line-height: 1.55;
  min-height: 40px;
  max-height: 200px;
  overflow-y: auto;
  padding: 2px 0;
}

.ai-textarea::placeholder { color: #555; }
.ai-textarea::-webkit-scrollbar { width: 4px; }
.ai-textarea::-webkit-scrollbar-thumb { background: #444; border-radius: 2px; }

.ai-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  gap: 6px;
}

.ai-toolbar-left {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-tool-btn {
  background: transparent;
  border: none;
  color: #666;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
  transition: background 0.15s, color 0.15s;
}

.ai-tool-btn:hover { background: #2e3338; color: #bbb; transform: none; box-shadow: none; }

.ai-divider {
  width: 1px;
  height: 18px;
  background: linear-gradient(to bottom, transparent, #444, transparent);
  margin: 0 2px;
  flex-shrink: 0;
}

.ai-toggle-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 20px;
  padding: 4px 10px;
  height: 30px;
  cursor: pointer;
  color: #666;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font);
  box-shadow: none;
  transition: all 0.18s;
  white-space: nowrap;
}

.ai-toggle-btn:hover { color: #bbb; transform: none; box-shadow: none; }

.ai-toggle-btn.active[data-mode="search"] {
  background: rgba(30,174,219,0.12);
  border-color: #1eaedb;
  color: #1eaedb;
}

.ai-toggle-btn.active[data-mode="think"] {
  background: rgba(139,92,246,0.12);
  border-color: #8b5cf6;
  color: #8b5cf6;
}

.ai-toggle-label { pointer-events: none; }

.ai-send-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: #b8ff12;
  color: #111;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: none;
  transition: background 0.15s, transform 0.15s, opacity 0.15s;
}

.ai-send-btn:hover:not(:disabled) { background: #a8ef00; transform: scale(1.07); box-shadow: none; }
.ai-send-btn:disabled { background: #2e3338; color: #555; cursor: default; box-shadow: none; }

.ai-file-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.ai-file-thumb {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #333;
}

.ai-file-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ai-file-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ── Botão flutuante de IA ── */
.ai-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--dark);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 18px rgba(21, 59, 42, 0.35);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  text-decoration: none;
}

.ai-fab:hover {
  background: var(--dark-2);
  transform: translateY(-3px) scale(1.06);
  box-shadow: 0 8px 28px rgba(21, 59, 42, 0.45);
}

.ai-fab svg {
  width: 28px;
  height: 28px;
  color: var(--accent);
  flex-shrink: 0;
}

.ai-fab-tooltip {
  position: fixed;
  bottom: 92px;
  right: 28px;
  z-index: 998;
  background: var(--dark);
  color: #f2f8f4;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 20px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.ai-fab:hover + .ai-fab-tooltip,
.ai-fab:focus + .ai-fab-tooltip {
  opacity: 1;
  transform: translateY(0);
}

/* ── Agenda Calendar ───────────────────────────────────────────────────────── */

.agenda-month-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.agenda-month-label {
  font-weight: 700;
  color: var(--dark);
  font-size: 1.05rem;
  text-transform: capitalize;
  min-width: 160px;
  text-align: center;
}

.agenda-month-bar #agendaTodayBtn {
  margin-left: auto;
}

.agenda-calendar {
  max-width: 1020px;
  margin: 0 auto;
}

.agenda-calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 6px;
  padding: 0 2px;
}

.agenda-calendar-weekdays span {
  text-align: center;
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.agenda-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.agenda-calendar-cell {
  height: 104px;
  background: var(--surface);
  border-radius: 9px;
  padding: 7px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow 0.15s var(--ease), transform 0.12s var(--ease);
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}

.agenda-calendar-cell:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.agenda-calendar-cell--empty {
  background: transparent;
  box-shadow: none;
  cursor: default;
  height: 104px;
}

.agenda-calendar-cell--empty:hover {
  box-shadow: none;
  transform: none;
}

.agenda-calendar-cell--today {
  outline: 2px solid var(--accent-2);
  outline-offset: -2px;
}

.agenda-calendar-cell-day {
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--dark);
}

.agenda-calendar-cell--today .agenda-calendar-cell-day {
  color: var(--accent-2);
}

.agenda-calendar-cell-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.agenda-calendar-item {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 0.71rem;
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--soft);
  border-left: 3px solid transparent;
  overflow: hidden;
  white-space: nowrap;
}

.agenda-calendar-item--proc { border-left-color: var(--accent-2); }
.agenda-calendar-item--sped { border-left-color: #5b9bd5; }

.agenda-calendar-item-time {
  font-weight: 700;
  color: var(--muted);
  flex-shrink: 0;
}

.agenda-calendar-item-cliente {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
}

.agenda-calendar-more {
  font-size: 0.63rem;
  font-weight: 700;
  color: var(--muted);
  padding: 0 4px;
}

@media (max-width: 768px) {
  .agenda-calendar-cell,
  .agenda-calendar-cell--empty {
    height: 78px;
    padding: 5px;
    border-radius: 8px;
  }

  .agenda-calendar-item-time { display: none; }
}

@media (max-width: 560px) {
  .agenda-month-label { min-width: 0; font-size: 0.95rem; }

  .agenda-calendar-weekdays,
  .agenda-calendar-grid {
    gap: 3px;
  }

  .agenda-calendar-weekdays span { font-size: 0.62rem; }

  .agenda-calendar-cell,
  .agenda-calendar-cell--empty {
    height: 56px;
    padding: 3px;
    border-radius: 6px;
  }

  .agenda-calendar-cell-day { font-size: 0.7rem; }
  .agenda-calendar-item-cliente { font-size: 0.62rem; }
  .agenda-calendar-more { font-size: 0.58rem; padding: 0 2px; }
}

.agenda-day-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.agenda-card {
  background: var(--surface);
  border-radius: 10px;
  padding: 13px 14px 10px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid transparent;
  transition: box-shadow 0.15s var(--ease), transform 0.12s var(--ease);
}

.agenda-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.agenda-card--proc { border-left-color: var(--accent-2); }
.agenda-card--sped { border-left-color: #5b9bd5; }

.agenda-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
  gap: 6px;
}

.agenda-badge {
  font-size: 0.67rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.agenda-badge--proc { background: var(--accent); color: var(--dark); }
.agenda-badge--sped { background: #5b9bd5; color: #fff; }

.agenda-card-time {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}

.agenda-card-cliente {
  font-weight: 700;
  font-size: 0.96rem;
  color: var(--dark);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agenda-card-tipo {
  font-size: 0.81rem;
  color: var(--muted);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agenda-card-meta {
  font-size: 0.77rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.agenda-card-obs {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 6px;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agenda-card-status-row {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

.agenda-card-status-select {
  font-size: 0.75rem;
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--soft);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}

/* ── Autenticação e controle de acesso ─────────────────────────────────────── */

/* Conteúdo oculto até auth.js validar sessão e perfil */
html.auth-pending body {
  visibility: hidden;
}

/* Ações escondidas conforme o perfil (o banco também bloqueia via RLS) */
body.perm-readonly .quick-actions,
body.perm-readonly button[onclick^="edit"],
body.perm-readonly button[onclick^="delete"],
body:not(.perm-admin) button[onclick^="deleteCliente"] {
  display: none !important;
}

body.perm-readonly input[onchange^="toggleFvProduto"],
body.perm-readonly input[onchange^="updateFvLicencas"],
body.perm-readonly .agenda-card-status-select {
  pointer-events: none;
  opacity: 0.55;
}

/* ====== Menu lateral (montado pelo auth.js) ====== */
:root {
  --sidebar-w: 264px;
  --sidebar-w-collapsed: 78px;
  --sidebar-bg: #0f2d20;
  --sidebar-bg-2: #153b2a;
  --sidebar-text: #b9cbc0;
  --sidebar-text-strong: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, 0.07);
  --sidebar-line: rgba(255, 255, 255, 0.08);
}

body.has-sidebar {
  padding-left: var(--sidebar-w);
  transition: padding-left 0.25s var(--ease);
}

body.has-sidebar.sidebar-collapsed {
  padding-left: var(--sidebar-w-collapsed);
}

/* Mais específico que as larguras de .container das media queries:
   o espaço do menu já sai do padding do body. */
body.has-sidebar .container {
  width: 100%;
  max-width: 1280px;
  padding-left: 32px;
  padding-right: 32px;
}

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 0% 0%, rgba(184, 255, 18, 0.10), transparent 42%),
    linear-gradient(180deg, var(--sidebar-bg-2) 0%, var(--sidebar-bg) 100%);
  color: var(--sidebar-text);
  border-right: 1px solid var(--sidebar-line);
  box-shadow: 4px 0 24px rgba(15, 45, 32, 0.12);
  transition: width 0.25s var(--ease), transform 0.25s var(--ease);
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 20px 16px 18px 18px;
  border-bottom: 1px solid var(--sidebar-line);
}

.sidebar-brand-link {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  color: var(--sidebar-text-strong);
  text-decoration: none;
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  color: var(--dark);
  font-size: 0.86rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  box-shadow: 0 6px 16px rgba(184, 255, 18, 0.25);
}

.sidebar-brand-text {
  display: grid;
  line-height: 1.1;
  white-space: nowrap;
}

.sidebar-brand-text strong {
  font-size: 1rem;
  font-weight: 900;
}

.sidebar-brand-text small {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.app-sidebar button.sidebar-collapse,
.app-sidebar button.sidebar-action,
.mobile-topbar button.mobile-menu-btn {
  display: grid;
  place-items: center;
  padding: 0;
  background: transparent;
  color: var(--sidebar-text);
  box-shadow: none;
  transform: none;
}

.app-sidebar button.sidebar-collapse {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 9px;
  border: 1px solid var(--sidebar-line);
}

.app-sidebar button.sidebar-collapse:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-strong);
}

.sidebar-collapse .sidebar-icon {
  width: 18px;
  height: 18px;
  transition: transform 0.25s var(--ease);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 12px;
  display: grid;
  align-content: start;
  gap: 18px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.sidebar-group {
  display: grid;
  gap: 2px;
}

.sidebar-group-title {
  padding: 0 12px 6px;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(185, 203, 192, 0.55);
  white-space: nowrap;
}

.sidebar-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 11px;
  color: var(--sidebar-text);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-strong);
}

.sidebar-link.active {
  background: var(--accent);
  color: var(--dark);
  font-weight: 900;
  box-shadow: 0 6px 18px rgba(184, 255, 18, 0.18);
}

.sidebar-icon {
  width: 20px;
  height: 20px;
  flex: none;
}

.sidebar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.2s var(--ease);
}

.sidebar-user {
  display: grid;
  gap: 10px;
  padding: 14px 12px 16px;
  border-top: 1px solid var(--sidebar-line);
  background: rgba(0, 0, 0, 0.12);
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 0 4px;
}

.sidebar-avatar {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--dark);
  font-size: 0.8rem;
  font-weight: 900;
}

.sidebar-user-text {
  display: grid;
  justify-items: start;
  gap: 4px;
  min-width: 0;
}

.sidebar-user-text strong {
  max-width: 100%;
  color: var(--sidebar-text-strong);
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-text .user-role-badge {
  padding: 2px 8px;
  font-size: 0.66rem;
}

.sidebar-user-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.app-sidebar button.sidebar-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--sidebar-line);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.app-sidebar button.sidebar-action .sidebar-icon {
  width: 16px;
  height: 16px;
}

.app-sidebar button.sidebar-action:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-strong);
}

.app-sidebar button.sidebar-action--sair:hover {
  background: rgba(182, 66, 66, 0.22);
  border-color: rgba(182, 66, 66, 0.45);
  color: #ffd6d6;
}

/* Recolhido: só ícones (o nome aparece no title de cada link) */
body.sidebar-collapsed .app-sidebar {
  width: var(--sidebar-w-collapsed);
}

body.sidebar-collapsed .sidebar-brand {
  flex-direction: column;
  padding: 18px 0 14px;
}

body.sidebar-collapsed .sidebar-collapse .sidebar-icon {
  transform: rotate(180deg);
}

body.sidebar-collapsed .sidebar-brand-text,
body.sidebar-collapsed .sidebar-label,
body.sidebar-collapsed .sidebar-user-text {
  display: none;
}

body.sidebar-collapsed .sidebar-group-title {
  height: 1px;
  margin: 0 14px 8px;
  padding: 0;
  overflow: hidden;
  color: transparent;
  background: var(--sidebar-line);
}

body.sidebar-collapsed .sidebar-link {
  justify-content: center;
  padding: 0;
}

body.sidebar-collapsed .sidebar-user-info {
  justify-content: center;
  padding: 0;
}

body.sidebar-collapsed .sidebar-user-actions {
  grid-template-columns: 1fr;
}

body.sidebar-collapsed .app-sidebar button.sidebar-action {
  padding: 0;
}

/* Barra superior e fundo escuro: só no celular/tablet */
.mobile-topbar,
.sidebar-backdrop {
  display: none;
}

@media (max-width: 900px) {
  body.has-sidebar,
  body.has-sidebar.sidebar-collapsed {
    padding-left: 0;
  }

  body.has-sidebar .container {
    padding-left: 16px;
    padding-right: 16px;
  }

  .mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text-strong);
    box-shadow: 0 4px 16px rgba(15, 45, 32, 0.18);
  }

  .mobile-topbar .sidebar-logo {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 0.78rem;
  }

  .mobile-topbar button.mobile-menu-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--sidebar-line);
    color: var(--sidebar-text-strong);
  }

  .mobile-topbar button.mobile-menu-btn:hover {
    background: var(--sidebar-hover);
  }

  /* No celular o menu sempre abre completo, mesmo se estiver recolhido no desktop */
  .app-sidebar,
  body.sidebar-collapsed .app-sidebar {
    width: min(var(--sidebar-w), 86vw);
    transform: translateX(-100%);
    box-shadow: none;
  }

  body.sidebar-open .app-sidebar {
    transform: translateX(0);
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.3);
  }

  .app-sidebar .sidebar-collapse {
    display: none !important;
  }

  body.sidebar-collapsed .sidebar-brand {
    flex-direction: row;
    padding: 20px 16px 18px 18px;
  }

  body.sidebar-collapsed .sidebar-brand-text,
  body.sidebar-collapsed .sidebar-user-text {
    display: grid;
  }

  body.sidebar-collapsed .sidebar-label {
    display: inline;
  }

  body.sidebar-collapsed .sidebar-group-title {
    height: auto;
    margin: 0;
    padding: 0 12px 6px;
    color: rgba(185, 203, 192, 0.55);
    background: none;
  }

  body.sidebar-collapsed .sidebar-link {
    justify-content: flex-start;
    padding: 0 12px;
  }

  body.sidebar-collapsed .sidebar-user-info {
    justify-content: flex-start;
    padding: 0 4px;
  }

  body.sidebar-collapsed .sidebar-user-actions {
    grid-template-columns: 1fr 1fr;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 55;
    display: block;
    background: rgba(8, 24, 17, 0.5);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s var(--ease);
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  body.sidebar-open {
    overflow: hidden;
  }
}

@media (max-width: 600px) {
  body.has-sidebar .container {
    padding-left: 8px;
    padding-right: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.has-sidebar,
  .app-sidebar,
  .sidebar-backdrop,
  .sidebar-collapse .sidebar-icon {
    transition: none;
  }
}

@media print {
  .app-sidebar,
  .mobile-topbar,
  .sidebar-backdrop {
    display: none !important;
  }

  body.has-sidebar,
  body.has-sidebar.sidebar-collapsed {
    padding-left: 0;
  }
}

.user-role-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.role-admin { background: var(--accent); color: var(--dark); }
.role-tecnico { background: #e4f0ff; color: #254f8a; }
.role-consulta { background: #edf2f7; color: #334155; }

.status-ativo { background: #dcf7df; color: #15622b; }
.status-inativo { background: #ffe4e4; color: #9b1c1c; }

.user-you-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.usuario-papel-select {
  width: auto;
  min-width: 150px;
  padding: 6px 9px;
}

.usuarios-hint {
  margin-top: 12px;
}

.access-matrix {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.access-matrix > div {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--soft);
}

.access-matrix p {
  margin: 8px 0 0;
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.45;
}

/* Página de login */
.auth-layout {
  width: min(1040px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px 0;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  align-items: center;
  gap: 40px;
}

/* O PNG tem margem branca larga: o wrapper recorta até o desenho da logo e o
   multiply faz o fundo branco sumir sobre o fundo pontilhado da página. */
.auth-logo {
  width: min(460px, 100%);
  aspect-ratio: 5.1 / 1;
  overflow: hidden;
}

.auth-logo img {
  display: block;
  width: 111.8%;
  height: auto;
  margin: -14.7% 0 0 -6.7%;
  mix-blend-mode: multiply;
}

.auth-brand h1 {
  margin: 22px 0 12px;
  font-size: clamp(1.8rem, 3.4vw, 2.6rem);
  line-height: 1.12;
  color: var(--dark);
}

.auth-brand p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
  max-width: 460px;
}

.auth-roles {
  list-style: none;
  margin: 26px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
  max-width: 420px;
}

.auth-roles li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.auth-roles strong { color: var(--dark); }
.auth-roles span { color: var(--muted); text-align: right; }

.auth-card {
  padding: 30px;
  box-shadow: var(--shadow-lg);
}

.auth-card h2 {
  margin-bottom: 4px;
}

.auth-field {
  margin-bottom: 14px;
}

.auth-submit {
  width: 100%;
  margin-top: 6px;
  padding: 12px 16px;
}

.auth-links {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
  font-size: 0.86rem;
}

.auth-message {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.45;
}

.auth-message-erro { background: #ffe4e4; color: #9b1c1c; }
.auth-message-sucesso { background: #dcf7df; color: #15622b; }

@media (max-width: 820px) {
  .auth-layout {
    grid-template-columns: 1fr;
    gap: 24px;
    align-content: start;
  }

  .auth-roles { display: none; }
  .auth-card { padding: 22px; }
  .access-matrix { grid-template-columns: 1fr; }
}

/* ====== Home: resumo do dia ====== */
.today-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.today-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  text-decoration: none;
  transition: box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
}

.today-stat:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.today-stat-value {
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.today-stat-label {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.today-stat--alert {
  border-color: #f3c4c4;
  background: #fff6f6;
}

.today-stat--alert .today-stat-value {
  color: var(--danger);
}

.today-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.today-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.today-card-head h2 {
  margin: 0 0 4px;
}

.today-card-link {
  color: var(--dark);
  font-size: 0.85rem;
  font-weight: 800;
  white-space: nowrap;
}

.today-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 420px;
  overflow-y: auto;
}

.today-item {
  display: grid;
  grid-template-columns: minmax(48px, max-content) minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  border-top: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}

.today-list li:first-child .today-item {
  border-top: 0;
}

.today-item:hover {
  background: var(--soft);
}

.today-item--done {
  opacity: 0.6;
}

.today-item-time {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.today-item-main {
  min-width: 0;
}

.today-item-main strong,
.today-item-main small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.today-item-main small {
  margin-top: 2px;
}

@media (max-width: 1024px) {
  .today-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .today-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .today-item {
    grid-template-columns: minmax(44px, max-content) minmax(0, 1fr) auto;
  }

  .today-item .agenda-badge {
    display: none;
  }
}
