:root {
  color-scheme: dark;
  --bg:         #08090c;
  --bg-elevated:#0c0e12;
  --surface:    #12141a;
  --surface2:   #181b22;
  --surface3:   #1e222b;
  --border:     rgba(255, 255, 255, 0.06);
  --border2:    rgba(255, 255, 255, 0.1);
  --text:       #f0f2f7;
  --text-soft:  #b8bcc8;
  --muted:      #7a8194;
  --accent:     #0aa85a;
  --accent-bright: #3ddc84;
  --accent2:    rgba(0, 168, 90, 0.16);
  --accent-glow: rgba(0, 168, 90, 0.38);
  --ok:         #2ee59d;
  --ok-bg:      rgba(46, 229, 157, 0.1);
  --warn:       #ffb547;
  --warn-bg:    rgba(255, 181, 71, 0.1);
  --danger:     #ff6b6b;
  --danger-bg:  rgba(255, 107, 107, 0.1);
  --purple:     #b4a3ff;
  --purple-bg:  rgba(180, 163, 255, 0.1);
  --radius-sm:  8px;
  --radius:     12px;
  --radius-lg:  16px;
  --radius-xl:  22px;
  --shadow-sm:  0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md:  0 8px 32px rgba(0, 0, 0, 0.45);
  --shadow-lg:  0 24px 64px rgba(0, 0, 0, 0.55);
  --mono: 'DM Mono', ui-monospace, monospace;
  /* Mesma família do corpo: proporções mais abertas que Syne (evita títulos “achatados”) */
  --head: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --body: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --space-1: 6px;
  --space-2: 10px;
  --space-3: 16px;
  --space-4: 22px;
  --space-5: 28px;
  --main-max: 1480px;
  --input-min-h: 40px;
  /* Seta das listas suspensas (SVG) */
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%237a8194' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  --select-arrow-focus: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%233ddc84' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  /* Tons “enterprise” (secundário / documento) */
  --pro-secondary:     #8b9cb3;
  --pro-secondary-bg:  rgba(139, 156, 179, 0.08);
  --pro-secondary-bdr: rgba(139, 156, 179, 0.22);
  --focus-ring:        rgba(59, 130, 246, 0.35);
  --focus-ring-bg:     rgba(59, 130, 246, 0.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  margin: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection {
  background: rgba(61, 220, 132, 0.28);
  color: var(--text);
}

body:not(.app-visible) {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
body:not(.app-visible) .login-gate {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}
body:not(.app-visible) .app-shell {
  display: none !important;
}

body.app-visible {
  display: flex;
  flex-direction: row;
  background:
    radial-gradient(ellipse 120% 80% at 100% -20%, rgba(0, 168, 90, 0.11), transparent 50%),
    radial-gradient(ellipse 80% 50% at 0% 100%, rgba(180, 163, 255, 0.06), transparent 45%),
    var(--bg);
}
body.app-visible .login-gate {
  display: none !important;
}
body.app-visible .app-shell {
  display: flex !important;
  flex: 1;
  min-height: 100vh;
  min-width: 0;
}

.app-shell {
  width: 100%;
}

/* Perfis: itens de menu */
body.role-admin .only-colaborador {
  display: none !important;
}
body.role-colaborador .only-admin {
  display: none !important;
}

/* ── LOGIN: layout centrado (sem coluna lateral) ── */
.login-canvas {
  position: relative;
  flex: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px 48px;
  overflow: hidden;
}

.login-ambient {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 90% 65% at 50% -25%, rgba(0, 168, 90, 0.32), transparent 58%),
    radial-gradient(ellipse 55% 45% at 100% 15%, rgba(0, 144, 53, 0.12), transparent 50%),
    radial-gradient(ellipse 50% 40% at 0% 85%, rgba(16, 185, 129, 0.12), transparent 45%),
    linear-gradient(180deg, #050806 0%, #080c0a 50%, #08090c 100%);
}

.login-ambient::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.4;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 75% 70% at 50% 40%, #000 15%, transparent 72%);
  pointer-events: none;
}

.login-center {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
}

.login-top-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.login-logo-mark {
  width: 80px;
  height: 80px;
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.05) 0%, rgba(0, 0, 0, 0.2) 100%);
  border: 1px solid rgba(0, 168, 90, 0.22);
  box-shadow:
    0 0 40px rgba(0, 168, 90, 0.18),
    0 20px 56px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 1px 0 rgba(255, 255, 255, 0.12) inset;
  overflow: hidden;
}

.login-logo-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.login-wordmark {
  font-family: var(--head);
  font-weight: 800;
  font-size: 1.7rem;
  letter-spacing: -0.012em;
  color: #fafbfc;
  line-height: 1.12;
  font-feature-settings: 'kern' 1, 'liga' 1;
}

.login-wordmark span {
  background: linear-gradient(118deg, #b8f5d9 0%, #3ddc84 32%, #0aa85a 62%, #009035 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.login-card {
  width: 100%;
  padding: 34px 32px 32px;
  border-radius: 22px;
  background: linear-gradient(165deg, rgba(18, 26, 22, 0.94) 0%, rgba(8, 10, 12, 0.96) 100%);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid rgba(0, 168, 90, 0.18);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.07) inset,
    0 40px 100px -20px rgba(0, 0, 0, 0.68),
    0 0 100px -36px rgba(0, 168, 90, 0.22);
}

.login-heading {
  font-family: var(--head);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-align: center;
  margin: 0 0 26px;
  color: #f4f6fa;
  line-height: 1.25;
  font-feature-settings: 'kern' 1, 'liga' 1;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

.login-form .form-field {
  margin: 0;
  width: 100%;
  min-width: 0;
}

.login-field label {
  display: block;
  font-family: var(--body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(168, 174, 190, 0.95);
  margin-bottom: 8px;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
}

.input-wrap .input-icon {
  position: absolute;
  left: 16px;
  font-size: 14px;
  color: rgba(122, 129, 148, 0.9);
  pointer-events: none;
  font-family: var(--body);
  font-weight: 500;
  transition: color 0.2s;
}

.input-wrap:focus-within .input-icon {
  color: var(--accent-bright);
}

.input-wrap .input-has-icon {
  display: block;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding-left: 44px;
  padding-right: 16px;
  min-height: 50px;
  border-radius: 12px;
  font-size: 14px;
  background: rgba(6, 7, 10, 0.75);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35) inset;
  transition: border-color 0.22s, box-shadow 0.22s, background 0.22s;
}

.input-wrap .input-has-icon::placeholder {
  color: var(--muted);
  opacity: 0.85;
}

.input-wrap .input-has-icon:-webkit-autofill,
.input-wrap .input-has-icon:-webkit-autofill:hover,
.input-wrap .input-has-icon:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 48px #161922 inset;
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.input-wrap .input-has-icon:hover {
  border-color: rgba(255, 255, 255, 0.14);
}

.input-wrap .input-has-icon:focus {
  border-color: rgba(61, 220, 132, 0.55);
  box-shadow:
    0 0 0 3px rgba(0, 168, 90, 0.16),
    0 1px 3px rgba(0, 0, 0, 0.25) inset;
  outline: none;
  background: rgba(10, 16, 14, 0.96);
}

.login-card .btn-login-submit {
  width: 100%;
  margin-top: 10px;
  min-height: 52px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: linear-gradient(168deg, #4ae596 0%, #12b76a 26%, #0a8f52 68%, #007a3d 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.28) inset,
    0 10px 36px rgba(0, 143, 82, 0.42),
    0 4px 12px rgba(0, 0, 0, 0.28);
  transition: transform 0.18s ease, box-shadow 0.22s ease, filter 0.18s ease;
}

.login-card .btn-login-submit:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.3) inset,
    0 16px 44px rgba(0, 143, 82, 0.48),
    0 6px 16px rgba(0, 0, 0, 0.32);
}

.login-card .btn-login-submit:active {
  transform: translateY(0);
  filter: brightness(0.98);
}

.login-erro {
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 120, 120, 0.35);
  color: #fecaca;
  font-size: 13px;
  font-family: var(--body);
  padding: 12px 14px;
  border-radius: 12px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

.form-field.form-field-inline-toggle {
  flex-direction: row;
  align-items: center;
  gap: 12px;
}
.form-field.form-field-inline-toggle label {
  margin: 0;
}

/* Checkbox GR estilo formulário */
input[type="checkbox"].input-check {
  width: auto;
  accent-color: var(--accent);
  cursor: pointer;
}

