
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(124, 92, 255, 0.10), transparent 32%),
    linear-gradient(225deg, rgba(34, 199, 242, 0.08), transparent 34%),
    var(--bg);
}

button,
.settings-section .setting-toggle {
  min-height: 45px;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 11px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 7px;
  background: #0a1726;
}

.settings-section .setting-toggle input[type="checkbox"] {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  margin: 0;
  padding: 0;
  accent-color: var(--cyan);
  box-shadow: none;
  cursor: pointer;
}

input,
textarea,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  min-height: 76px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  padding: 12px 34px;
  background: rgba(7, 20, 34, 0.92);
  border-bottom: 1px solid rgba(124, 92, 255, 0.42);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(14px);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  width: fit-content;
  max-width: 100%;
  padding: 0;
  color: #ffffff;
  text-decoration: none;
  justify-self: center;
}

.brand-logo {
  display: block;
  width: 154px;
  height: 50px;
  object-fit: contain;
  object-position: center;
}

.brand-mark span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.brand-mark strong {
  display: none;
}

.brand-mark.logo-only {
  grid-column: 2;
}

.brand-mark.large {
  width: 100%;
  justify-content: center;
}

.page-title {
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
  min-width: 0;
  color: var(--ink);
  font-weight: 900;
  text-align: center;
}

.page-title span {
  display: block;
  font-size: 24px;
  line-height: 1;
}

.page-title small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.top-actions {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 20px 34px 34px;
}

.workspace,
.summary-panel,
.login-box,
.settings-section {
  background: rgba(7, 20, 34, 0.90);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.20);
}

.workspace {
  min-width: 0;
  /* `clip` recorta igual ao `hidden`, mas NAO cria contexto de rolagem: com
     `hidden` aqui, a barra de acoes grudada no rodape simplesmente nao
     grudava, porque o sticky passava a se ancorar nesta secao, que nao rola. */
  overflow: clip;
}

.workspace-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 14px;
  color: #ffffff;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.workspace-title span {
  font-size: 28px;
  line-height: 1;
  font-weight: 900;
}

.workspace-title small {
  display: none;
}

.new-quote-button {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 14px;
  white-space: nowrap;
}

.ai-builder {
  display: grid;
  gap: 11px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.ai-builder label {
  color: #c8d6e5;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.ai-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 154px;
  gap: 10px;
  align-items: stretch;
}

.ai-input-row textarea {
  min-height: 74px;
  line-height: 1.4;
  resize: vertical;
}

.ai-input-row button {
  min-height: 74px;
}

.ai-message {
  min-height: 17px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.ai-message.is-loading,
.row-status.is-pending,
.row-status.is-loading {
  color: var(--cyan);
}

.ai-message.is-loading {
  display: flex;
  align-items: center;
  gap: 9px;
}

/* `box-sizing` porque a borda entrava por fora dos 13px e o círculo saía
   maior que a faixa reservada para ele; a trilha vem do token para não ser um
   azul de tema escuro clareando sobre o fundo branco do tema claro. */
.ai-message.is-loading::before {
  box-sizing: border-box;
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  content: "";
  border: 2px solid color-mix(in srgb, var(--cyan) 24%, transparent);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: ai-loading-spin 0.8s linear infinite;
}

.ai-message.is-loading.is-changing {
  animation: ai-message-change 0.42s ease both;
}

@keyframes ai-loading-spin {
  to { transform: rotate(360deg); }
}

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

.ai-message.is-success,
.row-status.is-success {
  color: var(--green);
}

.ai-message.is-error,
.row-status.is-error {
  color: var(--danger);
}

.quote-toolbar {
  display: grid;
  grid-template-columns: 90px minmax(190px, 1fr) 170px 150px 120px;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.field,
.stack-form label,
.settings-section label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  color: #c8d6e5;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 7px;
  padding: 10px 11px;
  background: #0a1726;
  color: var(--ink);
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: #7589a3;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.20);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  background: var(--surface);
}

.parts-table {
  width: 100%;
  min-width: 660px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.parts-table th {
  height: 40px;
  padding: 11px 16px;
  color: #aec2d8;
  background: #091827;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  text-align: left;
  text-transform: uppercase;
}

.parts-table th:last-child {
  text-align: right;
}

.parts-table td {
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
  padding: 12px 16px;
  vertical-align: top;
  background: var(--surface);
}

.parts-table tr:nth-child(even) td {
  background: #0a1828;
}

.parts-table tr.is-open td {
  background: #102034;
}

.parts-table tr.is-service td {
  background: rgba(25, 174, 232, 0.055);
}

.parts-table tr.is-service td:first-child {
  box-shadow: inset 3px 0 0 var(--cyan);
}

.services-divider td {
  padding: 10px 16px;
  background: #071525 !important;
  border-top: 1px solid rgba(56, 189, 248, 0.42);
  border-bottom: 1px solid rgba(56, 189, 248, 0.24);
}

.services-divider td,
.services-divider strong,
.services-divider small {
  cursor: default;
}

.services-divider-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.services-divider strong {
  color: var(--cyan);
  font-size: 12px;
  text-transform: uppercase;
}

.services-divider small {
  color: #8ea5bb;
  font-size: 10px;
  font-weight: 800;
}

.parts-table input {
  min-height: 42px;
  border-color: rgba(148, 163, 184, 0.25);
  background: #0d1b2c;
}

.description-cell {
  width: auto;
}

.money-col,
.price-cell {
  width: 190px;
}

.price-cell {
  text-align: right;
}

.part-input-wrap {
  display: grid;
  gap: 8px;
}

.row-status {
  min-height: 14px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.description-entry {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 8px;
}

.description-entry > input {
  min-width: 0;
}

.manual-register-slot {
  display: flex;
  flex: 0 0 auto;
  gap: 7px;
}

.inline-search-button,
.inline-register-button {
  min-height: 42px;
  padding: 4px 9px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 900;
}

.inline-search-button {
  color: #e9e4ff;
  background: rgba(124, 92, 255, 0.12);
  border: 1px solid rgba(124, 92, 255, 0.42);
}

.inline-search-button:hover,
.inline-search-button:focus-visible {
  color: #ffffff;
  background: rgba(124, 92, 255, 0.24);
  outline: none;
}

.inline-search-button:disabled {
  color: #9b90d0;
  cursor: wait;
}

.inline-register-button {
  min-height: 42px;
  padding: 4px 9px;
  color: #dff7ff;
  background: rgba(56, 189, 248, 0.11);
  border: 1px solid rgba(56, 189, 248, 0.38);
}

.inline-register-button:hover,
.inline-register-button:focus-visible {
  color: #ffffff;
  background: rgba(56, 189, 248, 0.22);
  outline: none;
}

.inline-register-button:disabled {
  color: var(--green);
  border-color: rgba(16, 185, 129, 0.32);
  background: rgba(16, 185, 129, 0.09);
  cursor: default;
}

.row-status.is-warning {
  color: var(--warning);
}

.options-slot {
  display: grid;
  gap: 8px;
}

.suggestion-list {
  display: grid;
  gap: 8px;
  margin-top: 1px;
}

.suggestion-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 0;
  color: var(--ink);
  background: #091827;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 7px;
  overflow: hidden;
}

.suggestion-option:hover,
.suggestion-option:focus-within,
.suggestion-option.is-selected {
  border-color: var(--purple);
  background: #111f34;
}

.suggestion-option.is-selected {
  box-shadow: inset 3px 0 0 var(--purple);
}

.suggestion-select {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
  color: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: left;
}

.suggestion-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.suggestion-main strong,
.suggestion-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* O nome da peça é o que se lê primeiro: preso em branco fixo, ele sumia sobre
   o cartão branco do tema claro — a peça cadastrada aparecia como uma linha em
   branco com preço. O token vira a cor certa nos dois temas. */
.suggestion-main strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.suggestion-main small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.suggestion-price {
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  text-align: right;
}

.suggestion-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  padding-right: 10px;
}

.catalog-result-button {
  min-height: 28px;
  padding: 5px 9px;
  color: #dff7ff;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.42);
  border-radius: 7px;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

.catalog-result-button:hover,
.catalog-result-button:focus-visible {
  background: rgba(56, 189, 248, 0.24);
  outline: none;
}

.catalog-result-button:disabled {
  color: var(--green);
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.10);
  cursor: default;
}

.money-input {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  min-height: 42px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 7px;
  background: #0d1b2c;
  overflow: hidden;
}

.money-input span {
  display: grid;
  place-items: center;
  align-self: stretch;
  color: #ffffff;
  background: var(--purple);
  font-size: 12px;
  font-weight: 900;
}

.money-input input {
  min-height: 40px;
  border: 0;
  border-radius: 0;
  text-align: right;
  font-weight: 800;
}

.money-input:focus-within {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.20);
}

.money-input input:focus {
  box-shadow: none;
}

.primary-button,
.secondary-button,
.icon-button,
.danger-button,
.ghost-link {
  min-height: 40px;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 900;
  letter-spacing: 0;
  text-decoration: none;
}

.primary-button {
  color: #ffffff;
  background: linear-gradient(135deg, var(--purple), #5d7cff);
  border: 1px solid rgba(124, 92, 255, 0.65);
}

.secondary-button,
.ghost-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #f8fbff;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(148, 163, 184, 0.28);
  padding: 0 14px;
}

.primary-button[hidden],
.secondary-button[hidden],
.danger-button[hidden],
.ghost-link[hidden],
.icon-button[hidden] {
  display: none !important;
}

.icon-button,
.danger-button {
  color: #ffffff;
  background: #334155;
  border: 0;
}

.danger-button {
  background: rgba(239, 68, 68, 0.88);
}

.primary-button:hover,
.secondary-button:hover,
.icon-button:hover,
.danger-button:hover,
.ghost-link:hover {
  filter: brightness(1.08);
}

.primary-button:disabled,
.secondary-button:disabled,
.icon-button:disabled,
.danger-button:disabled {
  cursor: wait;
  opacity: 0.68;
  filter: none;
}

.login-box .ghost-link,
.result-row .ghost-link,
.settings-section .ghost-link {
  color: #ffffff;
}

.component-add-actions {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  padding: 16px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.component-picker {
  position: relative;
  max-width: 100%;
}

.component-picker-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.component-picker-toggle::after {
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  content: "";
  transform: translateY(-2px) rotate(45deg);
  transition: transform 160ms ease;
}

.component-picker-toggle[aria-expanded="true"]::after {
  transform: translateY(2px) rotate(225deg);
}

.component-picker-menu {
  /* Fixo, nao absoluto: `.workspace` (o cartao onde o botao "Adicionar"
     mora) usa `overflow: clip` pra arredondar os cantos sem quebrar o
     sticky da barra de acoes do rodape. Um menu absoluto, preso a esse
     cartao, nascia cortado — pra cima ou pra baixo — sempre que nao coubesse
     dentro da caixa dele, mesmo com espaco de sobra na tela. Por isso o JS
     move este elemento pra fora do cartao (filho direto do body) e calcula
     `top`/`bottom`/`left` na tela toda, nao mais relativo ao botao. */
  position: fixed;
  z-index: 90;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-content: start;
  gap: 6px;
  width: min(560px, calc(100vw - 68px));
  /* Teto de altura pro primeiro frame, antes do JS medir o espaco real e
     encolher isso; o menu (ate 16 opcoes) ganha rolagem propria pro resto. */
  max-height: min(420px, calc(100vh - 96px));
  overflow-y: auto;
  padding: 8px;
  background: #071525;
  border: 1px solid rgba(56, 189, 248, 0.42);
  border-radius: 7px;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.42);
}

.component-picker-menu[hidden] {
  display: none;
}

.component-picker-option {
  display: grid;
  gap: 3px;
  min-width: 0;
  min-height: 52px;
  padding: 9px 10px;
  color: #f8fbff;
  background: #0b1b2d;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}

.component-picker-option:hover,
.component-picker-option:focus-visible {
  background: #0d263d;
  border-color: var(--cyan);
  outline: none;
}

.component-picker-option span {
  overflow-wrap: anywhere;
  font-size: 12px;
  font-weight: 900;
}

.component-picker-option small {
  color: var(--cyan);
  font-size: 10px;
  font-weight: 700;
}

.component-picker-option.is-present small {
  color: #8ea5bb;
}

/* Salvar, Novo e Gerar PDF ficam grudados no rodapé da coluna. Num orçamento
   com muitos itens eles iam parar no fim de uma rolagem longa: para salvar era
   preciso descer a tela inteira, salvar, e subir de volta. Sticky mantém o
   lugar de sempre — nada muda de posição —, só deixa de sumir. Vale para
   Desktop, Notebook e Peças, que compartilham esta barra. */
.under-table-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px 16px 14px;
  border-top: 1px solid var(--line-light);
  background: var(--surface);
  /* A sombra separa a barra do conteúdo que passa por baixo: sem ela, no meio
     da rolagem, o botão parece flutuar solto sobre o texto. */
  box-shadow: 0 -6px 16px color-mix(in srgb, var(--ink) 7%, transparent);
}

@media (max-width: 640px) {
  /* No celular a barra vira coluna e três botões empilhados comeriam metade da
     tela: ali ela volta a rolar com o conteúdo. */
  .under-table-actions {
    position: static;
    box-shadow: none;
  }
}

.summary-panel {
  align-self: start;
  position: sticky;
  top: 96px;
  padding: 16px;
}

.summary-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  color: #ffffff;
  background: #0b1b2d;
  border: 1px solid rgba(124, 92, 255, 0.26);
  border-radius: 7px;
  font-weight: 900;
}

