/* ============================================================
   DESIGN SYSTEM — CARTAZ CORPORATIVO
   Baseado em design-system-mapeamento-atividades.html
   Estrutura em camadas fixas:
     1. TOKENS  — variáveis CSS (não alterar sem revisão)
     2. BASE    — reset e tipografia global
     3. COMPONENTES — sidebar, tabela, botões, toast, etc.
   ============================================================ */


/* ============================================================
   1. TOKENS
   ============================================================ */

@font-face {
  font-family: "Komika Axis";
  src: local("Komika Axis"), url("./fonts/KOMIKAX.ttf") format("truetype");
  font-style: normal;
  font-weight: 900;
  font-display: swap;
}

@font-face {
  font-family: "Komika Axis";
  src: local("Komika Axis"), url("./fonts/KOMIKAX.ttf") format("truetype");
  font-style: italic;
  font-weight: 900;
  font-display: swap;
}

:root {
  color-scheme: light;

  /* — Paleta do design system — */
  --navy-900:  #0B1F3A;
  --navy-800:  #12294A;
  --navy-700:  #1C3A5E;
  --navy-500:  #3B6690;
  --gold:      #A9825A;
  --paper:     #F5F6F8;
  --white:     #FFFFFF;
  --line:      #D8DEE6;
  --line-strong: #AEBBC7;
  --ink:       #16232F;
  --ink-muted: #5B6B7A;
  --ink-faint: #8996A3;

  /* — Status — */
  --status-active-bg:     #E7ECF2;
  --status-active-text:   #1C3A5E;
  --status-inactive-bg:   #EEEEEE;
  --status-inactive-text: #8996A3;

  /* — Tipografia — */
  --font-display: 'Spectral', Georgia, serif;
  --font-sans:    'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  --font-mono:    'IBM Plex Mono', Consolas, 'Courier New', ui-monospace, monospace;

  /* — Cores temáticas Fort (usadas nos templates de canvas — NÃO remover) — */
  --fort-red:    #d71920;
  --fort-yellow: #ffd23f;
  --fort-green:  #15803d;
  --fort-blue:   #0f5f9f;

  /* — Sombra — */
  --shadow: 0 12px 32px rgba(11, 31, 58, 0.14);
}


/* ============================================================
   2. BASE
   ============================================================ */

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

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
select,
textarea {
  font: inherit;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
}

p {
  margin: 0;
}


/* ============================================================
   3. COMPONENTES
   ============================================================ */

/* --- Layout geral --- */

.app-shell {
  display: grid;
  grid-template-columns: minmax(330px, 380px) minmax(0, 1fr);
  min-height: 100vh;
}

/* --- Sidebar --- */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  background: var(--navy-900);
  border-right: 1px solid var(--gold);
  overflow-y: auto;
}

/* --- Marca / cabeçalho --- */

.brand {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(169, 130, 90, 0.35);
}

.brand-mark {
  display: block;
  width: 44px;
  height: 44px;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

.brand h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 19px;
  line-height: 1.2;
  color: var(--white);
  letter-spacing: 0.01em;
}

.brand p {
  margin-top: 3px;
  color: #A9B7C6;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Painel com cantos abertos (assinatura do DS) --- */

.panel {
  position: relative;
  display: grid;
  gap: 12px;
  padding: 16px 16px 16px 18px;
  border: none;
  background: transparent;
}

/* Cantos abertos — assinatura visual */
.panel::before,
.panel::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
}

.panel::before {
  top: 0;
  left: 0;
  border-top: 1px solid var(--gold);
  border-left: 1px solid var(--gold);
}

.panel::after {
  bottom: 0;
  right: 0;
  border-bottom: 1px solid var(--gold);
  border-right: 1px solid var(--gold);
}

/* Cantos complementares via wrapper interno */
.panel > .panel-corner-tr,
.panel > .panel-corner-bl {
  display: none; /* usados apenas quando explicitamente adicionados ao HTML */
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-title svg {
  width: 16px;
  height: 16px;
  color: var(--gold);
}

.panel h2 {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: #A9B7C6;
}

/* --- Eyebrow label --- */

.eyebrow {
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--gold);
  margin: 0 0 6px;
}