.table-lancamentos td {
  font-size: 12px;
  vertical-align: middle;
}
.table-lancamentos .cell-obs {
  max-width: 18rem;
  line-height: 1.35;
  white-space: normal;
  overflow: visible;
  word-break: break-word;
}
.table-lancamentos .cell-erp-field {
  max-width: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.table-lancamentos .cell-centro-custo {
  max-width: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.table-lancamentos .cell-cte-num {
  max-width: 10.5rem;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.35;
}

/* Bloco NF + múltiplos CT-e */
.section-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 20px 0 10px;
}
.section-label:first-of-type {
  margin-top: 0;
}

.section-hint {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
  margin: 0 0 18px;
  max-width: 48rem;
  font-weight: 400;
}
.section-hint strong {
  color: var(--text-soft);
  font-weight: 500;
}

.cte-block {
  /* minmax(0) nos trilhos + min-width:0 nas células evita a grelha a “estourar” a largura */
  --cte-cols: minmax(116px, 0.75fr) minmax(100px, 0.9fr) minmax(112px, 0.4fr) minmax(96px, 1fr) minmax(84px, 0.85fr) minmax(96px, 1.1fr) minmax(96px, 1.1fr) 44px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 20px 22px 22px;
  margin-bottom: 12px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}
.cte-rows-header > span,
.cte-line > * {
  min-width: 0;
}
.cte-rows-header-tools {
  display: block;
  width: 100%;
  min-width: 36px;
}

.cte-rows-header {
  display: grid;
  grid-template-columns: var(--cte-cols);
  gap: 12px 12px;
  font-size: 9px;
  font-family: var(--mono);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.75px;
  margin-bottom: 2px;
  padding: 0 4px 12px 4px;
  border-bottom: 1px solid var(--border);
  align-items: end;
  font-weight: 500;
}
.cte-rows-header .cte-rows-header-erp {
  text-align: center;
  color: var(--text-soft);
  opacity: 1;
  letter-spacing: 0.04em;
}

.cte-line {
  display: grid;
  grid-template-columns: var(--cte-cols);
  gap: 12px 12px;
  align-items: center;
  margin-bottom: 10px;
  padding: 16px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.2s, background 0.2s;
}
.cte-line:hover {
  border-color: rgba(255, 255, 255, 0.1);
  background: #0e1015;
}
.cte-line:last-of-type {
  margin-bottom: 0;
}

.cte-line input {
  width: 100%;
}

.cte-line input[type="date"] {
  font-family: var(--body);
  font-size: 13px;
  min-height: var(--input-min-h);
  padding: 8px 12px;
  background: var(--surface3);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.cte-line input[type="date"]:focus {
  outline: none;
  border-color: rgba(100, 116, 139, 0.45);
  box-shadow: 0 0 0 1px var(--focus-ring);
}

.cte-line input[type="text"],
.cte-line input[type="number"] {
  min-height: var(--input-min-h);
  border-radius: 10px;
  padding: 8px 12px;
  background: var(--surface3);
  border: 1px solid var(--border2);
  color: var(--text);
  font-size: 13px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.cte-line input[type="text"]:focus,
.cte-line input[type="number"]:focus {
  outline: none;
  border-color: rgba(100, 116, 139, 0.45);
  box-shadow: 0 0 0 1px var(--focus-ring);
}
.cte-line input[type="number"] {
  font-family: var(--mono);
  font-size: 12px;
}

.cte-line select.cte-centro-custo,
.cte-line select.cte-campo-rodopar {
  width: 100%;
  height: var(--input-min-h);
  min-height: var(--input-min-h);
  max-height: var(--input-min-h);
  font-size: 13px;
  font-weight: 500;
  line-height: calc(var(--input-min-h) - 2px);
  padding: 0 36px 0 12px;
  background-color: var(--surface2);
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  border: 1px solid var(--border2);
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}
.cte-line select.cte-centro-custo:hover,
.cte-line select.cte-campo-rodopar:hover {
  border-color: rgba(255, 255, 255, 0.16);
  background-color: var(--surface3);
  background-image: var(--select-arrow);
}
.cte-line select.cte-centro-custo:focus,
.cte-line select.cte-campo-rodopar:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent2);
  background-color: var(--surface3);
  background-image: var(--select-arrow-focus);
}

/* Segmento CT-e | NF-e — alinhado à altura dos inputs, tipografia padronizada */
.cte-erp-segment {
  --cte-erp-pad: 2px;
  display: flex;
  align-items: stretch;
  width: 100%;
  min-width: 0;
  min-height: var(--input-min-h);
  padding: var(--cte-erp-pad);
  gap: 0;
  border-radius: 10px;
  background: var(--surface3);
  border: 1px solid var(--border2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  justify-self: stretch;
}
.cte-erp-opt {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.cte-erp-opt + .cte-erp-opt {
  border-left: 1px solid rgba(255, 255, 255, 0.07);
  margin-left: 0;
}
.cte-erp-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}
.cte-erp-opt-label {
  position: relative;
  z-index: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  min-height: calc(var(--input-min-h) - 2 * var(--cte-erp-pad));
  padding: 0 8px;
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  text-transform: none;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.16s, background 0.16s, box-shadow 0.16s;
}
.cte-erp-opt:hover .cte-erp-opt-label {
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.05);
}
.cte-erp-opt:has(input:checked) .cte-erp-opt-label[data-erp-tipo='cte'] {
  color: #b8f0d4;
  background: rgba(0, 168, 90, 0.2);
  box-shadow: 0 0 0 1px rgba(0, 200, 120, 0.35) inset, 0 1px 2px rgba(0, 0, 0, 0.18);
}
.cte-erp-opt:has(input[value='nf']:checked) .cte-erp-opt-label[data-erp-tipo='nf'] {
  color: #d4dce8;
  background: var(--pro-secondary-bg);
  box-shadow: 0 0 0 1px var(--pro-secondary-bdr) inset, 0 1px 2px rgba(0, 0, 0, 0.18);
}
.cte-erp-segment:has(:focus-within) {
  border-color: rgba(100, 116, 139, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 0 0 1px var(--focus-ring);
}

.erp-type-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.1rem;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1.2;
  border: 1px solid transparent;
}
.erp-type-tag--cte {
  color: #8fd9b8;
  background: rgba(0, 168, 90, 0.07);
  border-color: rgba(0, 168, 90, 0.22);
}
.erp-type-tag--nf {
  color: var(--pro-secondary);
  background: var(--pro-secondary-bg);
  border-color: var(--pro-secondary-bdr);
}

.cell-erp-tipo {
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  padding: 10px 10px !important;
}

.table-lancamentos thead th:nth-child(4) {
  /* coluna Qtd. docs */
  text-align: center;
}
.table-lancamentos tbody td:nth-child(4) {
  text-align: center;
}

.table-lancamentos .tac {
  text-align: center;
}

.lanc-acoes-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  align-items: center;
}

.lanc-obs-icon {
  font-size: 1.1em;
  line-height: 1;
  cursor: default;
}

.table-lancamentos .cell-obs--has {
  text-align: center;
  vertical-align: middle;
}

.th-acoes-lanc,
.cell-acoes-lanc {
  width: 1%;
  white-space: nowrap;
  text-align: center;
  vertical-align: middle;
}

.cell-acoes-lanc .btn-sm {
  font-weight: 600;
}

.th-acoes-user,
.cell-acoes-user {
  width: 1%;
  white-space: nowrap;
  text-align: center;
  vertical-align: middle;
}

.cell-acoes-user .user-btn-editar {
  font-weight: 600;
}

.table-lancamentos tbody tr.tr--destaque-linha-erro {
  outline: 2px solid var(--warn);
  outline-offset: -2px;
  background: rgba(245, 158, 11, 0.12);
}

.modal-edit-cte-line--destaque {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
  background: rgba(139, 92, 246, 0.08);
}

.btn-icon {
  padding: 0;
  width: var(--input-min-h);
  height: var(--input-min-h);
  min-width: var(--input-min-h);
  border-radius: var(--radius-sm);
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cte-toolbar {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.cte-toolbar .btn-sm {
  font-weight: 600;
  font-size: 12px;
  border: 1px solid var(--border2);
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.03);
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.cte-toolbar .btn-sm:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--text);
}

/* Resumo NF × soma cobrados (formulário) */
.nf-comparacao-preview {
  margin-top: 20px;
  padding: 16px 18px;
  border-radius: 10px;
  border: 1px solid var(--border2);
  background: var(--bg-elevated);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
.nf-comparacao-preview-title {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-soft);
  margin-bottom: 12px;
}
.nf-comparacao-preview-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  align-items: baseline;
  font-size: 13px;
}
.nf-comparacao-k {
  color: var(--muted);
}
.nf-comparacao-v {
  color: var(--text);
  font-weight: 600;
}

/* Abaixo deste ponto, a grelha de 8 colunas não cabe sem espremer texto
   (ex.: "CT-e" a cortar para "CT-"). Empilha em 1 coluna — cada campo com
   a largura toda, mais legível do que uma grelha apertada. */
@media (max-width: 1150px) {
  .cte-block {
    padding: 16px 14px 18px;
  }
  .cte-rows-header {
    display: none;
  }
  .cte-line {
    grid-template-columns: 1fr;
    padding: 16px 14px;
    margin-bottom: 14px;
    gap: 12px;
  }
  .cte-erp-segment {
    max-width: 100%;
  }
  .cte-line .cte-cell-remove {
    justify-self: end;
    margin-top: 2px;
  }
}

.listas-cadastro-grid {
  align-items: stretch;
}
.listas-cadastro-grid .card {
  display: flex;
  flex-direction: column;
}
.listas-cadastro-grid .card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
}
.listas-cadastro-grid .lista-cadastro-itens {
  flex: 1;
}

.lista-cadastro-add-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.lista-cadastro-add-row input {
  flex: 1;
  min-width: 160px;
}
.lista-cadastro-add-row--filial input[type='number'] {
  flex: 0 0 100px;
  min-width: 80px;
}
.lista-cadastro-add-row--filial input[type='text'] {
  flex: 1;
  min-width: 140px;
}

.lista-cadastro-help {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 14px;
}

.lista-cadastro-itens {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: min(52vh, 420px);
  overflow-y: auto;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.12);
}

.lista-cadastro-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.lista-cadastro-item:last-child {
  border-bottom: none;
}

.lista-cadastro-text {
  min-width: 0;
  word-break: break-word;
}

.lista-cadastro-empty {
  padding: 16px 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}