.summary-percent-input {
  display: grid;
  grid-template-columns: minmax(44px, 64px) auto;
  align-items: center;
  overflow: hidden;
  min-height: 34px;
  color: var(--cyan);
  background: rgba(32, 175, 224, 0.07);
  border: 1px solid rgba(32, 175, 224, 0.24);
  border-radius: 6px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.summary-percent-input:focus-within {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(32, 175, 224, 0.12);
}

.summary-percent-input input {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 0 4px 0 8px;
  color: #ffffff;
  background: transparent;
  border: 0;
  outline: 0;
  font: inherit;
  font-size: 14px;
  font-weight: 900;
  text-align: right;
}

.summary-percent-input span {
  padding-right: 8px;
  color: var(--cyan);
  font-size: 11px;
  white-space: nowrap;
}

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  cursor: text;
}

.summary-row > span:first-child {
  flex: 1;
  color: var(--muted);
  font-weight: 800;
}

.summary-services {
  cursor: default;
}

.summary-services > span:first-child {
  display: flex;
  align-items: baseline;
  gap: 6px;
  color: var(--cyan);
}

.summary-services small {
  color: #7f96ae;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.summary-services strong {
  color: #ffffff;
  font-size: 15px;
  white-space: nowrap;
}

.summary-services[hidden] {
  display: none;
}

.summary-money-input {
  display: grid;
  grid-template-columns: auto minmax(78px, 120px);
  align-items: center;
  min-width: 0;
  color: #ffffff;
  background: rgba(148, 163, 184, 0.04);
  border: 1px solid transparent;
  border-radius: 6px;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.summary-money-input:focus-within {
  background: rgba(32, 175, 224, 0.07);
  border-color: rgba(32, 175, 224, 0.72);
  box-shadow: 0 0 0 3px rgba(32, 175, 224, 0.10);
}

.summary-money-input > span {
  padding-left: 8px;
  color: #9eb1c8;
  font-size: 11px;
  font-weight: 900;
}

.summary-money-input input {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 8px 0 4px;
  color: #ffffff;
  background: transparent;
  border: 0;
  outline: 0;
  font: inherit;
  font-size: 16px;
  font-weight: 900;
  text-align: right;
}

.summary-row.big {
  font-size: 18px;
}

.summary-row.total {
  border-bottom: 0;
}

.summary-row.total > span:first-child {
  font-size: 20px;
}

.summary-row.total .summary-money-input {
  grid-template-columns: auto minmax(104px, 142px);
}

.summary-row.total .summary-money-input input {
  font-size: 21px;
}

.cash-payment-copy {
  display: grid;
  min-width: 0;
  justify-items: center;
  gap: 3px;
}

.cash-payment-copy > label,
.cash-payment-copy > .notebook-payment-label {
  color: #9eb1c8;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.15;
}

.cash-payment-note {
  display: block;
  overflow: hidden;
  max-width: 100%;
  color: #7f96ae;
  font-size: 8px;
  font-weight: 800;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cash-payment-note[hidden] {
  display: none !important;
}

.payment-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.payment-strip .payment-option {
  min-width: 0;
  min-height: 88px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 9px;
  padding: 10px;
  text-align: center;
  background: #0b1b2d;
}

.payment-strip .payment-option + .payment-option {
  border-left: 1px solid var(--line);
}

.payment-option > label,
.installment-count-input {
  color: #9eb1c8;
  font-weight: 900;
  font-size: 12px;
}

.installment-count-input {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin: 0 auto;
}

.installment-count-input input {
  width: 34px;
  padding: 0;
  color: #9eb1c8;
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(32, 175, 224, 0.28);
  outline: 0;
  font: inherit;
  font-weight: 900;
  text-align: right;
}

.installment-count-input:focus-within input {
  color: #ffffff;
  border-bottom-color: var(--cyan);
}

.payment-money-input {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  min-width: 0;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 6px;
  transition: border-color 160ms ease, background 160ms ease;
}

.payment-money-input:focus-within {
  background: rgba(255, 255, 255, 0.035);
  border-color: currentColor;
}

.payment-money-input > span {
  padding-left: 5px;
  color: currentColor;
  font-size: 10px;
  font-weight: 900;
}

.payment-money-input input {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 5px 0 3px;
  color: currentColor;
  background: transparent;
  border: 0;
  outline: 0;
  font: inherit;
  font-size: 16px;
  font-weight: 900;
  text-align: right;
}

.payment-money-input.is-cash {
  color: #fb7185;
}

.payment-money-input.is-installment {
  color: var(--cyan);
}

.summary-reset-button {
  width: 100%;
  min-height: 34px;
  margin-top: 10px;
  color: #9eb1c8;
  background: transparent;
  border: 1px dashed rgba(148, 163, 184, 0.26);
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
}

.summary-reset-button:hover,
.summary-reset-button:focus-visible {
  color: #ffffff;
  background: rgba(32, 175, 224, 0.07);
  border-color: rgba(32, 175, 224, 0.54);
  outline: none;
}

.muted-note,
.form-message {
  color: var(--muted);
  font-size: 13px;
}

.center-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
  background: var(--bg);
}

.login-box {
  width: min(420px, 100%);
  padding: 22px;
}

.login-brand {
  margin: 2px auto 20px;
}

.login-brand .brand-logo {
  width: min(190px, 62vw);
  height: 82px;
}

.stack-form {
  display: grid;
  gap: 14px;
  margin: 0;
}

.auth-sso {
  display: grid;
  gap: 12px;
  margin: 0;
}

.auth-sso[hidden],
.auth-divider[hidden] {
  display: none;
}

.auth-sso-copy {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.auth-sso-button {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
}

.auth-local-heading {
  display: grid;
  gap: 6px;
  text-align: center;
}

.auth-local-heading h1 {
  margin: 0;
  color: var(--ink);
  font-size: 20px;
}

.login-box .stack-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-box .stack-form input {
  width: 100%;
  min-height: 44px;
}

.login-box .form-message {
  min-height: 20px;
  margin: 14px 0 0;
  text-align: center;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--line);
}

.admin-shell {
  width: min(1220px, 100%);
  margin: 0 auto;
  padding: 20px 34px 34px;
}

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

.settings-section[data-admin-category="geral"],
.settings-section[data-admin-category="documentacao"],
.settings-section[data-admin-category="agenda"] {
  grid-column: 1 / -1;
}

.settings-section {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 16px;
}

.settings-section h2 {
  margin: 0 0 4px;
  font-size: 18px;
  color: #ffffff;
}

.backup-section {
  grid-column: 1 / -1;
}

.backup-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.backup-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

/* Situacao do pg_dump (ferramenta do backup): informativa em repouso, em
   alerta quando falta ou e mais antiga que o servidor. */
.backup-tool-status {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

/* Especificidade acima do tema claro (html[data-theme="light"] .backup-heading p). */
html .backup-heading .backup-tool-status[data-status="error"] {
  color: var(--danger);
}

.backup-status-badge {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  color: #a8c2d8;
  background: #0b1d2e;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 900;
}

.backup-status-badge[data-status="working"] {
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.55);
}

.backup-status-badge[data-status="success"] {
  color: #55e5b5;
  border-color: rgba(85, 229, 181, 0.48);
}

.backup-status-badge[data-status="error"] {
  color: #fb7185;
  border-color: rgba(251, 113, 133, 0.48);
}

.backup-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.backup-security-note {
  margin: 0;
  padding-left: 11px;
  color: #9fb2c8;
  border-left: 3px solid rgba(32, 175, 224, 0.58);
  font-size: 12px;
  line-height: 1.5;
}

.backup-dialog {
  width: min(520px, calc(100% - 28px));
  padding: 0;
  color: #dceaf6;
  background: #081827;
  border: 1px solid rgba(32, 175, 224, 0.42);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.46);
}

.backup-dialog::backdrop {
  background: rgba(1, 10, 20, 0.76);
  backdrop-filter: blur(3px);
}

.backup-dialog-content {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 24px;
}

.backup-dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  display: grid;
  padding: 0;
  place-content: center;
  color: #a9bdd1;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}

.backup-dialog-close:hover,
.backup-dialog-close:focus-visible {
  color: #ffffff;
  border-color: var(--cyan);
  outline: none;
}

.backup-dialog-eyebrow {
  color: var(--cyan);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.backup-dialog h2,
.backup-dialog p {
  margin: 0;
}

.backup-dialog h2 {
  padding-right: 42px;
  color: #ffffff;
  font-size: 21px;
}

.backup-dialog p {
  color: #b7c9d9;
  font-size: 13px;
  line-height: 1.55;
}

.backup-dialog strong {
  color: #ffffff;
  overflow-wrap: anywhere;
}

.backup-dialog-warning {
  padding: 11px 12px;
  background: rgba(251, 113, 133, 0.08);
  border-left: 3px solid #fb7185;
}

.backup-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 4px;
}

@media (max-width: 620px) {
  .backup-heading,
  .backup-actions,
  .backup-dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .backup-status-badge,
  .backup-actions button,
  .backup-dialog-actions button {
    width: 100%;
  }

  .backup-dialog-content {
    padding: 20px;
  }
}
.password-section {
  grid-column: span 1;
}

.admin-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: flex-end;
  padding: 2px 0;
}

.admin-settings-top-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  padding: 2px 0 0;
}

.admin-settings-top-actions .form-message {
  margin: 0;
  text-align: right;
}

.section-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.section-head h2,
.section-head p {
  margin-top: 0;
}

.catalog-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.catalog-head-actions [hidden] {
  display: none !important;
}

.catalog-shell {
  width: min(1180px, 100%);
}

.ghost-link.is-active {
  color: #ffffff;
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.52);
}

.catalog-search-panel {
  display: grid;
  gap: 9px;
  margin-bottom: 18px;
  padding: 16px;
  background: #071525;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 7px;
}

.catalog-search-panel > label {
  color: #d9e8f7;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.catalog-search-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.catalog-search-row input,
.catalog-search-row select {
  width: 100%;
  min-height: 44px;
}

.catalog-result-count {
  min-width: 76px;
  color: #38bdf8;
  font-size: 13px;
  font-weight: 900;
  text-align: right;
  white-space: nowrap;
}

.catalog-category-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 7px;
}

.catalog-category-card {
  min-height: 84px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px 15px;
  color: #cad8e7;
  background: #0b1b2d;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 7px;
  cursor: pointer;
  text-align: left;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.category-card-label {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
}

.category-card-label > span {
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
  font-size: 13px;
  font-weight: 850;
  line-height: 1.25;
}

.category-card-label > i,
.category-card-label > svg {
  flex: 0 0 auto;
  color: #5fbde8;
}

.catalog-category-card:hover .category-card-label > i,
.catalog-category-card:hover .category-card-label > svg,
.catalog-category-card:focus-visible .category-card-label > i,
.catalog-category-card:focus-visible .category-card-label > svg,
.catalog-category-card.is-active .category-card-label > i,
.catalog-category-card.is-active .category-card-label > svg {
  color: #ffffff;
}

.catalog-category-card strong {
  min-width: 27px;
  min-height: 27px;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
  color: #9eb1c8;
  background: rgba(148, 163, 184, 0.10);
  border-radius: 6px;
  font-size: 11px;
}

.catalog-category-card:hover,
.catalog-category-card:focus-visible {
  color: #ffffff;
  background: #10243a;
  border-color: rgba(56, 189, 248, 0.45);
  outline: none;
}

.catalog-category-card.is-active {
  color: #ffffff;
  background: rgba(56, 189, 248, 0.13);
  border-color: #38bdf8;
}

.catalog-category-card.is-active strong {
  color: #04111f;
  background: #38bdf8;
}

.catalog-category {
  display: grid;
  gap: 9px;
  padding-top: 14px;
  border-top: 1px solid rgba(148, 163, 184, 0.22);
}

.catalog-category:first-child {
  padding-top: 0;
  border-top: 0;
}

.catalog-category-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px;
}

