:root {
  --bg: #f5f7f5;
  --card: #fff;
  --text: #172620;
  --muted: #61716a;
  --accent: #214a73;
  --ok: #147252;
  --warn: #a26816;
  --err: #b3433b;
  --border: #dce3dc;
  --radius: 6px;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 3rem;
}

header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.65rem;
  letter-spacing: 0;
}

.sub { color: var(--muted); margin: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1rem;
}

.card h2 {
  margin: 0 0 0.85rem;
  font-size: 1.1rem;
}

.meta { list-style: none; padding: 0; margin: 0; color: var(--muted); }
.meta li { margin: 0.35rem 0; }
.ok { color: var(--ok); }
.erro { color: var(--err); }

form { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }

.file {
  flex: 1;
  min-width: 220px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  color: var(--muted);
  cursor: pointer;
}

.file input { display: none; }

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.secondary { background: #edf1f5; color: #244761; border: 1px solid #d4dce4; }
.btn.quiet { background: transparent; color: var(--muted); padding: 0.65rem; }

.flash { list-style: none; padding: 0; }
.flash li {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 0.75rem;
}
.flash .erro {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--err);
  color: var(--err);
}
.flash .success {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid var(--ok);
  color: var(--ok);
}

.modelos-table {
  width: 100%;
  border-collapse: collapse;
}
.modelos-table th, .modelos-table td {
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.btn-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  margin-left: 12px;
  transition: opacity 0.2s;
}
.btn-link:hover {
  text-decoration: underline;
  opacity: 0.8;
}
.btn-link.danger {
  color: var(--err);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 0.5rem 0 1rem;
}

th, td {
  text-align: left;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

code {
  background: #0f172a;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
}

.files, .warn, .erro-list {
  max-height: 220px;
  overflow: auto;
  padding-left: 1.1rem;
  color: var(--muted);
}

/* Log area */
#log {
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  padding: 8px;
  border: 1px solid var(--border);
  height: 160px;
  overflow: auto;
  white-space: pre-wrap;
}

.pbar progress { width: 220px; height: 14px; }
.pbar { margin-top: 6px; }

/* Responsive: stack controls on small screens */
@media (max-width: 640px) {
  form { flex-direction: column; align-items: stretch; }
  .file { width: 100%; }
  .card { padding: 1rem; }
  .pbar progress { width: 100%; }
}

/* per-row status */
.status.ok { color: var(--ok); font-weight: 600; }
.status.err { color: var(--err); font-weight: 700; }
.row-failed { background: rgba(239,68,68,0.04); }
.row-success { background: rgba(34,197,94,0.04); }

.warn li { color: var(--warn); }
.erro-list li { color: var(--err); }
.files a { color: #93c5fd; }
.resumo { font-size: 1.05rem; }

footer {
  margin-top: 2rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

/* Dropzone Styles */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1rem;
  text-align: center;
  background: rgba(26, 35, 50, 0.3);
  backdrop-filter: blur(8px);
  cursor: pointer;
  transition: all 0.25s ease;
  width: 100%;
  margin-bottom: 12px;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.05);
}
.dropzone.has-file {
  border-style: solid;
  border-color: var(--ok);
  background: rgba(34, 197, 94, 0.03);
}
.dz-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  user-select: none;
}
.dz-icon {
  width: 42px;
  height: 42px;
  color: var(--accent);
  opacity: 0.85;
}
.dz-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
}
.dz-info {
  font-size: 0.8rem;
  opacity: 0.75;
}
.dropzone.compact {
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  margin-bottom: 0;
}
.dropzone.compact .dz-message {
  gap: 0.25rem;
  flex-direction: row;
  justify-content: center;
}