/* ── SIDEBAR ── */
aside {
  width: 252px;
  min-width: 252px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, transparent 28%), var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 0 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: 4px 0 40px rgba(0, 0, 0, 0.2);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px 20px 22px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo-mark {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.06) 0%, rgba(0, 0, 0, 0.18) 100%);
  border: 1px solid rgba(0, 168, 90, 0.22);
  box-shadow:
    0 0 22px rgba(0, 168, 90, 0.14),
    0 6px 16px rgba(0, 0, 0, 0.28),
    0 0 0 1px rgba(255, 255, 255, 0.05) inset;
}
.sidebar-logo-svg {
  width: 100%;
  height: 100%;
  display: block;
}
.sidebar-brand .logo {
  padding: 0;
  border-bottom: none;
  flex: 1;
  min-width: 0;
}
.logo {
  font-family: var(--head);
  font-weight: 800;
  font-size: 19px;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.2;
  font-feature-settings: 'kern' 1, 'liga' 1;
}
.logo span {
  background: linear-gradient(105deg, var(--accent-bright), #6ee7b7);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

nav { flex: 1; padding: 14px 12px; }

.nav-section {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 16px 14px 8px;
  font-weight: 500;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  margin: 2px 0;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-soft);
  font-weight: 500;
  font-size: 14px;
  transition: color 0.18s, background 0.18s, box-shadow 0.18s;
  border-left: none;
  user-select: none;
}
.nav-item:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}
.nav-item.active {
  color: var(--text);
  background: linear-gradient(90deg, var(--accent2), transparent);
  box-shadow: inset 0 0 0 1px rgba(0, 168, 90, 0.28);
}
.nav-item.active .icon {
  color: var(--accent-bright);
}
.nav-item .icon {
  font-size: 15px;
  min-width: 20px;
  opacity: 0.85;
}
.nav-item .badge {
  margin-left: auto;
  background: linear-gradient(135deg, #f87171, #ef4444);
  color: #fff;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.35);
}

.sidebar-footer {
  padding: 18px 16px 16px;
  margin: 0 12px;
  border-top: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 12px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.15);
}
.sidebar-footer strong {
  display: block;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.btn-sidebar-logout,
.btn-sidebar-theme {
  margin-top: 14px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* ── MAIN ── */
main {
  flex: 1 1 0;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-5) clamp(20px, 3vw, 40px) 48px;
  width: 100%;
  max-width: var(--main-max);
  margin-inline: auto;
}

.screen { display: none; animation: fadeIn .2s ease; }
.screen.active { display: block; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── PAGE HEADER ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}
.page-header__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  justify-content: flex-end;
}
.page-title {
  font-family: var(--head);
  font-size: clamp(1.5rem, 2.6vw, 1.85rem);
  font-weight: 800;
  letter-spacing: -0.012em;
  line-height: 1.22;
  font-feature-settings: 'kern' 1, 'liga' 1;
}
.page-sub {
  color: var(--muted);
  margin-top: var(--space-1);
  font-size: 14px;
  max-width: 62ch;
  line-height: 1.5;
}
#screen-lancamento .page-header {
  margin-bottom: var(--space-3);
}
.page-sub--compact {
  max-width: 48ch;
  font-size: 13px;
  line-height: 1.45;
}

/* ── Cadastro (usuários + listas) — abas ── */
.cadastro-page-header {
  margin-bottom: 4px;
}
.cadastro-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.cadastro-tab {
  font-family: var(--body);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 16px;
  margin-bottom: -1px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.cadastro-tab:hover {
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.03);
}
.cadastro-tab.active {
  color: var(--accent-bright);
  border-bottom-color: var(--accent);
  background: rgba(0, 168, 90, 0.07);
}
.cadastro-panel-intro {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
  max-width: 72ch;
  margin-bottom: 20px;
}

/* ── BUTTONS ── */
.btn {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: var(--body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s, border-color 0.2s, color 0.2s;
}
.btn-primary {
  background: linear-gradient(135deg, #3ddc84 0%, var(--accent) 50%, #007a3d 100%);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.btn-primary:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(0, 168, 90, 0.38);
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-soft);
  border: 1px solid var(--border2);
}
.btn-ghost:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
}
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: 12px; border-radius: var(--radius-sm); }

.btn:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 2px;
}

.btn[disabled],
.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none !important;
}

/* Estado "a processar…" — bloqueia clique duplicado e mostra spinner sobre o texto do botão. */
.btn.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn.is-loading .btn-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn.is-loading .btn-spinner::after {
  content: '';
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  animation: btn-spin 0.6s linear infinite;
}
.btn-ghost.is-loading .btn-spinner::after,
.btn-icon.is-loading .btn-spinner::after {
  border-color: var(--border2);
  border-top-color: var(--text);
}
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

/* ── KPI CARDS ── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(12px, 2vw, 20px);
  margin-bottom: var(--space-5);
}
.kpi {
  position: relative;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.04) 0%, transparent 55%), var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.kpi::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  opacity: 0.9;
}
.kpi.danger::before { background: linear-gradient(90deg, var(--danger), #f97316); }
.kpi.warn::before { background: linear-gradient(90deg, var(--warn), #fbbf24); }
.kpi.ok::before { background: linear-gradient(90deg, var(--ok), #34d399); }
.kpi.accent::before { background: linear-gradient(90deg, var(--accent), var(--purple)); }
.kpi:hover {
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.kpi-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: var(--mono);
  font-weight: 500;
}
.kpi-value {
  font-family: var(--head);
  font-size: clamp(1.55rem, 3vw, 1.9rem);
  font-weight: 800;
  margin: 10px 0 6px;
  letter-spacing: -0.01em;
  line-height: 1.15;
  font-feature-settings: 'kern' 1, 'liga' 1;
}
.kpi-delta { font-size: 12px; color: var(--muted); }
.kpi.danger .kpi-value { color: #ff8a8a; }
.kpi.kpi--prejuizo .kpi-value {
  color: #ef4444;
}
.kpi.ok .kpi-value { color: #5ee9b5; }
.kpi.warn .kpi-value { color: #ffd08a; }
.kpi.accent .kpi-value { color: var(--accent-bright); }

@media (max-width: 1100px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
}

/* ── CARD ── */
.card {
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.035) 0%, transparent 42%), var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.25s, border-color 0.25s;
}
.card:hover {
  box-shadow: var(--shadow-md);
  border-color: rgba(255, 255, 255, 0.08);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.12);
}
.card-title {
  font-family: var(--head);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.008em;
  line-height: 1.3;
  font-feature-settings: 'kern' 1, 'liga' 1;
}
.card-body { padding: var(--space-4); }
.card-body--compact {
  padding: 14px 20px;
}
.card--mb {
  margin-bottom: 20px;
}
.card--narrow {
  max-width: 720px;
  margin-bottom: var(--space-4);
}
.two-col > .card--full {
  grid-column: 1 / -1;
}

/* ── Lançamentos: formulário + lista em coluna (lista usa largura total) ── */
.lancamentos-stack {
  display: flex;
  flex-direction: column;
  gap: clamp(18px, 2.5vw, 26px);
}
.lancamentos-stack > .card {
  margin-bottom: 0;
}
.lancamentos-stack .card--form-lancamento {
  max-width: min(100%, 900px);
  width: 100%;
}
.card-body--lancamento {
  padding: 20px 22px 22px;
  min-width: 0;
}
.card-body--lancamento .section-label--tight {
  margin: 20px 0 10px;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-soft);
}
.card-body--lancamento .section-label--tight:first-of-type {
  margin-top: 0;
}
.card-body--lancamento .section-hint--tight {
  margin: 0 0 16px;
  font-size: 12.5px;
  line-height: 1.5;
  max-width: 44rem;
}
.form-lancamento-nf--row {
  margin-bottom: 0;
  padding: 16px 18px;
  border-radius: 10px;
  border: 1px solid var(--border2);
  background: var(--bg-elevated);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}
.card-body--lancamento .form-grid--lanc {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
  align-items: end;
  margin: 0;
}
.card-body--lancamento .form-grid--lanc .form-field {
  gap: 6px;
  margin: 0;
}
.card-body--lancamento .form-grid--lanc label {
  font-size: 11px;
  letter-spacing: 0.08em;
}
.card-body--lancamento .form-grid--lanc input {
  min-height: 40px;
  padding: 8px 12px;
  font-size: 14px;
  border-radius: 9px;
}
@media (max-width: 520px) {
  .card-body--lancamento .form-grid--lanc {
    grid-template-columns: 1fr;
  }
}
/* Bloco de linhas: mesma grelha que o cabeçalho, altura e cantos alinhados */
.card--form-lancamento .cte-block--lanc {
  --cte-cols: minmax(112px, 0.75fr) minmax(96px, 0.88fr) minmax(108px, 0.38fr) minmax(92px, 1fr) minmax(80px, 0.82fr) minmax(92px, 1.05fr) minmax(92px, 1.05fr) 44px;
  --input-min-h: 40px;
  margin-bottom: 16px;
  padding: 16px 18px 16px;
  border-radius: 10px;
}
.card--form-lancamento .cte-block--lanc .cte-rows-header {
  gap: 10px 12px;
  padding: 0 0 10px 0;
  margin-bottom: 2px;
  font-size: 9px;
  letter-spacing: 0.07em;
}
.card--form-lancamento .cte-block--lanc .cte-line {
  margin-bottom: 10px;
  padding: 12px 14px;
  gap: 10px 12px;
  border-radius: 9px;
  background: var(--bg-elevated);
}
.card--form-lancamento .cte-line input[type="date"],
.card--form-lancamento .cte-line input[type="text"],
.card--form-lancamento .cte-line input[type="number"] {
  padding: 8px 11px;
  font-size: 13px;
  border-radius: 9px;
}
.card--form-lancamento .cte-line select.cte-centro-custo,
.card--form-lancamento .cte-line select.cte-campo-rodopar {
  font-size: 13px;
  min-height: var(--input-min-h);
  padding: 8px 32px 8px 11px;
  border-radius: 9px;
  background-position: right 9px center;
}
.card--form-lancamento .cte-toolbar {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  justify-content: flex-start;
}
.card--form-lancamento .cte-erp-segment {
  border-radius: 9px;
}
.card--form-lancamento .cte-erp-opt-label {
  min-height: calc(var(--input-min-h) - 2 * var(--cte-erp-pad, 2px));
  font-size: 11px;
}
.card--form-lancamento .cte-line .btn-icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 9px;
}
.card--form-lancamento .nf-comparacao-preview {
  margin-top: 0;
  margin-bottom: 0;
  padding: 14px 16px;
  border-radius: 10px;
}
.form-field--lancamento-obs {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border2);
  gap: 6px;
}
.form-field--lancamento-obs label {
  font-size: 11px;
  letter-spacing: 0.08em;
}
.form-field--lancamento-obs textarea {
  min-height: 80px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
  border-radius: 9px;
}
.card-body--lancamento .form-actions {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border2);
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}
.card-lancamentos-registrados {
  overflow: visible;
}
.card-lancamentos-registrados .card-header {
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 6px 20px;
}
.card-lancamentos-registrados .card-title {
  flex: 0 0 auto;
}