/* --- Campos de formulário --- */

.field {
  display: grid;
  gap: 5px;
}

.field span,
.mapping-grid span {
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
}

.field input,
.field select,
.mapping-grid input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--white);
  color: var(--ink);
  padding: 7px 10px;
  outline: none;
  font-size: 13px;
  box-sizing: border-box;
}

.field input[type="date"] {
  height: 36px;
  min-height: 36px;
  padding: 0 10px;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

input[type="date"] {
  font-family: var(--font-sans);
  color: var(--ink);
  cursor: pointer;
}

input[type="date"]::-webkit-datetime-edit {
  display: inline-flex;
  align-items: center;
  height: 100%;
  padding: 0;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--ink);
  text-transform: uppercase;
}

input[type="date"]::-webkit-datetime-edit-fields-wrapper {
  padding: 0;
}

input[type="date"]::-webkit-datetime-edit-text {
  color: var(--ink-muted);
  padding: 0 2px;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
  padding: 3px;
  margin-right: -2px;
  filter: brightness(0.2) sepia(1) hue-rotate(185deg) saturate(3);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
  transform: scale(1.08);
}

.field input:focus,
.field select:focus,
.mapping-grid input:focus,
.search input:focus {
  border-color: var(--navy-700);
  box-shadow: 0 0 0 2px rgba(28, 58, 94, 0.18);
}

/* Inputs e selects dentro da sidebar ficam com fundo levemente escurecido */
.sidebar .field input,
.sidebar .field select,
.sidebar .mapping-grid input {
  background: rgba(255, 255, 255, 0.92);
}

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

.mapping-grid label {
  display: grid;
  gap: 5px;
}

.mapping-grid input {
  text-align: center;
  font-weight: 800;
  text-transform: uppercase;
}

/* --- Matriz de 3x para Modelo, Tamanho e Fonte no painel Cartaz --- */
.cartaz-grid-3x {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.cartaz-grid-3x .field {
  min-width: 0;
}

.cartaz-grid-3x .field select {
  font-size: 11.5px;
  padding: 6px 4px;
  text-overflow: ellipsis;
}

/* --- Checkboxes / switches --- */

.switch-row {
  display: grid;
  gap: 9px;
}

.switch-row label {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  color: #B9C4D0;
  font-size: 13px;
  line-height: 1.35;
}

.switch-row input {
  margin-top: 2px;
}

/* --- Botões --- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 0;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  letter-spacing: 0.01em;
  transition: background 0.12s, border-color 0.12s;
}

.button svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.button.primary {
  background: var(--gold);
  color: var(--navy-900);
  border-color: var(--gold);
}

.button.primary:hover {
  background: #c2956a;
  border-color: #c2956a;
}

.button.secondary {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.06);
  color: #D0D8E0;
}

.button.secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* --- Painel de ações — grade 2×2 + CTA --- */

.actions {
  gap: 10px;
}

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

.actions-grid .button {
  font-size: 12px;
  padding: 8px 6px;
  min-height: 36px;
  flex-direction: column;
  gap: 4px;
}

.actions-grid .button svg {
  width: 15px;
  height: 15px;
}

.actions-cta {
  width: 100%;
  font-size: 13px;
  min-height: 42px;
  letter-spacing: 0.04em;
}

/* --- Schema do template CSV (expansível) --- */

.template-schema {
  border-left: 2px solid var(--gold);
  background: rgba(255, 255, 255, 0.04);
}

.template-schema > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--gold);
  user-select: none;
  transition: color 0.12s;
}

.template-schema > summary::-webkit-details-marker { display: none; }

.template-schema > summary::after {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--gold);
  transition: transform 0.18s;
  flex-shrink: 0;
}

.template-schema[open] > summary::after {
  transform: rotate(180deg);
}

.template-schema > summary:hover {
  color: #c2956a;
}

.template-schema-body {
  display: grid;
  gap: 6px;
  padding: 0 12px 12px;
}