.catalog-category-head h3 {
  margin: 0;
  color: #f8fbff;
  font-size: 14px;
}

.catalog-category-head span {
  color: #8fa7bf;
  font-size: 12px;
  font-weight: 800;
}

.catalog-category-list {
  display: grid;
  gap: 8px;
}

.catalog-panel {
  gap: 18px;
}

.catalog-quick-panel {
  gap: 10px;
}

.quick-product-head,
.quick-product-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(280px, 1.6fr) minmax(150px, 0.55fr);
  gap: 10px;
}

.quick-product-head {
  padding: 0 12px;
  color: #8fa7bf;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.quick-product-list {
  display: grid;
  gap: 8px;
}

.quick-product-row {
  align-items: end;
  padding: 10px 12px;
  background: #0b1b2d;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 7px;
}

.quick-product-row > label > span {
  display: none;
}

.quick-product-row input,
.quick-product-row select {
  width: 100%;
  min-height: 42px;
}

.quick-money-input {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
}

.quick-money-input > span {
  display: grid;
  place-items: center;
  min-height: 42px;
  color: #ffffff;
  background: #6d5dfc;
  border: 1px solid rgba(124, 92, 255, 0.65);
  border-right: 0;
  border-radius: 7px 0 0 7px;
  font-size: 12px;
  font-weight: 900;
}

.quick-money-input input {
  border-radius: 0 7px 7px 0;
}

.quick-entry-actions {
  justify-content: flex-start;
  padding-top: 4px;
}

.catalog-list {
  display: grid;
  gap: 10px;
}

.catalog-row {
  display: grid;
  grid-template-columns: 104px minmax(180px, 1fr) 140px 110px 92px;
  align-items: end;
  gap: 10px;
  padding: 12px;
  background: #0b1b2d;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.product-row {
  grid-template-columns: 170px minmax(260px, 1fr) 140px 92px;
}

.catalog-empty {
  margin: 0;
  padding: 20px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 7px;
}

.default-choice {
  min-height: 42px;
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
  color: #ffffff;
}

.default-choice input {
  width: 16px;
  min-height: auto;
  accent-color: var(--purple);
}

.catalog-price {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  color: var(--green);
  font-size: 14px;
}

.catalog-actions {
  justify-content: flex-end;
}

.models-shell {
  width: min(1320px, 100%);
}

.models-panel {
  gap: 18px;
}

.models-search {
  width: min(340px, 100%);
}

.models-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  align-items: start;
  gap: 12px;
}

.computer-model-card {
  display: grid;
  gap: 12px;
  padding: 15px;
  color: #edf6ff;
  background: #081827;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 7px;
}

.computer-model-card:not(.is-editing) {
  min-height: 360px;
  grid-template-rows: auto 1fr auto auto;
  border-top: 2px solid #38bdf8;
}

.computer-model-card:not(.is-editing):hover {
  background: #0a1c2d;
  border-color: rgba(56, 189, 248, 0.48);
}

.computer-model-card.is-editing {
  grid-column: 1 / -1;
}

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

.computer-model-head h3 {
  margin: 0 0 4px;
  color: #ffffff;
  font-size: 17px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.computer-model-head span {
  color: #8fa7bf;
  font-size: 11px;
}

.computer-model-config {
  display: grid;
  align-content: start;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
}

.computer-model-config-row {
  display: grid;
  grid-template-columns: 106px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 31px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.13);
}

.computer-model-config-row span {
  color: #38bdf8;
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
}

.computer-model-config-row strong {
  color: #edf6ff;
  font-size: 11px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.model-card-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.model-card-summary span {
  color: #8fa7bf;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.model-card-summary strong {
  color: #38bdf8;
  font-size: 19px;
  line-height: 1.1;
  white-space: nowrap;
}

.computer-model-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  flex-wrap: wrap;
}

.computer-model-card:not(.is-editing) .computer-model-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.computer-model-card:not(.is-editing) .computer-model-actions .primary-button {
  grid-column: 1 / -1;
}

.computer-model-actions button {
  min-height: 36px;
  padding: 0 10px;
  font-size: 12px;
}

.model-name-field {
  max-width: 620px;
}

.model-edit-head,
.model-edit-row {
  display: grid;
  grid-template-columns: 180px minmax(260px, 1fr) 150px 42px;
  gap: 9px;
}

.model-edit-head {
  padding: 0 2px;
  color: #8fa7bf;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.model-edit-items {
  display: grid;
  gap: 8px;
}

.model-edit-row {
  align-items: center;
}

.model-edit-row input,
.model-edit-row select {
  width: 100%;
  min-height: 40px;
}

.model-remove-item {
  width: 40px;
  min-height: 40px;
  padding: 0;
}

.model-edit-add {
  display: flex;
  justify-content: flex-start;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(380px, calc(100vw - 36px));
  padding: 12px 14px;
  color: #ffffff;
  background: #071322;
  border: 1px solid rgba(124, 92, 255, 0.48);
  border-radius: 7px;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1100px) {
  .catalog-category-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .summary-panel {
    position: static;
  }

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

  .catalog-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .catalog-category-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .catalog-category-card {
    min-height: 78px;
    padding: 12px;
  }

  .topbar {
    position: static;
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .brand-mark,
  .brand-mark.logo-only,
  .page-title,
  .top-actions {
    grid-column: 1;
    justify-self: center;
    text-align: center;
  }

  .brand-logo {
    width: 144px;
  }

  .top-actions {
    justify-content: center;
  }

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

  .workspace-title .new-quote-button {
    width: 100%;
  }

  .ai-input-row,
  .quote-toolbar,
  .settings-grid,
  .catalog-row,
  .catalog-search-row,
  .quick-product-row {
    grid-template-columns: 1fr;
  }

  .quick-product-head {
    display: none;
  }

  .quick-product-row > label > span {
    display: block;
  }

  .models-grid,
  .model-edit-row {
    grid-template-columns: 1fr;
  }

  .model-edit-head {
    display: none;
  }

  .models-search {
    width: 100%;
  }

  .computer-model-part {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .computer-model-part b {
    margin-top: 2px;
  }

  .computer-model-actions,
  .model-edit-add {
    justify-content: stretch;
  }

  .computer-model-actions button,
  .model-edit-add button {
    width: 100%;
  }

  .model-remove-item {
    width: 100%;
  }

  .catalog-result-count {
    text-align: left;
  }

  .ai-input-row button {
    min-height: 44px;
  }

  .parts-table {
    min-width: 560px;
  }

  .money-col,
  .price-cell {
    width: 160px;
  }

  .suggestion-option,
  .suggestion-select {
    grid-template-columns: 1fr;
  }

  .suggestion-price {
    text-align: left;
  }

  .suggestion-actions {
    padding: 0 10px 10px;
    flex-wrap: wrap;
  }

  .component-add-actions,
  .under-table-actions,
  .admin-actions,
  .section-head {
    justify-content: stretch;
    flex-direction: column;
  }

  .catalog-head-actions {
    width: 100%;
  }

  .component-picker {
    width: 100%;
  }

  .component-picker-menu {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(440px, calc(100vw - 48px));
  }

  .component-add-actions button,
  .under-table-actions button,
  .admin-actions button,
  .section-head button,
  .catalog-head-actions button {
    width: 100%;
  }

  .admin-shell,
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }
}

@media (max-width: 430px) {
  .catalog-category-cards {
    grid-template-columns: 1fr;
  }
}


/* Upgrades opcionais do orcamento */
.upgrades-panel {
  margin: 12px 16px 4px;
  padding: 16px;
  background: #081827;
  border: 1px solid rgba(56, 189, 248, 0.30);
  border-radius: 7px;
}

.upgrades-panel[hidden] {
  display: none;
}

.upgrades-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.upgrades-header span {
  color: #38bdf8;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.upgrades-header h3 {
  margin: 3px 0 0;
  color: #ffffff;
  font-size: 18px;
}

.upgrades-header small {
  max-width: 360px;
  color: #8fa7bf;
  font-size: 11px;
  text-align: right;
}

.upgrades-list {
  display: grid;
  gap: 9px;
}

.upgrade-row {
  display: grid;
  grid-template-columns: minmax(170px, 0.8fr) minmax(220px, 1.3fr) minmax(170px, 0.7fr) minmax(180px, 0.8fr) 40px;
  align-items: end;
  gap: 9px;
  padding: 12px;
  background: #0b1b2d;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 7px;
}

.upgrade-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.upgrade-field > span,
.upgrade-difference > span {
  color: #8fa7bf;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.upgrade-field input,
.upgrade-field select {
  width: 100%;
  min-height: 42px;
}

.upgrade-price-field .money-input {
  min-height: 42px;
}

.upgrade-difference {
  min-height: 42px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 4px 0;
}

.upgrade-difference strong {
  color: #38d9a9;
  font-size: 15px;
}

.upgrade-difference small {
  color: #8fa7bf;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upgrade-remove {
  width: 40px;
  height: 42px;
  color: #fecaca;
  background: rgba(239, 68, 68, 0.10);
  border: 1px solid rgba(239, 68, 68, 0.38);
  border-radius: 7px;
  cursor: pointer;
  font-weight: 900;
}

.upgrade-remove:hover,
.upgrade-remove:focus-visible {
  color: #ffffff;
  background: rgba(239, 68, 68, 0.82);
  outline: none;
}

@media (max-width: 1100px) {
  .upgrade-row {
    grid-template-columns: 1fr 1.4fr 1fr;
  }

  .upgrade-difference {
    grid-column: 1 / 3;
  }

  .upgrade-remove {
    grid-column: 3;
    grid-row: 2;
    justify-self: end;
  }
}

@media (max-width: 760px) {
  .upgrades-panel {
    margin: 10px 12px 2px;
    padding: 12px;
  }

  .upgrades-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .upgrades-header small {
    text-align: left;
  }

  .upgrade-row {
    grid-template-columns: 1fr;
  }

  .upgrade-difference,
  .upgrade-remove {
    grid-column: 1;
    grid-row: auto;
  }

  .upgrade-remove {
    width: 100%;
  }
}


/* Version and changelog */
.app-version {
  position: fixed;
  right: 14px;
  bottom: 10px;
  z-index: 80;
  border: 0;
  padding: 4px 7px;
  background: rgba(6, 29, 59, 0.72);
  color: #8eb4cc;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  opacity: 0.72;
  transition: color 160ms ease, opacity 160ms ease, background 160ms ease;
}

/* No toque o selo deixa de flutuar. Fixo no canto inferior direito ele fica
 * por cima da lista, e o canto inferior direito é justamente onde a linha da
 * tarefa põe o botão de comentar: o toque ia para o selo, não para o botão —
 * medido com elementFromPoint, o selo vencia. Como ele é o último filho do
 * body, tirar o `fixed` já o joga para o fim da página, onde não cobre nada.
 * O acesso ao changelog continua o mesmo, só deixa de disputar o dedo. */
@media (pointer: coarse) {
  .app-version {
    position: static;
    display: block;
    margin: 18px auto 22px;
    width: fit-content;
    opacity: 1;
  }
}

.app-version:hover,
.app-version:focus-visible {
  background: #061d3b;
  color: #22b8ee;
  opacity: 1;
  outline: 1px solid #22b8ee;
  outline-offset: 2px;
}

.changelog-dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: min(680px, calc(100vh - 32px));
  padding: 0;
  overflow: hidden;
  border: 1px solid #26435f;
  border-radius: 8px;
  background: #071a2d;
  color: #f5f9fc;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.48);
}

.changelog-dialog::backdrop {
  background: rgba(2, 10, 20, 0.72);
  backdrop-filter: blur(3px);
}

.changelog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px;
  border-bottom: 1px solid #203a53;
}

.changelog-eyebrow {
  display: block;
  margin-bottom: 4px;
  color: #22b8ee;
  font-size: 10px;
  font-weight: 800;
}