.card-header-hint {
  font-family: var(--body);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.45;
  max-width: min(40ch, 100%);
  margin-left: auto;
  text-align: right;
}
@media (max-width: 640px) {
  .card-header-hint {
    margin-left: 0;
    text-align: left;
    max-width: none;
  }
}
.table-wrap--lancamentos {
  overflow-x: visible;
  padding: 0 0 4px;
}
@media (max-width: 1024px) {
  .table-wrap--lancamentos {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
}
.table-lancamentos {
  width: 100%;
  min-width: 0;
}
.table-lancamentos thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  box-shadow: 0 1px 0 var(--border);
}
.table-lancamentos tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.025);
}
.table-lancamentos tbody tr:hover {
  background: rgba(255, 255, 255, 0.045);
}

/* ── TABLE ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: rgba(0, 0, 0, 0.2);
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:hover { background: var(--surface2); }
tbody tr:last-child { border-bottom: none; }
td { padding: 11px 14px; font-size: 13px; }
td.mono { font-family: var(--mono); font-size: 12px; }

/* ── BADGES ── */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-family: var(--mono);
  font-weight: 500;
  white-space: nowrap;
}
.badge-ok      { background: var(--ok-bg);     color: var(--ok); }
.badge-warn    { background: var(--warn-bg);    color: var(--warn); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-accent  { background: var(--accent2);    color: var(--accent); }
.badge-purple  { background: var(--purple-bg);  color: var(--purple); }

/* ── FILTERS ── */
.filter-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}
.filter-row input,
.filter-row select {
  min-height: var(--input-min-h);
  border-radius: var(--radius-sm);
  font-family: var(--body);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}
.filter-row input {
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 10px 14px;
}
.filter-row input:hover {
  border-color: rgba(255, 255, 255, 0.12);
}
.filter-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent2);
  background: var(--surface3);
}

/* ── FORM ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.cols3 { grid-template-columns: 1fr 1fr 1fr; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
label { font-size: 12px; color: var(--muted); font-family: var(--mono); text-transform: uppercase; letter-spacing: 1px; }
input[type="text"],
input[type="number"],
input[type="date"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea {
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  min-height: var(--input-min-h);
  font-family: var(--body);
  font-size: 13px;
  line-height: 1.35;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
  width: 100%;
  box-sizing: border-box;
}

/* Remove as setas nativas de incremento/decremento dos campos numéricos —
   inconsistentes entre navegadores e destoam do resto do design. */
input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Listas suspensas — mesmo padrão visual em cadastro, modal e CT-e */
select {
  display: block;
  width: 100%;
  max-width: 100%;
  height: var(--input-min-h);
  min-height: var(--input-min-h);
  max-height: var(--input-min-h);
  padding: 0 40px 0 12px;
  font-family: var(--body);
  font-size: 13px;
  font-weight: 500;
  line-height: calc(var(--input-min-h) - 2px);
  color: var(--text);
  background-color: var(--surface2);
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  border: 1px solid var(--border2);
  border-radius: 10px;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, transform 0.12s ease;
  box-sizing: border-box;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
select::-ms-expand {
  display: none;
}
select:hover {
  border-color: rgba(255, 255, 255, 0.16);
  background-color: var(--surface3);
  background-image: var(--select-arrow);
}
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent2);
  background-color: var(--surface3);
  background-image: var(--select-arrow-focus);
}
select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
option,
optgroup {
  background-color: var(--surface);
  color: var(--text);
  font-family: var(--body);
  font-size: 13px;
  font-weight: 500;
}
optgroup {
  font-weight: 700;
  color: var(--muted);
}
option {
  padding: 8px 12px;
  font-weight: 500;
  color: var(--text);
}
option:checked {
  font-weight: 600;
}

/* Filtros: selects em linha (largura automática, depois do bloco global select) */
.filter-row select {
  width: auto;
  min-width: 160px;
  flex: 1 1 140px;
  max-width: min(280px, 100%);
}
.filter-row .csel {
  width: auto;
  min-width: 160px;
  flex: 1 1 140px;
  max-width: min(280px, 100%);
}

/* ══════════════════════════════════════════════════════════════
   DROPDOWN CUSTOMIZADO — substitui o popup nativo do <select>
   (o navegador não permite estilizar cantos/sombra/hover do popup
   nativo). O <select> original fica no DOM, oculto mas funcional:
   `.value`, eventos change/input e toda a lógica existente continuam
   a funcionar sem alterações — só o visual do menu é outro.
   ══════════════════════════════════════════════════════════════ */
.csel {
  position: relative;
  width: 100%;
  min-width: 0;
}
.csel-native {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}
.csel-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  height: var(--input-min-h);
  min-height: var(--input-min-h);
  max-height: var(--input-min-h);
  padding: 0 12px;
  font-family: var(--body);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background-color: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}
.csel-trigger-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.csel-trigger-label--placeholder {
  color: var(--muted);
  font-weight: 400;
}
.csel-trigger-arrow {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 16px;
  transition: transform 0.18s ease;
}
.csel-trigger:hover {
  border-color: rgba(255, 255, 255, 0.16);
  background-color: var(--surface3);
}
.csel-trigger:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent2);
}
.csel-trigger:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.csel.csel-open .csel-trigger {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent2);
  background-color: var(--surface3);
}
.csel.csel-open .csel-trigger-arrow {
  transform: rotate(180deg);
  background-image: var(--select-arrow-focus);
}

.csel-portal {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 300;
}
.csel-menu {
  position: fixed;
  pointer-events: auto;
  overflow-y: auto;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  animation: cselIn 0.14s ease;
  transform-origin: top center;
}
.csel-menu--acima {
  transform-origin: bottom center;
}
@keyframes cselIn {
  from { opacity: 0; transform: scaleY(0.94) translateY(-2px); }
  to { opacity: 1; transform: none; }
}
.csel-optgroup-label {
  padding: 8px 10px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-family: var(--mono);
  white-space: nowrap;
}
.csel-option {
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  white-space: normal;
  overflow-wrap: break-word;
  line-height: 1.35;
}
.csel-option.is-active {
  background: var(--surface3);
}
.csel-option.is-selected {
  background: var(--accent2);
  color: var(--accent-bright);
  font-weight: 700;
}
.csel-option.is-selected.is-active {
  filter: brightness(1.12);
}
.csel-option[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}
.csel-empty {
  padding: 10px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

input:hover,
textarea:hover {
  border-color: rgba(255, 255, 255, 0.12);
}
input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent2);
  background: var(--surface3);
}

/* Senha e autofill: mesmo visual escuro (evita fundo branco do Chrome) */
input[type="password"]::placeholder {
  color: var(--muted);
  opacity: 0.85;
}
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--surface2) inset !important;
  box-shadow: 0 0 0 1000px var(--surface2) inset !important;
  border: 1px solid var(--border2) !important;
  transition: background-color 99999s ease-out;
}
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--surface3) inset !important;
  box-shadow: 0 0 0 1000px var(--surface3) inset !important;
  border-color: var(--accent) !important;
}
textarea { resize: vertical; min-height: 80px; }

.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.form-actions--row-full {
  grid-column: 1 / -1;
}

.form-field--mb {
  margin-bottom: var(--space-3);
}
.form-field--mb-wide {
  margin-bottom: 20px;
}

.filter-search {
  width: min(240px, 100%);
}

/* ── TOAST ── */
#toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: linear-gradient(135deg, #34d399, var(--ok));
  color: #042018;
  padding: 14px 22px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
  transform: translateY(80px);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.35s ease;
  z-index: 999;
  pointer-events: none;
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(255, 255, 255, 0.15) inset;
}
#toast.show { transform: none; opacity: 1; }

/* ── PROGRESS BAR ── */
.progress-bar { height: 6px; background: var(--border2); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.progress-fill { height: 100%; border-radius: 3px; transition: width .5s ease; }

/* ── AVATAR ── */
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--head);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-3); }