.wrap.wide {
  max-width: 1180px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.actions {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  gap: 1rem;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.compact-form {
  align-items: end;
}

label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
}

input,
select {
  width: 100%;
  margin-top: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0f172a;
  color: var(--text);
  padding: 0.65rem 0.75rem;
  font: inherit;
}

select option[hidden] {
  display: none;
}

.muted {
  color: var(--muted);
}

.list {
  display: grid;
  gap: 0.75rem;
}

.list-item {
  display: grid;
  gap: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  background: rgba(15, 23, 42, 0.35);
}

.list-item span,
.list-item small {
  color: var(--muted);
}

.btn-link.no-margin {
  margin-left: 0;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.columns {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.entry-table {
  min-width: 900px;
  margin: 0;
}

.entry-table th {
  position: sticky;
  top: 0;
  background: #111827;
  z-index: 1;
}

.entry-table input {
  min-width: 160px;
  margin-top: 0;
}

.compact-log {
  min-height: 90px;
  max-height: 180px;
  overflow: auto;
  margin-top: 1rem;
}

.download-area {
  margin-top: 1rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.chip,
.status-badge {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  background: #0f172a;
  color: #cbd5e1;
  font-size: 0.78rem;
  font-weight: 700;
}

.status-em_preenchimento { color: #93c5fd; border-color: rgba(59, 130, 246, 0.5); }
.status-em_validacao { color: #fbbf24; border-color: rgba(251, 191, 36, 0.5); }
.status-validado { color: #22c55e; border-color: rgba(34, 197, 94, 0.5); }
.status-relatorio_mensal { color: #c084fc; border-color: rgba(192, 132, 252, 0.5); }
.status-postado { color: #5eead4; border-color: rgba(94, 234, 212, 0.5); }
.status-ajuste { color: #f87171; border-color: rgba(248, 113, 113, 0.5); }

.stats-grid {
  margin-bottom: 1rem;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

.stat-card strong {
  color: var(--text);
  font-size: 2rem;
  line-height: 1;
}

.workflow-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}

.workflow-actions form,
.list-item form {
  display: inline;
  margin: 0;
}

.audit-list {
  display: grid;
  gap: 0.6rem;
}

.audit-item {
  display: grid;
  gap: 0.15rem;
  border-left: 3px solid var(--accent);
  background: rgba(15, 23, 42, 0.35);
  padding: 0.65rem 0.85rem;
  border-radius: 6px;
}

.audit-item span,
.audit-item small {
  color: var(--muted);
}

@media (max-width: 900px) {
  .grid.two,
  .grid.four,
  .columns {
    grid-template-columns: 1fr;
  }

  .topbar,
  .section-head {
    flex-direction: column;
  }
}

/* Operational surface: restrained color, dense tables, clear focus states. */
.wrap { max-width: 900px; }
.wrap.wide { max-width: 1260px; }
.topbar { padding: 0.45rem 0 1.25rem; margin-bottom: 1.25rem; border-bottom: 1px solid var(--border); }
.topbar .actions { justify-content: flex-end; }
.eyebrow { display: block; color: var(--accent); text-transform: uppercase; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.08em; margin-bottom: 0.35rem; }
.brand-lockup, .login-brand { display: flex; align-items: center; gap: 0.65rem; }
.brand-lockup { margin-bottom: 0.85rem; }
.brand-emblem { display: inline-block; flex: none; width: 42px; height: 42px; background: #fff url("q_nexus_brand.jpg") center -9px / 148px 83px no-repeat; border: 1px solid #dce3dc; border-radius: 6px; }
.brand-wordmark { color: #29313d; font-size: 0.92rem; font-weight: 800; letter-spacing: 0.03em; }
.brand-wordmark small { display: block; color: #64707b; font-size: 0.68rem; font-weight: 600; letter-spacing: 0.03em; }
.card { padding: 1.15rem 1.25rem; }
.grid > *, .card { min-width: 0; }
.card:has(table) { overflow-x: auto; }
.card h2 { font-size: 1rem; }
.wrap.wide > section.card { background: transparent; border: 0; padding: 0; margin: 1.5rem 0; }
.wrap.wide > section.card > h2 { padding-bottom: 0.65rem; border-bottom: 1px solid var(--border); }
.btn { border-radius: 5px; padding: 0.68rem 1rem; min-height: 40px; line-height: 1.25; }
.btn:hover:not(:disabled) { filter: brightness(0.94); }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid #17835d; outline-offset: 2px; }
.topbar form { gap: 0; }
input[type="hidden"] { display: none !important; }
.grid.four.compact-form { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.compact-form > button { align-self: end; }
input, select { background: #fff; border-radius: 5px; }
code { background: #eff3ef; }
th { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; color: #54665a; background: #f7f9f7; }
td, th { padding: 0.65rem 0.7rem; }
tr:hover td { background: #fafcfa; }
#log, .compact-log { background: #f2f5f2; color: var(--text); border: 1px solid var(--border); }
.dropzone { background: #f9fbf9; backdrop-filter: none; }
.dropzone:hover, .dropzone.dragover { background: #edf6f0; }
.dropzone.has-file { background: #eef8f0; }
.list-item { background: white; border-radius: 5px; }
.entry-table th { background: #edf3ee; }
.entry-table th small { display: block; color: #7a8b80; font-size: 0.67rem; margin-bottom: 0.2rem; }
.sheet-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; padding: 0.7rem 0.9rem; background: #edf3ee; border: 1px solid var(--border); border-bottom: 0; font-size: 0.82rem; }
.sheet-heading span { color: var(--muted); }
.model-preview { grid-column: 1 / -1; width: 100%; padding: 1rem; border: 1px solid var(--border); background: #fff; border-radius: 5px; color: var(--muted); }
.model-preview h3 { margin: 0 0 0.45rem; color: var(--text); font-size: 0.95rem; }
.model-preview p { margin: 0.35rem 0 0.8rem; }
.mapping-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.8rem; }
.mapping-grid label { color: var(--text); font-size: 0.78rem; font-weight: 650; }
.mapping-grid select { display: block; width: 100%; margin-top: 0.35rem; }
.mapping-status { color: var(--accent); font-weight: 700; }
.invite-note { grid-column: span 2; align-self: end; margin: 0; }
.form-error { color: var(--err); border-left: 3px solid var(--err); padding: 0.65rem 0.75rem; background: #fff7f6; }
@media (max-width: 850px) { .invite-note { grid-column: 1 / -1; } }
@media (max-width: 850px) { .mapping-grid { grid-template-columns: 1fr; } }
.chip, .status-badge { border-radius: 4px; background: #f4f7f4; color: #42534a; }
.status-em_preenchimento { color: #315d7c; border-color: #c9deeb; background: #eef5f9; }
.status-em_validacao { color: #805916; border-color: #eed7ad; background: #fff8e9; }
.status-validado { color: #176947; border-color: #b9dec8; background: #eff8f1; }
.status-relatorio_mensal { color: #5d5b80; border-color: #d5d1e5; background: #f5f3fa; }
.status-postado { color: #0b665d; border-color: #b3dcd5; background: #edf8f5; }
.status-ajuste { color: #a13630; border-color: #ecc4c1; background: #fff2f0; }
.stat-card strong { font-size: 1.7rem; }
.audit-item { background: #f7f9f7; }
.login-page { display: grid; place-items: center; }
.login-shell { width: min(420px, calc(100% - 2rem)); }
.login-brand { margin-bottom: 2rem; }
.brand-mark { display: grid; place-items: center; background: var(--accent); color: #fff; width: 34px; height: 34px; border-radius: 5px; font-size: 1.1rem; font-weight: 800; }
.login-panel { background: white; border: 1px solid var(--border); padding: 2rem; border-radius: 6px; }
.login-panel h1 { margin: 0 0 0.4rem; font-size: 1.5rem; }
.login-panel .sub { margin-bottom: 1.5rem; }
.login-panel .stack { gap: 1.2rem; }
.login-panel .btn { width: 100%; }
.form-error { color: var(--err); background: #fff2f0; padding: 0.7rem; border-radius: 4px; }
@media (max-width: 900px) { .grid.four.compact-form { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid.four.compact-form { grid-template-columns: 1fr; } .wrap { padding: 1rem; } .topbar .actions { justify-content: flex-start; } }


/* Sync state and field workflow */
.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 36px;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}
.sync-dot {
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 3px #fff1d8;
}
.sync-status[data-sync-state="online"],
.sync-status[data-sync-state="synced"] { color: var(--ok); }
.sync-status[data-sync-state="online"] .sync-dot,
.sync-status[data-sync-state="synced"] .sync-dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px #e5f4ea;
}
.sync-status[data-sync-state="syncing"] { color: var(--accent); }
.sync-status[data-sync-state="syncing"] .sync-dot {
  background: var(--accent);
  animation: qnx-pulse 1s infinite;
}
.sync-status[data-sync-state="queued"],
.sync-status[data-sync-state="offline"] { color: var(--warn); }
.sync-status[data-sync-state="queued"] .sync-dot,
.sync-status[data-sync-state="offline"] .sync-dot {
  background: var(--warn);
  box-shadow: 0 0 0 3px #fff1d8;
}
.sync-status[data-sync-state="error"],
.sync-status[data-sync-state="conflict"] { color: var(--err); }
.sync-status[data-sync-state="error"] .sync-dot,
.sync-status[data-sync-state="conflict"] .sync-dot {
  background: var(--err);
  box-shadow: 0 0 0 3px #fde8e6;
}
.sync-now-button { white-space: nowrap; }
@keyframes qnx-pulse { 50% { opacity: 0.35; } }

.entry-table input {
  width: 100%;
  min-width: 9rem;
  min-height: 42px;
}
.workflow-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

/* On a phone, each spreadsheet row becomes a readable field card. */
@media (max-width: 640px) {
  .topbar { gap: 0.8rem; }
  .topbar .actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    align-items: stretch;
  }
  .topbar .actions > .sync-status {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
  .topbar .actions > .btn,
  .topbar .actions > form,
  .topbar .actions > form .btn {
    width: 100%;
    text-align: center;
  }
  .topbar .actions > form { display: block; }
  .table-scroll { overflow: visible; }
  .entry-table,
  .entry-table thead,
  .entry-table tbody,
  .entry-table tr,
  .entry-table td {
    display: block;
    width: 100%;
  }
  .entry-table { min-width: 0; }
  .entry-table thead { display: none; }
  .entry-table tr {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin: 0 0 0.8rem;
    padding: 0.5rem;
    box-shadow: 0 2px 8px rgba(23, 38, 32, 0.06);
  }
  .entry-table td {
    display: grid;
    grid-template-columns: minmax(7rem, 36%) 1fr;
    gap: 0.65rem;
    align-items: center;
    padding: 0.45rem 0.25rem;
    border-bottom: 1px solid #edf1ed;
  }
  .entry-table td:first-child {
    display: flex;
    justify-content: space-between;
    border-bottom: 0;
    color: var(--accent);
    font-weight: 800;
  }
  .entry-table td[data-label]::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
  }
  .entry-table td:last-child {
    display: block;
    border-bottom: 0;
    padding-top: 0.7rem;
  }
  .entry-table td:last-child .btn { width: 100%; }
  .entry-table input { min-width: 0; }
  .workflow-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
  .workflow-actions form,
  .workflow-actions .btn { width: 100%; }
}


/* Scope assignment, KPI and collaboration surfaces */
textarea {
  width: 100%;
  margin-top: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  color: var(--text);
  padding: 0.65rem 0.75rem;
  font: inherit;
  resize: vertical;
}
.assignment-list {
  display: grid;
  gap: 0.8rem;
}
.assignment-card {
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f9fbf9;
}
.assignment-heading,
.assignment-footer,
.message-heading {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}
.assignment-heading small {
  display: block;
  color: var(--muted);
  margin-top: 0.2rem;
}
.assignment-card select[multiple] {
  min-height: 112px;
  background: #fff;
}
.assignment-footer {
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}
.kpi-card {
  min-height: 128px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.45rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-top: 4px solid var(--accent);
  border-radius: 6px;
  background: #fff;
}
.kpi-card span,
.kpi-card small {
  color: var(--muted);
}
.kpi-card span {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.kpi-card strong {
  color: var(--text);
  font-size: 2rem;
  line-height: 1;
}
.kpi-card small {
  font-size: 0.76rem;
}
.kpi-primary { border-top-color: var(--accent); }
.kpi-info { border-top-color: #477c9f; }
.kpi-warning { border-top-color: var(--warn); }
.kpi-danger { border-top-color: var(--err); }
.kpi-success { border-top-color: var(--ok); }
.kpi-purple { border-top-color: #70669b; }
.kpi-neutral { border-top-color: #718078; }
.kpi-status-list {
  display: grid;
  gap: 0.85rem;
}
.kpi-status-row {
  display: grid;
  gap: 0.35rem;
}
.kpi-status-label {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--text);
  font-size: 0.84rem;
}
.kpi-status-label strong {
  color: var(--accent);
}
.kpi-bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1ed;
}
.kpi-bar > span {
  display: block;
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: var(--accent);
}
.kpi-bar > .status-em_preenchimento { background: #5f8eaa; }
.kpi-bar > .status-em_validacao { background: var(--warn); }
.kpi-bar > .status-ajuste { background: var(--err); }
.kpi-bar > .status-validado { background: var(--ok); }
.kpi-bar > .status-relatorio_mensal { background: #70669b; }
.kpi-bar > .status-postado { background: #19756c; }
.notification-badge {
  display: inline-flex;
  min-width: 1.35rem;
  min-height: 1.35rem;
  align-items: center;
  justify-content: center;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--err);
  color: #fff;
  font-size: 0.72rem;
  vertical-align: middle;
}
.message-list,
.observation-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
  max-height: 420px;
  overflow: auto;
}
.message-item,
.observation-item {
  display: grid;
  gap: 0.35rem;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 5px;
  background: #f9fbf9;
}
.message-item.unread {
  border-left-color: var(--warn);
  background: #fffaf0;
}
.message-item p,
.observation-item p {
  margin: 0.15rem 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.message-item small,
.observation-item small {
  color: var(--muted);
}
.evidence-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 1rem;
}
.evidence-card {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
  padding: 0.55rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #f9fbf9;
  font-size: 0.78rem;
}
.evidence-card small {
  color: var(--muted);
  overflow-wrap: anywhere;
}
.evidence-thumb {
  display: block;
  width: 100%;
  height: 116px;
  object-fit: cover;
  border-radius: 4px;
  background: #edf1ed;
}
.image-template-note {
  margin-top: 1rem;
  font-size: 0.78rem;
}

@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .assignment-heading,
  .assignment-footer,
  .message-heading { align-items: flex-start; flex-direction: column; }
  .evidence-grid { grid-template-columns: 1fr; }
  .kpi-card { min-height: 112px; }
}

/* CRM operational board */
.crm-toolbar { margin: 1rem 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 0.85rem 0; }
.crm-tabs { display: flex; gap: 1.2rem; flex-wrap: wrap; margin-bottom: 0.85rem; }
.crm-tabs a { color: var(--muted); text-decoration: none; font-weight: 600; padding: 0.35rem 0; border-bottom: 2px solid transparent; }
.crm-tabs a.active { color: var(--accent); border-color: var(--accent); }
.crm-tabs span, .crm-board-section h2 small { font-size: 0.78rem; color: var(--muted); }
.crm-filters { display: flex; gap: 0.55rem; align-items: end; }
.crm-filters label { flex: 1 1 135px; min-width: 120px; font-size: 0.76rem; color: var(--muted); font-weight: 600; }
.crm-filters input:not([type=checkbox]), .crm-filters select { display: block; width: 100%; margin-top: 0.3rem; min-width: 0; }
.crm-filters .crm-check { flex: 0 0 auto; display: flex; gap: 0.4rem; align-items: center; padding-bottom: 0.65rem; }
.crm-filters .btn { padding: 0.65rem 0.8rem; }
.crm-board-section { margin: 1.4rem 0; }
.crm-board-section h2 { margin: 0 0 0.8rem; color: var(--accent); font-size: 1.12rem; }
.crm-board { display: grid; grid-auto-columns: minmax(215px, 1fr); grid-auto-flow: column; gap: 0.65rem; overflow-x: auto; padding-bottom: 0.6rem; scrollbar-width: thin; }
.crm-column { min-width: 215px; background: #f0f3f2; border: 1px solid var(--border); border-radius: 6px; }
.crm-column h3 { display: flex; justify-content: space-between; align-items: center; gap: 0.4rem; margin: 0; padding: 0.7rem; font-size: 0.8rem; }
.crm-column-items { display: grid; align-content: start; gap: 0.5rem; padding: 0 0.5rem 0.5rem; max-height: 600px; overflow-y: auto; }
.crm-work-item { display: grid; gap: 0.38rem; min-width: 0; padding: 0.7rem; background: #fff; border: 1px solid var(--border); border-radius: 5px; }
.crm-work-item.is-overdue { border-left: 3px solid var(--err); }
.crm-work-heading, .crm-work-foot { display: flex; justify-content: space-between; align-items: start; gap: 0.5rem; }
.crm-work-heading strong { font-size: 0.85rem; overflow-wrap: anywhere; }
.crm-work-item small, .crm-work-foot { color: var(--muted); font-size: 0.74rem; overflow-wrap: anywhere; }
.crm-work-foot { border-top: 1px solid var(--border); padding-top: 0.45rem; align-items: center; }
.crm-work-foot a { color: var(--accent); font-weight: 700; white-space: nowrap; }
.crm-work-foot .overdue { color: var(--err); font-weight: 700; }
.priority { font-size: 0.67rem; text-transform: uppercase; white-space: nowrap; font-weight: 700; color: var(--muted); }
.priority-alta, .priority-critica { color: var(--err); }
.priority-baixa { color: var(--ok); }
.crm-plan { border-top: 1px solid var(--border); padding-top: 0.4rem; }
.crm-plan summary { font-size: 0.72rem; color: var(--accent); cursor: pointer; }
.crm-plan form { display: grid; gap: 0.4rem; margin-top: 0.5rem; }
.crm-plan label { font-size: 0.72rem; }
.crm-plan input, .crm-plan select { display: block; width: 100%; margin-top: 0.2rem; }
.crm-empty { padding: 0.5rem; font-size: 0.75rem; }
@media (max-width: 640px) {
  .crm-filters label { flex-basis: calc(50% - 0.4rem); }
  .crm-board { grid-auto-columns: minmax(240px, 82vw); }
}

/* Model validation and batch review */
.validation-checklist { border: 1px solid var(--border); border-left: 3px solid var(--accent); background: #f8faf9; border-radius: 5px; padding: 0.9rem; margin: 0.9rem 0; }
.validation-checklist h3 { margin: 0 0 0.4rem; color: var(--accent); font-size: 1rem; }
.validation-checklist p { margin: 0.4rem 0; font-size: 0.82rem; }
.validation-items { display: grid; gap: 0.5rem; align-items: start; margin: 0.75rem 0; }
.validation-items label { display: flex; gap: 0.5rem; align-items: start; font-size: 0.85rem; }
.validation-items .btn { justify-self: start; }
.validation-warning { background: #fff8e8; border: 1px solid #e8cc84; padding: 0.6rem; font-size: 0.82rem; }
.validation-warning ul { margin: 0.3rem 0 0; padding-left: 1.25rem; }
.crm-work-links { display: flex; justify-content: space-between; gap: 0.4rem; align-items: center; font-size: 0.72rem; }
.crm-work-links a { color: var(--accent); font-weight: 700; }
.batch-section, .model-rules-section { margin: 1.4rem 0; }
.batch-section h2, .model-rules-section h2 { color: var(--accent); font-size: 1.12rem; margin: 0 0 0.8rem; }
.batch-grid, .model-rules-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 0.8rem; }
.batch-group, .model-rules-item { display: grid; align-content: start; gap: 0.5rem; background: #fff; border: 1px solid var(--border); border-radius: 5px; padding: 0.85rem; min-width: 0; }
.batch-group h3 { margin: 0; font-size: 0.85rem; overflow-wrap: anywhere; }
.batch-group p { margin: 0; font-size: 0.76rem; }
.batch-group label, .model-rules-item fieldset label { display: flex; gap: 0.45rem; align-items: start; width: 100%; font-size: 0.82rem; overflow-wrap: anywhere; }
.batch-group .btn { justify-self: start; }
.model-rules-item summary { cursor: pointer; display: grid; gap: 0.2rem; overflow-wrap: anywhere; }
.model-rules-item summary small { color: var(--muted); }
.model-rules-item form { margin-top: 0.8rem; }
.model-rules-item fieldset { border: 1px solid var(--border); max-height: 220px; overflow-y: auto; padding: 0.6rem; width: 100%; }
.model-rules-item fieldset legend { font-size: 0.8rem; font-weight: 700; }
.model-rules-item input[type=number] { width: 5rem; display: block; }