.template-schema-body span {
  color: var(--ink-faint);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.template-schema-body code {
  display: block;
  color: #D0D8E0;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.7;
  overflow-wrap: anywhere;
  background: rgba(0,0,0,0.2);
  padding: 8px 10px;
}

/* — Blocos internos de cada formato — */

.schema-block {
  display: grid;
  gap: 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(216, 222, 230, 0.12);
}

.schema-block:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.schema-label {
  font-size: 10px !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.12em !important;
  color: var(--gold) !important;
}

.schema-note {
  font-size: 11px;
  color: var(--ink-faint);
  line-height: 1.5;
  margin: 0;
  font-style: italic;
}

/* — Mapeamento de colunas XLSX — */

.schema-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 8px;
}

.schema-cols > div {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.schema-cols b {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
  min-width: 14px;
}

.schema-cols span {
  font-size: 11.5px !important;
  color: #B9C4D0 !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-weight: 400 !important;
}

.schema-cols em {
  color: var(--ink-faint);
  font-size: 10.5px;
}

/* --- Área de trabalho (canvas + tabela) --- */

.workspace {
  min-width: 0;
  padding: 18px;
}

.preview-region {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  height: calc(100vh - 36px);
  min-height: 620px;
}

/* --- Toolbar (barra de métricas + busca) --- */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
}

.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.metrics span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--white);
  color: var(--ink-muted);
  font-size: 12px;
}

.metrics strong {
  color: var(--ink);
  font-weight: 600;
}

.metric-filter-pill {
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.metric-filter-pill:hover {
  background: #f1f4f8 !important;
  border-color: var(--navy-800) !important;
  color: var(--navy-900) !important;
}

.metric-filter-pill:active {
  transform: translateY(1px);
}

.search {
  display: grid;
  grid-template-columns: 16px minmax(180px, 300px);
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--white);
}

.search svg {
  width: 16px;
  height: 16px;
  color: var(--ink-faint);
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  min-height: 34px;
  font-size: 13px;
  color: var(--ink);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.history-dropdown-wrapper {
  position: relative;
}

.btn-history-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line-strong);
  background: var(--white);
  color: var(--ink-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}

.btn-history-toggle:hover,
.btn-history-toggle.active {
  background: #f1f4f8;
  color: var(--navy-900);
  border-color: var(--navy-800);
}

.btn-history-toggle svg {
  width: 17px;
  height: 17px;
}

.history-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--gold);
  color: var(--navy-900);
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  padding: 0 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.history-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 360px;
  max-width: 90vw;
  background: #ffffff;
  border: 1px solid var(--line-strong);
  box-shadow: 0 12px 28px -4px rgba(15, 23, 42, 0.18), 0 4px 10px -2px rgba(15, 23, 42, 0.08);
  z-index: 1050;
  display: flex;
  flex-direction: column;
}

.history-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #0f172a;
  color: #ffffff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.history-popover-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.history-popover-title svg {
  width: 14px;
  height: 14px;
  color: var(--gold);
}

.btn-clear-history {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 11px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  transition: all 0.15s;
}

.btn-clear-history:hover {
  color: #f87171;
  background: rgba(248, 113, 113, 0.12);
}

.history-list-container {
  max-height: 380px;
  overflow-y: auto;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.12s;
  gap: 10px;
}

.history-item:hover {
  background: #f8fafc;
}

.history-item:last-child {
  border-bottom: none;
}

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

.history-item-title {
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #64748b;
}

.history-item-count {
  display: inline-flex;
  align-items: center;
  background: #e2e8f0;
  color: #334155;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 3px;
}

.btn-history-delete {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
  transition: all 0.15s;
}

.btn-history-delete:hover {
  opacity: 1;
  color: #ef4444;
  background: #fee2e2;
}

.btn-history-delete svg {
  width: 14px;
  height: 14px;
}

.history-empty {
  padding: 24px 16px;
  text-align: center;
  color: #64748b;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.history-empty svg {
  width: 24px;
  height: 24px;
  color: #cbd5e1;
}

/* --- Layout canvas + tabela --- */

.preview-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.85fr) minmax(440px, 1.15fr);
  gap: 16px;
  min-height: 0;
}