.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ── CHIP ── */
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.chip {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid var(--border2);
  color: var(--muted);
  transition: all .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active {
  background: linear-gradient(135deg, var(--accent2), rgba(0, 168, 90, 0.1));
  border-color: rgba(61, 220, 132, 0.45);
  color: var(--accent-bright);
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(16px, 2vw, 24px);
}

.three-col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(16px, 2vw, 24px);
}

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

@media (max-width: 1400px) {
  .three-col { grid-template-columns: 1fr; }
}

/* ── MODAL ── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(4, 6, 10, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, transparent 35%), var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  width: 480px;
  max-width: 90vw;
  padding: 28px 30px;
  animation: fadeIn 0.28s ease;
  box-shadow: var(--shadow-lg);
}
.modal-title {
  font-family: var(--head);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  letter-spacing: -0.008em;
  line-height: 1.3;
}
.modal--wide {
  max-width: 960px;
  width: min(92vw, 960px);
}

/* ── Modal de confirmação genérica (ações destrutivas/irreversíveis) ──
   z-index acima dos outros modais: é aberto por cima do modal de detalhe. */
#modal-confirmacao {
  z-index: 200;
}
.modal--confirmacao {
  width: 420px;
  text-align: center;
}
.modal--confirmacao .modal-title {
  text-align: center;
}
.modal-confirmacao-icone {
  width: 46px;
  height: 46px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--head);
  font-size: 22px;
  font-weight: 800;
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(255, 107, 107, 0.3);
}
.modal-confirmacao-msg {
  color: var(--text-soft);
  font-size: 13.5px;
  line-height: 1.55;
  margin: 0 0 24px;
}
.modal--confirmacao .form-actions {
  justify-content: center;
  margin-top: 0;
}
.lanc-detalhe-resumo { margin-bottom: 0.75rem; }
.lanc-detalhe-rodopar { margin-bottom: 0.5rem; }
.lanc-detalhe-rodopar-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: none;
  overflow: visible;
}
.lanc-detalhe-rodopar-item {
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.12);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}
.lanc-detalhe-rodopar-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  font-size: 11px;
  line-height: 1.3;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border2);
  color: var(--muted);
  font-weight: 500;
  background: rgba(0, 0, 0, 0.1);
}
.lanc-detalhe-rodopar-ix {
  color: var(--text, #e5e7eb);
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.02em;
}
.lanc-detalhe-rodopar-head .mono { color: #f3f4f6; font-size: 12px; font-weight: 600; }
.lanc-detalhe-rodopar-head-muted {
  margin-left: auto;
  font-size: 10px;
  color: var(--muted);
}
.lanc-detalhe-rodopar-body { padding: 8px 10px 10px; }
.lanc-detalhe-rodopar-body .conferencia-detalhe-dl { margin: 0; }
#modal-detalhe-lancamento-rodopar .section-label--rodopar {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  opacity: 0.9;
}

/* Rodopar: cartão denso, dados organizados (topo + grelha + fila de estados) */
.rodopar-resumo { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.rodopar-painel--resumo {
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.14);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04);
  overflow: hidden;
}
.rodopar-painel--dense .rodopar-resumo-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border2);
  background: rgba(0, 0, 0, 0.12);
}
.rodopar-painel--dense .rodopar-docline {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  color: #f3f4f6;
  flex: 1;
  min-width: 0;
}
.rodopar-resumo-when {
  margin: 0;
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.rodopar-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  border-bottom: 1px solid var(--border2);
}
@media (max-width: 600px) {
  .rodopar-metrics { grid-template-columns: 1fr; }
}
.rodopar-metric {
  padding: 8px 10px;
  min-width: 0;
  border-left: 1px solid var(--border2);
}
.rodopar-metric:first-child { border-left: 0; }
@media (max-width: 600px) {
  .rodopar-metric { border-left: 0; border-top: 1px solid var(--border2); }
  .rodopar-metric:first-child { border-top: 0; }
}
.rodopar-metric__k {
  display: block;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 3px;
  line-height: 1.3;
}
.rodopar-metric__campo { font-weight: 500; text-transform: none; letter-spacing: 0.01em; color: #a5b4fc; }
.rodopar-metric__v {
  display: block;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  color: #f9fafb;
  word-break: break-word;
}
.rodopar-badge-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.06);
}
.rodopar-badge-pair { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.rodopar-badge-pair__l { font-size: 10px; color: var(--muted); font-weight: 500; }
.rodopar-badge-pair .badge { font-size: 10px; padding: 2px 7px; }
.rodopar-erp-dump { margin: 0; }
.rodopar-erp-dump__sum {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  list-style: none;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: #e5e7eb;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--border2);
  border-radius: 6px;
  user-select: none;
}
.rodopar-erp-dump__sum::marker { content: ''; }
.rodopar-erp-dump__sum::-webkit-details-marker { display: none; }
.rodopar-erp-dump__sum-tit { font-family: var(--head); }
.rodopar-erp-dump__sum-n {
  font-weight: 600;
  color: #a1a1aa;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.2);
}
.rodopar-erp-dump[open] .rodopar-erp-dump__sum { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.rodopar-erp-dump__leg {
  margin: 0;
  padding: 5px 10px 6px;
  font-size: 10px;
  line-height: 1.4;
  color: #9ca3af;
  background: rgba(0, 0, 0, 0.12);
  border: 1px solid var(--border2);
  border-top: 0;
}
.rodopar-erp-dump__leg .leg-violeta { color: #a78bfa; }
.rodopar-erp-dump__leg .leg-verde { color: #34d399; }
.rodopar-sem-dump { margin: 0; font-size: 11px; }
.rodopar-code { font-size: 0.95em; }
.rodopar-dump__body--table {
  overflow: visible;
  border: 1px solid var(--border2);
  border-radius: 0 0 6px 6px;
  border-top: 0;
  background: rgba(0, 0, 0, 0.18);
}
.rodopar-sql-scroll { margin: 0; min-width: 0; }
.rodopar-sql-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  line-height: 1.4;
  margin: 0;
}
.rodopar-sql-th-k { width: 34%; }
.rodopar-sql-th-v { width: 66%; }
.rodopar-sql-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
  padding: 6px 8px 6px 10px;
  background: rgba(22, 22, 28, 0.98);
  border-bottom: 1px solid var(--border2);
}
.rodopar-sql-table tbody tr.rodopar-sql-row:nth-child(odd) { background: rgba(255, 255, 255, 0.02); }
.rodopar-sql-table tbody tr.rodopar-sql-row:hover { background: rgba(99, 102, 241, 0.05); }
.rodopar-sql-k {
  padding: 5px 6px 5px 10px;
  vertical-align: top;
  color: #9ca3af;
  font-size: 11px;
  font-weight: 500;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  word-break: break-word;
}
.rodopar-sql-v {
  padding: 5px 10px 5px 8px;
  vertical-align: top;
  color: #f3f4f6;
  font-size: 12px;
  font-weight: 500;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  word-break: break-word;
}
.rodopar-sql-cel--tot.rodopar-sql-k,
.rodopar-sql-cel--tot.rodopar-sql-v { box-shadow: inset 3px 0 0 0 #818cf8; }
.rodopar-sql-cel--ref.rodopar-sql-k,
.rodopar-sql-cel--ref.rodopar-sql-v { box-shadow: inset 3px 0 0 0 #34d399; }
.rodopar-sql-cel--tot.rodopar-sql-cel--ref.rodopar-sql-k,
.rodopar-sql-cel--tot.rodopar-sql-cel--ref.rodopar-sql-v {
  box-shadow: inset 3px 0 0 0 #818cf8, inset 6px 0 0 0 #34d399;
}
.rodopar-sql-cel--muted.rodopar-sql-v { color: #9ca3af; opacity: 0.7; }
.lanc-detalhe-resumo-grid {
  display: grid;
  grid-template-columns: minmax(120px, auto) 1fr;
  gap: 0.4rem 1.25rem;
  align-items: baseline;
  font-size: 0.9rem;
}
#modal-detalhe-lancamento .lanc-detalhe-resumo--modal {
  grid-template-columns: auto 1fr auto 1fr;
  gap: 0.25rem 0.75rem;
  font-size: 0.82rem;
  line-height: 1.35;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.1);
}
#modal-detalhe-lancamento .lanc-detalhe-k { font-size: 11px; }
#modal-detalhe-lancamento .lanc-detalhe-v { font-size: 12px; }
.lanc-detalhe-k { color: var(--muted); }
.lanc-detalhe-v { min-width: 0; }
.lanc-detalhe-table-wrap { max-height: none; overflow: visible; }
#modal-detalhe-lancamento .lanc-detalhe-table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}
#modal-detalhe-lancamento .modal--wide {
  padding: 12px 14px 14px;
  max-width: min(96vw, 1120px);
  width: min(96vw, 1120px);
  max-height: min(92vh, 900px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#modal-detalhe-lancamento .modal--wide .modal-title {
  flex-shrink: 0;
}
#modal-detalhe-lancamento .modal--wide .form-actions { flex-shrink: 0; }
#modal-detalhe-lancamento .lanc-detalhe-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
  padding-bottom: 20px;
  scroll-padding-bottom: 16px;
}
#modal-detalhe-lancamento .modal-title { font-size: 15px; margin-bottom: 8px; }

#modal-detalhe-lancamento-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.lanc-detalhe-edit {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}
.form-grid-modal-edit {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.form-grid-modal-edit .full {
  grid-column: 1 / -1;
}
#modal-detalhe-lancamento .modal-edit-cte-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#modal-detalhe-lancamento .modal-edit-cte-wrap .modal-edit-cte-line {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: var(--bg-elevated);
}

/* Rodopar: tabela unificada no modal */
.table-rodopar-modal {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  line-height: 1.35;
  border: 1px solid var(--border2);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.1);
}
.table-rodopar-modal thead th {
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--border2);
  white-space: nowrap;
}
.table-rodopar-modal tbody td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border2);
  vertical-align: middle;
}
.table-rodopar-modal tbody tr:last-child td { border-bottom: 0; }
.table-rodopar-modal .th-ix,
.table-rodopar-modal .tr-ix { width: 1.75rem; text-align: center; }

