:root {
  --bg: #0f1216;
  --panel: #161b22;
  --muted: #8b949e;
  --text: #e6edf3;
  --accent: #58a6ff;
  --ok: #3fb950;
  --warn: #f2cc60;
  --danger: #f85149;
}

/* Tema claro: sobrescreve variáveis quando aplicado em body */
.theme-light {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --muted: #596775;
  --text: #0b1a28;
  --accent: #0a66cc;
  --ok: #2e8b57;
  --warn: #b8860b;
  --danger: #b03030;
}

/* Tema escuro explícito (opcional) */
.theme-dark {
  --bg: #0f1216;
  --panel: #161b22;
  --muted: #8b949e;
  --text: #e6edf3;
  --accent: #58a6ff;
  --ok: #3fb950;
  --warn: #f2cc60;
  --danger: #f85149;
}

* { box-sizing: border-box; }
button {
  border-radius: 9px;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 700;
}
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', Arial, sans-serif; }

.app-header, .app-footer { padding: 2.12mm 3.18mm; background: var(--panel); border-bottom: 0.26mm solid #23262d; }
.app-header { position: relative; }
.app-footer { border-top: 0.26mm solid #23262d; border-bottom: none; text-align: center; }
h1 { margin: 0; font-size: 5.29mm; }

#nav { display: flex; gap: 1.59mm; margin-top: 1.59mm; flex-wrap: wrap; }
.nav-btn { padding: 1.59mm 2.12mm; background: #1f242b; border: 0.26mm solid #2b3138; border-radius: 1.59mm; color: var(--text); cursor: pointer; }
.nav-btn.active { border-color: var(--accent); color: var(--accent); }

/* Tema claro: aumentar contraste nas abas de navegação */
.theme-light .nav-btn { background: #f3f6fa; border-color: #c9d2dc; color: var(--text); }
.theme-light .nav-btn.active { border-color: var(--accent); color: var(--accent); background: #e6f0ff; }

.admin-tabs-nav { display: flex; gap: 1.59mm; margin-top: 1.59mm; flex-wrap: wrap; }
.tab-btn { padding: 1.59mm 2.12mm; background: #1f242b; border: 0.26mm solid #2b3138; border-radius: 1.59mm; color: var(--text); cursor: pointer; }
.tab-btn.active { border-color: var(--accent); color: var(--accent); }
.admin-tabs-content { margin-top: 2.12mm; }
.admin-tab-pane { display: none; min-height: 21.17mm; border-radius: 2.12mm; border: 0.26mm dashed #2b3138; background: #0f1318; padding: 2.12mm; }
.admin-tab-pane.active { display: block; }
.admin-subtab-pane { display: none; }
.admin-subtab-pane.active { display: block; }
main#app:has(> .admin-page-panel) { height:calc(100vh - 58px); min-height:0; overflow:hidden; padding:12px 20px; }
.admin-page-panel { height:100%; min-height:0; display:flex; flex-direction:column; margin:0; padding:10px; overflow:hidden; }
.admin-page-panel .admin-tabs-nav { flex:0 0 auto; margin-top:0; gap:8px; }
.admin-page-panel .tab-btn { padding:7px 10px; }
.admin-page-panel .admin-tabs-content { flex:1 1 auto; min-height:0; display:flex; margin-top:8px; overflow:hidden; }
.admin-page-panel .admin-tab-pane { min-height:0; width:100%; height:100%; padding:10px; overflow-y:auto; overscroll-behavior:contain; }
.country-rule-row:nth-child(odd) { background: #f7faff; }
.country-rule-row:nth-child(even) { background: #edf4ff; }
.country-rule-row:hover { background: #dfeeff; }
.contract-admin-grid { display:grid; grid-template-columns:minmax(190px,.8fr) minmax(340px,1.7fr) minmax(240px,1fr); gap:14px; align-items:start; }
.contract-admin-card { min-width:0; margin:0; }
.contract-admin-card textarea { width:100%; box-sizing:border-box; }
.contract-admin-tags, .contract-admin-list { max-height:calc(100vh - 330px); min-height:260px; overflow-y:auto; padding-right:4px; }
.contract-admin-tags .btn { display:block; width:100%; text-align:left; margin:4px 0; white-space:normal; }
.contract-admin-list .list-item { width:100%; text-align:left; cursor:pointer; margin:4px 0; }
.contract-admin-list .list-item.selected { border-color:var(--accent); background:color-mix(in srgb, var(--accent) 10%, var(--panel)); }
.fiscal-subtabs { height:100%; min-height:0; display:flex; flex-direction:column; gap:8px; }
.fiscal-subtabs-nav { flex:0 0 auto; margin:0; }
.fiscal-subtabs > .muted { flex:0 0 auto; margin:0; }
.fiscal-subtabs-content { flex:1 1 auto; min-height:0; display:flex; overflow:hidden; }
.fiscal-subtab-pane { display:none; width:100%; min-height:0; padding:2px; overflow-y:auto; overscroll-behavior:contain; }
.fiscal-subtab-pane.active { display:block; }
.fiscal-subtab-pane .contract-admin-list { max-height:calc(100vh - 310px); overflow-y:auto; }
.fiscal-address-fields { margin-top:10px; }
@media (max-width:768px) { .fiscal-subtabs { height:auto; } .fiscal-subtabs-content { min-height:420px; } .fiscal-subtab-pane .contract-admin-list { max-height:360px; } }
@media (max-width:1050px) { .contract-admin-grid { grid-template-columns:1fr; } .contract-admin-tags, .contract-admin-list { max-height:360px; } }
@media (max-width:768px) { main#app:has(> .admin-page-panel) { height:calc(100vh - 58px); padding:8px; } .admin-page-panel { padding:8px; } .admin-page-panel .admin-tabs-nav { gap:6px; } .admin-page-panel .tab-btn { padding:6px 8px; } .admin-page-panel .admin-tab-pane { padding:8px; } }
.admin-scroll-pane { max-height: 90vh; overflow-y: auto; }
.theme-light .tab-btn { background: #f3f6fa; border-color: #c9d2dc; color: var(--text); }
.theme-light .tab-btn.active { border-color: var(--accent); color: var(--accent); background: #e6f0ff; }
.theme-light .admin-tab-pane { background: #f8fbff; border-color: #c9d2dc; }

/* Botão de engrenagem (admin) */
.gear-btn { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 6px; border: 0.26mm solid #2b3138; background: #1f242b; color: var(--text); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 16px; line-height: 1; }
.gear-btn:hover { border-color: var(--accent); color: var(--accent); }
.gear-btn[hidden] { display: none !important; }

/* Tema claro: botão de engrenagem legível */
.theme-light .gear-btn { border-color: #c9d2dc; background: #f3f6fa; color: var(--text); }
.theme-light .gear-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Indicador de usuário logado */
.user-indicator { position: absolute; top: 6px; right: 40px; padding: 4px 8px; background: var(--panel); border: 0.26mm solid #2b3138; border-radius: 4px; color: var(--muted); font-size: 12px; white-space: nowrap; }

main#app { padding: 2.12mm; }

.panel { background: var(--panel); border: 0.26mm solid #23262d; border-radius: 2.12mm; padding: 2.65mm; margin-bottom: 3.18mm; }
.panel h2 { margin: 0 0 1.59mm 0; font-size: 4.23mm; }
.rows { display: grid; grid-template-columns: repeat(auto-fit, minmax(58.28mm, 1fr)); gap: 2.12mm; }
.rows.twoCols { grid-template-columns: repeat(2, minmax(58.28mm, 1fr)); }
.rows.threeCols { grid-template-columns: repeat(3, minmax(58.28mm, 1fr)); }
.rows.fourCols { grid-template-columns: repeat(4, minmax(58.28mm, 1fr)); }
/* Alinhamento à esquerda e gap horizontal de 3px para grids específicos */
.rows.leftAligned { justify-items: start; justify-content: start; column-gap: 3px; }
.rows.leftAligned.twoCols { grid-template-columns: repeat(2, auto); }
.rows.leftAligned.threeCols { grid-template-columns: repeat(3, auto); }
/* Uma coluna para título acima e conteúdo abaixo */
.rows.oneCol { grid-template-columns: 1fr; }

label { display: block; font-size: 3.18mm; color: var(--muted); margin-bottom: 0.53mm; }
input[type="text"], input[type="number"], input[type="date"], select, textarea { width: 100%; padding: 1.59mm; border-radius: 1.59mm; border: 0.26mm solid #2b3138; background: #0f1318; color: var(--text); }
.rows input:disabled, .rows select:disabled, .rows textarea:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  background: #0d1116;
  border-color: #1f262d;
  box-shadow: inset 0 0.53mm 0 rgba(255,255,255,0.04), inset 0 -0.53mm 0 rgba(0,0,0,0.35);
}
.theme-light input[type="text"], .theme-light input[type="number"], .theme-light input[type="date"], .theme-light select, .theme-light textarea {
  border-color: #c9d2dc;
  background: #f8fbff;
  color: var(--text);
}
textarea { min-height: 21.17mm; }
.btn { padding: 1.59mm 2.65mm; border-radius: 9px; border: 0.26mm solid #2b3138; background: #1f242b; color: var(--text); cursor: pointer; font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-weight: 700; }
.btn.icon-btn { padding: 4px; width: 32px; height: 32px; min-width: 32px; display: inline-flex; align-items: center; justify-content: center; }
.btn.icon-btn svg { width: 18px; height: 18px; display: block; }
.btn.primary { border-color: var(--accent); color: var(--text); background: #103252; }
.btn.danger { border-color: var(--danger); color: var(--danger); background: #221215; }
.theme-light .btn { border-color: #c9d2dc; background: #f3f6fa; color: var(--text); }
.theme-light .btn.primary { background: #e6f0ff; }
.theme-light .btn.danger { background: #ffe7e7; color: #b03030; border-color: #e4b5b5; }
.btnRow { display: flex; gap: 1.59mm; margin-top: 1.59mm; flex-wrap: wrap; }
.plan-cards { display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:12px; margin:12px 0; }
.plan-card { appearance:none; width:100%; padding:0; overflow:hidden; text-align:left; border:1px solid #2b3138; border-radius:10px; background:var(--panel); color:var(--text); cursor:pointer; font:inherit; box-shadow:0 2px 8px rgba(0,0,0,.12); }
.plan-card:hover { border-color:var(--accent); transform:translateY(-1px); }
.plan-card.selected { outline:2px solid var(--accent); border-color:var(--accent); }
.plan-card-band { padding:14px; color:#fff; min-height:96px; display:flex; flex-direction:column; justify-content:center; gap:4px; }
.plan-card-name { font-weight:800; letter-spacing:.04em; text-transform:uppercase; }
.plan-card-price { font-size:28px; font-weight:800; line-height:1; }
.plan-card-cycle { font-size:12px; opacity:.94; }
.plan-card-body { padding:13px; display:grid; gap:7px; font-size:13px; color:var(--muted); }
.plan-card-body strong { color:var(--text); }
.plan-summary { border:1px solid #2b3138; border-radius:9px; padding:12px; display:grid; gap:6px; background:rgba(88,166,255,.06); }
.plan-summary-total { color:var(--text); font-size:18px; font-weight:800; }
.theme-light .plan-card, .theme-light .plan-summary { border-color:#c9d2dc; }
.license-expired-footer-warning { margin-left:14px; color:var(--danger); font-weight:700; font-size:12px; }
.license-expired-readonly #app [data-license-locked="true"] { opacity:.56; cursor:not-allowed; }
@media (max-width:640px) { .license-expired-footer-warning { display:block; margin:6px 0 0; } }
.crud-action-bar { display:flex; gap:8px; margin:0 0 14px; flex-wrap:wrap; }
.crud-action-bar .crud-action { min-width:96px; min-height:34px; padding:6px 14px; border-radius:9px; font:700 13px/1.2 Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.crud-action-bar .crud-action-save { border-color:var(--accent); background:#103252; color:var(--text); }
.crud-action-bar .crud-action-cancel { background:#1f242b; color:var(--text); }
.crud-action-bar .crud-action-delete { border-color:var(--danger); background:#221215; color:var(--danger); }
.theme-light .crud-action-bar .crud-action-save { background:#e6f0ff; }
.theme-light .crud-action-bar .crud-action-cancel { background:#f3f6fa; color:var(--text); }
.theme-light .crud-action-bar .crud-action-delete { background:#ffe7e7; color:#b03030; border-color:#e4b5b5; }
.list-row-actions .btn,
.list-item > .btnRow .btn,
.list-item > div > .btnRow .btn {
  min-height:34px;
  padding:6px 14px;
  border-radius:6px;
  font:600 14px/1.2 Arial, sans-serif;
}
@media (max-width: 560px) { .crud-action-bar .crud-action { flex:1 1 96px; } }

/* Aba Usuários: cadastro, liberações e lista no mesmo espaço de trabalho. */
.user-management-grid { display:grid; grid-template-columns:minmax(260px, .95fr) minmax(300px, 1.1fr) minmax(280px, 1fr); gap:12px; height:calc(100vh - 150px); min-height:0; max-height:760px; }
.user-management-block { display:flex; min-width:0; min-height:0; flex-direction:column; gap:10px; padding:12px; overflow:hidden; border:1px solid #c9d2dc; border-radius:8px; background:var(--panel); }
.user-management-block > h3 { margin:0; color:var(--text); font-size:15px; }
.user-editor-block { overflow-y:auto; }
.user-editor-block .crud-action-bar { margin:0; }
.user-editor-block .rows { grid-template-columns:1fr; }
.user-editor-block .rows .btnRow { margin-top:0; }
.user-permissions-block > .muted { margin-top:-5px; }
.user-permission-tree { min-height:0; overflow-y:auto; padding:4px 2px; }
.user-permission-branch { margin:2px 0; }
.user-permission-node { display:flex; align-items:center; gap:7px; min-height:30px; padding:3px 5px; margin:1px 0; border-radius:5px; color:var(--text); cursor:pointer; }
.user-permission-node:hover { background:rgba(59,130,246,.10); }
.user-permission-node input { width:auto; margin:0; }
.user-permission-folder,.user-permission-toggle { display:inline-grid; width:20px; height:20px; place-items:center; flex:0 0 20px; border:0; background:transparent; color:var(--accent); font:700 14px/1 Arial, sans-serif; }
.user-permission-toggle { cursor:pointer; border-radius:4px; }
.user-permission-toggle:hover { background:rgba(59,130,246,.14); }
.user-permission-children { margin-left:22px; padding-left:10px; border-left:1px solid #c9d2dc; }
.user-permission-branch.is-collapsed .user-permission-children { display:none; }
.user-permission-children.is-disabled { opacity:.58; }
.user-permission-children .muted { margin:4px 5px 7px; }
.user-list-block .list { flex:1; min-height:0; max-height:none !important; overflow-y:auto !important; overflow-x:hidden; }
.user-list-block .list-item { align-items:flex-start; gap:8px; }
.user-list-block .btnRow { margin-top:0; justify-content:flex-end; }
.user-list-block .list-record-actions { margin-top:8px; justify-content:flex-start; }
@media (max-width: 1100px) { .user-management-grid { grid-template-columns:repeat(2, minmax(0, 1fr)); height:auto; max-height:none; } .user-list-block { grid-column:1 / -1; min-height:300px; } }
@media (max-width: 720px) { .user-management-grid { grid-template-columns:1fr; } .user-list-block { grid-column:auto; min-height:320px; } }
/* Versão compacta com gap horizontal de 3px */
/* Malhas e Clientes: formulário e lista ocupam blocos independentes. */
.split-management-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, .9fr);
  gap: 12px;
  height: calc(100vh - 150px);
  min-height: 0;
  max-height: 760px;
}
.split-management-block {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  gap: 10px;
  padding: 12px;
  overflow: hidden;
  border: 1px solid #c9d2dc;
  border-radius: 8px;
  background: var(--panel);
}
.split-management-block > h3 { margin: 0; color: var(--text); font-size: 15px; }
.split-management-editor { overflow-y: auto; }
.split-management-editor .crud-action-bar { margin: 0; }
.split-management-list .list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none !important;
  overflow-y: auto !important;
  overflow-x: hidden;
}
@media (max-width: 1000px) {
  .split-management-grid { grid-template-columns: 1fr; height: auto; max-height: none; }
  .split-management-list { min-height: 320px; }
}

/* Listas de cadastros e histórico: rolagem própria para não ampliar a janela. */
.viewport-scroll-list {
  min-height: 0;
  max-height: calc(100vh - 330px) !important;
  overflow-y: auto !important;
  overflow-x: hidden;
}
.grades-viewport-list {
  max-height: min(260px, calc((100vh - 430px) / 2)) !important;
}
.history-viewport-list {
  max-height: calc(100vh - 290px) !important;
}

/* Referências: editor e grade ocupam a altura útil sem espaço reservado no topo. */
main#app:has(> .references-page-panel) {
  display: flex;
  flex-direction: column;
}
.references-page-panel {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  margin-bottom: 0;
  overflow: hidden;
}
@media (min-width: 1101px) {
  .references-page-panel {
    height: min(760px, calc(100dvh - 172px));
    max-height: min(760px, calc(100dvh - 172px));
  }
}
.references-workspace {
  grid-template-columns: minmax(320px, 30%) minmax(0, 70%) !important;
  align-items: stretch !important;
  height: calc(100vh - 150px);
  min-height: 0;
  max-height: 760px;
}
.references-page-panel .references-workspace {
  flex: 1 1 auto;
  height: auto !important;
  max-height: none !important;
  min-height: 0;
}
.references-editor-pane,
.references-list-pane {
  min-width: 0;
  min-height: 0;
}
.references-editor-pane { overflow-y: auto; }
.references-subtabs-nav {
  flex: 0 0 auto;
  margin-bottom: 0;
}
.references-subtab-pane {
  display: none;
  flex: 1 0 auto;
  min-width: 0;
  flex-direction: column;
  gap: 10px;
}
.references-subtab-pane.active { display: flex; }
.references-subtab-pane[hidden] { display: none !important; }
.references-subtab-pane > .panel { margin: 0; }
.references-list-actions { align-items: center; }
.references-pdf-feedback { display: flex; align-items: center; min-height: 0; }
.modal-overlay.reference-assoc-modal-overlay { padding: 20px; }
.modal.reference-assoc-modal {
  display: flex;
  width: min(700px, 100vw);
  max-width: 100vw;
  height: auto;
  max-height: calc(100dvh - 40px);
  margin: 0;
  border-radius: 16px;
  flex-direction: column;
  overflow: auto;
}
.reference-assoc-modal-body {
  flex: 0 1 auto;
  min-height: auto;
  overflow: visible;
}
.reference-assoc-modal .modal-actions { flex: 0 0 auto; }
.reference-malha-combobox {
  position: relative;
  width: 100%;
}
.reference-malha-combobox-input {
  width: 100%;
  padding-right: 42px;
}
.reference-malha-combobox-toggle {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 38px;
  height: calc(100% - 2px);
  padding: 0;
  border: 0;
  border-radius: 0 8px 8px 0;
  background: transparent;
  color: #496b93;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.reference-malha-combobox-toggle:hover { background: #f3f7fc; }
.reference-malha-combobox-options {
  position: static;
  max-height: 350px;
  overflow-y: auto;
  margin-top: 4px;
  border: 1px solid #cbd8e8;
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(15, 47, 90, .16);
}
.reference-malha-combobox-option {
  display: block;
  width: 100%;
  padding: 9px 11px;
  border: 0;
  border-bottom: 1px solid #edf2f7;
  border-radius: 0;
  background: #fff;
  color: #234567;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.reference-malha-combobox-option:last-child { border-bottom: 0; }
.reference-malha-combobox-option:hover,
.reference-malha-combobox-option.is-active {
  background: #eaf2ff;
  color: #1d5ba8;
}
.reference-malha-combobox-empty {
  padding: 10px 11px;
  color: #64748b;
  font-size: 13px;
}
.reference-assoc-edit-body { grid-template-columns: 1fr; }
.reference-assoc-edit-fields-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
}
.reference-assoc-edit-fields-row .reference-malha-combobox {
  min-width: 0;
}
.reference-assoc-decor-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding-bottom: 8px;
  white-space: nowrap;
}
.reference-assoc-edit-actions { margin-top: 10px; }
@media (max-width: 520px) {
  .reference-assoc-edit-fields-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
  }
  .reference-assoc-decor-filter { gap: 4px; font-size: 12px; }
}
.references-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 36px;
  padding: 4px 8px;
  border: 1px solid #c9d2dc;
  border-radius: 4px;
  overflow-x: auto;
  overflow-y: hidden;
}
.references-pager-selection-actions,
.references-pager-size {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.references-pager .btn,
.references-pager select { flex: 0 0 auto; }
.references-list-pane {
  margin-top: 0 !important;
  padding-top: 0;
  overflow: hidden;
}
.references-list-pane > .panel { margin: 0; }
.references-list-pane .references-viewport-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none !important;
  overflow-y: auto !important;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}
.reference-list-card { cursor: pointer; }
.reference-list-card:hover { box-shadow: inset 0 0 0 1px #93c5fd; }
.reference-list-card:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.reference-list-card img { cursor: zoom-in; }
.reference-list-card input { cursor: pointer; }
.reference-list-record-content { display: flex; flex-direction: column; gap: 1px; }
.reference-list-title { line-height: 1.35; }
.reference-list-grade { display: flex; align-items: center; flex-wrap: wrap; line-height: 1.35; }
.reference-list-grade > span + span::before { content: ' • '; color: #64748b; }
.reference-recycling-symbol { color: #15803d; font-size: 15px; font-weight: 800; line-height: 1; }
.editable-list-card { cursor: pointer; }
.editable-list-card:hover { box-shadow: inset 0 0 0 1px #93c5fd; }
.editable-list-card:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.editable-list-card input { cursor: pointer; }
.grades-viewport-list .btnRow { display: none; }
@media (max-width: 1100px) {
  .references-workspace { grid-template-columns: 1fr !important; height: auto; max-height: none; }
  .references-list-pane { min-height: 360px; }
  .references-pager { justify-content: flex-start; }
}

.btnRow.tight { gap: 3px; }

/* Compactar topo apenas nos painéis específicos */
.panel.panel-compact { padding-top: 6px; }
.panel.panel-compact h3 { margin-top: 0; }

.list { border: 0.26mm dashed #2b3138; border-radius: 2.12mm; padding: 1.59mm; }
.list-item { display: flex; align-items: center; justify-content: space-between; padding: 1.06mm 1.59mm; border-bottom: 0.26mm solid #23262d; }
.list-item:last-child { border-bottom: none; }
.group-header { display: flex; align-items: center; padding: 4px 6px; border-bottom: 0.26mm solid #23262d; cursor: pointer; color: var(--muted); font-weight: 600; }
.theme-light .group-header { border-color: #c9d2dc; }
.muted { color: var(--muted); font-size: 2.91mm; }

.grid { display: grid; gap: 1.59mm; }
.grid.cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-6 { grid-template-columns: repeat(6, 1fr); }

.card { border: 0.26mm solid #23262d; border-radius: 2.12mm; padding: 1.59mm; background: #101419; }
.theme-light .card { border-color: #d6dee7; background: #ffffff; }
.label-card { height: 100%; break-inside: avoid; page-break-inside: avoid; overflow: hidden; }

/* Alerta visual quando um cartão extrapola a área útil (preview/edição) */
.label-card[data-overflow="1"] {
  outline: 0.3mm solid var(--danger);
  box-shadow: 0 0 0 1px rgba(248,81,73,0.35) inset;
  position: relative;
}
.label-card[data-overflow="1"]::after {
  content: "extrapola área útil";
  position: absolute;
  top: 1mm;
  right: 1mm;
  font-size: 2.5mm;
  color: var(--danger);
  background: rgba(248,81,73,0.08);
  border: 0.2mm solid var(--danger);
  border-radius: 1mm;
  padding: 0.6mm 1.2mm;
  line-height: 1;
}

/* Ajustes específicos de impressão: remover espaçamentos do container para não reduzir a primeira página */
@media print {
  .panel { padding: 0; margin: 0; border: 0; }
}
.flex { display: flex; gap: 1.59mm; }
.drag-item { padding: 2.12mm; border: 0.26mm dashed #2b3138; border-radius: 1.59mm; cursor: move; background: #0f1318; display:flex; align-items:center; }
.layout-required-icon { margin-left:auto; min-width:16px; height:16px; display:inline-flex; align-items:center; justify-content:center; border-radius:50%; background:#dc2626; color:#fff; font-weight:800; font-size:14px; line-height:1; cursor:help; }
.theme-light .drag-item { border-color: #c9d2dc; background: #f8fbff; }
.drop-zone { min-height: 37.04mm; padding: 2.12mm; border: 0.53mm dashed #2b3138; border-radius: 2.12mm; }
.theme-light .drop-zone { border-color: #c9d2dc; background: #ffffff; }
.preview-logo { max-height: 12.7mm; max-width: 42.33mm; border: 0.26mm solid #2b3138; border-radius: 1.59mm; }
/* Realce visual quando arrastando sobre a área de layout */
.drag-hover { outline: 0.3mm dashed var(--accent); box-shadow: 0 0 0 1px rgba(88,166,255,0.35) inset; }

/* Layouts: paleta, canvas e editor de item ampliado. */
.layouts-grid { display: grid; grid-template-columns: 18% 34% 24% 24%; gap: 2.12mm; align-items: stretch; }
.layouts-page-panel {
  display: flex;
  height: calc(100dvh - 82px);
  max-height: calc(100dvh - 82px);
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}
.layouts-page-panel > .layouts-grid { flex: 1 1 auto; min-height: 0; }
/* Painéis que precisam permanecer visíveis durante a rolagem */
.panel.sticky { position: sticky; top: 0; align-self: start; }
/* Painéis dentro do grid devem ocupar toda a altura da linha */
.layouts-grid > .panel { height: 100%; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.layouts-grid > .panel > h3 { margin-top: 0; }
.layouts-card-header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.layouts-card-header > h3 { margin: 0; }
.layouts-card-header > .btnRow,
.layouts-card-header > .admin-tabs-nav { margin: 0; }
.layouts-grid > .panel > .list,
.layouts-grid > .panel > .drop-zone,
.layouts-editor-content {
  min-height: 0;
  max-height: none !important;
  flex: 1 1 auto;
  overflow: auto !important;
}
.layout-omitted-list { min-height: 115px; padding: 8px; border: 1px dashed #d48b00; border-radius: 8px; background: #fff9ed; overflow: auto; }
.layout-omitted-item { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 7px 4px; border-bottom: 1px solid #f0d8a5; font-size: 13px; }
.layout-omitted-item:last-child { border-bottom: 0; }
.layout-omitted-item .btn { min-width: 28px; padding: 2px 7px; color: #9b1c1c; }
.item-editor-panel .layout-omitted-list { min-height: 175px; margin-top: 10px; }
@media (max-width: 980px) {
  .layouts-grid { grid-template-columns: 1fr; }
  .layouts-grid > .item-editor-panel { grid-column: auto !important; }
  .layouts-page-panel { overflow-y: auto; }
  .layouts-page-panel > .layouts-grid { flex: 0 0 auto; }
  .layouts-grid > .panel { min-height: 360px; }
}

/* Preview e editor de elementos da aba ZPL lado a lado */
.zpl-preview-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 1fr);
  gap: 10px;
  align-items: start;
}
.zpl-preview-editor-layout > * { min-width: 0; }
@media (max-width: 900px) {
  .zpl-preview-editor-layout { grid-template-columns: 1fr; }
}

/* Títulos compactos dos blocos da aba ZPL */
.zpl-page-panel { padding: 4px; }
.zpl-section-panel { padding: 6px; }
.zpl-section-panel > h3,
.zpl-preview-title-row > h3 {
  margin: 0 0 4px;
  font-size: 16px;
  line-height: 1.15;
}
.zpl-preview-title-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.zpl-preview-title-row > h3 { margin-bottom: 0; }
.zpl-preview-barcode-value { overflow-wrap: anywhere; }
.zpl-preview-zoom-controls { display:flex; align-items:center; gap:4px; margin-left:auto; }
.zpl-preview-zoom-btn { min-width:26px; padding:1px 6px; line-height:1.2; }
.zpl-preview-zoom-label { min-width:42px; text-align:center; font-variant-numeric:tabular-nums; }
.zpl-print-settings-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.zpl-print-settings-grid > * { min-width: 0; }
.zpl-print-settings-grid input,
.zpl-print-settings-grid select { width: 100%; min-width: 0; }
@media (max-width: 1200px) {
  .zpl-print-settings-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .zpl-print-settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .zpl-print-settings-grid { grid-template-columns: 1fr; }
}

/* Réguas do editor de Layout (overlay dentro da área) */
.ruler-top, .ruler-left { position: absolute; z-index: 5; pointer-events: none; }

/* Réguas HTML/CSS em milímetros (sem canvas/pxPerMm) */
.ruler-top-html {
  position: static;
  display: block;
  pointer-events: none;
  height: 6mm;
  background-image:
    /* marcas menores a cada 1mm */
    repeating-linear-gradient(to right, rgba(127,127,127,0.4) 0, rgba(127,127,127,0.4) 0.2mm, transparent 0.2mm, transparent 1mm);
}
.ruler-left-html {
  position: static;
  display: block;
  pointer-events: none;
  width: 12mm;
  background-image:
    /* marcas menores a cada 1mm */
    repeating-linear-gradient(to bottom, rgba(127,127,127,0.4) 0, rgba(127,127,127,0.4) 0.2mm, transparent 0.2mm, transparent 1mm);
}

/* Ícones de alinhamento no Inspector */
.align-icons { display: flex; gap: 6px; align-items: center; }
.align-icon-btn { width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; border: 0.26mm solid #2b3138; border-radius: 1.59mm; background: #0e1216; color: var(--text); cursor: pointer; padding: 0; }
.theme-light .align-icon-btn { border-color: #c9d2dc; background: #f3f6fa; }
.align-icon-btn.selected { border-color: #4da3ff; box-shadow: 0 0 0 2px rgba(77,163,255,0.25) inset; }
.align-icon-btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.layout-font-toolbar { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.layout-font-toolbar-group { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.layout-font-toolbar-group > label { margin: 0; }
.layout-font-alignment-stack { display: flex; flex-direction: column; gap: 8px; }
.layout-font-face-control { display: flex; align-items: center; gap: 6px; min-width: 0; }
.layout-font-face-control > select { min-width: 0; flex: 1 1 auto; }
.layout-format-btn-uppercase { min-width: 34px; font-size: 11px; font-weight: 800; letter-spacing: -1px; }
.layout-icon-mode-control { display: grid; gap: 4px; margin-top: 8px; }
.layout-icon-mode-selector { display: flex; flex-wrap: wrap; gap: 6px; }
.layout-icon-mode-selector .btn { flex: 1 1 80px; }
.layout-block-controls { display: grid; gap: 8px; margin-top: 8px; }
.layout-block-title { margin: 0; }
.layout-block-fields { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.layout-block-options { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.layout-block-option-check { display: flex; align-items: center; gap: 4px; min-height: 32px; margin: 0; }
.layout-block-option-field { width: min(180px, 100%); }
.layout-adjustments-grid { display: grid; gap: 14px; }
.layout-adjustment-section { display: grid; gap: 8px; }
.layout-adjustment-title { margin: 0; }
.layout-adjustment-margins { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.layout-adjustment-meta { display: grid; gap: 8px; }
.layout-adjustment-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.layout-adjustment-target-row { display: flex; align-items: end; gap: 8px; flex-wrap: wrap; }
.layout-adjustment-target-row > div:first-child { flex: 0 0 auto; }
.layout-adjustment-gap-row { display: flex; align-items: end; gap: 8px; flex-wrap: wrap; }
.layout-adjustment-gap-row > div:first-child { flex: 0 0 auto; }
.layout-adjustment-lock { display: flex; align-items: center; gap: 4px; margin: 0; }
.layout-stack-no-wrap { white-space: nowrap; }
@media (max-width: 760px) {
  .layout-adjustment-margins { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.layout-format-btn {
  width: 30px;
  height: 30px;
  margin-bottom: 0;
  border: 1px solid #c9d2dc;
  border-radius: 6px;
  background: #f3f6fa;
  color: #334155;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.layout-format-btn-italic { font-style: italic; }
.layout-format-btn:hover { background: #e6edf5; }
.layout-format-btn.active { border-color: #2563eb; background: #dbeafe; color: #1d4ed8; box-shadow: inset 0 0 0 1px rgba(37,99,235,.16); }
.layout-format-btn:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.layout-ref-search-wrap { position: relative; width: 100%; }
.layout-ref-suggestions {
  position: absolute;
  z-index: 30;
  top: calc(100% + 2px);
  right: 0;
  left: 0;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid #c9d2dc;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 8px 18px rgba(15, 23, 42, .16);
}
.layout-ref-suggestion { display: block; width: 100%; padding: 8px 10px; border: 0; border-bottom: 1px solid #eef2f7; background: #fff; color: #334155; text-align: left; cursor: pointer; }
.layout-ref-suggestion:last-child { border-bottom: 0; }
.layout-ref-suggestion:hover, .layout-ref-suggestion:focus-visible { background: #eff6ff; color: #1d4ed8; outline: none; }
.layout-ref-suggestion-empty { padding: 8px 10px; color: #64748b; font-size: 12px; }
.ruler-label {
  position: absolute;
  font-family: ui-monospace, monospace;
  font-size: 3mm;
  color: currentColor;
}

.notice { padding: 2.12mm; border-radius: 1.59mm; background: #0f1318; border: 0.26mm solid #23262d; }
.theme-light .notice { background: #f8fbff; border-color: #c9d2dc; color: var(--text); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.danger { color: var(--danger); }

@media print {
  /* Remove cabeçalhos e rodapés automáticos do navegador */
  body { 
    background: white; 
    color: black; 
    margin: 0 !important;
    padding: 0 !important;
    height: auto !important;
    min-height: 0 !important;
  }
  html { background: white !important; height: auto !important; min-height: 0 !important; }
  /* Remover quaisquer espaçamentos globais do container principal na impressão */
  main#app {
    margin: 0 !important;
    padding: 0 !important;
  }
  
  .app-header, .app-footer, #nav { display: none; }
  .panel { 
    border: none; 
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    page-break-after: avoid;
    page-break-inside: avoid;
  }
  .print-hide { display: none; }
  
  /* Remove título "Impressão" */
  .panel h2 {
    display: none;
  }
  /* Linhas de guia para validação de pads/margens na impressão */
  .ruler-line { position: absolute; z-index: 2; pointer-events: none; }
  .ruler-top-print { left: 0; right: 0; border-top: 0.2mm dashed #888; }
  .ruler-left-print { top: 0; bottom: 0; border-left: 0.2mm dashed #888; }
  
  /* Remove espaçamentos do grid de etiquetas */
  .grid {
    margin: 0 !important;
    padding: 0 !important;
    gap: 0 !important;
    grid-gap: 0 !important;
    border: none !important;
    background: transparent !important;
  }
  
  /* Remover bordas/radius/fundos das etiquetas (colunas) na impressão */
  .card.label-card {
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }
  /* Ocultar alerta de overflow na impressão */
  .label-card[data-overflow]::after {
    display: none !important;
  }
  .preview-logo { border: none !important; }
  
  /* Remove qualquer espaçamento adicional */
  * {
    box-sizing: border-box !important;
  }
}

/* Modal genérico */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 9999; }
.modal { background: var(--panel); border: 0.26mm solid #23262d; border-radius: 2.12mm; padding: 3.18mm; width: 80mm; max-width: 90vw; max-height: 80vh; box-shadow: 0 4px 20px rgba(0,0,0,0.5); overflow: auto; }
.modal h3 { margin: 0 0 2.12mm 0; font-size: 4.23mm; }
.modal-actions { display: flex; gap: 1.59mm; justify-content: flex-end; margin-top: 2.12mm; }
/* Log output box for schema verification (readable on dark theme) */
.log-box {
  max-height: 200px;
  overflow: auto;
  background: #ffffff;
  color: #111111;
  padding: 10px;
  border: 1px solid #dddddd;
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.4;
}

/* Ícones: grid responsivo em colunas e tabela */
.icons-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(70mm, 1fr)); gap: 2.12mm; align-items: flex-start; }
.icon-card h3 { margin: 0 0 1.59mm 0; font-size: 3.7mm; }

.vf-table { width: 100%; border-collapse: collapse; }
.vf-table th, .vf-table td { border: 0.26mm solid #2b3138; padding: 1.06mm 1.59mm; vertical-align: middle; }
.vf-table th { text-align: left; color: var(--muted); font-weight: 600; }

.thumb-4mm { width: 4mm; height: 4mm; object-fit: contain; display: inline-block; }
/* Seletor de pictogramas nas Malhas */
.icon-picker { border: 0.26mm solid #2b3138; border-radius: 2.12mm; padding: 1.59mm; background: #0f1318; }
.theme-light .icon-picker { border-color: #c9d2dc; background: #ffffff; }
.icon-current { display: flex; min-height: 34px; align-items: center; gap: 1.59mm; box-sizing: border-box; padding: 1.06mm; border: 0.26mm solid #2b3138; border-radius: 1.59mm; background: transparent; cursor: pointer; transition: border-color .16s ease, box-shadow .16s ease; }
.icon-current.selected { border-style: solid; }
.theme-light .icon-current { border-color: #c9d2dc; background: #ffffff; }
.theme-light .icon-current:hover { border-color: #93b4d8; }
.theme-light .icon-current.is-open { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.icon-current[aria-disabled="true"] { cursor: not-allowed; opacity: .72; }
.icon-picker-placeholder { color: var(--muted); font-size: 12px; font-style: italic; }
.icon-picker-chevron { margin-left: auto; color: var(--muted); font-size: 20px; font-style: normal; line-height: 1; transition: transform .16s ease; }
.icon-current.is-open .icon-picker-chevron { transform: rotate(180deg); }
.icon-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(20mm, 1fr)); gap: 1.59mm; margin-top: 1.59mm; }
.icon-option { display: flex; align-items: center; gap: 1.06mm; padding: 1.06mm; border: 0.26mm solid #2b3138; border-radius: 1.59mm; background: #0e1216; cursor: pointer; }
.icon-option.active { border-color: var(--accent); }
.theme-light .icon-option { border-color: #c9d2dc; background: #f8fbff; }
.icon-thumb { width: 6mm; height: 6mm; object-fit: contain; }
.malha-fibras-total {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  margin-top: 8px;
  padding: 4px 10px;
  border: 1px solid #cbd8e8;
  border-radius: 8px;
  background: #f7faff;
  color: #38526f;
  font-size: 13px;
  font-weight: 700;
}
.malha-fibras-total.is-invalid {
  border-color: #fca5a5;
  background: #fee2e2;
  color: #b91c1c;
}
.malha-validation-status {
  align-self: center;
  color: #c73636;
  font-size: 12px;
  font-weight: 700;
}
.malha-field-invalid {
  border-color: #ef4444 !important;
  background: #fff5f5 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .12) !important;
}
.icon-picker.malha-field-invalid { border-color: #ef4444 !important; }
/* Tabela de Ícones: colunas ajustadas */
.vf-table .col-grau, .vf-table th.col-grau { width: 8mm; text-align: center; }
.vf-table .col-desc, .vf-table th.col-desc { white-space: normal; word-break: break-word; }
.vf-table .col-img, .vf-table th.col-img { width: 12mm; }

/* Grade e quantidades no preview de impressão */
.grade-box { display: flex; flex-direction: column; gap: 4px; }
.grade-inline { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.grade-item { display: flex; flex-direction: row; align-items: center; gap: 10px; width: 100%; }
.grade-label { min-width: 50px; text-align: right; margin: 0; font-size: 3.5mm; font-weight: 600; color: var(--text); white-space: nowrap; }
.grade-input { flex: 1; text-align: left; padding-left: 8px; }
.grade-box .grade-item { display: grid !important; grid-template-columns: 34px minmax(0, 1fr) 54px; align-items: center; gap: 8px; }
.grade-box .grade-input { width: 100%; min-width: 0; }
.grade-box .prototype-grade-item { grid-template-columns: minmax(64px, max-content) minmax(0, 25%); justify-content: start; }
.grade-box .prototype-grade-item .grade-label { min-width: 0; text-align: left; }
.grade-item-header { min-height: 17px; }
.grade-item-header > span { min-width: 0; }
.grade-extra-heading { color: var(--muted); font-size: 11px; font-weight: 700; text-align: center; }

/* Sub-abas da grade e dos ajustes de deslocamento no preview de impressão. */
.print-preview-subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
  border-bottom: 1px solid #d0d7de;
}
.print-preview-subtab {
  margin: 0 0 -1px;
  padding: 6px 8px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: #64748b;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.print-preview-subtab:hover { background: #f1f5f9; color: #334155; }
.print-preview-subtab.active { border-bottom-color: #2563eb; color: #2563eb; }
.print-preview-subtab-pane[hidden] { display: none; }

/* Remover spinners/setas dos inputs numéricos da grade */
.grade-input::-webkit-outer-spin-button,
.grade-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.grade-input[type=number] {
  -moz-appearance: textfield;
}
/* Debug modal styles */
.log-box { font-family: monospace; }
.log-item { padding: 6px; border-left: 3px solid #444; margin-bottom: 6px; background: #121212; }
.log-item.info { border-color: #2e7d32; background: #0f1b10; }
.log-item.error { border-color: #c62828; background: #1b0c0c; color: #ffb3b3; }
.log-item .log-time { color: #999; margin-right: 6px; }
.log-item .log-type { color: #ccc; margin-right: 6px; }
.log-item .log-label { color: #eee; margin-right: 6px; }
.log-item pre.log-details { white-space: pre-wrap; color: #ddd; margin: 4px 0 0; }

/* Aba Identificacoes */
.identificacoes-page-panel { display: grid; gap: 10px; }
.ident-editor-grid { display: grid; grid-template-columns: minmax(250px, .8fr) minmax(300px, 1.2fr); gap: 10px; align-items: start; }
.ident-settings-card, .ident-fields-card, .ident-preview-card { min-width: 0; }
.ident-settings-card h3, .ident-fields-card h3, .ident-preview-card h3 { margin: 0 0 8px; font-size: 16px; }
.ident-settings-card { display: grid; gap: 8px; }
.ident-control { display: grid; gap: 3px; min-width: 0; font-size: 12px; color: var(--muted); }
.ident-control input, .ident-control select, .ident-layout-actions input, .ident-settings-card > select { width: 100%; min-width: 0; }
.ident-status { min-height: 18px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.ident-layout-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; min-width: 0; }
.ident-section-label { margin: 4px 0 2px; font-size: 12px; font-weight: 600; color: var(--muted); }
.ident-columns-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.ident-columns-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.ident-columns-actions .btn { padding: 3px 7px; font-size: 11px; }
.ident-columns-list { display: flex; flex-wrap: wrap; gap: 5px 10px; max-height: 124px; overflow: auto; padding: 6px; border: 1px solid var(--border, #c7d1df); border-radius: 5px; }
.ident-column-check { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; white-space: nowrap; }
.ident-fields-list { display: flex; flex-wrap: wrap; gap: 6px; min-height: 34px; }
.ident-field-chip { cursor: grab; border: 1px solid var(--accent, #1677ff); border-radius: 999px; background: var(--panel, #fff); color: inherit; padding: 4px 9px; font-size: 12px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ident-field-chip:active { cursor: grabbing; }
.ident-preview-card { display: grid; gap: 9px; }
.ident-preview-drop { min-height: 68px; border: 1px dashed #6f849d; border-radius: 6px; padding: 7px; transition: border-color .15s, background .15s; }
.ident-preview-drop.is-dragover { border-color: var(--accent, #1677ff); background: color-mix(in srgb, var(--accent, #1677ff) 10%, transparent); }
.ident-drop-title { margin-bottom: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
.ident-configured-fields { display: grid; gap: 5px; }
.ident-configured-field { display: grid; grid-template-columns: minmax(0, 1fr) minmax(90px, 120px) auto; gap: 6px; align-items: center; font-size: 12px; }
.ident-configured-field > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ident-configured-field select { min-width: 0; width: 100%; }
.ident-field-missing { color: #bf3e3e; font-weight: 600; }
.ident-preview-canvas { min-height: 310px; overflow: auto; border: 1px solid var(--border, #c7d1df); border-radius: 6px; background-color: #eef3f8; background-size: cover; background-position: center; }
.ident-preview-canvas.is-dragover { outline: 2px solid var(--accent, #1677ff); outline-offset: -2px; }
.ident-preview-content { min-height: 308px; padding: 12px; background: rgba(255,255,255,.80); color: #17212b; }
.ident-result-cards { display: grid; gap: 10px; }
.ident-result-matrix { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.ident-result-card { padding: 10px; border: 1px solid #b7c5d4; border-radius: 6px; background: rgba(255,255,255,.94); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.ident-result-title { margin-bottom: 8px; font-size: 13px; font-weight: 700; }
.ident-result-value { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-top: 1px solid #dbe3eb; font-size: 13px; }
.ident-result-value strong { overflow-wrap: anywhere; text-align: right; }
.ident-result-label { color: #4c5a67; font-size: 12px; }
.ident-result-table { width: 100%; border-collapse: collapse; background: rgba(255,255,255,.94); font-size: 13px; }
.ident-result-table th, .ident-result-table td { padding: 7px 8px; border: 1px solid #b7c5d4; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.ident-result-table th { background: rgba(230,238,247,.96); }

@media (max-width: 980px) {
  .ident-editor-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .ident-layout-actions, .ident-configured-field { grid-template-columns: 1fr; }
  .ident-columns-header { align-items: flex-start; flex-direction: column; }
  .ident-columns-actions { justify-content: flex-start; }
  .ident-result-matrix { grid-template-columns: 1fr; }
}

/* Editor por blocos da aba Identificacoes */
.ident-v2-output-palette { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.ident-v2-output-tool { min-width: 0; min-height: 54px; display: grid; gap: 2px; align-content: center; cursor: grab; border: 1px solid var(--accent, #1677ff); border-radius: 6px; background: var(--panel, #fff); color: inherit; text-align: center; }
.ident-v2-output-tool:active { cursor: grabbing; }
.ident-v2-output-tool span { font-size: 11px; color: var(--muted); }
.ident-v2-preview-card { min-width: 0; }
.ident-v2-preview-card > h3 { margin: 0 0 8px; font-size: 16px; }
.ident-v2-workspace { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(330px, .85fr); gap: 10px; align-items: start; }
.ident-v2-editor-panel { display: grid; gap: 10px; min-width: 0; }
.ident-v2-formatting-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.ident-v2-formatting-toolbar > strong { margin-right: 3px; font-size: 13px; }
.ident-v2-formatting-toolbar select { min-width: 104px; max-width: 145px; }
.ident-v2-formatting-toolbar input { width: 62px; }
.ident-v2-config-card { display: grid; gap: 8px; min-width: 0; }
.ident-v2-config-card > h3 { margin: 0; font-size: 16px; }
.ident-v2-tabs { display: flex; flex-wrap: wrap; gap: 0; border-bottom: 1px solid var(--border, #c7d1df); }
.ident-v2-tab { position: relative; margin: 0 0 -1px; border: 1px solid transparent; border-bottom: 1px solid var(--border, #c7d1df); border-radius: 6px 6px 0 0; background: transparent; color: var(--muted); padding: 7px 10px; cursor: pointer; font-size: 12px; }
.ident-v2-tab:hover { color: inherit; background: color-mix(in srgb, var(--accent, #1677ff) 6%, transparent); }
.ident-v2-tab:focus-visible { z-index: 1; outline: 2px solid var(--accent, #1677ff); outline-offset: -2px; }
.ident-v2-tab.active { z-index: 1; border-color: var(--border, #c7d1df); border-bottom-color: var(--panel, #fff); background: var(--panel, #fff); color: var(--accent, #1677ff); font-weight: 600; }
.ident-v2-tab-panel { display: grid; gap: 8px; min-width: 0; padding-top: 2px; }
.ident-v2-tab-panel[hidden] { display: none; }
.ident-v2-layout-controls-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; align-items: end; }
.ident-v2-layout-controls-grid > .btn { width: 100%; }
.ident-v2-layout-check { min-height: 32px; align-self: end; }
.ident-v2-layout-span { grid-column: 1 / -1; min-width: 0; }
.ident-v2-layout-span > select { width: 100%; min-width: 0; }
.ident-v2-preview-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(235px, 290px); gap: 10px; align-items: start; }
.ident-v2-canvas { position: relative; min-height: 560px; overflow: auto; border: 1px solid var(--border, #c7d1df); border-radius: 6px; background-color: #eef3f8; background-position: center; background-size: cover; }
.ident-v2-canvas.ident-v2-label-canvas { width: 100%; min-height: 0; height: auto; }
.ident-v2-canvas.is-dragover { outline: 2px solid var(--accent, #1677ff); outline-offset: -2px; }
.ident-v2-label-safe-area { position: absolute; z-index: 0; box-sizing: border-box; border: 1px dashed #d4380d; pointer-events: none; }
.ident-v2-empty-canvas { display: grid; place-items: center; min-height: 558px; padding: 12px; color: #607387; text-align: center; }
.ident-v2-block { position: absolute; z-index: 1; min-width: 150px; min-height: 100px; overflow: auto; resize: both; box-sizing: border-box; border: 1px solid #71859a; border-radius: 6px; background: rgba(255,255,255,.94); box-shadow: 0 1px 3px rgba(0,0,0,.14); user-select: none; }
.ident-v2-block.selected { z-index: 2; border: 2px solid var(--accent, #1677ff); box-shadow: 0 0 0 2px rgba(22,119,255,.16); }
.ident-v2-block.is-dragover { border-color: var(--accent, #1677ff); background: rgba(224,239,255,.97); }
.ident-v2-block-content { min-height: 100%; padding: 7px; overflow: auto; color: #17212b; user-select: text; }
.ident-v2-card-content { box-sizing: border-box; display: flex; flex-direction: column; height: 100%; }
.ident-v2-card-content > .ident-v2-output { width: 100%; }
.ident-v2-print-counter { position: absolute; z-index: 10; min-width: 26px; padding: 2px 4px; color: #111; background: rgba(255,255,255,.72); border: 1px dashed transparent; border-radius: 3px; cursor: move; user-select: none; white-space: nowrap; touch-action: none; }
.ident-v2-print-counter.selected, .ident-v2-print-counter:hover { border-color: var(--accent, #1677ff); background: rgba(224,239,255,.94); }
.ident-v2-erase-mode .ident-v2-block { pointer-events: none; }
.ident-v2-erase-selection { position: absolute; z-index: 20; pointer-events: none; border: 2px dashed #d4380d; background: rgba(212,56,13,.18); }
.ident-v2-placeholder { display: grid; min-height: 72px; place-items: center; padding: 8px; color: #607387; font-size: 12px; text-align: center; }
.ident-v2-output { display: grid; gap: 7px; }
.ident-v2-output-value-only { gap: 0; }
.ident-v2-card-result { padding: 7px; border: 1px solid #c4d0dc; border-radius: 4px; background: rgba(255,255,255,.9); }
.ident-v2-card-title { margin-bottom: 6px; overflow-wrap: anywhere; }
.ident-v2-card-value-only { padding: 0; border: 0; border-radius: 0; background: transparent; }
.ident-v2-card-value-only .ident-v2-card-title { margin-bottom: 2px; }
.ident-v2-group-title { margin-bottom: 5px; font-size: .9em; font-weight: 700; }
.ident-v2-value-row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; border-top: 1px solid #dbe3eb; }
.ident-v2-value-row span { color: #4c5a67; font-size: .9em; }
.ident-v2-value-row strong { overflow-wrap: anywhere; text-align: right; }
.ident-v2-value-only { display: block; overflow-wrap: anywhere; text-align: inherit; }
.ident-v2-table-result { width: 100%; border-collapse: collapse; background: rgba(255,255,255,.92); font-size: inherit; }
.ident-v2-table-result th, .ident-v2-table-result td { padding: .38em .5em; border: 1px solid #b7c5d4; text-align: inherit; vertical-align: top; overflow-wrap: anywhere; }
.ident-v2-table-result th { background: rgba(230,238,247,.96); font-size: .9em; }
.ident-v2-matrix-table th { position: relative; }
.ident-v2-column-resizer { position: absolute; z-index: 1; top: 0; right: -3px; bottom: 0; width: 7px; cursor: col-resize; touch-action: none; }
.ident-v2-column-resizer:hover { background: color-mix(in srgb, var(--accent, #1677ff) 35%, transparent); }
.ident-v2-item-editor { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; min-width: 0; min-height: 220px; padding: 9px; border: 1px solid #71859a; border-radius: 6px; background: var(--panel, #fff); }
.ident-v2-item-editor > strong, .ident-v2-item-editor > .muted, .ident-v2-item-editor > .ident-v2-editor-label, .ident-v2-item-editor > .ident-v2-editor-fields, .ident-v2-item-editor > .btn.danger { grid-column: 1 / -1; }
.ident-v2-editor-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.ident-v2-editor-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; max-height: 245px; overflow: auto; }
.ident-v2-editor-field { display: grid; grid-template-columns: minmax(0, 1fr) minmax(80px, 100px) auto; gap: 5px; align-items: center; font-size: 12px; }
.ident-v2-editor-field strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ident-v2-editor-field select { min-width: 0; width: 100%; }
.ident-v2-check { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; }
.ident-v2-counter-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.ident-v2-counter-toolbar select { min-width: 105px; max-width: 130px; }
.ident-v2-counter-toolbar input { width: 58px; }
.ident-v2-toolbar-icon { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; padding: 0; border: 1px solid var(--border, #71859a); border-radius: 5px; background: var(--panel, #fff); color: inherit; cursor: pointer; }
.ident-v2-toolbar-icon.selected { border-color: var(--accent, #1677ff); box-shadow: 0 0 0 2px rgba(22,119,255,.16); color: var(--accent, #1677ff); }

@media (max-width: 980px) {
  .ident-v2-workspace { grid-template-columns: 1fr; }
  .ident-v2-preview-layout { grid-template-columns: 1fr; }
  .ident-v2-item-editor { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ident-v2-item-editor > strong, .ident-v2-item-editor > .ident-v2-editor-label, .ident-v2-editor-fields { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  .ident-v2-layout-controls-grid { grid-template-columns: 1fr; }
  .ident-v2-layout-span { grid-column: auto; }
  .ident-v2-formatting-toolbar { align-items: flex-start; }
  .ident-v2-formatting-toolbar > strong { flex-basis: 100%; }
  .ident-v2-output-palette, .ident-v2-item-editor, .ident-v2-editor-fields, .ident-v2-editor-field { grid-template-columns: 1fr; }
  .ident-v2-canvas { min-height: 470px; }
  .ident-v2-empty-canvas { min-height: 468px; }
}

/* Debug: painel flutuante não bloqueante */
.debug-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 9998; pointer-events: none; }
.debug-panel {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 9999;
  background: var(--panel);
  border: 0.26mm solid #23262d;
  border-radius: 2.12mm;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  width: 420px;
  max-width: 90vw;
  max-height: 80vh;
  resize: both;
  overflow: auto;
}
.debug-title { cursor: move; font-weight: 600; padding: 6px 8px; border-bottom: 1px solid #2b3138; }
.debug-content { padding: 8px; }
.debug-actions { display: flex; gap: 6px; justify-content: flex-end; padding: 8px; border-top: 1px solid #2b3138; }

/* --------------------------------------------------------------------------
   Casca visual do SafeLabel: referência de navegação e superfícies claras.
   Mantém as classes existentes para não alterar os fluxos das telas.
   -------------------------------------------------------------------------- */
:root,
.theme-light {
  --bg: #f8fafc;
  --panel: #ffffff;
  --muted: #64748b;
  --text: #172033;
  --accent: #2563eb;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #dc2626;
  --border: #e2e8f0;
  --surface-muted: #f8fafc;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-md: 0 10px 25px rgba(15, 23, 42, .08);
}

html, body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

body { overflow-x: hidden; }
button, input, select, textarea { font: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(37, 99, 235, .22);
  outline-offset: 1px;
}

.app-sidebar {
  position: fixed;
  z-index: 30;
  top: 0;
  bottom: 0;
  left: 0;
  display: flex;
  width: 280px;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .22s ease, transform .22s ease;
}
.app-sidebar:hover { box-shadow: var(--shadow-md); }
.brand-lockup {
  display: flex;
  min-height: 64px;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid #f1f5f9;
  color: #0f172a;
  white-space: nowrap;
}
.brand-mark {
  display: grid;
  width: 42px;
  height: 36px;
  flex: 0 0 42px;
  place-items: center;
  border-radius: 10px;
  overflow: hidden;
  background: #eff6ff;
}
.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.brand-name { overflow: hidden; font-size: 13px; font-weight: 800; letter-spacing: .02em; }
.sidebar-nav {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 16px 12px;
  scrollbar-color: #cbd5e1 transparent;
  scrollbar-width: thin;
}
/* O estilo legado de #nav usava flex-wrap para abas horizontais. Na sidebar,
   isso criava uma segunda coluna fora da área visível após "Grades". */
#nav.sidebar-nav {
  flex-wrap: nowrap;
  margin-top: 0;
}
.sidebar-nav::-webkit-scrollbar { width: 8px; }
.sidebar-nav::-webkit-scrollbar-thumb { border: 2px solid #fff; border-radius: 999px; background: #cbd5e1; }
.sidebar-footer { padding: 12px; border-top: 1px solid #f1f5f9; }
.nav-btn.sidebar-nav-btn {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  gap: 14px;
  overflow: hidden;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  transition: background .16s ease, border-color .16s ease, color .16s ease;
}
.nav-btn.sidebar-nav-btn svg { width: 20px; height: 20px; flex: 0 0 20px; }
.nav-btn.sidebar-nav-btn:hover { background: #f8fafc; color: #334155; }
.nav-btn.sidebar-nav-btn.active { border-color: #dbeafe; background: #eff6ff; color: #2563eb; }
.nav-btn.sidebar-nav-btn.nav-logout { color: #dc2626; }
.nav-btn.sidebar-nav-btn.nav-logout:hover { background: #fef2f2; color: #b91c1c; }
.nav-label { overflow: hidden; font-size: 13px; font-weight: 600; }

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 64px;
  align-items: center;
  gap: 16px;
  margin-left: 280px;
  padding: 0 28px;
  background: rgba(255, 255, 255, .94);
  border: 0;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 1px rgba(15, 23, 42, .02);
  backdrop-filter: blur(10px);
  transition: margin-left .22s ease;
}
.topbar-title { min-width: 0; }
.topbar-kicker { display: block; margin-bottom: 1px; color: #163b6d; font-size: 16px; font-weight: 800; letter-spacing: .06em; }
.app-header h1 { margin: 0; color: #172033; font-size: 16px; font-weight: 700; line-height: 1.25; }
.topbar-user { display: flex; min-width: 0; flex: 1; justify-content: flex-end; }
.user-indicator {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  padding: 5px 8px 5px 5px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: #475569;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}
.user-indicator:hover { border-color: #e2e8f0; background: #f8fafc; }
.user-avatar { display: grid; width: 29px; height: 29px; flex: 0 0 29px; place-items: center; border-radius: 50%; background: #dbeafe; color: #1d4ed8; font-size: 12px; font-weight: 800; }
.user-name { overflow: hidden; max-width: 210px; text-overflow: ellipsis; }
.gear-btn, .mobile-menu-btn {
  position: static;
  display: inline-grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  padding: 0;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  color: #64748b;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.gear-btn:hover, .mobile-menu-btn:hover { border-color: #bfdbfe; background: #eff6ff; color: #2563eb; }
.mobile-menu-btn { display: none; }

main#app {
  min-height: calc(100vh - 102px);
  margin-left: 280px;
  padding: 28px;
  transition: margin-left .22s ease;
}
.app-footer {
  margin-left: 280px;
  padding: 12px 28px;
  border: 0;
  border-top: 1px solid var(--border);
  background: transparent;
  color: #94a3b8;
  font-size: 11px;
  text-align: center;
  transition: margin-left .22s ease;
}

.footer-announcement {
  min-width: 0;
  justify-self: stretch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  color: #46627f;
}
.footer-announcement a { color: inherit; text-decoration: none; }
.footer-announcement a:hover { text-decoration: underline; }
.messages-btn {
  position: relative;
  border: 0;
  background: transparent;
  color: #ef4444;
  cursor: pointer;
  font-size: 17px;
  padding: 4px;
}
.messages-btn[data-unread]::after {
  content: attr(data-unread);
  position: absolute;
  top: -4px;
  right: -6px;
  min-width: 14px;
  height: 14px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 9px;
  line-height: 14px;
}

.panel, .card, .notice, .admin-tab-pane, .drop-zone, .drag-item, .icon-picker {
  border-color: var(--border);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}
.panel { padding: 20px; border-radius: 12px; margin-bottom: 20px; }
.panel h2 { margin-bottom: 14px; color: #172033; font-size: 19px; }
.panel h3, .panel h4 { color: #1e293b; }
.card { border-radius: 10px; }
.list { border-color: var(--border); border-style: solid; background: #fff; }
.list-item, .group-header { border-color: #eef2f7; }
.group-header { color: #475569; }
.muted, label { color: var(--muted); }
label { font-size: 12px; font-weight: 600; }
input[type="text"], input[type="password"], input[type="number"], input[type="date"], select, textarea,
.theme-light input[type="text"], .theme-light input[type="password"], .theme-light input[type="number"], .theme-light input[type="date"], .theme-light select, .theme-light textarea {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  box-shadow: inset 0 1px 1px rgba(15, 23, 42, .02);
}
input:hover, select:hover, textarea:hover { border-color: #94a3b8; }
input:focus, select:focus, textarea:focus { border-color: #2563eb; outline: 0; box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.rows input:disabled, .rows select:disabled, .rows textarea:disabled { border-color: #e2e8f0; background: #f8fafc; box-shadow: none; }
.btn {
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  background: #fff;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
  transition: background .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.btn:hover { border-color: #94a3b8; background: #f8fafc; box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn.primary { border-color: #2563eb; background: #2563eb; color: #fff; }
.btn.primary:hover { border-color: #1d4ed8; background: #1d4ed8; }
.btn.danger { border-color: #fecaca; background: #fef2f2; color: #dc2626; }
.btn.danger:hover { border-color: #fca5a5; background: #fee2e2; }
.theme-light .btn, .theme-light .btn.primary, .theme-light .btn.danger { color: inherit; }
.theme-light .btn.primary { color: #fff; background: #2563eb; }
.theme-light .btn.danger { color: #dc2626; background: #fef2f2; }
.tab-btn, .theme-light .tab-btn { border: 1px solid transparent; border-radius: 8px; background: #f8fafc; color: #64748b; }
.tab-btn:hover { background: #f1f5f9; color: #334155; }
.tab-btn.active, .theme-light .tab-btn.active { border-color: #dbeafe; background: #eff6ff; color: #2563eb; }
.admin-tab-pane, .theme-light .admin-tab-pane { border-style: solid; border-radius: 10px; }
.vf-table th, .vf-table td { border-color: var(--border); }
.vf-table th { background: #f8fafc; color: #475569; }
.modal-overlay { background: rgba(15, 23, 42, .42); padding: 20px; }
.modal { width: min(560px, 100%); border: 1px solid var(--border); border-radius: 14px; background: #fff; box-shadow: var(--shadow-md); }
.modal h3 { color: #172033; }
.modal-actions { border-top: 1px solid #f1f5f9; padding-top: 14px; }
.device-agent-install-guide-modal { width: min(1080px, 100%); max-height: 90vh; }
.device-agent-smartscreen-guide { margin: 16px 0; }
.device-agent-smartscreen-guide-image { display: block; width: 50%; height: auto; margin: 0 auto; border: 1px solid #d6e1ee; border-radius: 10px; }
.device-agent-smartscreen-guide figcaption { margin-top: 8px; text-align: center; }
.debug-panel { border-color: var(--border); background: #fff; box-shadow: var(--shadow-md); }
.debug-title, .debug-actions { border-color: #e2e8f0; }

.mobile-nav-backdrop { display: none; }

@media (max-width: 768px) {
  .app-sidebar { width: 280px; transform: translateX(-100%); box-shadow: var(--shadow-md); }
  body.mobile-nav-open .app-sidebar { transform: translateX(0); }
  .mobile-nav-backdrop { position: fixed; z-index: 25; inset: 0; background: rgba(15, 23, 42, .38); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
  body.mobile-nav-open .mobile-nav-backdrop { display: block; opacity: 1; pointer-events: auto; }
  .app-header, main#app, .app-footer { margin-left: 0; }
  .app-header { min-height: 58px; padding: 0 16px; gap: 12px; }
  .mobile-menu-btn { display: inline-grid; }
  .topbar-kicker { display: none; }
  .app-header h1 { font-size: 15px; }
  .user-name { display: none; }
  .user-indicator { padding-right: 0; }
  main#app { min-height: calc(100vh - 94px); padding: 16px; }
  .app-footer { padding: 10px 16px; }
  .panel { padding: 16px; border-radius: 10px; }
  .rows.twoCols, .rows.threeCols, .rows.fourCols, .grid.cols-2, .grid.cols-3, .grid.cols-4, .grid.cols-6 { grid-template-columns: 1fr; }
}

@media print {
  .app-sidebar, .mobile-nav-backdrop, .app-header, .app-footer { display: none !important; }
  main#app { min-height: 0; margin: 0 !important; padding: 0 !important; }
}

/* Listas de cadastros: leitura rápida, ações previsíveis e códigos discretos. */
.panel > .list > .list-item {
  position: relative;
  min-height: 58px;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid #e7edf5;
  background: #fff;
}
.panel > .list > .list-item:nth-child(even) { background: #f7faff; }
.panel > .list > .list-item:hover { background: #eff6ff; }
.panel > .list > .list-item:last-child { border-bottom: 0; }
.list-row-content { min-width: 0; flex: 1 1 auto; }
.list-item:has(> .list-record-content) {
  align-items: flex-start;
  justify-content: flex-start;
}
.list-item:has(> .list-record-content + .list-record-actions) {
  flex-direction: column;
  align-items: stretch;
}
/* Listas de cadastros: linhas alternadas para leitura rápida. */
.cadastro-record-list > .list-item {
  min-height: 46px;
  background: #ffffff;
  transition: background .16s ease, box-shadow .16s ease;
}
.cadastro-record-list > .list-item:nth-child(even) { background: #f8fafc; }
.cadastro-record-list > .editable-list-card:hover { background: #eff6ff; }
.cadastro-record-list > .editable-list-card:focus-visible {
  background: #eff6ff;
  outline: 2px solid #2563eb;
  outline-offset: -2px;
}
.cadastro-record-list > .list-item.is-selected,
.cadastro-record-list > .grade-catalog-item.is-selected { background: #e8f0ff; }
.list-record-content {
  min-width: 0;
  flex: 1 1 auto;
  color: #334155;
}
.list-record-summary {
  display: flex;
  align-items: baseline;
  gap: 0;
  min-width: 0;
  flex-wrap: wrap;
  line-height: 1.5;
}
.list-record-title,
.list-record-content > .list-row-title {
  color: #1e293b;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.list-record-details,
.list-record-content > .muted {
  color: #475569;
  font-size: 12px;
  overflow-wrap: anywhere;
}
.list-record-separator { color: #64748b; font-weight: 600; }
/* Registros legados que ainda têm título e detalhe como irmãos recebem o
   mesmo resumo visual sem precisar alterar seus handlers. */
.list-record-content > .list-row-title { display: inline; }
.list-record-content > .list-row-title:not(:has(.list-language-code))::after { content: ': '; color: #64748b; }
.list-record-content > .list-row-title + .muted { display: inline; }
.list-record-content > .list-row-title .list-language-code::before { content: ': '; color: #64748b; font-family: Arial, sans-serif; font-weight: 600; }
.list-record-actions {
  display: flex;
  flex: 0 0 auto;
  justify-content: flex-start;
  align-items: center;
  gap: 6px;
  margin: 8px 0 0;
  flex-wrap: wrap;
}
.panel > .list > .list-item .list-record-actions {
  position: static;
  padding: 0;
  margin-top: 8px;
}
.list-record-summary > .list-record-actions {
  order: 10;
  width: 100%;
}
.list-record-summary > .list-row-title { order: 1; }
.list-record-summary > .list-code { order: 2; }
.list-record-summary > .list-code::before { content: ': '; color: #64748b; font-family: Arial, sans-serif; font-weight: 600; }
.list-record-summary > .muted { order: 3; }
.list-row-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: #1e293b;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.list-code {
  display: inline-block;
  color: #64748b;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .015em;
}
.list-language-code {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 1px 7px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.language-active-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
  color: #385b7f;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}
.language-active-toggle input { accent-color: #2563eb; cursor: pointer; }
.language-active-toggle input:not(:checked) + span { color: #7b8794; font-weight: 600; }
.list-languages {
  margin-top: 4px;
  color: #334155;
  font-size: 12px;
  line-height: 1.5;
}
.panel > .list > .list-item .btnRow,
.panel > .list > .list-item .list-row-actions {
  display: flex;
  flex: 0 0 auto;
  justify-content: flex-end;
  gap: 6px;
  margin: 0 0 0 auto;
}
/* Cadastros legados ainda aninham a área de ações no texto da linha. */
.panel > .list > .list-item:has(.btnRow):not(:has(> .btnRow)) { padding-right: 235px; }
.panel > .list > .list-item .btnRow:not(:last-child) {
  position: absolute;
  top: 12px;
  right: 14px;
}
.panel > .list > .list-item > .btnRow,
.panel > .list > .list-item > .list-row-actions { position: static; }
.panel > .list > .list-item .btn {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}
.panel > .list > .list-item .list-record-actions,
.user-list-block .list-record-actions {
  position: static;
  width: auto;
  margin: 8px 0 0;
  padding: 0;
  justify-content: flex-start;
}

@media (max-width: 768px) {
  .panel > .list > .list-item:has(.btnRow):not(:has(> .btnRow)) { padding-right: 14px; }
  .panel > .list > .list-item .btnRow:not(:last-child) {
    position: static;
    width: 100%;
    margin-top: 10px;
  }
  .panel > .list > .list-item { align-items: flex-start; flex-wrap: wrap; }
}

/* Protótipo: cada coluna respeita o espaço disponível e seus controles não invadem o card vizinho. */
.prototype-layout-scroll {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  padding-bottom: 2px;
}
.prototype-main-grid {
grid-template-columns: minmax(280px, 1fr) minmax(500px, 2.05fr) minmax(340px, 1.65fr);
min-width: 1180px;
}
.prototype-main-grid > *,
.prototype-column,
.prototype-column > .panel,
.prototype-column .list-item,
.prototype-column .rows > * { min-width: 0; max-width: 100%; }
.prototype-column > .panel { overflow: hidden; }
.prototype-column .list,
.prototype-column .btnRow { max-width: 100%; }
.prototype-column .list { overflow-x: auto; }
.prototype-column .btnRow { flex-wrap: wrap; }
.prototype-column input,
.prototype-column select,
.prototype-column textarea,
.prototype-column iframe { min-width: 0; max-width: 100%; }
.prototype-column label,
.prototype-column .muted { overflow-wrap: anywhere; }
.prototype-print-workspace {
  display: grid;
  grid-template-columns: minmax(150px, .55fr) minmax(230px, 1fr);
  gap: 12px;
  align-items: start;
  margin-top: 10px;
}
.prototype-print-grade-area { min-width: 0; }
.prototype-print-workspace .prototype-print-tabs { min-width: 0; }
.prototype-edit-tabs { margin-bottom: 0; }
.prototype-edit-tab-list {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  border-bottom: 1px solid #dbe3ed;
}
.prototype-edit-tab {
  margin: 0 0 -1px;
  padding: 6px 8px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: #64748b;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.prototype-edit-tab:hover { background: #f1f5f9; color: #334155; }
.prototype-edit-tab.active { border-bottom-color: #2563eb; color: #2563eb; }
.prototype-edit-tab:focus-visible { outline: 2px solid #2563eb; outline-offset: -2px; }
.prototype-edit-tab-pane[hidden] { display: none; }
.prototype-edit-parts-content { display: flex; flex-direction: column; gap: 10px; }
.prototype-print-tabs { margin-bottom: 0; }
.prototype-print-tab-list {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  border-bottom: 1px solid #dbe3ed;
}
.prototype-print-tab {
  margin: 0 0 -1px;
  padding: 6px 8px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: #64748b;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.prototype-print-tab:hover { background: #f1f5f9; color: #334155; }
.prototype-print-tab.active { border-bottom-color: #2563eb; color: #2563eb; }
.prototype-print-tab:focus-visible { outline: 2px solid #2563eb; outline-offset: -2px; }
.prototype-print-tab-pane[hidden] { display: none; }
.prototype-print-queue-stack { display: flex; flex-direction: column; gap: 8px; }
.prototype-print-queue-stack > .panel { margin: 0; }
.prototype-malhas-content { min-width: 0; }
.prototype-offset-content { min-width: 0; }
@media (max-width: 760px) {
  .prototype-edit-tab-list { overflow-x: auto; }
  .prototype-edit-tab { flex: 0 0 auto; }
  .prototype-print-tab-list { overflow-x: auto; }
  .prototype-print-tab { flex: 0 0 auto; }
}

/* Sidebar compacta: ícones sempre visíveis, nomes aparecem apenas durante a interação. */
@media (min-width: 769px) {
  .app-sidebar { width: 72px; transition: width .22s ease, box-shadow .22s ease, transform .22s ease; }
  .brand-lockup { justify-content: center; gap: 0; padding: 0 15px; }
  .brand-name { width: 0; opacity: 0; transition: width .2s ease, opacity .15s ease; }
  .sidebar-nav { padding-right: 10px; padding-left: 10px; }
  .sidebar-footer { padding: 10px; }
  .nav-btn.sidebar-nav-btn { justify-content: center; gap: 0; padding-right: 10px; padding-left: 10px; }
  .nav-label { width: 0; opacity: 0; transition: width .2s ease, opacity .15s ease; }
  .app-header, main#app, .app-footer { margin-left: 72px; }

  body.sidebar-expanded .app-sidebar { width: 280px; }
  body.sidebar-expanded .brand-lockup { justify-content: flex-start; gap: 12px; padding: 0 20px; }
  body.sidebar-expanded .brand-name { width: auto; opacity: 1; }
  body.sidebar-expanded .sidebar-nav { padding-right: 12px; padding-left: 12px; }
  body.sidebar-expanded .sidebar-footer { padding: 12px; }
  body.sidebar-expanded .nav-btn.sidebar-nav-btn { justify-content: flex-start; gap: 14px; padding-right: 12px; padding-left: 12px; }
  body.sidebar-expanded .nav-label { width: auto; opacity: 1; }
  body.sidebar-expanded .app-header,
  body.sidebar-expanded main#app,
  body.sidebar-expanded .app-footer { margin-left: 280px; }
}

/* Administração > Abas: ordenação global do menu lateral. */
.admin-nav-order-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px;
  margin-top: 14px;
}
.admin-nav-order-item {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  background: #fff;
  color: #334155;
  cursor: grab;
  user-select: none;
}
.admin-nav-order-item:active { cursor: grabbing; }
.admin-nav-order-item:hover { border-color: #93c5fd; background: #f8fbff; }
.admin-nav-order-item.is-dragging { opacity: .45; }
.admin-nav-order-item.is-drop-target { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37, 99, 235, .16); }
.admin-nav-order-item svg { width: 19px; height: 19px; flex: 0 0 19px; color: #2563eb; }
.admin-nav-order-grip { color: #94a3b8; font-weight: 800; letter-spacing: -1px; }
.admin-nav-order-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }

/* A preferência de impressora/papel é salva automaticamente por layout. */
button[title="Salvar impressora e folha para este layout"] { display: none; }

/* Autenticação: visual próprio sem alterar a interface após o login. */
body.login-screen {
  min-height: 100%;
  background: var(--bg);
}
body.login-screen .app-sidebar,
body.login-screen .app-header,
body.login-screen .app-footer,
body.login-screen .mobile-nav-backdrop {
  display: none !important;
}
body.login-screen main#app {
  display: grid;
  min-height: 100vh;
  margin-left: 0 !important;
  padding: clamp(20px, 5vw, 64px);
  place-items: center;
}
.login-screen-shell {
  width: min(880px, 100%);
}
.login-card {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(280px, .92fr);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow-md);
}
.login-card-column { min-width: 0; }
.login-card-column-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: clamp(28px, 5vw, 52px);
}
.login-brand { display: flex; min-height: 144px; align-items: center; justify-content: center; }
.login-logo-image {
  display: block;
  width: min(280px, 100%);
  max-height: 144px;
  object-fit: contain;
  object-position: center;
}
.login-card-form { gap: 18px; }
.login-form-intro { display: grid; gap: 4px; }
.login-form-intro h2 { margin: 0; color: var(--text); font-size: 21px; }
.login-form-intro p { margin: 0; color: var(--muted); font-size: 13px; }
.login-field { display: grid; gap: 6px; }
.login-field label { color: var(--text); font-size: 13px; font-weight: 700; }
.login-field input {
  width: 100%;
  min-height: 44px;
  border-color: var(--border);
  background: var(--panel);
}
.login-password-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
.login-password-control .btn { min-height: 44px; white-space: nowrap; }
.login-actions { justify-content: flex-start; margin-top: 4px; }
.login-actions .btn { min-height: 44px; padding-right: 24px; padding-left: 24px; }
.login-card-welcome {
  display: grid;
  align-items: center;
  padding: clamp(32px, 5vw, 56px);
  background: linear-gradient(145deg, #174b85, #0f2f5a);
  color: #fff;
}
.login-welcome-content { display: grid; gap: 16px; }
.login-welcome-eyebrow {
  color: #bfdbfe;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.login-card-welcome h1 { margin: 0; color: #fff; font-size: clamp(28px, 4vw, 38px); line-height: 1.12; }
.login-card-welcome p { margin: 0; color: #dbeafe; font-size: 15px; line-height: 1.65; }
.login-card-welcome .login-welcome-help { margin-top: 10px; color: #bfdbfe; font-size: 12px; }

/* Cadastro de empresa: tela exclusiva, sem a coluna institucional do login. */
body.login-screen.company-registration-screen main#app {
  padding: 12px;
  place-items: stretch;
}
.login-screen-shell-registration {
  width: 100%;
  min-height: calc(100dvh - 24px);
}
.login-card-registration {
  width: 100%;
  min-height: calc(100dvh - 24px);
  grid-template-columns: minmax(0, 1fr);
}
.login-card-registration .login-card-welcome { display: none; }
.login-card-registration .login-card-column-form {
  gap: 10px;
  padding: clamp(16px, 2.2vw, 30px);
}
.login-card-registration .login-brand { min-height: 64px; }
.login-card-registration .login-logo-image { width: min(180px, 100%); max-height: 64px; }
.company-registration-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 10px;
}
.company-registration-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 14px;
}
.company-registration-fields .login-field { min-width: 0; }
.company-registration-fields .company-registration-api-filled {
  cursor: default;
  background: #f1f5f9;
  border-color: #bfdbfe;
  color: #334155;
}
.company-registration-field-street { grid-column: span 2; }
.company-registration-section-title {
  grid-column: 1 / -1;
  margin: 2px 0 0;
  color: var(--text);
  font-size: 15px;
}
.login-card-registration .login-actions { margin-top: 0; }

@media (max-height: 760px) and (min-width: 681px) {
  .login-card-registration .login-card-column-form { gap: 7px; padding-top: 12px; padding-bottom: 12px; }
  .login-card-registration .login-brand { min-height: 50px; }
  .login-card-registration .login-logo-image { max-height: 50px; }
  .company-registration-form, .company-registration-fields { gap: 7px 10px; }
  .login-card-registration .login-field { gap: 4px; }
  .login-card-registration .login-field label { font-size: 12px; }
  .login-card-registration .login-field input,
  .login-card-registration .login-field select,
  .login-card-registration .login-actions .btn { min-height: 38px; }
}

@media (max-width: 680px) {
  body.login-screen main#app { padding: 16px; place-items: start center; }
  .login-screen-shell { margin: auto 0; }
  .login-card { grid-template-columns: minmax(0, 1fr); border-radius: 16px; }
  .login-card-column-form { gap: 14px; padding: 28px 22px; }
  .login-brand { min-height: 116px; }
  .login-logo-image { max-height: 116px; }
  .login-card-welcome { min-height: 190px; padding: 30px 22px; }
  body.login-screen.company-registration-screen main#app { padding: 12px; }
  .login-screen-shell-registration, .login-card-registration { min-height: auto; }
  .company-registration-fields { grid-template-columns: minmax(0, 1fr); }
  .company-registration-field-street { grid-column: auto; }
}

/* Rodapé da aplicação: sessão e administração sem cabeçalho superior. */
main#app { min-height: calc(100vh - 58px); }
.app-footer {
  display: grid;
  min-height: 58px;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 10px 28px;
  text-align: center;
}
.footer-session {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-self: end;
  gap: 8px;
}
.footer-user { min-width: 0; }
.footer-user .user-indicator {
  position: static;
  top: auto;
  right: auto;
}
.app-footer .gear-btn { flex: 0 0 34px; }
body.login-screen .mobile-menu-btn { display: none !important; }

@media (max-width: 768px) {
  main#app { min-height: calc(100vh - 58px); }
  .mobile-menu-btn {
    position: fixed;
    z-index: 35;
    top: 12px;
    left: 12px;
    display: inline-grid;
    box-shadow: var(--shadow-md);
  }
  .app-footer {
    grid-template-columns: minmax(0, 1fr) auto;
    margin-left: 0;
    padding: 10px 16px;
  }
  .footer-spacer { display: none; }
  #footer-copyright { justify-self: start; }
  .footer-session { gap: 4px; }
  .footer-user .user-indicator { padding-right: 5px; }
  .footer-user .user-name { display: none; }
}

/* Sem cabeçalho, os cadastros usam a altura útil da janela e preservam o rodapé. */
main#app {
  padding-top: 12px;
  padding-bottom: 12px;
}
main#app > .panel:last-child { margin-bottom: 0; }
.ident-v2-page {
  height: min(760px, calc(100dvh - 82px));
  max-height: min(760px, calc(100dvh - 82px));
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
}
.grades-page-panel {
  display: flex;
  height: calc(100dvh - 82px);
  max-height: calc(100dvh - 82px);
  min-height: 0;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: hidden;
}
.grades-workspace {
  flex: 1 1 auto;
  min-height: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}
.grades-subtabs-nav { flex: 0 0 auto; }
.split-management-grid.grades-subtab-grid {
  width: 100%;
  height: 100%;
  max-height: none;
}
.grades-subtab-pane {
  display: none;
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 10px;
  overflow: hidden;
}
.grades-subtab-pane.active { display: flex; }
.grades-subtab-card {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 0;
  overflow: hidden;
}
.grades-subtab-card > h3,
.grades-subtab-card > h4 { margin: 0; }
.grade-items-picker-list {
  max-height: min(55vh, 480px);
  overflow-y: auto;
}
.grade-catalog-item.is-disabled {
  opacity: .58;
  cursor: not-allowed;
}
.grades-workspace-card {
  display: flex;
  min-width: 0;
  min-height: 0;
  height: 100%;
  flex-direction: column;
  overflow: hidden;
  margin-bottom: 0;
}
.grades-workspace-list {
  min-height: 0;
  max-height: none !important;
  overflow-x: hidden;
  overflow-y: auto !important;
}
.grades-items-list,
.grades-list {
  flex: 1 1 0;
}
.grades-selected-list:empty {
  display: none;
}
.grades-selected-list:not(:empty) {
  flex: 0 1 32%;
}
.grade-catalog-item {
  cursor: pointer;
}
.grade-catalog-item.is-selected {
  background: #e8f0ff;
  border-color: #2f66d0;
}
.grade-composition-item {
  cursor: grab;
}
.grade-composition-item:active {
  cursor: grabbing;
}
@media (max-width: 980px) {
  .grades-page-panel { overflow-y: auto; }
  .grades-workspace { flex: 0 0 auto; grid-template-columns: 1fr; }
  .grades-workspace-card { min-height: 360px; }
}
@media (max-width: 1000px) {
  .grades-page-panel { overflow-y: auto; }
  .grades-subtab-pane { overflow: visible; }
  .split-management-grid.grades-subtab-grid { height: auto; }
}
.user-management-grid,
.split-management-grid,
.references-workspace {
  height: min(760px, calc(100dvh - 172px));
  max-height: min(760px, calc(100dvh - 172px));
}

@media (max-width: 1100px) {
  .user-management-grid,
  .split-management-grid,
  .references-workspace {
    height: auto;
    max-height: none;
  }
}

@media (max-width: 768px) {
  main#app { padding: 10px 12px; }
}

/* --------------------------------------------------------------------------
   Tema claro: identidade SafeLabel inspirada na tela de acesso.
   Esta camada é intencionalmente limitada ao tema claro para preservar os
   demais temas e manter os layouts e fluxos existentes.
   -------------------------------------------------------------------------- */
.theme-light {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #102a4c;
  --muted: #58708f;
  --accent: #2563eb;
  --border: #d9e2ef;
  --surface-muted: #f7f9fc;
  --shadow-sm: 0 1px 2px rgba(15, 47, 90, .05);
  --shadow-md: 0 14px 34px rgba(15, 47, 90, .10);
}

.theme-light .app-sidebar {
  background: linear-gradient(160deg, #1f528d 0%, #17457d 48%, #0f2f5a 100%);
  border-right-color: rgba(255, 255, 255, .14);
  box-shadow: 5px 0 24px rgba(15, 47, 90, .14);
}
.theme-light .app-sidebar:hover { box-shadow: 7px 0 28px rgba(15, 47, 90, .18); }
.theme-light .brand-lockup {
  border-bottom-color: rgba(255, 255, 255, .16);
  color: #ffffff;
}
.theme-light .brand-mark {
  border: 1px solid rgba(255, 255, 255, .32);
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 4px 12px rgba(7, 28, 58, .18);
}
.theme-light .brand-name { color: #ffffff; font-size: 14px; letter-spacing: .035em; }
.theme-light .sidebar-nav {
  scrollbar-color: rgba(191, 219, 254, .66) transparent;
}
.theme-light .sidebar-nav::-webkit-scrollbar-thumb {
  border-color: #16447c;
  background: rgba(191, 219, 254, .72);
}
.theme-light .nav-btn.sidebar-nav-btn {
  color: rgba(239, 246, 255, .84);
  font-weight: 650;
}
.theme-light .nav-btn.sidebar-nav-btn:hover {
  background: rgba(255, 255, 255, .11);
  color: #ffffff;
}
.theme-light .nav-btn.sidebar-nav-btn.active {
  border-color: rgba(255, 255, 255, .25);
  background: rgba(255, 255, 255, .17);
  box-shadow: inset 3px 0 0 #93c5fd;
  color: #ffffff;
}
.theme-light .nav-btn.sidebar-nav-btn.nav-logout { color: #fee2e2; }
.theme-light .nav-btn.sidebar-nav-btn.nav-logout:hover {
  background: rgba(127, 29, 29, .28);
  color: #ffffff;
}
.theme-light .sidebar-footer { border-top-color: rgba(255, 255, 255, .16); }

.theme-light .app-header {
  background: rgba(255, 255, 255, .91);
  border-bottom-color: #dce5f0;
  box-shadow: 0 1px 0 rgba(15, 47, 90, .03);
}
.theme-light .topbar-kicker {
  color: #28598f;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.theme-light .app-header h1 { color: #102a4c; font-size: 17px; font-weight: 750; }
.theme-light .user-indicator {
  border-color: #dbe5f1;
  background: #f8fbff;
  color: #38526f;
}

.theme-light main#app { background: var(--bg); }
.theme-light .panel,
.theme-light .card,
.theme-light .notice,
.theme-light .admin-tab-pane,
.theme-light .drop-zone,
.theme-light .drag-item,
.theme-light .icon-picker {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.theme-light .panel { border-radius: 14px; }
.theme-light .panel h2 { color: #102a4c; font-size: 20px; font-weight: 750; }
.theme-light .panel h3,
.theme-light .panel h4 { color: #173b68; }
.theme-light .list {
  border-color: #dbe4ef;
  border-radius: 10px;
  background: #ffffff;
}
.theme-light .list-item,
.theme-light .group-header { border-color: #e8eef5; }
.theme-light .list-record-content { color: #294765; }
.theme-light .cadastro-record-list > .list-item { background: #ffffff; }
.theme-light .cadastro-record-list > .list-item:nth-child(even) { background: #f5f7fa; }
.theme-light .cadastro-record-list > .editable-list-card:hover,
.theme-light .cadastro-record-list > .list-item:hover { background: #edf5ff; }
.theme-light .cadastro-record-list > .list-item.is-selected,
.theme-light .cadastro-record-list > .grade-catalog-item.is-selected { background: #dbeafe; }

/* Listas de cadastro: a mesma hierarquia visual da lista de Fibras. */
.cadastro-record-list > .list-item {
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
}
.cadastro-record-list .list-record-content,
.cadastro-record-list .list-row-content {
  min-width: 0;
  line-height: 1.45;
}
.cadastro-record-list .list-row-title,
.cadastro-record-list .list-record-title {
  display: block;
  color: #1e293b;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.cadastro-record-list .list-record-summary {
  display: grid;
  gap: 4px;
  align-items: start;
}
.cadastro-record-list .list-record-separator { display: none; }
.cadastro-record-list .list-record-details,
.cadastro-record-list .list-record-content > .muted,
.cadastro-record-list .list-row-content > .muted,
.cadastro-record-list .list-record-summary > .list-code {
  display: block;
  color: #475569;
  font-family: inherit;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: normal;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.cadastro-record-list .list-record-summary > .list-code::before { content: none; }
.cadastro-record-list .list-languages { margin-top: 4px; }
.theme-light .cadastro-record-list .list-row-title,
.theme-light .cadastro-record-list .list-record-title { color: #173b68; }
.theme-light .cadastro-record-list .list-record-details,
.theme-light .cadastro-record-list .list-record-content > .muted,
.theme-light .cadastro-record-list .list-row-content > .muted,
.theme-light .cadastro-record-list .list-record-summary > .list-code { color: #58708f; }

.theme-light input[type="text"],
.theme-light input[type="password"],
.theme-light input[type="number"],
.theme-light input[type="date"],
.theme-light select,
.theme-light textarea {
  border-color: #cbd8e8;
  border-radius: 9px;
  background: #ffffff;
  color: #102a4c;
}
.theme-light input:hover,
.theme-light select:hover,
.theme-light textarea:hover { border-color: #9db5d0; }
.theme-light input:focus,
.theme-light select:focus,
.theme-light textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}
.theme-light .rows input:disabled,
.theme-light .rows select:disabled,
.theme-light .rows textarea:disabled,
.theme-light input:disabled,
.theme-light select:disabled,
.theme-light textarea:disabled {
  border-color: #dce5f0;
  background: #f4f7fb;
  color: #758aa3;
  opacity: 1;
}

.theme-light .btn {
  border-color: #cbd8e8;
  border-radius: 9px;
  background: #ffffff;
  color: #234567;
  font-weight: 700;
}
.theme-light .btn:hover {
  border-color: #9db5d0;
  background: #f6f9fd;
  box-shadow: 0 3px 10px rgba(15, 47, 90, .08);
}
.theme-light .btn.primary,
.theme-light .crud-action-bar .crud-action-save {
  border-color: #2563eb;
  background: #2563eb;
  box-shadow: 0 5px 12px rgba(37, 99, 235, .18);
  color: #ffffff;
}
.theme-light .btn.primary:hover,
.theme-light .crud-action-bar .crud-action-save:hover { border-color: #1d4ed8; background: #1d4ed8; }
.theme-light .btn:disabled,
.theme-light .btn:disabled:hover,
.theme-light .crud-action-bar .crud-action:disabled,
.theme-light .crud-action-bar .crud-action:disabled:hover {
  border-color: #d9e2ef;
  background: #eef3f8;
  box-shadow: none;
  color: #91a1b5;
  cursor: not-allowed;
}
.theme-light .btn.danger,
.theme-light .crud-action-bar .crud-action-delete {
  border-color: #fecaca;
  background: #fff5f5;
  box-shadow: none;
  color: #c73636;
}
.theme-light .crud-action-bar .crud-action-cancel { background: #ffffff; color: #234567; }

.theme-light .tab-btn,
.theme-light .admin-tabs-nav .tab-btn {
  border-color: transparent;
  border-radius: 9px;
  background: #f3f6fa;
  color: #58708f;
  font-weight: 700;
}
.theme-light .tab-btn:hover { background: #eaf1f9; color: #234567; }
.theme-light .tab-btn.active,
.theme-light .admin-tabs-nav .tab-btn.active {
  border-color: #cfe0f7;
  background: #e9f2ff;
  color: #1d5ba8;
}
.theme-light .modal-overlay { background: rgba(10, 35, 67, .48); }
.theme-light .modal {
  border-color: #d6e1ee;
  border-radius: 16px;
  box-shadow: 0 18px 42px rgba(10, 35, 67, .22);
}
.theme-light .modal h3 { color: #102a4c; }
.theme-light .modal-actions { border-top-color: #e7edf4; }
.theme-light .app-footer {
  border-top-color: #dce5f0;
  color: #6f849c;
}

@media (max-width: 768px) {
  .theme-light .app-sidebar { box-shadow: 7px 0 28px rgba(15, 47, 90, .24); }
  .theme-light .mobile-nav-backdrop { background: rgba(10, 35, 67, .48); }
  .theme-light .mobile-menu-btn {
    border-color: #cbd8e8;
    background: #ffffff;
    color: #17457d;
  }
}