.poster-stage {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 16px;
  border: 1px solid var(--line);
  background:
    linear-gradient(45deg, rgba(11, 31, 58, 0.04) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(11, 31, 58, 0.04) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(11, 31, 58, 0.04) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(11, 31, 58, 0.04) 75%),
    var(--paper);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

#posterCanvas {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 140px);
  width: auto;
  height: auto;
  background: var(--white);
  box-shadow: var(--shadow);
}

/* --- Tabela de produtos --- */

.table-region {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--white);
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}

thead {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--paper);
  box-shadow: inset 0 -1px 0 var(--line-strong);
}

th,
td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

/* Células editáveis por duplo clique */
.editable-cell {
  cursor: pointer;
  position: relative;
  transition: background 0.12s ease;
}

.editable-cell:hover {
  background: rgba(11, 31, 58, 0.05);
}

.editable-cell.is-editing {
  padding: 0 !important;
  background: #ffffff !important;
}

.editable-cell.is-editing .cell-input {
  border-color: var(--navy-800, #0b1f3a);
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(11, 31, 58, 0.2);
  color: #000000;
  height: 100%;
}

.cell-input {
  width: 100%;
  border: 1px solid var(--navy-800, #0b1f3a);
  background: #ffffff;
  padding: 5px 6px;
  font-family: inherit;
  font-size: 13px;
  color: #000000;
  border-radius: 0;
  outline: none;
  box-shadow: 0 0 0 2px rgba(11, 31, 58, 0.15);
  box-sizing: border-box;
}

.cell-input-price {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.cell-input-code {
  font-family: var(--font-mono, monospace);
  font-size: 12px;
}

.cell-input-desc {
  font-weight: 500;
}

.cell-input-unit {
  text-align: center;
  text-transform: uppercase;
  font-weight: 600;
}

th {
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
}

th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease;
}

th.sortable:hover {
  background: var(--paper, #F3F5F7);
  color: var(--navy-900, #16232F);
}

.th-content {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: 100%;
}

.sort-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  font-size: 10px;
  line-height: 1;
  color: var(--ink-faint, #8996A3);
  opacity: 0.35;
  transition: opacity 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.sort-indicator::after {
  content: "↕";
}

th.sortable:hover .sort-indicator {
  opacity: 0.7;
}

th.sort-asc {
  color: var(--navy-800, #16232F);
  font-weight: 600;
  background: var(--paper, #F3F5F7);
}

th.sort-asc .sort-indicator {
  opacity: 1;
  color: var(--navy-700, #1B365D);
}

th.sort-asc .sort-indicator::after {
  content: "▲";
}

th.sort-desc {
  color: var(--navy-800, #16232F);
  font-weight: 600;
  background: var(--paper, #F3F5F7);
}

th.sort-desc .sort-indicator {
  opacity: 1;
  color: var(--navy-700, #1B365D);
}

th.sort-desc .sort-indicator::after {
  content: "▼";
}

tbody tr {
  cursor: pointer;
  user-select: none;
  transition: background 0.1s ease, color 0.1s ease;
}

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

/* Linha selecionada (Design System — tom corporativo azul/aço) */
tbody tr.selected {
  background: var(--status-active-bg);
  color: var(--navy-900);
}

tbody tr.selected:hover {
  background: #DCE5F0;
}

/* Linha ativa (produto em exibição no cartaz) */
tbody tr.active {
  box-shadow: inset 3px 0 0 var(--navy-700);
  font-weight: 500;
}

tbody tr.selected.active {
  background: #DFE8F3;
  box-shadow: inset 3px 0 0 var(--navy-700);
}

tbody tr.invalid {
  background: #fff0f0;
  color: var(--ink-faint);
  cursor: not-allowed;
  opacity: 0.65;
}

tbody tr.invalid:hover {
  background: #ffeaea;
}

/* Largura e alinhamento das colunas da tabela principal */
th.col-check,
td.col-check {
  width: 38px;
  min-width: 38px;
  max-width: 38px;
  text-align: center;
  padding: 4px 2px;
  vertical-align: middle;
}

.row-checkbox,
#tableSelectAll {
  cursor: pointer;
  width: 16px;
  height: 16px;
  accent-color: var(--navy-800, #0b1f3a);
  vertical-align: middle;
  margin: 0 auto;
  display: block;
}

th.col-code,
td.col-code {
  width: 95px;
  font-family: var(--font-mono);
  font-size: 12.5px;
}

th.col-price,
td.col-price,
th.col-price2,
td.col-price2 {
  width: 95px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

th.col-unit,
td.col-unit {
  width: 80px;
  text-align: center;
}

.description-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty {
  height: 160px;
  color: var(--ink-faint);
  text-align: center;
  font-style: italic;
}

/* --- Badges de status (pill) --- */

.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 0;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pill-active {
  background: var(--status-active-bg);
  color: var(--status-active-text);
}

.pill-inactive {
  background: var(--status-inactive-bg);
  color: var(--status-inactive-text);
}

/* --- Toast notifications --- */

.toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 8px;
  z-index: 20;
  width: min(360px, calc(100vw - 36px));
}

.toast {
  padding: 11px 14px;
  border-left: 3px solid var(--gold);
  background: var(--navy-900);
  color: var(--white);
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.4;
}

.toast.warning {
  border-left-color: #d4a338;
  background: var(--navy-800);
}

.toast.error {
  border-left-color: var(--fort-red);
  background: #1a0a0a;
}

/* --- Barcode helper (oculto fora da tela) --- */

.barcode-source {
  position: fixed;
  left: -9999px;
  top: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}


/* --- Botão Destaque de Importação Inteligente na Sidebar --- */

.btn-smart-import {
  background: rgba(169, 130, 90, 0.1) !important;
  border: 1px solid var(--gold) !important;
  color: var(--gold) !important;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  border-radius: 0;
  transition: background 0.12s ease, color 0.12s ease;
}

.btn-smart-import:hover {
  background: var(--gold) !important;
  color: var(--navy-900) !important;
  box-shadow: none;
}

/* ============================================================
   MODAL DE IMPORTAÇÃO INTELIGENTE & MATCHING
   Fiel aos princípios do Design System: Navy, Papel e Linhas Finas
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 31, 58, 0.75);
  backdrop-filter: blur(2px);
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 960px;
  max-height: calc(100vh - 40px);
  background: var(--white);
  border: 1px solid var(--line-strong);
  border-top: 3px solid var(--gold);
  border-radius: 0;
  box-shadow: var(--shadow);
  color: var(--ink);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--navy-900);
  color: var(--white);
  border-bottom: 1px solid var(--gold);
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-icon-badge {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  background: rgba(169, 130, 90, 0.15);
  border: 1px solid var(--gold);
  color: var(--gold);
  border-radius: 0;
  flex-shrink: 0;
}

.modal-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 500;
  color: var(--white);
  line-height: 1.2;
}

.modal-subtitle {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: #A9B7C6;
  font-family: var(--font-sans);
}

.modal-close-btn {
  background: transparent;
  border: 1px solid transparent;
  color: #A9B7C6;
  cursor: pointer;
  padding: 6px;
  display: grid;
  place-items: center;
  border-radius: 0;
  transition: color 0.12s ease, border-color 0.12s ease;
}

.modal-close-btn:hover {
  color: var(--white);
  border-color: var(--gold);
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  flex: 1;
  background: var(--paper);
}

/* --- Abas Corporativas --- */
.modal-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line-strong);
  padding-bottom: 0;
}

.modal-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  border-radius: 0;
  cursor: pointer;
  transition: all 0.12s ease;
}

.modal-tab:hover {
  color: var(--navy-900);
}

.modal-tab.active {
  color: var(--navy-900);
  font-weight: 600;
  border-bottom-color: var(--gold);
  background: var(--white);
}

.tab-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.promo-textarea {
  width: 100%;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--white);
  color: var(--ink);
  resize: vertical;
  min-height: 120px;
}

.promo-textarea:focus {
  outline: none;
  border-color: var(--navy-700);
}

.field-hint {
  margin: 0;
  font-size: 11.5px;
  color: var(--ink-faint);
  font-style: normal;
}

.promo-field-block {
  margin-bottom: 0;
}

.promo-field-block span {
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
}

/* --- Grade de Configurações da Campanha --- */
.promo-settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 14px;
  background: var(--white);
  border: 1px solid var(--line);
}

.promo-settings-grid .field.full-width {
  grid-column: 1 / -1;
}

.promo-settings-grid .field span {
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
}

.promo-settings-grid input,
.promo-settings-grid select {
  min-height: 36px;
  padding: 6px 10px;
  font-family: var(--font-sans);
  font-size: 13px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--white);
  color: var(--ink);
}

.promo-settings-grid input:focus,
.promo-settings-grid select:focus {
  outline: none;
  border-color: var(--navy-700);
}

/* --- Seção de Base Cadastral --- */
.promo-matching-section {
  padding: 12px 16px;
  background: var(--white);
  border: 1px solid var(--line);
  border-left: 3px solid var(--navy-700);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.matching-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.matching-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink);
}

.matching-status svg {
  width: 15px;
  height: 15px;
  color: var(--navy-500);
}

.matching-note {
  margin: 0;
  font-size: 11.5px;
  color: var(--ink-faint);
  line-height: 1.4;
}

.btn-load-base {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  min-height: 32px;
  background: var(--navy-900) !important;
  color: var(--white) !important;
  border: 1px solid var(--navy-700) !important;
  border-radius: 0;
  cursor: pointer;
}

.btn-load-base:hover {
  background: var(--navy-700) !important;
}

.modal-process-bar {
  display: flex;
  justify-content: flex-end;
}

#promoProcessBtn {
  min-width: 220px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 0;
}

/* --- Container de Entradas Sanfona / Retrátil --- */
.promo-inputs-wrapper {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.promo-inputs-toggle-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--white);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--gold);
}

.toggle-bar-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--navy-900);
}