.th-rodopar-acoes,
.td-rodopar-acoes {
  width: 1%;
  white-space: nowrap;
  text-align: center;
  vertical-align: middle;
}

.td-rodopar-acoes .btn-sm {
  font-weight: 600;
}

.rodopar-resumo-acoes {
  margin-top: 10px;
}

.rodopar-acoes-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}

.rodopar-acoes-stack .btn-sm {
  width: 100%;
  box-sizing: border-box;
}
.td-rodopar-doc { min-width: 7rem; }
.td-rodopar-num { white-space: nowrap; }
.td-rodopar-erp { min-width: 8.5rem; }
.tag-campo-erp {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  margin-right: 4px;
  border-radius: 3px;
  background: rgba(99, 102, 241, 0.22);
  color: #c4b5fd;
  vertical-align: middle;
}
.td-rodopar-badges .badge { font-size: 9px; padding: 2px 5px; }
.td-rodopar-when { font-size: 10px; color: var(--muted); white-space: nowrap; }
.td-rodopar-aviso { font-size: 11px; color: #f87171; padding: 8px; }
.tr-rodopar-sub .td-rodopar-subcell {
  padding: 0 6px 6px 8px;
  background: rgba(0, 0, 0, 0.06);
  border-top: 0;
}
.rodopar-modal-wrap { margin: 0; }

/** Tabela Rodopar no modal: muitas colunas — scroll horizontal local para não cortar Ações. */
#modal-detalhe-lancamento-rodopar .rodopar-modal-wrap {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  margin-bottom: 2px;
}
#modal-detalhe-lancamento-rodopar .table-rodopar-modal {
  width: max-content;
  min-width: 100%;
  max-width: none;
  overflow: visible;
}
#modal-detalhe-lancamento-rodopar .th-rodopar-acoes,
#modal-detalhe-lancamento-rodopar .td-rodopar-acoes {
  min-width: 9.25rem;
  width: auto;
  position: sticky;
  right: 0;
  z-index: 1;
  background: var(--surface2);
  box-shadow: -6px 0 12px rgba(0, 0, 0, 0.35);
}
#modal-detalhe-lancamento-rodopar .table-rodopar-modal thead .th-rodopar-acoes {
  background: var(--surface3);
  z-index: 2;
}
#modal-detalhe-lancamento-rodopar .tr-rodopar-sub .rodopar-erp-dump { margin: 0; }
#modal-detalhe-lancamento-rodopar .tr-rodopar-sub .rodopar-erp-dump__sum { font-size: 11px; padding: 5px 8px; }
#modal-detalhe-lancamento-rodopar .tr-rodopar-sub .rodopar-erp-dump__leg { font-size: 9px; padding: 4px 8px; }
#modal-detalhe-lancamento-rodopar .tr-rodopar-sub .rodopar-dump__body--table { border-radius: 0 0 4px 4px; }
.table-lancamentos tbody tr.tr--clickable-lanc { cursor: pointer; }
.table-lancamentos tbody tr.tr--clickable-lanc:hover { background: rgba(255, 255, 255, 0.04); }
.card--prejuizo-detalhe { margin-top: 0.25rem; }
.card--prejuizo-detalhe .card-header--prejuizo-detalhe {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 2px;
  padding: 6px 12px 8px 14px;
  border-bottom: 1px solid var(--border2);
  background: rgba(0, 0, 0, 0.1);
}
.card--prejuizo-detalhe .card-header--prejuizo-detalhe .card-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
  letter-spacing: -0.01em;
}
.prejuizo-hint {
  margin: 0;
  font-size: 10.5px;
  line-height: 1.3;
  font-weight: 500;
  color: var(--muted);
  max-width: 100%;
  text-align: left;
}
.table-wrap--prejuizo-detalhe {
  padding: 0 0 2px;
}
.table-prejuizo-detalhe {
  width: 100%;
  font-size: 12px;
  line-height: 1.3;
  border-collapse: collapse;
}
.table-prejuizo-detalhe thead th {
  padding: 5px 8px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border2);
  background: rgba(0, 0, 0, 0.12);
  white-space: nowrap;
}
.table-prejuizo-detalhe tbody td {
  padding: 4px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
}
.table-prejuizo-detalhe tbody tr:last-child td { border-bottom: 0; }
.table-prejuizo-detalhe .btn-sm { font-size: 10px; padding: 2px 8px; }
.table-prejuizo-detalhe .prejuizo-empty { font-size: 11px; padding: 8px; line-height: 1.35; }

/* ── TIMELINE ── */
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: flex; gap: 14px; padding-bottom: 18px; position: relative; }
.tl-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 13px;
  top: 28px;
  bottom: 0;
  width: 1px;
  background: var(--border);
}
.tl-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}
.tl-content { flex: 1; }
.tl-title { font-size: 13px; font-weight: 500; }
.tl-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* toggle switch */
.toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.toggle-input { display: none; }
.toggle-track {
  width: 36px; height: 20px;
  background: var(--border2);
  border-radius: 10px;
  position: relative;
  transition: background .2s;
}
.toggle-input:checked + .toggle-track { background: var(--accent); }
.toggle-thumb {
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  position: absolute;
  top: 3px; left: 3px;
  transition: transform .2s;
}
.toggle-input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
  font-family: var(--mono);
}
.tag--accent { background: var(--accent2); color: var(--accent-bright); }
.tag--purple { background: var(--purple-bg); color: var(--purple); }
.tag--ok { background: var(--ok-bg); color: var(--ok); }
.tag--warn { background: var(--warn-bg); color: var(--warn); }

/* ── Tons de texto (valores / status) ── */
.tone-ok { color: var(--ok); }
.tone-warn { color: var(--warn); }
.tone-danger { color: var(--danger); }
.tone-muted { color: var(--muted); }
.tone-accent { color: var(--accent-bright); }

/* ── Dashboard: progresso ── */
.dashboard-progress-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}
@media (max-width: 768px) {
  .dashboard-progress-grid {
    grid-template-columns: 1fr;
  }
}
.progress-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: var(--space-1);
}
.progress-stat-row strong {
  font-weight: 600;
}
.progress-fill--ok { width: 88%; background: var(--ok); }
.progress-fill--danger { width: 4%; background: var(--danger); }
.progress-fill--warn { width: 7%; background: var(--warn); }

/* ── Timeline: dots por estado ── */
.tl-dot--danger { background: var(--danger-bg); color: var(--danger); }
.tl-dot--ok { background: var(--ok-bg); color: var(--ok); }
.tl-dot--accent { background: var(--accent2); color: var(--accent-bright); }
.tl-dot--warn { background: var(--warn-bg); color: var(--warn); }

/* ── Chips (filtros confronto) ── */
.chip--ok {
  border-color: var(--ok-bg);
  color: var(--ok);
}
.chip--danger {
  border-color: var(--danger-bg);
  color: var(--danger);
}
.chip--warn {
  border-color: var(--warn-bg);
  color: var(--warn);
}

/* ── Modal ── */
.modal-alert {
  margin-bottom: var(--space-3);
  padding: 14px 18px;
  background: var(--danger-bg);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 107, 107, 0.45);
}
.modal-alert__kicker {
  color: var(--danger);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.modal-alert__title {
  font-weight: 600;
  margin-top: 4px;
  color: var(--text);
}
.modal-alert__meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}
.modal-alert__meta .tone-danger {
  font-weight: 600;
}

/* ── Confronto: filtro topo ── */
.filter-card--confronto {
  margin-bottom: 20px;
}