.changelog-header h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.changelog-close {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border: 1px solid #2c4964;
  border-radius: 6px;
  background: #0d263d;
  color: #dcebf5;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.changelog-close:hover,
.changelog-close:focus-visible {
  border-color: #22b8ee;
  color: #22b8ee;
  outline: 0;
}

.changelog-content {
  max-height: calc(100vh - 150px);
  padding: 20px 22px 24px;
  overflow-y: auto;
}

.release-entry + .release-entry {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid #203a53;
}

.release-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.release-heading strong {
  color: #22b8ee;
  font-size: 14px;
}

.release-heading time {
  color: #88a5b9;
  font-size: 12px;
}

.release-entry h3 {
  margin: 8px 0 12px;
  font-size: 16px;
  letter-spacing: 0;
}

.release-entry ul {
  display: grid;
  gap: 9px;
  margin: 0;
  padding-left: 18px;
  color: #b9cedd;
  font-size: 13px;
  line-height: 1.45;
}

.release-entry li::marker {
  color: #22b8ee;
}

@media (max-width: 600px) {
  .app-version {
    right: 8px;
    bottom: 8px;
  }

  .changelog-header,
  .changelog-content {
    padding-left: 18px;
    padding-right: 18px;
  }
}

/* GestaoTech backup por e-mail */
.backup-email-panel {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid #28415a;
  border-radius: 8px;
  background: #091a2a;
}

.backup-email-heading,
.backup-history-heading,
.backup-email-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.backup-email-heading h3,
.backup-history-heading h3 {
  margin: 3px 0 4px;
  color: #f7fbff;
  font-size: 17px;
}

.backup-email-heading p,
.backup-history-heading span {
  margin: 0;
  color: #93abc0;
  font-size: 13px;
}

.backup-email-toggle {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid #2e536f;
  border-radius: 6px;
  background: #10283c;
  color: #dcecff;
  font-weight: 700;
  white-space: nowrap;
}

.backup-email-toggle input {
  width: 18px;
  height: 18px;
  accent-color: #19afe1;
}

.backup-email-grid {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) minmax(110px, .7fr) minmax(180px, 1fr);
  gap: 13px;
  margin-top: 18px;
}

.backup-email-wide {
  grid-column: 1 / -1;
}

.backup-schedule-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  align-items: end;
  gap: 13px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #20394e;
}

.backup-time-zone {
  min-height: 42px;
  display: flex;
  align-items: center;
  color: #8ea8be;
  font-size: 12px;
}

.backup-email-actions {
  justify-content: flex-start;
  margin-top: 16px;
}

.backup-history {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #20394e;
}

.backup-history-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.backup-history-item {
  display: grid;
  grid-template-columns: 10px minmax(180px, .8fr) minmax(220px, 1.4fr);
  align-items: center;
  gap: 11px;
  min-height: 54px;
  padding: 9px 12px;
  border: 1px solid #29445b;
  border-radius: 6px;
  background: #0c2133;
}

.backup-history-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e84155;
}

.backup-history-item[data-status="success"] .backup-history-indicator {
  background: #20c87a;
}

.backup-history-item strong,
.backup-history-item span {
  display: block;
}

.backup-history-item strong {
  color: #f2f8ff;
  font-size: 13px;
}

.backup-history-item span,
.backup-history-item p,
.backup-history-empty {
  margin: 2px 0 0;
  color: #8ea8be;
  font-size: 12px;
}

@media (max-width: 760px) {
  .backup-email-heading,
  .backup-history-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .backup-email-grid,
  .backup-schedule-grid {
    grid-template-columns: 1fr;
  }

  .backup-email-wide {
    grid-column: auto;
  }

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

  .backup-history-item {
    grid-template-columns: 10px 1fr;
  }

  .backup-history-item p {
    grid-column: 2;
  }
}


.postgres-connection-panel {
  grid-column: 1 / -1;
}

.postgres-connection-heading span {
  color: var(--cyan);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .06em;
}

.postgres-connection-heading h2 { margin: 4px 0 0; }

.postgres-connection-heading p {
  max-width: 680px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.postgres-connection-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
  max-width: 720px;
}

.postgres-connection-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
}

.postgres-fresh-database {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-top: 18px;
  padding: 15px;
  background: rgba(8, 145, 178, .07);
  border: 1px solid rgba(34, 211, 238, .28);
  border-radius: 8px;
}

.postgres-fresh-database span {
  color: var(--cyan);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .06em;
}

.postgres-fresh-database h3 { margin: 4px 0 0; color: var(--ink); font-size: 14px; }
.postgres-fresh-database p { max-width: 520px; margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }

.postgres-fresh-database-actions {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  align-items: end;
  gap: 8px;
  min-width: min(100%, 420px);
}

.postgres-fresh-database-actions label { margin: 0; }

.postgres-use-new-toggle {
  grid-column: 1 / -1;
  justify-content: flex-start;
}

.authentication-panel {
  grid-column: 1 / -1;
}

/* Interruptor da integracao com o Authentik.
   Precisa de dois nomes de classe para vencer `.settings-section label`, que
   empilha em coluna e transformaria o trilho num circulo. */
.auth-mode-switch {
  max-width: 720px;
}

.settings-section .switch-control {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  min-height: 0;
  padding: 14px 16px;
  border: 1px solid rgba(148, 163, 184, .26);
  border-radius: 10px;
  background: rgba(15, 32, 51, .55);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease;
}

.settings-section .switch-control:hover {
  border-color: rgba(34, 211, 238, .4);
  background: rgba(15, 32, 51, .8);
}

.settings-section .switch-control:has(input:focus-visible) {
  border-color: var(--cyan);
  outline: 2px solid rgba(34, 211, 238, .35);
  outline-offset: 2px;
}

/* O checkbox real fica invisivel mas continua sendo o alvo do teclado. */
.settings-section .switch-control input[type="checkbox"] {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  padding: 0;
  margin: 0;
  overflow: hidden;
  border: 0;
  clip-path: inset(50%);
  white-space: nowrap;
}

.settings-section .switch-track {
  position: relative;
  display: block;
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: rgba(148, 163, 184, .3);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, .22);
  transition: background 180ms ease, box-shadow 180ms ease;
}

.settings-section .switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f8fafc;
  box-shadow: 0 1px 3px rgba(2, 6, 23, .5);
  transition: transform 180ms cubic-bezier(.32, .72, .35, 1.04);
}

.settings-section .switch-control input:checked ~ .switch-track {
  background: var(--cyan);
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, .55);
}

.settings-section .switch-control input:checked ~ .switch-track .switch-thumb {
  transform: translateX(18px);
}

.settings-section .switch-control:has(input:disabled) {
  cursor: not-allowed;
  opacity: .55;
}

/* Herda de `.settings-section label`, entao precisa reafirmar o texto. */
.settings-section .switch-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.settings-section .switch-text strong {
  color: #eaf2fb;
  font-size: 13px;
  font-weight: 800;
}

.settings-section .switch-text small {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.45;
}

/* Campos do Authentik perdem a cor quando a integracao esta desligada. */
.postgres-connection-grid.is-disabled {
  opacity: .4;
  pointer-events: none;
}

.auth-mode-warning {
  max-width: 720px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(251, 191, 36, .4);
  border-radius: 8px;
  background: rgba(251, 191, 36, .1);
  color: #fcd34d;
  font-size: 12px;
  line-height: 1.45;
}

.auth-mode-warning[hidden] {
  display: none;
}

@media (max-width: 620px) {
  .postgres-connection-grid { grid-template-columns: 1fr; }
  .postgres-connection-actions { flex-direction: column; }
  .postgres-connection-actions button { width: 100%; }
  .postgres-fresh-database { align-items: stretch; flex-direction: column; }
  .postgres-fresh-database-actions { grid-template-columns: 1fr; min-width: 0; }
  .postgres-fresh-database-actions button { width: 100%; }
}
#backupWeekDayField[hidden],
#backupMonthDayField[hidden] {
  display: none !important;
}

/* Admin organization */
.admin-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px 34px 42px;
}

.admin-category-nav {
  position: sticky;
  z-index: 4;
  top: 12px;
  display: flex;
  gap: 8px;
  margin: 0 0 18px;
  padding: 9px;
  overflow-x: auto;
  background: rgba(7, 20, 34, .88);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .18);
  backdrop-filter: blur(12px);
}

.admin-category-nav button {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}

.admin-category-nav button:hover,
.admin-category-nav button:focus-visible,
.admin-category-nav button[aria-pressed="true"] {
  color: var(--ink);
  background: rgba(34, 211, 238, .09);
  border-color: rgba(34, 211, 238, .38);
}

/* Barra de categorias rolavel.
 *
 * No celular so quatro das nove categorias cabem, e nada dizia que havia mais
 * ao lado. O esmaecido aparece na ponta onde ainda existe conteudo escondido —
 * as classes vem de admin.js, que escuta a rolagem — e some ao chegar ao fim,
 * para nao mentir. A barra de rolagem nativa fica oculta porque o esmaecido ja
 * cumpre o papel e ela roubava altura da faixa fixa. */
.admin-category-nav {
  scrollbar-width: none;
  scroll-behavior: smooth;
}

.admin-category-nav::-webkit-scrollbar {
  display: none;
}

.admin-category-nav.has-overflow-end {
  mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 34px), transparent 100%);
}