.toggle-bar-info svg {
  width: 15px;
  height: 15px;
  color: var(--gold);
}

.btn-toggle-inputs {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 500;
  background: var(--paper);
  color: var(--navy-900);
  border: 1px solid var(--line-strong);
  border-radius: 0;
  cursor: pointer;
  transition: background 0.12s ease;
}

.btn-toggle-inputs:hover {
  background: var(--status-active-bg);
  border-color: var(--navy-700);
}

.promo-inputs-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: opacity 0.18s ease;
}

.promo-inputs-content.collapsed {
  display: none !important;
}

/* --- Resultados / Tabela de Revisão Expandida --- */
.promo-results {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
  padding-top: 6px;
  border-top: 1px solid var(--line-strong);
}

.promo-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.promo-results-header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  color: var(--navy-900);
}

.promo-stats-badges {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* --- Grade de 2 Listas Lado a Lado (Preço 1 e Preço 2) --- */
.promo-dual-input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.promo-dual-file-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.promo-input-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.promo-col-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.promo-col-header strong {
  font-size: 12px;
  color: var(--navy-900);
  font-weight: 500;
}

.col-badge {
  display: inline-block;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge-p1 {
  background: var(--gold);
  color: var(--navy-900);
}

.badge-p2 {
  background: var(--navy-700);
  color: var(--white);
}

.match-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 10.5px;
  font-weight: 500;
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.match-badge-success {
  background: var(--status-active-bg);
  color: var(--status-active-text);
  border: 1px solid var(--line-strong);
}

.match-badge-flavors {
  background: #FAF3E8;
  color: #8A5B29;
  border: 1px solid #E8D5BE;
}

.match-badge-fragrance {
  background: #EEF2F6;
  color: var(--navy-700);
  border: 1px solid var(--navy-500);
}

.match-badge-neutral {
  background: var(--status-inactive-bg);
  color: var(--status-inactive-text);
  border: 1px solid var(--line);
}

.match-badge-app {
  background: #e6f4ea;
  color: #137333;
  border: 1px solid #ceead6;
  font-weight: 600;
}

.match-badge-single {
  background: #e8f0fe;
  color: #1a73e8;
  border: 1px solid #d2e3fc;
  font-weight: 600;
}

.match-badge-crm {
  background: #f3e8fd;
  color: #7627bb;
  border: 1px solid #e1cbf7;
  font-weight: 600;
}

/* --- Estilos da Aba Cruzar Rede + Encarte --- */
.rede-encarte-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rede-encarte-upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.rede-upload-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--paper-bg);
  border: 1px solid var(--line);
  padding: 14px;
  border-radius: 4px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.rede-upload-card:hover {
  border-color: var(--gold-dark);
}

.rede-upload-card.loaded {
  border-color: #34a853;
  background: #fcfdfc;
}

.upload-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.upload-card-title {
  display: flex;
  flex-direction: column;
}

.upload-card-title strong {
  font-size: 13px;
  color: var(--navy-900);
}

.upload-card-subtitle {
  font-size: 11px;
  color: var(--navy-500);
}

.upload-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px 12px;
  background: var(--white);
  border: 2px dashed var(--line);
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
  user-select: none;
}