/* ── Dashboard: barra de filtros alinhada ── */
.filter-card--dashboard {
  margin-bottom: var(--space-3);
}
.filter-card--dashboard .card-body--compact {
  padding: 14px 16px 12px;
}
.dash-filters {
  display: grid;
  grid-template-columns:
    minmax(132px, 150px)
    minmax(132px, 150px)
    minmax(140px, 1fr)
    minmax(160px, 1.2fr)
    minmax(160px, 1.2fr)
    auto;
  gap: 10px 12px;
  align-items: end;
}
.dash-filters__field,
.dash-filters__actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  margin: 0;
  /* anula estilo global de `label` (mono / uppercase no contentor) */
  font-family: var(--body);
  font-size: inherit;
  letter-spacing: normal;
  text-transform: none;
  color: inherit;
}
.dash-filters__lab {
  display: block;
  height: 14px;
  line-height: 14px;
  font-family: var(--body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.dash-filters__lab--spacer {
  visibility: hidden;
  user-select: none;
}
.dash-filters__control {
  width: 100%;
  height: var(--input-min-h);
  min-height: var(--input-min-h);
  max-height: var(--input-min-h);
  box-sizing: border-box;
  margin: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background-color: var(--surface2);
  color: var(--text);
  font-family: var(--body);
  font-size: 13px;
  line-height: 1.2;
  outline: none;
}
input.dash-filters__control[type="date"] {
  padding: 0 12px;
  appearance: none;
  -webkit-appearance: none;
  border-radius: 10px;
  font-weight: 500;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
select.dash-filters__control {
  padding: 0 36px 0 12px;
  border-radius: 10px;
  font-weight: 500;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
.dash-filters__control:hover {
  border-color: rgba(255, 255, 255, 0.14);
}
.dash-filters__control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent2);
  background-color: var(--surface3);
}
select.dash-filters__control:focus {
  background-image: var(--select-arrow-focus);
}
.dash-filters__btns {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--input-min-h);
}
.dash-filters__btns .btn {
  height: var(--input-min-h);
  padding-left: 14px;
  padding-right: 14px;
  white-space: nowrap;
}
.dash-filters__hint {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.4;
}
@media (max-width: 1100px) {
  .dash-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .dash-filters__actions {
    grid-column: 1 / -1;
  }
}
@media (max-width: 640px) {
  .dash-filters {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── Formulário NF (2 colunas) ── */
.form-grid--nf {
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.form-field--mt {
  margin-top: var(--space-3);
}
.form-field--hint {
  margin-top: var(--space-2);
}

.form-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

/* ── Sidebar meta ── */
.sidebar-role {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

/* ── Tabela: permissões ── */
.th-center { text-align: center; }
.td-center { text-align: center; }

/* ── Cadastro usuários: células ── */
.user-cell {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.user-cell__name {
  font-weight: 600;
  color: var(--text);
}
.avatar--demo {
  background: var(--accent2);
  color: var(--accent-bright);
}
.avatar--local {
  background: var(--ok-bg);
  color: var(--ok);
}
.mono-faint {
  font-size: 12px;
  color: var(--text-soft);
}
.badge--neutral {
  background: var(--surface2);
  color: var(--muted);
}

/* Conferência ERP */
.card--conferencia {
  margin-top: 1.25rem;
}
.card-header--conferencia {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.conferencia-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.conferencia-resumo {
  margin-bottom: 1.25rem;
}
.conferencia-resumo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px 20px;
}
.conferencia-resumo-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.conferencia-resumo-item .k {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-family: var(--mono);
}
.conferencia-resumo-item .v {
  font-size: 1rem;
}
.table-conferencia {
  width: 100%;
  font-size: 13px;
}
#conferencia-panel .table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
#conferencia-panel .table-conferencia {
  width: max-content;
  min-width: 100%;
}
#conferencia-panel .th-acoes-conf,
#conferencia-panel .td-rodopar-acoes {
  min-width: 9rem;
}
#conferencia-panel .td-rodopar-acoes {
  position: sticky;
  right: 0;
  z-index: 1;
  background: var(--surface2);
  box-shadow: -6px 0 10px rgba(0, 0, 0, 0.3);
}
#conferencia-panel .table-conferencia thead .th-acoes-conf {
  background: var(--surface3);
  z-index: 2;
}
.conferencia-detalhe-cell {
  background: var(--surface2);
  border-top: none !important;
  padding: 12px 16px 16px !important;
  vertical-align: top;
}
.conferencia-detalhe-dl {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px 16px;
  margin: 0;
}
.conferencia-detalhe-pair {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
}
.conferencia-detalhe-dl-destaque {
  font-weight: 600;
  color: var(--accent-bright);
}
.conferencia-detalhe-dl-campo dt {
  color: var(--ok);
  font-weight: 600;
}
.badge-conferencia-lucro {
  background: rgba(22, 163, 74, 0.22);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.45);
  font-weight: 600;
}
.badge-conferencia-prejuizo {
  background: rgba(220, 38, 38, 0.22);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.5);
  font-weight: 600;
}
.badge-conferencia-empate {
  background: var(--surface3);
  color: #9ca3af;
  border: 1px solid var(--border);
}
.badge-conferencia-divergente {
  background: rgba(234, 88, 12, 0.2);
  color: #fb923c;
  border: 1px solid rgba(249, 115, 22, 0.5);
  font-weight: 600;
}
.badge-conferencia-nao {
  background: rgba(234, 179, 8, 0.2);
  color: #facc15;
  border: 1px solid rgba(234, 179, 8, 0.45);
  font-weight: 600;
}
.badge-conferencia-erro {
  background: var(--surface3);
  color: #9ca3af;
  border: 1px solid var(--border);
  font-weight: 600;
}
/* Conferência — coluna ERP (lançado vs Rodopar) */
.badge-erp-confirmado {
  background: rgba(22, 163, 74, 0.22);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.45);
  font-weight: 600;
}
.badge-erp-divergente {
  background: #FFEDD5;
  color: #9A3412;
  border: 1px solid #FB923C;
  font-weight: 600;
}
.badge-erp-nao {
  background: #FEF9C3;
  color: #854D0E;
  border: 1px solid #FDE047;
  font-weight: 600;
}
.badge-erp-erro {
  background: var(--surface3);
  color: #9ca3af;
  border: 1px solid var(--border);
  font-weight: 600;
}
.badge-erp-neutro {
  background: var(--surface3);
  color: #9ca3af;
  border: 1px solid var(--border);
  font-weight: 500;
}
.conferencia-nao-encontrado-msg {
  color: #facc15;
  font-size: 13px;
  line-height: 1.45;
}

/* ── Scrollbar (refino) ── */
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* ══════════════════════════════════════════════════════════════
   TEMA CLARO — só dentro da aplicação (nunca no ecrã de login).
   O seletor exige `.app-visible` de propósito: garante que a tela
   de login continua sempre escura, mesmo que a preferência de
   tema claro fique guardada de uma sessão anterior.
   ══════════════════════════════════════════════════════════════ */
body.app-visible.theme-light {
  color-scheme: light;
  --bg:         #f3f4f7;
  --bg-elevated:#ffffff;
  --surface:    #ffffff;
  --surface2:   #f3f5f8;
  --surface3:   #e9ecf1;
  --border:     rgba(15, 23, 42, 0.08);
  --border2:    rgba(15, 23, 42, 0.14);
  --text:       #171a21;
  --text-soft:  #4b5266;
  --muted:      #6b7280;
  --shadow-sm:  0 2px 8px rgba(15, 23, 42, 0.08);
  --shadow-md:  0 8px 32px rgba(15, 23, 42, 0.1);
  --shadow-lg:  0 24px 64px rgba(15, 23, 42, 0.14);
  /* Tons "vivos" (accent/ok/warn/danger/purple) foram pensados para brilhar
     sobre fundo quase-preto — sobre branco ficam claros demais e o texto
     some. Versões mais escuras/saturadas, com contraste adequado. */
  --accent:       #0a8f52;
  --accent-bright:#087a44;
  --accent2:      rgba(10, 143, 82, 0.12);
  --accent-glow:  rgba(10, 143, 82, 0.22);
  --ok:           #0a7d47;
  --ok-bg:        rgba(10, 125, 71, 0.12);
  --warn:         #b45309;
  --warn-bg:      rgba(180, 83, 9, 0.12);
  --danger:       #dc2626;
  --danger-bg:    rgba(220, 38, 38, 0.1);
  --purple:       #7c3aed;
  --purple-bg:    rgba(124, 58, 237, 0.1);
  --pro-secondary:     #55627a;
  --pro-secondary-bg:  rgba(85, 98, 122, 0.1);
  --pro-secondary-bdr: rgba(85, 98, 122, 0.3);
}

/* Overlays pensados para superfícies escuras (branco translúcido) precisam
   da versão espelhada (escuro translúcido) para continuarem visíveis sobre
   fundo claro — o resto herda das variáveis acima e já se ajusta sozinho. */
body.app-visible.theme-light .btn-ghost {
  background: rgba(15, 23, 42, 0.035);
}
body.app-visible.theme-light .btn-ghost:hover {
  background: rgba(15, 23, 42, 0.06);
  border-color: rgba(15, 23, 42, 0.18);
}
body.app-visible.theme-light .nav-item:hover {
  background: rgba(15, 23, 42, 0.05);
}
body.app-visible.theme-light .cadastro-tab:hover {
  background: rgba(15, 23, 42, 0.035);
}
body.app-visible.theme-light .cte-toolbar .btn-sm {
  background: rgba(15, 23, 42, 0.035);
}
body.app-visible.theme-light .cte-toolbar .btn-sm:hover {
  background: rgba(15, 23, 42, 0.06);
  border-color: rgba(15, 23, 42, 0.18);
}
body.app-visible.theme-light .cte-line:hover {
  border-color: rgba(15, 23, 42, 0.14);
}
body.app-visible.theme-light .cte-erp-opt:hover .cte-erp-opt-label {
  background: rgba(15, 23, 42, 0.05);
}
body.app-visible.theme-light .kpi:hover {
  border-color: rgba(15, 23, 42, 0.12);
}
body.app-visible.theme-light .card:hover {
  border-color: rgba(15, 23, 42, 0.1);
}
body.app-visible.theme-light .table-lancamentos tbody tr:nth-child(even) {
  background: rgba(15, 23, 42, 0.02);
}
body.app-visible.theme-light .table-lancamentos tbody tr:hover {
  background: rgba(15, 23, 42, 0.035);
}
body.app-visible.theme-light .table-lancamentos tbody tr.tr--clickable-lanc:hover {
  background: rgba(15, 23, 42, 0.03);
}
body.app-visible.theme-light .table-prejuizo-detalhe tbody td {
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}
body.app-visible.theme-light .filter-row input:hover,
body.app-visible.theme-light input:hover,
body.app-visible.theme-light textarea:hover,
body.app-visible.theme-light select:hover,
body.app-visible.theme-light .csel-trigger:hover {
  border-color: rgba(15, 23, 42, 0.18);
}
body.app-visible.theme-light select:hover {
  background-color: var(--surface3);
}
body.app-visible.theme-light ::-webkit-scrollbar-thumb:hover {
  background: rgba(15, 23, 42, 0.18);
}