.admin-category-nav.has-overflow-start {
  mask-image: linear-gradient(to right, transparent 0, #000 34px, #000 100%);
}

.admin-category-nav.has-overflow-start.has-overflow-end {
  mask-image: linear-gradient(to right, transparent 0, #000 34px, #000 calc(100% - 34px), transparent 100%);
}

.admin-category-heading {
  grid-column: 1 / -1;
  scroll-margin-top: 78px;
  padding: 16px 2px 0;
}

/* Formularios do painel em colunas.
 *
 * As secoes mais antigas (Empresa, Valores, Pagamento, Documentacao, Anexos,
 * IA, Pesquisa de precos) empilhavam um campo por linha; em monitor largo cada
 * caixa de texto passava de 1200px para receber um telefone ou um percentual.
 * Aqui os campos curtos entram numa grade que se ajusta a largura disponivel, e
 * o que precisa de linha inteira (titulo, ajuda, texto longo, interruptor)
 * continua ocupando tudo. Nenhuma secao com layout proprio e afetada: a grade
 * so vale para quem recebe a classe no HTML. */
.settings-section.settings-form-grid {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  align-items: start;
  column-gap: 14px;
}

.settings-section.settings-form-grid > h2,
.settings-section.settings-form-grid > p,
.settings-section.settings-form-grid > .setting-toggle,
.settings-section.settings-form-grid > label:has(textarea) {
  grid-column: 1 / -1;
}

.settings-section.settings-form-grid > .settings-help {
  margin-top: -4px;
}

[data-admin-category][hidden] {
  display: none !important;
}

.admin-category-heading span,
.access-groups-heading span,
.app-users-heading span {
  color: var(--cyan);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .06em;
}

.admin-category-heading h2 {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 19px;
}

.admin-category-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

/* Internal access management */
.user-access-section {
  grid-column: 1 / -1;
}

.user-access-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.user-access-heading span {
  color: var(--cyan);
  font-size: 9px;
  font-weight: 900;
}

.delivery-estimate {
  margin: 10px 0 2px;
  padding: 9px 10px;
  color: var(--ink);
  background: color-mix(in srgb, var(--cyan) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--cyan) 38%, var(--line));
  border-radius: 7px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.user-access-heading h2 { margin: 4px 0 0; }

.user-access-heading p {
  max-width: 620px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

/* `--surface` aqui, `--surface-2` na linha/cartão lá embaixo: parece invertido
   (o painel "mais alto" ganhando o tom mais claro do tema claro), mas é o que
   sobra sem contraste: o rótulo ciano do cabeçalho (`.access-groups-heading
   span`, `.app-users-heading span`) contra `--surface-2` no claro media 4,23
   — abaixo do teto de 4,5 — e contra `--surface` (branco) passa de sobra. */
.access-groups-panel,
.app-users-panel {
  min-width: 0;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.access-groups-heading,
.app-users-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.access-groups-heading h3,
.app-users-heading h3 {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 15px;
}

.access-groups-heading .primary-button {
  min-height: 34px;
  padding: 0 11px;
  font-size: 11px;
  white-space: nowrap;
}

.admin-heading-actions,
.access-groups-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.access-groups-footer { margin-top: 14px; }

.access-groups-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.access-group-card {
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.access-group-title {
  padding: 11px 12px;
  background: color-mix(in srgb, var(--cyan) 8%, transparent);
  border-bottom: 1px solid var(--line);
}

.access-group-title strong,
.access-group-title small,
.access-module-copy strong,
.access-module-copy small {
  display: block;
}

.access-group-title strong,
.access-module-copy strong { color: var(--ink); font-size: 12px; }
.access-group-title small,
.access-module-copy small { margin-top: 3px; color: var(--muted); font-size: 10px; }

.access-module-list { display: grid; }

.access-module-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}

.access-module-row:first-child { border-top: 0; }

.access-permission-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.access-permission-toggle {
  display: inline-flex !important;
  min-height: 29px;
  align-items: center;
  gap: 5px;
  margin: 0 !important;
  padding: 0 8px;
  color: var(--muted) !important;
  background: color-mix(in srgb, var(--muted) 7%, transparent);
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
  font-size: 10px !important;
  font-weight: 800;
  letter-spacing: normal !important;
  text-transform: none !important;
}

.access-permission-toggle:has(input:checked) {
  color: var(--ink) !important;
  background: color-mix(in srgb, var(--cyan) 12%, transparent);
  border-color: color-mix(in srgb, var(--cyan) 52%, transparent);
}

.access-permission-toggle:has(input:disabled) { cursor: not-allowed; opacity: .45; }
.access-permission-toggle input { width: 13px; height: 13px; accent-color: var(--cyan); }

.app-users-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.work-hours-admin {
  grid-column: 1 / -1;
}

.work-hours-heading > span {
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.work-hours-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.work-hours-list {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.work-hours-row {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(130px, 170px) minmax(130px, 170px) 100px;
  align-items: end;
  gap: 14px;
  padding: 14px;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
}

.work-hours-row:first-child {
  grid-template-columns: minmax(190px, 1fr) minmax(130px, 170px) minmax(130px, 170px);
}

.work-hours-row + .work-hours-row {
  border-top: 1px solid var(--line);
}

.work-hours-row > div {
  display: grid;
  align-self: center;
  gap: 3px;
}

.work-hours-row strong {
  color: var(--text);
  font-size: 14px;
}

.work-hours-row small {
  color: var(--muted);
  font-size: 11px;
}

.work-hours-row label {
  gap: 5px;
}

.work-hours-row input[type="time"] {
  min-height: 38px;
}

.work-hours-closed {
  display: flex !important;
  min-height: 38px;
  flex-direction: row !important;
  align-items: center;
  justify-content: center;
  gap: 7px !important;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
}

.work-hours-closed input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.work-hours-row.is-closed input[type="time"] {
  opacity: 0.45;
}

@media (max-width: 760px) {
  .work-hours-row,
  .work-hours-row:first-child {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .work-hours-row > div {
    grid-column: 1 / -1;
  }

  .work-hours-closed {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

.local-user-create {
  margin-top: 14px;
  padding: 12px;
  background: color-mix(in srgb, var(--cyan) 6%, transparent);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.local-user-create-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* Sem isto o título e o botão disputam a mesma largura e acabam impressos um
   por cima do outro quando a coluna estreita. */
.local-user-create-heading > div { min-width: 0; flex: 1 1 160px; }
.local-user-create-heading button { flex: 0 0 auto; }

.local-user-create-heading span { color: var(--muted); font-size: 10px; font-weight: 800; }
.local-user-create-heading h3 { margin: 3px 0 0; color: var(--ink); font-size: 14px; }
.local-user-create-heading button { min-height: 34px; }
.local-user-create-note { margin: 8px 0 0; color: var(--muted); font-size: 10px; }

.local-user-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.local-user-fields[hidden] { display: none; }
.local-user-fields label { display: grid; gap: 5px; margin: 0; color: var(--muted); font-size: 10px; font-weight: 800; }
.local-user-fields input,
.local-user-fields select { width: 100%; min-height: 40px; }
.local-user-photo-field,
.local-user-create-actions { grid-column: 1 / -1; }
.local-user-photo-field small { color: var(--muted); font-size: 10px; font-weight: 500; }
.local-user-photo-field input { padding: 7px; }

.local-user-create-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.app-user-row {
  display: grid;
  grid-template-columns: 5px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 12px;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.app-user-indicator {
  width: 4px;
  height: 38px;
  border-radius: 4px;
  background: var(--cyan);
}

.app-user-indicator { grid-row: 1 / span 2; height: 100%; }
.app-user-identity,
.app-user-access { grid-column: 2; }

.app-user-identity strong,
.app-user-identity small,
.app-user-access small {
  display: block;
}

.app-user-identity strong {
  color: var(--ink);
  font-size: 13px;
}

.app-user-identity {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.app-user-avatar {
  display: grid;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  place-items: center;
  overflow: hidden;
  color: var(--ink);
  background: color-mix(in srgb, var(--cyan) 18%, var(--surface));
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 900;
}

.app-user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.app-user-identity > div { min-width: 0; }
.app-user-delete { width: fit-content; min-height: 32px; margin-top: 8px; padding: 0 10px; font-size: 10px; }

.app-user-identity small,
.app-user-access small {
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-user-access label {
  display: grid;
  gap: 5px;
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.app-user-access select { min-height: 36px; }

.app-users-empty {
  margin: 0;
  padding: 25px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 7px;
  text-align: center;
}

html[data-theme="light"] .admin-category-nav { background: #f7fbfd; border-color: #aac9d9; }
html[data-theme="light"] .admin-category-heading h2 { color: #082f49; }
html[data-theme="light"] :is(.admin-category-heading p, .admin-category-nav button) { color: #41667d; }

/* Gestão compacta de usuários e permissões */
.access-management-modern { display: grid; grid-template-columns: 1fr; gap: 20px; }
.app-user-toolbar { display: grid; grid-template-columns: minmax(190px, 1fr) repeat(3, minmax(120px, .55fr)); gap: 8px; margin: 12px 0 6px; }
.app-user-toolbar label { display: grid; gap: 4px; color: var(--muted); font-size: 9px; font-weight: 800; text-transform: uppercase; }
.app-user-toolbar :is(input, select) { min-height: 36px; padding: 0 10px; }
.app-user-hide-disabled { display: inline-flex; min-height: 32px; align-items: center; gap: 7px; margin-top: 4px; color: var(--muted); font-size: 11px; font-weight: 700; cursor: pointer; }
.app-user-hide-disabled input { width: 15px; height: 15px; accent-color: var(--cyan); }
@media (pointer: coarse) {
  .app-user-hide-disabled { min-height: 40px; }
}
.app-users-summary { margin: 8px 0 12px; color: var(--muted); font-size: 11px; }
.app-user-row-compact { grid-template-columns: minmax(180px, 1.3fr) minmax(210px, 1fr) auto; gap: 12px; padding: 9px 10px; border-color: color-mix(in srgb, var(--line) 70%, transparent); }
.app-user-row-compact .app-user-identity { grid-column: auto; }
.app-user-row-compact [data-edit-user] { cursor: pointer; }
.app-user-row-compact .app-user-avatar { width: 32px; height: 32px; flex-basis: 32px; }
.app-user-summary { display: flex; min-width: 0; align-items: center; gap: 8px; color: var(--ink); font-size: 10px; }
.app-user-summary > span:first-child { font-weight: 800; }
.app-user-summary small { margin-left: auto; color: var(--muted); white-space: nowrap; }
.app-user-status { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); }
.app-user-status i { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; }
.app-user-status[data-status="disabled"] i { background: #94a3b8; }
.app-user-status[data-status="blocked"] i { background: #ef4444; }
.app-user-actions { display: flex; align-items: center; gap: 5px; }
.app-user-actions > button { min-height: 32px; padding: 0 10px; }
.app-user-actions details { position: relative; }
.app-user-actions summary { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 7px; cursor: pointer; list-style: none; }
.app-user-actions summary::-webkit-details-marker { display: none; }
.app-user-actions details > div { position: absolute; right: 0; z-index: 10; display: grid; min-width: 130px; padding: 5px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 28px rgba(0, 0, 0, .18); }
.app-user-actions details button { min-height: 32px; padding: 0 9px; color: var(--ink); background: transparent; border: 0; text-align: left; }

/* Lixeira da conta desativada, ao lado do Editar. Discreta em repouso e vermelha
   só na interação, para não competir com a ação principal da linha. */
/* `place-content` também: o reset de `button` traz `justify-content: space-between`,
   que empurraria o ícone para a borda esquerda do botão. */
.app-user-actions .app-user-trash { display: grid; width: 32px; height: 32px; padding: 0; place-items: center; place-content: center; color: var(--muted); background: transparent; border: 0; border-radius: 8px; cursor: pointer; transition: color .15s ease, background-color .15s ease; }
.app-user-actions .app-user-trash svg { display: block; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.app-user-actions .app-user-trash:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }
.app-user-actions .app-user-trash:focus-visible { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); outline: 2px solid color-mix(in srgb, var(--danger) 45%, transparent); outline-offset: 1px; }

/* Quando a lista tem alguma conta excluível, toda linha reserva a coluna da
   lixeira: Editar e "..." ficam alinhados de uma linha para a outra em vez de
   dançarem 37px para o lado nas linhas sem o botão. */
@media (min-width: 701px) {
  .app-users-list-trash .app-user-actions { display: grid; grid-template-columns: auto 32px 32px; }
  .app-users-list-trash .app-user-actions > .secondary-button { grid-column: 1; }
  .app-users-list-trash .app-user-actions > .app-user-trash { grid-column: 2; }
  .app-users-list-trash .app-user-actions > details { grid-column: 3; }
}
.user-password-dialog { width: min(420px, calc(100vw - 28px)); max-width: none; max-height: none; margin: auto; padding: 0; overflow: hidden; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 24px 70px rgba(2, 10, 22, .36); }
.user-password-dialog::backdrop { background: rgba(2, 10, 22, .64); backdrop-filter: blur(4px); }
.user-password-card { display: grid; width: 100%; margin: 0; padding: 0; overflow: hidden; box-sizing: border-box; }
.user-password-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 24px 18px; }
.user-password-heading > div { min-width: 0; }
.user-password-heading span { display: block; margin-bottom: 5px; color: var(--cyan); font-size: 9px; font-weight: 900; letter-spacing: .09em; }
.user-password-heading h2 { margin: 0; color: var(--ink); font-size: 21px; line-height: 1.2; }
.user-password-heading p { margin: 6px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.user-password-heading > button { display: grid; width: 34px; min-width: 34px; height: 34px; min-height: 34px; place-items: center; padding: 0; color: var(--muted); background: color-mix(in srgb, var(--muted) 7%, transparent); border: 0; border-radius: 9px; font-size: 18px; cursor: pointer; }
.user-password-heading > button:hover,
.user-password-heading > button:focus-visible { color: var(--ink); background: color-mix(in srgb, var(--cyan) 12%, transparent); outline: 2px solid color-mix(in srgb, var(--cyan) 35%, transparent); }
.user-password-body { padding: 0 24px 22px; }
.user-password-field { display: grid; gap: 7px; color: var(--ink); font-size: 10px; font-weight: 800; }
.user-password-field input { display: block; width: 100%; min-width: 0; height: 44px; padding: 0 13px; box-sizing: border-box; color: var(--ink); background: color-mix(in srgb, var(--surface) 94%, var(--muted)); border: 1px solid var(--line); border-radius: 9px; }
.user-password-field input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px color-mix(in srgb, var(--cyan) 15%, transparent); outline: none; }
.user-password-field input::-ms-reveal,
.user-password-field input::-ms-clear { display: none; }
.user-password-field small { color: var(--muted); font-size: 9px; font-weight: 500; }
.user-password-dialog .form-message:empty { display: none; }
.user-password-dialog .form-message { margin: 10px 0 0; }

.agenda-automations-admin { display: grid; gap: 18px; }
.agenda-automations-heading span, .agenda-automation-card header span { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .1em; }
.agenda-automations-heading h2 { margin: 4px 0; }
.agenda-automations-heading p { margin: 0; color: var(--muted); }
.agenda-automations-list { display: grid; gap: 10px; }
.agenda-automation-row { display: grid; grid-template-columns: 10px minmax(220px, 1fr) auto; gap: 14px; align-items: center; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.agenda-automation-state { align-self: stretch; display: grid; place-items: center; }
.agenda-automation-state span { width: 4px; height: 100%; min-height: 44px; border-radius: 999px; background: var(--line); transition: background .2s ease, transform .2s ease; }
.agenda-automation-row.is-enabled .agenda-automation-state span { background: var(--accent); transform: scaleY(.9); }
.agenda-automation-summary > div { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.agenda-automation-summary p, .agenda-automation-summary small { margin: 4px 0 0; color: var(--muted); }
.agenda-automation-badge { padding: 3px 8px; color: var(--muted); background: var(--soft-surface); border-radius: 999px; font-size: 11px; font-weight: 700; }
.is-enabled .agenda-automation-badge { color: var(--accent); }
.agenda-automation-actions { display: flex; gap: 7px; align-items: center; }
.agenda-automation-icon-button { min-height: 36px; padding: 0 10px; color: var(--muted); background: transparent; border: 0; border-radius: 8px; cursor: pointer; }
.agenda-automation-icon-button:hover { color: var(--ink); background: var(--soft-surface); }
.agenda-automation-dialog { width: min(780px, calc(100vw - 28px)); max-width: none; max-height: calc(100vh - 28px); margin: auto; padding: 0; overflow: hidden; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 24px 70px rgba(2, 10, 22, .4); }
.agenda-automation-dialog::backdrop { background: rgba(2, 10, 22, .64); backdrop-filter: blur(4px); }
.agenda-automation-card { display: grid; max-height: calc(100vh - 28px); margin: 0; }
.agenda-automation-card > header, .agenda-automation-card > footer { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 18px 22px; }
.agenda-automation-card > header { border-bottom: 1px solid var(--line); }
.agenda-automation-card > footer { justify-content: flex-end; border-top: 1px solid var(--line); }
.agenda-automation-card header h2 { margin: 3px 0 0; font-size: 20px; }
.agenda-automation-card header button { width: 36px; height: 36px; color: var(--muted); background: var(--soft-surface); border: 0; border-radius: 9px; font-size: 20px; cursor: pointer; }
.agenda-automation-body, .agenda-automation-result-body { min-height: 0; padding: 22px; overflow: auto; }
.agenda-automation-name { display: grid; gap: 7px; font-weight: 700; }
.agenda-automation-flow { display: grid; grid-template-columns: 1fr auto 1fr auto 1.25fr; gap: 10px; align-items: center; margin: 18px 0; }
.agenda-automation-flow section { min-height: 86px; padding: 14px; background: var(--soft-surface); border-radius: 12px; }
.agenda-automation-flow small { display: block; margin-bottom: 8px; color: var(--accent); font-weight: 800; }
.agenda-automation-flow > span { color: var(--muted); }
.agenda-automation-scope { display: flex; flex-wrap: wrap; gap: 10px 18px; margin: 0 0 16px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.agenda-automation-scope legend { padding: 0 5px; font-weight: 800; }
.agenda-automation-scope label { display: flex; gap: 7px; align-items: center; }
.agenda-automation-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.agenda-automation-metrics span { padding: 14px; text-align: center; background: var(--soft-surface); border-radius: 12px; }
.agenda-automation-metrics strong { display: block; font-size: 22px; }
.agenda-automation-affected, .agenda-automation-history { display: grid; gap: 8px; margin-top: 16px; }
.agenda-automation-affected > div, .agenda-automation-history article { display: flex; justify-content: space-between; gap: 12px; padding: 12px; background: var(--soft-surface); border-radius: 10px; }
.agenda-automation-history article { display: block; }
.agenda-automation-history article > div { display: flex; justify-content: space-between; gap: 12px; }
.agenda-automation-history p { margin: 5px 0 0; color: var(--muted); }
.checklist-templates-admin { align-self: start; }
.checklist-templates-grid { display: grid; grid-template-columns: 1fr; gap: 12px; align-items: start; }
.checklist-templates-list { display: grid; gap: 8px; }
.checklist-templates-empty { display: flex; align-items: center; gap: 12px; min-height: 72px; padding: 14px 16px; color: var(--muted); background: var(--soft-surface); border-radius: 12px; text-align: left; }
.checklist-templates-empty > span, .checklist-template-row-icon { display: grid; flex: 0 0 auto; width: 34px; height: 34px; place-items: center; color: var(--accent); background: var(--surface); border-radius: 10px; }
.checklist-templates-empty svg, .checklist-template-row-icon svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.checklist-templates-empty div { display: grid; gap: 3px; }
.checklist-templates-empty small { color: var(--muted); }
.checklist-template-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 12px; background: var(--soft-surface); border-radius: 11px; }
.checklist-template-row-copy { display: grid; grid-template-columns: auto 1fr; gap: 3px 8px; min-width: 0; align-items: center; }
.checklist-template-row-copy small { color: var(--muted); }
.checklist-template-row-copy > span { grid-column: 1 / -1; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.checklist-template-row-actions { display: flex; gap: 7px; align-items: center; }
.checklist-template-more { position: relative; }
.checklist-template-more summary { display: grid; width: 36px; height: 36px; place-items: center; color: var(--muted); background: transparent; border-radius: 9px; list-style: none; cursor: pointer; }
.checklist-template-more summary::-webkit-details-marker { display: none; }
.checklist-template-more summary:hover, .checklist-template-more summary:focus-visible { color: var(--ink); background: var(--surface-2); outline: 2px solid color-mix(in srgb, var(--accent) 28%, transparent); }
.checklist-template-more > div { position: absolute; z-index: 20; top: calc(100% + 5px); right: 0; display: grid; min-width: 130px; padding: 5px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 14px 36px rgba(2, 10, 22, .2); }
.checklist-template-more button { min-height: 34px; padding: 0 10px; color: var(--ink); background: transparent; border: 0; border-radius: 7px; text-align: left; cursor: pointer; }
.checklist-template-more button:hover { background: var(--surface-2); }

.checklist-template-dialog { width: min(620px, calc(100vw - 28px)); max-width: none; max-height: min(760px, calc(100dvh - 28px)); margin: auto; padding: 0; overflow: hidden; color: var(--ink); background: transparent; border: 0; border-radius: 18px; box-shadow: 0 26px 76px rgba(2, 10, 22, .34); }
.checklist-template-dialog::backdrop { background: rgba(2, 10, 22, .62); backdrop-filter: blur(4px); }
.checklist-template-dialog-card { display: grid; max-height: min(760px, calc(100dvh - 28px)); grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.checklist-template-dialog-card > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 22px 17px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface-2) 65%, var(--surface)); }
.checklist-template-dialog-card > header span { color: var(--cyan); font-size: 9px; font-weight: 900; letter-spacing: .09em; }
.checklist-template-dialog-card > header h2 { margin: 4px 0 0; color: var(--ink); font-size: 20px; }
.checklist-template-dialog-card > header p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.checklist-template-dialog-card > header button { display: grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; padding: 0; color: var(--muted); background: var(--surface-2); border: 0; border-radius: 9px; font-size: 18px; cursor: pointer; }
.checklist-template-dialog-body { display: grid; align-content: start; gap: 18px; min-height: 0; padding: 20px 22px; overflow-y: auto; }
.checklist-template-name { display: grid; gap: 7px; color: var(--ink); font-size: 12px; font-weight: 800; }
.checklist-template-name input { width: 100%; min-height: 42px; }
.checklist-template-items-editor { display: grid; gap: 10px; }
.checklist-template-items-editor > div:first-child { display: grid; gap: 3px; }
.checklist-template-items-editor small { color: var(--muted); font-size: 11px; }
.checklist-template-editable-items { display: grid; gap: 6px; }
.checklist-template-editable-item { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 7px; align-items: center; padding: 6px; background: var(--surface-2); border-radius: 10px; }
.checklist-template-item-handle { display: grid; width: 28px; height: 34px; place-items: center; color: var(--muted); }
.checklist-template-item-handle svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }
.checklist-template-editable-item input { width: 100%; min-width: 0; min-height: 36px; background: var(--surface); }
.checklist-template-editable-item > div { display: flex; gap: 2px; }
.checklist-template-editable-item button { display: grid; width: 30px; height: 30px; place-items: center; padding: 0; color: var(--muted); background: transparent; border: 0; border-radius: 7px; cursor: pointer; }
.checklist-template-editable-item button:hover { color: var(--ink); background: var(--surface); }
.checklist-template-editable-item button:last-child:hover { color: #dc3545; }
.checklist-template-add-item { width: fit-content; min-height: 34px; padding: 0 8px; color: var(--accent); background: transparent; border: 0; border-radius: 8px; font-weight: 750; cursor: pointer; }
.checklist-template-add-item:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.checklist-template-dialog-card > footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface-2) 55%, var(--surface)); }

@media (max-width: 760px) {
  .checklist-template-row { grid-template-columns: auto minmax(0, 1fr); align-items: center; }
  .checklist-template-row-actions { grid-column: 2; justify-content: flex-start; }
  .checklist-template-dialog-card > header, .checklist-template-dialog-body, .checklist-template-dialog-card > footer { padding-right: 16px; padding-left: 16px; }
  .checklist-template-editable-item { grid-template-columns: minmax(0, 1fr) auto; }
  .checklist-template-item-handle { display: none; }
  .checklist-template-editable-item > div { grid-column: 1 / -1; justify-content: flex-end; }
  .agenda-automation-row { grid-template-columns: 7px 1fr; }
  .agenda-automation-actions { grid-column: 2; display: grid; grid-template-columns: 1fr 1fr; }
  .agenda-automation-actions .primary-button { grid-column: 1 / -1; }
  .agenda-automation-flow { grid-template-columns: 1fr; }
  .agenda-automation-flow > span { transform: rotate(90deg); justify-self: center; }
  .agenda-automation-metrics { grid-template-columns: 1fr; }
  .agenda-automation-card > header, .agenda-automation-card > footer, .agenda-automation-body, .agenda-automation-result-body { padding: 16px; }
  .agenda-automation-affected > div { display: grid; }
}
.user-password-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 24px; background: color-mix(in srgb, var(--muted) 4%, transparent); border-top: 1px solid var(--line); }
.user-password-actions button { width: auto; min-height: 38px; padding: 0 16px; }

@media (max-width: 520px) {
  .user-password-heading { padding: 20px 20px 16px; }
  .user-password-body { padding: 0 20px 20px; }
  .user-password-actions { padding: 13px 20px; }
  .user-password-actions button { flex: 1; }
}
.access-group-tabs { display: flex; gap: 3px; margin: 12px 0; padding: 3px; background: var(--surface-soft, rgba(148,163,184,.08)); border-radius: 9px; }
.access-group-tabs button { min-height: 34px; flex: 1; padding: 0 8px; color: var(--muted); background: transparent; border: 0; }
.access-group-tabs button[aria-selected="true"] { color: var(--ink); background: var(--surface); box-shadow: 0 2px 8px rgba(2,12,27,.12); }
.access-group-matrix { padding: 0; overflow: hidden; }
.access-group-matrix .access-group-title { padding: 10px 12px; }
.access-matrix-header { display: grid; grid-template-columns: minmax(150px, 220px) minmax(0, 1fr); padding: 7px 12px; color: var(--muted); border-bottom: 1px solid var(--line); font-size: 9px; font-weight: 850; text-transform: uppercase; }
.access-group-matrix .access-module-row { grid-template-columns: minmax(150px, 220px) minmax(0, 1fr); padding: 9px 12px; border: 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 65%, transparent); border-radius: 0; }
.access-group-matrix .access-permission-controls { justify-content: flex-start; gap: 5px; }
.access-group-matrix .access-permission-toggle { min-height: 28px; padding: 0 7px; border-color: transparent; background: color-mix(in srgb, var(--muted) 7%, transparent); }
/* Achado ao verificar o redesenho desta secao (15/09/2026): com z-index 90/91
   o drawer ficava ATRAS do topbar (header-fix.css, z-index 200), que e sticky e
   cobre toda a largura — o proprio cabecalho do drawer (titulo e X de fechar)
   sumia atras dele, e o X so recebia clique onde o topbar nao alcancava. Sobe
   para depois do topbar, mantendo o mesmo espacamento de 1 entre fundo e drawer. */
.user-access-backdrop { position: fixed; inset: 0; z-index: 210; background: rgba(2, 10, 22, .56); backdrop-filter: blur(2px); }
.user-access-drawer { position: fixed; top: 0; right: 0; z-index: 211; display: grid; width: min(520px, 100vw); height: 100dvh; grid-template-rows: auto minmax(0, 1fr) auto; color: var(--ink); background: var(--surface); box-shadow: -18px 0 48px rgba(2, 10, 22, .3); transform: translateX(102%); transition: transform 190ms ease; }
.user-access-drawer[aria-hidden="false"] { transform: none; }
.user-access-drawer > header,
.user-access-drawer > footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.user-access-drawer > footer { justify-content: flex-end; border-top: 1px solid var(--line); border-bottom: 0; }
.user-access-drawer > header span { color: var(--cyan); font-size: 9px; font-weight: 900; }
.user-access-drawer > header h2 { margin: 3px 0 0; font-size: 18px; }
.user-access-drawer > header button { width: 36px; min-height: 36px; padding: 0; }
.user-access-drawer-body { overflow-y: auto; padding: 18px; }
.user-access-drawer-body > section { padding: 15px 0; border-bottom: 1px solid var(--line); }
.user-access-profile { display: flex; align-items: center; gap: 11px; padding-top: 0 !important; }
.user-access-profile .app-user-avatar { width: 46px; height: 46px; flex-basis: 46px; }
.user-access-profile-identity { min-width: 0; flex: 1 1 auto; }
.user-access-profile :is(strong, span, small) { display: block; }
.user-access-profile span,
.user-access-profile small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.user-access-name-field { display: grid; gap: 4px; margin: 0; }
.user-access-name-field span { margin-top: 0 !important; color: var(--muted); font-size: 10px; font-weight: 800; }
.user-access-name-field input { min-height: 34px; padding: 0 9px; color: var(--ink); font-size: 14px; font-weight: 800; }
.user-access-authentik-hint { margin: 6px 0 0; padding: 7px 9px; color: var(--muted); background: color-mix(in srgb, var(--cyan) 8%, transparent); border-radius: 7px; font-size: 10px; line-height: 1.4; }
.user-access-fields h3,
.user-access-overrides h3,
.user-access-history h3 { margin: 0 0 10px; font-size: 13px; }
.user-access-fields > div { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.user-access-fields label { display: grid; gap: 5px; color: var(--muted); font-size: 10px; font-weight: 800; }
/* Alvo de toque dos seletores da ficha (Função, Status, Pessoa no GestãoClick):
   38px no celular ficava abaixo dos 40px que a auditoria cobra. */
@media (pointer: coarse) {
  .user-access-fields select { min-height: 40px; }
}
.user-access-fields [data-access-warning] { margin: 10px 0 0; padding: 9px 10px; color: var(--muted); background: color-mix(in srgb, var(--cyan) 8%, transparent); border-radius: 7px; font-size: 10px; line-height: 1.45; }
.user-access-overrides > div:first-child p { margin: -6px 0 12px; color: var(--muted); font-size: 10px; }
.user-permission-list { display: grid; gap: 3px; }
.user-permission-list label { display: grid; grid-template-columns: minmax(0, 1fr) 100px; align-items: center; gap: 8px; min-height: 38px; padding: 4px 7px; border-radius: 7px; font-size: 10px; }
.user-permission-list label:hover { background: color-mix(in srgb, var(--cyan) 6%, transparent); }
.user-permission-list select { min-height: 30px; padding: 0 7px; font-size: 10px; }
.user-access-history [data-user-history] { display: grid; gap: 6px; }
.user-access-history article { padding: 9px 10px; background: color-mix(in srgb, var(--muted) 6%, transparent); border-radius: 7px; }
.user-access-history article :is(strong, p, time) { display: block; margin: 0; }
.user-access-history article strong { font-size: 10px; }
.user-access-history article p,
.user-access-history article time { margin-top: 3px; color: var(--muted); font-size: 9px; }

@media (max-width: 700px) {
  .app-user-toolbar { grid-template-columns: 1fr 1fr; }
  .app-user-search { grid-column: 1 / -1; }

  /* Cartão do usuário no celular: identidade e o menu "..." dividem a primeira
     linha; função/status, último acesso e o botão Editar ficam cada um na sua
     linha. Nenhuma célula é compartilhada, então nada se sobrepõe, e as larguras
     são todas relativas — nome e e-mail longos quebram em vez de estourar. */
  .app-user-row-compact {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: 10px;
    padding: 12px;
  }

  .app-user-row-compact .app-user-identity {
    grid-column: 1;
    grid-row: 1;
    align-items: flex-start;
  }

  .app-user-row-compact .app-user-identity strong {
    font-size: 14px;
    line-height: 1.25;
    overflow: visible;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .app-user-row-compact .app-user-identity small {
    overflow: visible;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .app-user-summary {
    grid-column: 1 / -1;
    grid-row: 2;
    flex-wrap: wrap;
    gap: 6px 12px;
    font-size: 12px;
  }

  .app-user-summary small { width: 100%; margin-left: 0; white-space: normal; }

  /* `display: contents` solta o botão e o menu como itens do próprio grid: o
     "..." sobe para a primeira linha e Editar desce para a última. */
  .app-user-row-compact .app-user-actions { display: contents; }

  .app-user-row-compact .app-user-actions details {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  .app-user-row-compact .app-user-actions > button {
    grid-column: 1 / -1;
    grid-row: 3;
    justify-self: end;
    min-height: 36px;
    padding: 0 18px;
  }

  /* A lixeira divide a linha do Editar pela ponta oposta: alvo de toque maior e
     longe da ação principal, sem nenhuma célula compartilhada no meio. */
  .app-user-row-compact .app-user-actions > button.app-user-trash {
    justify-self: start;
    width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 0;
  }

  .app-user-row-compact .app-user-actions > button.app-user-trash svg { width: 18px; height: 18px; }

  .local-user-create-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .local-user-create-heading button { width: 100%; }
  .local-user-fields { grid-template-columns: 1fr; }
  .pending-invitation-actions button { flex: 1 1 auto; }
  .access-matrix-header { display: none; }
  .access-group-matrix .access-module-row { grid-template-columns: 1fr; }
  .user-access-drawer { width: calc(100vw - 10px); }
  .user-access-fields > div { grid-template-columns: 1fr; }
}

/* Documentation audit panel */
.documentation-audit-section {
  grid-column: 1 / -1;
}

.documentation-audit-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.documentation-audit-heading span {
  color: var(--cyan);
  font-size: 9px;
  font-weight: 900;
}

.documentation-audit-heading h2 {
  margin: 4px 0 0;
}

.documentation-audit-heading p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.documentation-audit-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(5, minmax(128px, 0.65fr));
  gap: 12px;
  margin-top: 18px;
}

.documentation-audit-list {
  display: grid;
  gap: 7px;
  margin-top: 15px;
}

.documentation-audit-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 5px minmax(220px, 1fr) minmax(180px, 0.65fr) minmax(190px, 0.55fr);
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  color: var(--ink);
  background: rgba(5, 20, 34, 0.52);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.documentation-audit-indicator {
  width: 4px;
  height: 34px;
  background: var(--cyan);
  border-radius: 4px;
}

.documentation-audit-row[data-level="yellow"] .documentation-audit-indicator { background: #f4bd4f; }
.documentation-audit-row[data-level="red"] .documentation-audit-indicator { background: #ef6679; }

.documentation-audit-row :is(strong, span, small) {
  display: block;
  min-width: 0;
}

.documentation-audit-action strong,
.documentation-audit-user span,
.documentation-audit-date span {
  overflow: hidden;
  color: var(--ink);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.documentation-audit-action small,
.documentation-audit-user small,
.documentation-audit-date small {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.documentation-audit-date {
  text-align: right;
}

.documentation-audit-level {
  color: #38bdf8 !important;
  font-size: 8px !important;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.documentation-audit-level[data-level="yellow"] { color: #eab54b !important; }
.documentation-audit-level[data-level="red"] { color: #ef6679 !important; }

.documentation-audit-empty {
  margin: 0;
  padding: 28px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 6px;
  text-align: center;
}

html[data-theme="light"] .documentation-audit-row {
  color: #082f49;
  background: #f3f9fc;
  border-color: #aac9d9;
}

html[data-theme="light"] :is(.documentation-audit-action strong, .documentation-audit-user span, .documentation-audit-date span) {
  color: #082f49;
}

html[data-theme="light"] :is(.documentation-audit-action small, .documentation-audit-user small, .documentation-audit-date small, .documentation-audit-heading p, .documentation-audit-empty) {
  color: #41667d;
}

html[data-theme="light"] .documentation-audit-level { color: #087cab !important; }
html[data-theme="light"] .documentation-audit-level[data-level="yellow"] { color: #9a6200 !important; }
html[data-theme="light"] .documentation-audit-level[data-level="red"] { color: #b4233b !important; }

@media (max-width: 1120px) {
  .documentation-audit-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .local-user-fields { grid-template-columns: minmax(0, 1fr); }
  .local-user-photo-field,
  .local-user-create-actions { grid-column: 1; }

  .documentation-audit-filters {
    grid-template-columns: minmax(0, 1fr);
  }

  .documentation-audit-row {
    grid-template-columns: 4px minmax(0, 1fr);
  }

  .documentation-audit-row > :not(.documentation-audit-indicator) {
    grid-column: 2;
  }

  .documentation-audit-indicator {
    grid-row: 1 / span 3;
    height: 100%;
  }

  .documentation-audit-date {
    text-align: left;
  }
}

@media (max-width: 520px) {
  .admin-shell { padding: 16px 12px 30px; }
  .admin-category-nav { top: 7px; margin-bottom: 12px; }
  .admin-category-heading { padding-top: 12px; }
  .admin-settings-top-actions {
    align-items: stretch;
    flex-direction: column;
  }
  .admin-settings-top-actions .primary-button { width: 100%; }
  .admin-settings-top-actions .form-message { text-align: left; }
  .access-groups-heading { align-items: stretch; flex-direction: column; }
  .access-groups-heading .primary-button { width: 100%; }
  .admin-heading-actions { align-items: stretch; flex-direction: column; }
  .admin-heading-actions button,
  .access-groups-footer .primary-button { width: 100%; }
  .access-module-row { grid-template-columns: 1fr; }
  .access-permission-controls { justify-content: flex-start; }

  .user-access-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .user-access-heading button { width: 100%; }

  .documentation-audit-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .documentation-audit-heading button {
    width: 100%;
  }
}

/* ------------------------------------------------------------------ *
 * Acesso: verificação por código, convite e nova senha.
 * Mesma caixa de login, mesmos tokens — claro e escuro saem de graça.
 *
 * As regras nascem escopadas em `.login-box` de propósito: a caixa de login já
 * declara `.login-box .stack-form input`, e um seletor mais fraco aqui perde a
 * disputa e devolve o campo esticado de 44px — foi o que deformou a caixinha de
 * "confiar neste dispositivo".
 * ------------------------------------------------------------------ */
.auth-help {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.auth-identity {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
  text-align: center;
}

.auth-identity strong {
  color: var(--ink);
  font-size: 15px;
}

.auth-identity span {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.auth-code {
  gap: 16px;
}

.auth-code .auth-local-heading {
  gap: 4px;
}

.auth-code-target {
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.2px;
  overflow-wrap: anywhere;
}

.auth-code-inputs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.login-box .stack-form .auth-code-digit {
  width: 100%;
  min-height: 56px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
  color: var(--ink);
  font-size: 24px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: center;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

/* Dígito preenchido ganha destaque sem precisar de JavaScript. */
.login-box .stack-form .auth-code-digit:not(:placeholder-shown) {
  border-color: color-mix(in srgb, var(--purple) 55%, var(--line));
  background: color-mix(in srgb, var(--purple) 12%, transparent);
}

.login-box .stack-form .auth-code-digit:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--purple) 26%, transparent);
  outline: none;
}

/* Confiar no dispositivo: interruptor próprio, porque a caixa nativa não aceita
   tamanho de forma consistente entre navegadores e temas.

   `.stack-form label` empilha os campos em coluna. Aqui a linha é horizontal de
   propósito, e sem declarar a direção o interruptor herda a coluna: a base de
   42px vira altura, ele fica quadrado e o texto cai para baixo dele. */
.login-box .stack-form label.auth-trust-toggle {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-2) 55%, transparent);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.login-box .stack-form label.auth-trust-toggle:hover {
  border-color: color-mix(in srgb, var(--purple) 45%, var(--line));
}

.login-box .stack-form label.auth-trust-toggle:has(input:checked) {
  border-color: color-mix(in srgb, var(--purple) 60%, var(--line));
  background: color-mix(in srgb, var(--purple) 12%, transparent);
}

.login-box .stack-form .auth-trust-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.auth-trust-switch {
  position: relative;
  flex: 0 0 42px;
  width: 42px;
  height: 24px;
  margin-top: 1px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 38%, transparent);
  transition: background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.15s ease;
}

.auth-trust-switch::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(4, 12, 24, 0.45);
  transform: translateY(-50%);
  transition: transform 0.18s ease;
}

.auth-trust-toggle input:checked + .auth-trust-switch {
  border-color: var(--purple);
  background: var(--purple);
}

.auth-trust-toggle input:checked + .auth-trust-switch::after {
  transform: translate(18px, -50%);
}

.auth-trust-toggle input:focus-visible + .auth-trust-switch {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--purple) 28%, transparent);
}

.auth-trust-text {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.auth-trust-text strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.auth-trust-text small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
}

/* "Manter conectado": mesmo interruptor, fora das seções de login (vale para
   o local e para o Authentik). `.stack-form` é grid, e grid vence o `[hidden]`
   do navegador — mesma razão de `.auth-sso[hidden]`. */
.login-box .auth-keep-signed-in {
  margin-top: 14px;
}

.auth-keep-signed-in[hidden] {
  display: none;
}

.auth-code-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.auth-code-actions-divider {
  width: 1px;
  height: 14px;
  background: var(--line);
}

.login-box .auth-link {
  padding: 6px 4px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--cyan);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.login-box .auth-link:hover:not([disabled]) {
  text-decoration: underline;
}

.login-box .auth-link:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 2px;
}

.login-box .auth-link.is-muted {
  color: var(--muted);
  font-weight: 600;
}

.login-box .auth-link[disabled] {
  color: var(--muted);
  cursor: default;
}

/* Erro não pode chegar como texto solto do mesmo tom do resto da página. */
.login-box .form-message.is-error {
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  font-weight: 600;
}

@media (max-width: 420px) {
  .auth-code-inputs {
    gap: 6px;
  }

  .login-box .stack-form .auth-code-digit {
    min-height: 50px;
    border-radius: 10px;
    font-size: 20px;
  }

  .login-box .stack-form label.auth-trust-toggle {
    padding: 11px 12px;
    gap: 10px;
  }

  /* Na largura do celular as duas ações não cabem lado a lado; empilhadas, o
     separador entre elas perde o sentido. */
  .auth-code-actions {
    flex-direction: column;
    gap: 2px;
  }

  .auth-code-actions-divider {
    display: none;
  }
}

/* ------------------------------------------------------------------ *
 * Servidor de e-mail, segurança de login, convites e dispositivos.
 * ------------------------------------------------------------------ */
.smtp-heading,
.login-security-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.smtp-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--line-light);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.smtp-status-badge[data-state="ok"] {
  border-color: color-mix(in srgb, #16a34a 45%, transparent);
  background: color-mix(in srgb, #16a34a 12%, transparent);
  color: #15803d;
}

.smtp-status-badge[data-state="warn"] {
  border-color: color-mix(in srgb, #f59e0b 45%, transparent);
  background: color-mix(in srgb, #f59e0b 12%, transparent);
  color: #b45309;
}

html[data-theme="dark"] .smtp-status-badge[data-state="ok"] { color: #4ade80; }
html[data-theme="dark"] .smtp-status-badge[data-state="warn"] { color: #fbbf24; }

.smtp-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: 14px;
}

.smtp-wide {
  grid-column: 1 / -1;
}

.smtp-test {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.smtp-test label {
  min-width: 260px;
  flex: 1 1 260px;
}

/* Integração GestãoClick: mesmo vocabulário visual do painel SMTP, mais a
   tabela de mapeamento de situações. */
.gestaoclick-actions {
  align-items: center;
}

.gestaoclick-mapping-rows {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.gestaoclick-mapping-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--line-light);
  border-radius: var(--radius);
  background: var(--surface);
}

.gestaoclick-mapping-row strong {
  font-size: 13px;
  color: var(--ink);
}

.gestaoclick-mapping-row select {
  min-width: 170px;
}

/* Formas de pagamento "já faturadas" (Apoio ao Faturamento): a mesma linha
   das demais tabelas da integração, em grade densa — o cadastro pode ter
   dezenas de formas. */
.gestaoclick-rc-methods {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 6px 12px;
  margin-top: 4px;
}

.gestaoclick-rc-method {
  border: 1px solid var(--line-light);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 7px 12px;
}

/* Uma automação por linha: o que acontece à esquerda, o status escolhido à
   direita. Mesmo desenho das situações do GestãoClick, com espaço para a frase
   que explica quando o passo dispara. */
.order-stage-rows {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.order-stage-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  padding: 11px 13px;
  border: 1px solid var(--line-light);
  border-radius: var(--radius);
  background: var(--surface);
}

/* Motivos de cancelamento: mesma linha em cartao dos passos do pedido, com o
   campo tomando a largura e o remover encostado na direita. */
.order-cancel-reasons {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.order-cancel-reason-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--line-light);
  border-radius: var(--radius);
  background: var(--surface);
}

/* O reset global impoe width: 100% em input: aqui ele deve dividir a linha com
   o botao, e nao empurra-lo para baixo. */
.order-cancel-reason-row input {
  width: auto;
  flex: 1 1 auto;
  min-width: 0;
}

/* A caixa "avisar quem pagou" das formas de pagamento de despesa: nao disputa
   a linha com o nome — ela e uma escolha curta ao lado, com alvo de toque
   proprio. O input dela volta a ter largura de caixa, e nao de campo. */
.order-expense-source-notify {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  min-height: 32px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
}

.order-cancel-reason-row .order-expense-source-notify input {
  width: 16px;
  height: 16px;
  flex: none;
  margin: 0;
}

@media (max-width: 640px) {
  .order-cancel-reason-row:has(.order-expense-source-notify) { flex-wrap: wrap; }
  .order-expense-source-notify { order: 3; }
}

.order-cancel-reason-row .secondary-button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
}

/* Opções de "Adiar notificação": mesma linha em cartão dos motivos de
   cancelamento, com rótulo, quantidade e unidade lado a lado. */
.notification-snooze-options {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.notification-snooze-option-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--line-light);
  border-radius: var(--radius);
  background: var(--surface);
}

.notification-snooze-option-row input[data-snooze-label] {
  width: auto;
  flex: 1 1 160px;
  min-width: 0;
}

.notification-snooze-option-row input[data-snooze-amount] {
  width: 72px;
  flex: 0 0 72px;
}

.notification-snooze-option-row select[data-snooze-unit] {
  width: auto;
  flex: 0 0 auto;
}

.notification-snooze-option-row .secondary-button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
}

.order-stage-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
  flex: 1 1 260px;
}

.order-stage-copy strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.order-stage-copy small {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.4;
}

/* `width: auto` porque o reset global de `input, textarea, select` impoe
   `width: 100%`: sem isto o seletor toma a linha inteira e desce para baixo do
   texto, e a linha passa de 59px para 109px -- medido. */
.order-stage-row select {
  width: auto;
  min-width: 210px;
  flex: 0 1 auto;
}

/* No celular o seletor passa a ocupar a linha inteira: espremido ao lado do
   texto ele fica com alvo pequeno demais e corta o nome do status. */
@media (max-width: 620px) {
  .order-stage-row select {
    width: 100%;
    min-width: 0;
    flex: 1 1 100%;
  }
}

/* Prazos do RMA: a mesma linha em cartão dos passos, com um número pequeno e a
   unidade à direita. `width: auto` pelo mesmo motivo do seletor acima — o
   reset global daria a linha inteira ao campo. */
/* Dois seletores para vencer `.settings-section label`, que empilha em coluna
   e mandaria a unidade para baixo do numero. */
.settings-section .order-deadline-field {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.order-deadline-field input {
  width: 84px;
  min-width: 0;
  flex: 0 0 auto;
  text-align: right;
}

/* Alvo de toque de 40px no celular, como a auditoria cobra. */
@media (max-width: 620px) {
  .order-deadline-field input { min-height: 40px; }
}

.backup-smtp-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.login-security-requirements {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.login-security-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
}

.login-security-item i {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  margin-top: 2px;
  border-radius: 50%;
  background: color-mix(in srgb, #f59e0b 22%, transparent);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, #f59e0b 55%, transparent);
}

.login-security-item[data-ok="true"] i {
  background: color-mix(in srgb, #16a34a 22%, transparent);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, #16a34a 55%, transparent);
}

.pending-invitations {
  display: grid;
  gap: 8px;
  margin: 4px 0 14px;
}

.pending-invitations[hidden] {
  display: none;
}

.pending-invitations-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pending-invitations-title span {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  padding: 0 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand, #3549d6) 14%, transparent);
  color: var(--brand, #3549d6);
  font-size: 11px;
}

.pending-invitation {
  display: grid;
  align-items: center;
  gap: 10px;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.6fr) auto;
  padding: 12px 14px;
  border: 1px dashed var(--line-light);
  border-radius: 12px;
  background: var(--surface);
}

.pending-invitation-identity {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.pending-invitation-identity strong {
  color: var(--ink);
  font-size: 14px;
}

.pending-invitation-identity small,
.pending-invitation-meta small {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.pending-invitation-meta {
  display: grid;
  gap: 3px;
}

.pending-invitation-role {
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.pending-invitation-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #b45309;
  font-size: 12px;
  font-weight: 700;
}

.pending-invitation-status i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.pending-invitation-status[data-state="expired"] {
  color: var(--muted);
}

html[data-theme="dark"] .pending-invitation-status { color: #fbbf24; }
html[data-theme="dark"] .pending-invitation-status[data-state="expired"] { color: var(--muted); }

.pending-invitation-actions {
  display: flex;
  gap: 6px;
}

.user-access-security {
  display: grid;
  gap: 10px;
}

.user-security-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border: 1px solid var(--line-light);
  border-radius: 12px;
}

.user-security-row div {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.user-security-row strong {
  color: var(--ink);
  font-size: 13px;
}

.user-security-row span {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.user-security-devices {
  display: grid;
  gap: 6px;
}

.user-security-device {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--muted) 8%, transparent);
}

.user-security-device strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
}

.user-security-device small {
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 760px) {
  .pending-invitation {
    grid-template-columns: 1fr;
  }

  .pending-invitation-actions,
  .user-security-row,
  .user-security-device {
    flex-wrap: wrap;
  }

  .smtp-test label {
    min-width: 0;
  }
}

/* Alteração de e-mail e exclusão de usuário. */
.user-email-current {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid var(--line-light);
  border-radius: 10px;
  background: color-mix(in srgb, var(--muted) 8%, transparent);
}

.user-email-current span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.user-email-current strong {
  color: var(--ink);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.user-email-note {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.user-email-note ul {
  margin: 0;
  padding-left: 18px;
}

.user-email-note small {
  color: var(--muted);
  font-size: 11px;
}

.user-delete-warning {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
}

.user-delete-extra {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.user-delete-extra[hidden] {
  display: none;
}

.user-delete-confirm {
  background: #d92d4c;
  border-color: #d92d4c;
  color: #ffffff;
}

.user-delete-confirm:hover {
  background: #b91c3c;
  border-color: #b91c3c;
}

.user-access-danger {
  display: grid;
  gap: 8px;
  padding: 13px;
  border: 1px solid color-mix(in srgb, #d92d4c 32%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, #d92d4c 7%, transparent);
}

.user-access-danger h3 {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
}

.user-access-danger p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.user-delete-trigger {
  justify-self: start;
  color: #d92d4c;
  border-color: color-mix(in srgb, #d92d4c 45%, transparent);
}

.user-delete-trigger[disabled] {
  color: var(--muted);
  border-color: var(--line-light);
  cursor: not-allowed;
}

.app-user-actions details button.app-user-danger { color: #d92d4c; }
.app-user-actions details button.app-user-danger[disabled] { color: var(--muted); cursor: not-allowed; }

/* Origem do orçamento na tela Consultar: Avulso ou SOL/PED da Central. */
.consult-origin {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.consult-origin-chip {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 2px 7px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--cyan) 14%, transparent);
  color: var(--cyan);
  white-space: nowrap;
}

.consult-origin-chip.is-order {
  background: color-mix(in srgb, var(--purple) 15%, transparent);
  color: var(--purple);
}

.consult-origin-avulso {
  font-size: 12px;
  color: var(--muted);
}

/* --------------- opção salva na solicitação (pós-salvamento) -------------- */

/* Quem cota decide aqui: montar outra opção ou concluir e enviar. Só aparece
   quando o orçamento nasceu de uma solicitação. */
.quote-origin-dialog {
  width: min(430px, calc(100vw - 24px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--ink);
}

.quote-origin-dialog::backdrop {
  background: rgba(4, 14, 26, 0.55);
  backdrop-filter: blur(4px);
}

.quote-origin-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.quote-origin-heading span {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.09em;
  color: var(--muted);
}

.quote-origin-heading h2 {
  margin: 4px 0 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
}

/* Fechar em SVG e não no caractere `&times;`: o glifo de texto tem o centro
   óptico acima do geométrico e nasce torto dentro da caixa, por mais que a
   caixa esteja centrada. */
.quote-origin-dialog .quote-origin-close {
  display: grid;
  width: 32px;
  height: 32px;
  min-height: 32px;
  flex: 0 0 32px;
  padding: 0;
  place-content: center;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.quote-origin-dialog .quote-origin-close:hover,
.quote-origin-dialog .quote-origin-close:focus-visible {
  border-color: var(--line);
  color: var(--ink);
}

.quote-origin-close svg { width: 15px; height: 15px; }

.quote-origin-body {
  display: grid;
  gap: 7px;
  padding: 16px 18px;
}

.quote-origin-body p {
  margin: 0;
  font-size: 13px;
  color: var(--ink);
}

.quote-origin-hint {
  font-size: 12px !important;
  color: var(--muted) !important;
}

.quote-origin-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}

@media (max-width: 520px) {
  .quote-origin-actions .secondary-button,
  .quote-origin-actions .primary-button { flex: 1 1 auto; justify-content: center; }
}

/* v1.196.0 - `.sr-only` era usada em tres lugares (cabecalho Acoes das tabelas de Redes e
   busca de modelos de checklist da Agenda) e nao existia em folha nenhuma: o texto que
   deveria ficar so para o leitor de tela aparecia na tela. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