.upload-dropzone:hover {
  border-color: var(--navy-800);
  background: #fafbfc;
}

.upload-dropzone i {
  color: var(--navy-700);
  width: 28px;
  height: 28px;
  pointer-events: none;
}

.dropzone-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--navy-800);
  word-break: break-word;
  max-width: 90%;
  pointer-events: none;
}

.btn-dropzone-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: #f1f5f9;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  color: var(--navy-800);
  pointer-events: none;
  margin-top: 4px;
  transition: all 0.15s ease;
}

.upload-dropzone:hover .btn-dropzone-action {
  background: var(--navy-900);
  color: #ffffff;
  border-color: var(--navy-900);
}

.upload-dropzone input[type="file"] {
  display: none !important;
}

.upload-file-status {
  font-size: 11.5px;
  color: var(--navy-600);
  padding: 4px 8px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.03);
}

.upload-file-status.success {
  color: #137333;
  background: #e6f4ea;
  font-weight: 500;
}

.rede-banner-info {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  color: var(--navy-900);
  font-size: 12px;
}

.rede-banner-info i {
  color: #2563eb;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 2px;
}

.rede-banner-info strong {
  display: block;
  font-size: 12.5px;
  margin-bottom: 2px;
}

.rede-banner-info p {
  margin: 0;
  color: var(--navy-700);
  line-height: 1.4;
}