/* Cabeçalhos de card/tabela usavam um véu preto pensado para destacar sobre
   fundo escuro (quase imperceptível lá); sobre branco isso virava uma barra
   cinza pesada. Troca por um véu escuro bem mais leve, mesmo espírito visual. */
body.app-visible.theme-light .card-header {
  background: rgba(15, 23, 42, 0.035);
}
body.app-visible.theme-light thead th {
  background: rgba(15, 23, 42, 0.045);
}
body.app-visible.theme-light .table-prejuizo-detalhe thead th {
  background: rgba(15, 23, 42, 0.035);
}
body.app-visible.theme-light .table-rodopar-modal {
  background: rgba(15, 23, 42, 0.025);
}
body.app-visible.theme-light .table-rodopar-modal thead th {
  background: rgba(15, 23, 42, 0.045);
}
body.app-visible.theme-light #modal-detalhe-lancamento .lanc-detalhe-resumo--modal {
  background: rgba(15, 23, 42, 0.035);
}

/* ── Botão primário: o degradê verde-neon com brilho (pensado para se
   destacar sobre fundo quase-preto) destoa sobre branco — versão sóbria,
   sólida, sem halo colorido. ── */
body.app-visible.theme-light .btn-primary {
  background: linear-gradient(135deg, #12a86a 0%, #0a8f52 55%, #06703d 100%);
  border-color: rgba(15, 23, 42, 0.08);
  box-shadow: 0 2px 10px rgba(10, 143, 82, 0.22);
}
body.app-visible.theme-light .btn-primary:hover {
  box-shadow: 0 4px 16px rgba(10, 143, 82, 0.3);
}
body.app-visible.theme-light .chip.active {
  background: linear-gradient(135deg, var(--accent2), rgba(10, 143, 82, 0.08));
  border-color: rgba(10, 143, 82, 0.4);
}

/* ── Badges/etiquetas com cor fixa em hex/rgba (não usam variável) ──
   Mesmo problema: tons claros para "brilhar" no escuro ficam ilegíveis
   sobre branco. Troca por pares escuro-sobre-claro, no mesmo espírito que
   já existia em badge-erp-divergente/badge-erp-nao. */
body.app-visible.theme-light .badge-conferencia-lucro,
body.app-visible.theme-light .badge-erp-confirmado {
  background: #dcfce7;
  color: #15803d;
  border-color: #86efac;
}
body.app-visible.theme-light .badge-conferencia-prejuizo {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}
body.app-visible.theme-light .badge-conferencia-divergente {
  background: #ffedd5;
  color: #9a3412;
  border-color: #fb923c;
}
body.app-visible.theme-light .badge-conferencia-nao {
  background: #fef9c3;
  color: #854d0e;
  border-color: #fde047;
}
body.app-visible.theme-light .badge-conferencia-empate,
body.app-visible.theme-light .badge-conferencia-erro,
body.app-visible.theme-light .badge-erp-erro,
body.app-visible.theme-light .badge-erp-neutro {
  background: #e5e7eb;
  color: #4b5563;
  border-color: #d1d5db;
}

/* Segmento CT-e / NF-e selecionado (formulário de lançamento) */
body.app-visible.theme-light .cte-erp-opt:has(input:checked) .cte-erp-opt-label[data-erp-tipo='cte'] {
  color: #0a7d47;
  background: rgba(10, 143, 82, 0.14);
  box-shadow: 0 0 0 1px rgba(10, 143, 82, 0.4) inset, 0 1px 2px rgba(15, 23, 42, 0.06);
}
body.app-visible.theme-light .cte-erp-opt:has(input[value='nf']:checked) .cte-erp-opt-label[data-erp-tipo='nf'] {
  color: #3d4657;
}
body.app-visible.theme-light .erp-type-tag--cte {
  color: #0a7d47;
}
body.app-visible.theme-light .tag-campo-erp {
  background: rgba(79, 70, 229, 0.12);
  color: #4338ca;
}
body.app-visible.theme-light .td-rodopar-aviso {
  color: #b91c1c;
}
body.app-visible.theme-light .conferencia-nao-encontrado-msg {
  color: #92400e;
}

/* KPIs: valores em tom claro (pop sobre fundo escuro) ficam ilegíveis
   sobre cartão branco — mesma cor-base, versão escura o suficiente. */
body.app-visible.theme-light .kpi.danger .kpi-value {
  color: #dc2626;
}
body.app-visible.theme-light .kpi.ok .kpi-value {
  color: #0a7d47;
}
body.app-visible.theme-light .kpi.warn .kpi-value {
  color: #b45309;
}

/* ── Painéis de dados técnicos do Rodopar/ERP (resumo denso + dump SQL) ──
   Usam texto claro fixo (pensado só para fundo escuro), por isso mantêm-se
   sempre escuros, tal como o sidebar — trocar só o fundo deixaria o texto
   praticamente ilegível sobre um fundo claro. */
body.app-visible.theme-light .rodopar-painel--resumo,
body.app-visible.theme-light .rodopar-erp-dump {
  --bg-elevated:#0c0e12;
  --surface:    #12141a;
  --surface2:   #181b22;
  --surface3:   #1e222b;
  --border:     rgba(255, 255, 255, 0.06);
  --border2:    rgba(255, 255, 255, 0.1);
  --text:       #f0f2f7;
  --text-soft:  #b8bcc8;
  --muted:      #7a8194;
  --accent:       #0aa85a;
  --accent-bright:#3ddc84;
  --accent2:      rgba(0, 168, 90, 0.16);
  --accent-glow:  rgba(0, 168, 90, 0.38);
  --ok:           #2ee59d;
  --ok-bg:        rgba(46, 229, 157, 0.1);
  --warn:         #ffb547;
  --warn-bg:      rgba(255, 181, 71, 0.1);
  --danger:       #ff6b6b;
  --danger-bg:    rgba(255, 107, 107, 0.1);
  --purple:       #b4a3ff;
  --purple-bg:    rgba(180, 163, 255, 0.1);
  background: #12141a;
  color-scheme: dark;
}
body.app-visible.theme-light .rodopar-painel--resumo .btn-ghost,
body.app-visible.theme-light .rodopar-erp-dump .btn-ghost {
  background: rgba(255, 255, 255, 0.03);
}
body.app-visible.theme-light .rodopar-painel--resumo .btn-ghost:hover,
body.app-visible.theme-light .rodopar-erp-dump .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.18);
}
body.app-visible.theme-light .rodopar-sql-table thead th {
  background: rgba(22, 22, 28, 0.98);
}
/* Os badges de resultado (LUCRO/PREJUÍZO/...) usam cor fixa, não variável —
   dentro deste painel sempre escuro, mantêm exatamente o tom original. */
body.app-visible.theme-light .rodopar-painel--resumo .badge-conferencia-lucro,
body.app-visible.theme-light .rodopar-painel--resumo .badge-erp-confirmado {
  background: rgba(22, 163, 74, 0.22);
  color: #22c55e;
  border-color: rgba(34, 197, 94, 0.45);
}
body.app-visible.theme-light .rodopar-painel--resumo .badge-conferencia-prejuizo {
  background: rgba(220, 38, 38, 0.22);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.5);
}
body.app-visible.theme-light .rodopar-painel--resumo .badge-conferencia-divergente {
  background: rgba(234, 88, 12, 0.2);
  color: #fb923c;
  border-color: rgba(249, 115, 22, 0.5);
}
body.app-visible.theme-light .rodopar-painel--resumo .badge-conferencia-nao {
  background: rgba(234, 179, 8, 0.2);
  color: #facc15;
  border-color: rgba(234, 179, 8, 0.45);
}
body.app-visible.theme-light .rodopar-painel--resumo .badge-conferencia-empate,
body.app-visible.theme-light .rodopar-painel--resumo .badge-conferencia-erro,
body.app-visible.theme-light .rodopar-painel--resumo .badge-erp-erro,
body.app-visible.theme-light .rodopar-painel--resumo .badge-erp-neutro {
  background: var(--surface3);
  color: #9ca3af;
  border-color: var(--border);
}

/* ── Sidebar: mantém-se sempre escura, independente do tema ── */
body.app-visible.theme-light aside {
  --bg-elevated:#0c0e12;
  --surface:    #12141a;
  --surface2:   #181b22;
  --surface3:   #1e222b;
  --border:     rgba(255, 255, 255, 0.06);
  --border2:    rgba(255, 255, 255, 0.1);
  --text:       #f0f2f7;
  --text-soft:  #b8bcc8;
  --muted:      #7a8194;
  --accent:       #0aa85a;
  --accent-bright:#3ddc84;
  --accent2:      rgba(0, 168, 90, 0.16);
  --accent-glow:  rgba(0, 168, 90, 0.38);
  --ok:           #2ee59d;
  --ok-bg:        rgba(46, 229, 157, 0.1);
  --warn:         #ffb547;
  --warn-bg:      rgba(255, 181, 71, 0.1);
  --danger:       #ff6b6b;
  --danger-bg:    rgba(255, 107, 107, 0.1);
  --purple:       #b4a3ff;
  --purple-bg:    rgba(180, 163, 255, 0.1);
  color-scheme: dark;
}
body.app-visible.theme-light aside .btn-ghost {
  background: rgba(255, 255, 255, 0.03);
}
body.app-visible.theme-light aside .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.18);
}
body.app-visible.theme-light aside .nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
}