.rede-encarte-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 14px;
  background: var(--paper-bg);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.rede-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.input-readonly {
  background: #f1f3f4 !important;
  color: #5f6368 !important;
  cursor: not-allowed !important;
}

.rede-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--navy-800);
  cursor: pointer;
}

.rede-checkbox-label input[type="checkbox"] {
  accent-color: var(--navy-900);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.rede-process-bar {
  display: flex;
  justify-content: center;
  margin-top: 4px;
}

.btn-process-rede {
  min-width: 260px;
  padding: 11px 24px;
  font-size: 13.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 4px;
  cursor: pointer;
}


.promo-table-wrapper {
  flex: 1;
  min-height: 380px;
  max-height: calc(100vh - 270px);
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  background: var(--white);
}

.promo-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  font-size: 12.5px;
}

.promo-table th {
  padding: 8px 12px;
  background: var(--navy-900);
  color: var(--white);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--gold);
}

.promo-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.promo-table input {
  width: 100%;
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
}

.promo-table input:focus {
  outline: none;
  border-color: var(--navy-700);
  background: var(--white);
}

.promo-btn-delete {
  background: transparent;
  border: none;
  color: var(--fort-red);
  cursor: pointer;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: opacity 0.12s;
}

.promo-btn-delete:hover {
  opacity: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px;
  background: var(--white);
  border-top: 1px solid var(--line);
}

/* ============================================================
   RESPONSIVO
   ============================================================ */

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--gold);
  }

  .preview-region {
    height: auto;
  }

  .preview-layout {
    grid-template-columns: 1fr;
  }

  #posterCanvas {
    max-height: 72vh;
  }
}

@media (max-width: 680px) {
  .sidebar,
  .workspace {
    padding: 12px;
  }

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

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

  .search {
    grid-template-columns: 16px minmax(0, 1fr);
  }

  .table-region {
    max-height: 60vh;
  }
}
