/*
 * FLOWS - folha unica, sem framework.
 *
 * Cores, espacos e fonte vem de tokens.css (design system "Flows · JCB LATAM").
 * Os nomes abaixo sao os que as telas ja usavam, agora so apelidos dos tokens:
 * nenhum hex solto nesta folha.
 */

:root {
  --page:        var(--surface-page);
  --border-soft: var(--divider);
  --text-faint:  var(--gray-500);

  --accent:       var(--action);
  --accent-hover: var(--action-hover);

  --success:      var(--green-700);
  --success-text: var(--green-800);
  --success-bg:   var(--green-100);
  --warning-text: var(--amber-800);
  --warning-bg:   var(--amber-100);
  --danger:       var(--red-700);
  --danger-soft:  var(--red-100);
  --danger-bg:    var(--red-100);

  --radius:      var(--radius-md);
  --radius-card: var(--radius-md);
  --radius-pill: var(--radius-full);

  --font: var(--font-sans);
}

* { box-sizing: border-box; }

/* O atributo hidden vence o display das classes (.step, .alert são flex). */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 20px;
  color: var(--text);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
}

:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--focus-ring); }

/* Conteudo, navbar e header na mesma coluna de content-max. */
.wrap { max-width: var(--content-max); margin: 0 auto; padding: 0 var(--space-6); }

a { color: var(--text-muted); text-decoration: none; }
a:hover { color: var(--text); }

/* ---------- Login ---------- */

.login-screen {
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--page);
  position: relative;
  padding: 24px;
}

/* Card de login: o unico card fixo com sombra, por ser o elemento em destaque
   da pagina (design system: shadow-menu so em flutuante e no login). */
.login-card {
  width: var(--login-max);
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-8);
  box-shadow: var(--shadow-menu);
}

/* Espaco reservado para a marca da empresa. O logotipo da JCB e marca de
   terceiros e nao e distribuido com o software - ver README. */
.logo-slot {
  width: 180px;
  height: 56px;
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--text-faint);
  font-size: 12px;
}


/* Logotipo JCB (jcb-logo.svg, campo amarelo + placa). Altura fixa e largura
   pelo aspecto 2,56:1 — a marca nao pode ser recolorida nem distorcida. 48px no
   login, 36px na navbar, nunca abaixo de 32px. */
.brand-logo {
  height: 48px;
  width: auto;
  display: block;
  margin: 0 auto 24px;
}
.login-brand { text-align: center; margin-bottom: var(--space-6); }
.login-brand .tagline { color: var(--text-muted); margin-top: var(--space-2); }
.login-links { text-align: center; margin-top: var(--space-4); }

.login-footer {
  position: absolute;
  bottom: 24px;
  font-size: 12px;
  color: var(--text-faint);
}

/* ---------- Formularios ---------- */

.field { margin-bottom: 16px; }
.field:last-of-type { margin-bottom: 24px; }

/* label 14/20 medium em text-muted; campo com borda border-control e foco no
   anel amarelo. */
.label {
  display: block;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  margin-bottom: var(--space-2);
  color: var(--text-muted);
}

.input, .textarea, .select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-control);
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 20px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
}

.input::placeholder, .textarea::placeholder { color: var(--text-muted); }
.input.is-upper:not(:placeholder-shown) { text-transform: uppercase; }
.textarea { resize: vertical; }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--focus-ring); box-shadow: 0 0 0 2px var(--focus-ring); }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.field-compact { margin-bottom: var(--space-4); }

/* Formulario sozinho na pagina (trocar senha, icone e acesso). */
.form-narrow { max-width: 560px; }

/* ---------- Botoes ---------- */

/* Button do design system: primario amarelo com texto preto; secundario com
   borda; terciario so texto; perigo em danger-text. Nunca botao preto. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s;
}

.btn-block { width: 100%; padding: 13px; }
.btn-primary { background: var(--action); color: var(--on-action); font-weight: 600; }
.btn-primary:hover { background: var(--action-hover); color: var(--on-action); }
.btn-secondary { background: var(--surface); border-color: var(--border-control); color: var(--text-muted); }
.btn-secondary:hover { background: var(--gray-100); color: var(--text-muted); }
.btn-danger { background: var(--surface); color: var(--danger-text); }
.btn-danger:hover { background: var(--red-50); color: var(--danger-text); }
.btn-sm { padding: var(--space-1) var(--space-3); }
.btn[aria-disabled="true"] { opacity: .5; cursor: default; pointer-events: none; }
/* Decisao na fila: as duas acoes da tela, na paleta de feedback (verde e
   vermelho 700 com texto branco, contraste acima de 4,5:1). */
.btn-approve { background: var(--green-700); color: var(--white); font-weight: 600; }
.btn-approve:hover { background: var(--green-800); color: var(--white); }
.btn-reject { background: var(--red-700); color: var(--white); font-weight: 600; }
.btn-reject:hover { background: var(--red-800); color: var(--white); }

.btn-icon { display: inline-flex; align-items: center; gap: var(--space-2); white-space: nowrap; }

/* Botao terciario: texto com seta, sem fundo ("Ver historico completo"). */
.btn-tertiary { display: inline-flex; align-items: center; gap: var(--space-1); color: var(--text-muted); font-weight: 500; }
.btn-tertiary:hover { color: var(--jcb-yellow-dark); }

/* Desabilitado = opacidade reduzida, mantendo a cor do botao (design system):
   trocar o fundo deixava "Rejeitar" com texto branco sobre vermelho claro. */
.btn[disabled], .btn:disabled { cursor: not-allowed; opacity: .5; }

/* Link de acao em linha de tabela ou card: o terciario do design system. */
.btn-link {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
}

.btn-link:hover { color: var(--jcb-yellow-dark); }
.btn-link.is-danger { color: var(--danger-text); }

/* ---------- Layout da aplicacao ---------- */

/* Navbar (componente Navbar do design system): barra preta fixa, logo + sigla,
   item ativo em action, menu do usuario no avatar. */
.header {
  background: var(--surface-inverse);
  color: var(--text-on-inverse);
  border-bottom: 1px solid rgba(252, 175, 38, 0.3); /* jcb-yellow a 30% */
  position: sticky;
  top: 0;
  z-index: 3;
}

.header-inner { height: var(--navbar-height); display: flex; align-items: center; gap: var(--space-6); }

.header-brand { display: flex; align-items: center; gap: var(--space-3); margin-right: auto; flex-shrink: 0; }
.header-logo { display: block; height: var(--logo-nav-height); width: auto; }
/* Nome por extenso ao lado da sigla, so onde cabe junto dos itens (1280px+). */
.product-name { display: none; font-size: 12px; line-height: 16px; color: var(--text-on-inverse-muted); white-space: nowrap; }
@media (min-width: 1280px) { .product-name { display: inline; } }

.product-tag {
  display: inline-block;
  background: var(--action);
  color: var(--on-action);
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.header-nav { display: flex; align-items: center; gap: var(--space-1); }

.header-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-on-inverse);
  font-weight: 500;
  white-space: nowrap;
  transition: background-color .15s, color .15s;
}

.header-nav a:hover { background: var(--gray-800); color: var(--text-on-inverse); }
.header-nav a[aria-current="page"] { background: var(--action); color: var(--on-action); }
.header-nav a[aria-current="page"]:hover { background: var(--action-hover); }

.nav-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  background: var(--action);
  color: var(--on-action);
  font-size: 12px;
  line-height: 20px;
  font-weight: 700;
  text-align: center;
}

.header-nav a[aria-current="page"] .nav-count { background: var(--on-action); color: var(--action); }

.header-sep { width: 1px; height: 24px; background: var(--gray-800); }

/* Menu do usuario: <details> nativo, sem JavaScript. */
.user-menu { position: relative; }
.user-menu summary { list-style: none; }
.user-menu summary::-webkit-details-marker { display: none; }

.user-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.user-toggle:hover { background: var(--gray-800); }

.avatar {
  width: var(--avatar-size);
  height: var(--avatar-size);
  border-radius: var(--radius-full);
  background: var(--action);
  color: var(--on-action);
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.user-name { line-height: 16px; white-space: nowrap; }
.user-name b { display: block; font-weight: 500; font-size: 14px; line-height: 20px; }
.user-name span { font-size: 12px; color: var(--text-on-inverse-muted); }
.user-chevron { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; }

.user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + var(--space-2));
  width: var(--menu-width);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-menu);
  padding: var(--space-1) 0;
  color: var(--text);
}

.user-dropdown-head { padding: var(--space-2) var(--space-4); font-size: 12px; line-height: 16px; color: var(--text-muted); }
.user-dropdown hr { border: 0; border-top: 1px solid var(--divider); margin: var(--space-1) 0; }
.user-dropdown form { margin: 0; }

.user-dropdown a, .user-dropdown button {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-4);
  color: var(--text);
  background: none;
  border: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.user-dropdown a:hover, .user-dropdown button:hover { background: var(--surface-hover); }
.user-dropdown .is-danger { color: var(--danger-text); }

/* Header de pagina (componente PageHeader): preto, titulo + contexto + acao. */
.page-header { background: var(--surface-inverse); color: var(--text-on-inverse); }
.page-header .wrap { padding-top: var(--space-4); padding-bottom: var(--space-4); display: flex; align-items: center; gap: var(--space-4); }
.page-header-text { margin-right: auto; }
.page-title { font-size: 24px; line-height: 32px; font-weight: 700; margin: 0; }
.page-subtitle { margin: 2px 0 0; color: var(--text-on-inverse-muted); }
/* Breadcrumb acima do titulo: itens sao links, o ultimo e o titulo em texto. */
.breadcrumb ol { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0 0 var(--space-1); padding: 0; list-style: none; font-size: 12px; line-height: 16px; color: var(--text-on-inverse-muted); }
.breadcrumb li + li::before { content: "/"; margin-right: var(--space-2); }
.breadcrumb a { color: var(--gray-200); }
.breadcrumb a:hover { color: var(--action); }
.breadcrumb [aria-current] { color: var(--text-on-inverse); }

.page { padding-top: var(--space-8); padding-bottom: var(--space-12); }

/* ---------- Cartoes e tabelas ---------- */

/* Card de conteudo: space-6, borda, sem sombra. */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--space-6);
}

.card-flush { padding: 0; overflow: hidden; }
.card-form { padding: var(--space-6); }

/* card-title 16/24 semibold: titulo de card nunca maior que isso. */
.card-title {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--divider);
  font-size: 16px;
  line-height: 24px;
  font-weight: 600;
}

.table-scroll { overflow-x: auto; }

table.data { width: 100%; border-collapse: collapse; }

/* DataTable: cabecalho claro (gray-100) fixo ao rolar, caixa de frase; numero tabular. */
table.data th {
  position: sticky;
  top: 0;
  background: var(--gray-100);
  color: var(--text);
  border-bottom: 1px solid var(--divider);
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-weight: 600;
  white-space: nowrap;
}

table.data td {
  padding: var(--space-3) var(--space-4);
  white-space: nowrap;
  border-bottom: 1px solid var(--divider);
  vertical-align: middle;
}

table.data tbody tr:hover { background: var(--surface-hover); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td.wrap { white-space: normal; }
table.data td.muted { color: var(--text-muted); }
table.data td.strong { font-weight: 600; }
table.data td.ref { font-weight: 600; }
table.data td.ref a { color: var(--text); }
table.data td.action { text-align: right; }
table.data .num-col { text-align: right; }
/* Status com etapa em coluna estreita: o badge quebra linha em vez de rolar. */
table.data td.wrap .badge { white-space: normal; border-radius: var(--radius-md); text-align: left; }
table.data .center { text-align: center; }
.num { font-variant-numeric: tabular-nums; }

.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--gray-50);
  border-top: 1px solid var(--divider);
  color: var(--text-muted);
}

/* EmptyState: diz por que esta vazio e o que fazer. */
.empty-state {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--space-12);
  text-align: center;
  color: var(--text-muted);
}

.empty-state.is-flush { border: 0; border-radius: 0; }

/* ---------- Painel ---------- */

.page-section { margin-top: var(--space-8); }
.section-heading { font-size: 20px; line-height: 28px; font-weight: 600; margin: 0 0 var(--space-4); }

/* MetricCard: rotulo em caixa alta (unico lugar permitido), valor tabular,
   cor so quando pede acao. */
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }

.metric-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  color: var(--text);
}

.metric-card.is-link:hover { background: var(--surface-hover); color: var(--text); }
.metric-label { font-size: 12px; line-height: 16px; font-weight: 500; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); }
.metric-value { font-size: 24px; line-height: 32px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: var(--space-1); }
.metric-value.is-warn { color: var(--metric-warn); }
.metric-value.is-empty { color: var(--jcb-gray-light); }
.metric-context { font-size: 12px; line-height: 16px; color: var(--text-muted); margin-top: var(--space-1); }

/* AreaCard: o card inteiro e o link; um unico estilo, sem cor por tipo. */
.area-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }

.area-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  color: var(--text);
  transition: border-color .15s;
}

.area-card:hover { border-color: var(--action); color: var(--text); }
.area-card:hover .area-card-go { color: var(--jcb-yellow-dark); }

.area-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--gray-100);
  color: var(--text-muted);
  display: grid;
  place-items: center;
  margin-bottom: var(--space-2);
}

.area-card-title { margin: 0; font-size: 16px; line-height: 24px; font-weight: 600; }
.area-card-description { margin: 0; color: var(--text-muted); flex: 1; }
.area-card-go { display: flex; align-items: center; gap: var(--space-1); color: var(--text-muted); font-weight: 500; margin-top: var(--space-2); transition: color .15s; }

/* Icones Heroicons outline. */
.ui-icon { flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Importação de notas de crédito ---------- */

.import-card { margin-bottom: var(--space-6); }
.import-form { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.import-hint { font-size: 12px; line-height: 16px; color: var(--text-muted); margin: var(--space-3) 0 0; }
.metrics.is-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.import-section { margin-top: var(--space-6); }

/* Icone do tipo de fluxo na lista da administracao: cinza, como no AreaCard. */
.flow-type-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--gray-100);
  color: var(--text-muted);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

/* ---------- Badges ---------- */

/* StatusBadge: par fundo 100 / texto 800 da mesma familia, com icone. */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-warn    { background: var(--amber-100); color: var(--amber-800); }
.badge-success { background: var(--green-100); color: var(--green-800); }
.badge-error   { background: var(--red-100);   color: var(--red-800); }
.badge-neutral { background: var(--gray-100);  color: var(--gray-700); }

/* Papel e etiqueta neutra: sem cor por categoria. */
.badge-role { margin-right: var(--space-1); }

/* ---------- Novo pedido ---------- */

.request-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: start;
}

/* Titulo de secao dentro de card ou formulario (card-title 16/24). */
.section-title { font-size: 16px; line-height: 24px; font-weight: 600; margin-bottom: var(--space-4); }

.flow-type-list { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-6); }

/* Selecionado: contorno action, sem trocar o fundo (design system). */
.flow-type-option {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  flex-wrap: wrap;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
}

.flow-type-option .name { font-weight: 600; }
.flow-type-option .description { font-size: 12px; line-height: 16px; color: var(--text-muted); }
.flow-type-option input { position: absolute; opacity: 0; pointer-events: none; }
.flow-type-option:has(input:checked) { border-color: var(--action); box-shadow: 0 0 0 1px var(--action); }
.flow-type-option:has(input:focus-visible) { box-shadow: 0 0 0 2px var(--focus-ring); }

/* Stepper: etapas do tipo de fluxo; feita em verde, atual em amarelo. */
.steps-panel .step { display: flex; gap: var(--space-3); margin-bottom: var(--space-4); }

.steps-panel .step .order {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--gray-100);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.steps-panel .step.is-done .order { background: var(--green-100); border-color: var(--green-100); color: var(--green-800); }
.steps-panel .step.is-current .order { background: var(--action); border-color: var(--action); color: var(--on-action); }
.steps-panel .step.is-rejected .order { background: var(--red-100); border-color: var(--red-100); color: var(--red-800); }
.steps-panel .step .name { font-weight: 500; padding-top: 2px; }
.steps-panel .step .name small { display: block; font-weight: 400; color: var(--text-muted); font-size: 12px; line-height: 16px; margin-top: 2px; }
.steps-panel .hint { font-size: 12px; line-height: 16px; color: var(--text-muted); margin-top: var(--space-2); }

.attachment-hint { font-size: 12px; line-height: 16px; color: var(--text-muted); margin-top: var(--space-2); }

/* ---------- Adiantamento de Viagem ---------- */

/* Blocos do formulário separados por divisória, dentro do mesmo card. */
.form-section + .form-section { border-top: 1px solid var(--divider); padding-top: var(--space-6); margin-top: var(--space-2); }

/* Campo que vem do cadastro ou do cálculo: lido, não digitado. */
.input[readonly] { background: var(--gray-50); color: var(--text); font-variant-numeric: tabular-nums; }

.field-error, .hint.field-error { font-size: 12px; line-height: 16px; color: var(--red-800); margin-top: var(--space-2); }

/* Campo com botão ao lado (Cotação + Buscar câmbio). */
.field-inline { display: flex; gap: var(--space-2); align-items: stretch; }
.field-inline .input { flex: 1; min-width: 0; }

/* Alerta dentro do formulário (confirmação do gestor, moeda sem PTAX). */
.alert-inline { margin: 0 0 var(--space-4); }
.alert-inline p { margin: 0; }
.alert-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-top: var(--space-3); }

/* Combobox com busca: a lista flutua sob o campo (sombra de flutuante). */
.combobox { position: relative; }
.combobox-list {
  position: absolute;
  top: calc(100% + var(--space-1));
  left: 0;
  right: 0;
  z-index: 10;
  margin: 0;
  padding: var(--space-1) 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-menu);
  max-height: 280px;
  overflow-y: auto;
}
.combobox-option { padding: var(--space-2) var(--space-4); cursor: pointer; }
.combobox-option small { display: block; font-size: 12px; line-height: 16px; color: var(--text-muted); }
.combobox-option:hover, .combobox-option[aria-selected="true"] { background: var(--surface-hover); }
.combobox-empty { padding: var(--space-2) var(--space-4); font-size: 14px; line-height: 20px; color: var(--text-muted); }

/* ---------- Fila de aprovacao ---------- */

.queue-card { margin-bottom: var(--space-4); }

.queue-card .title { display: flex; justify-content: space-between; gap: var(--space-3); font-size: 16px; line-height: 24px; font-weight: 600; }
.queue-card .amount { white-space: nowrap; font-variant-numeric: tabular-nums; }
.queue-card .subtitle { color: var(--text-muted); margin-top: var(--space-1); }
.queue-card .reference { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.queue-decision { margin-top: var(--space-4); }
/* "Ver e decidir" so existe na lista do celular (abaixo de 768px). */
.queue-open { display: none; }

/* DecisionPanel: o mesmo formulario na fila e na pagina do pedido. */
.decision .textarea { margin-bottom: var(--space-3); }
.decision-actions { display: flex; gap: var(--space-2); }
.decision-panel { margin-top: var(--space-6); }
.decision-title { margin: 0; font-size: 16px; line-height: 24px; font-weight: 600; }
.decision-step { margin: var(--space-1) 0 var(--space-4); font-size: 12px; line-height: 16px; color: var(--text-muted); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ---------- Administracao ---------- */

/* Tabs: sublinhado action no ativo, cada aba com URL propria. */
.tabs {
  display: flex;
  flex-wrap: wrap;
  column-gap: var(--space-6);
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--divider);
}

.tabs a {
  display: block;
  padding: var(--space-3) 0;
  margin-bottom: -1px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}

.tabs a:hover { color: var(--text); }
.tabs a.is-active { color: var(--text); font-weight: 600; border-bottom-color: var(--action); }

.toolbar { display: flex; justify-content: flex-end; gap: var(--space-2); margin-bottom: var(--space-4); }
.users-form { margin-bottom: var(--space-6); }

/* FilterBar: filtro dentro de card, label acima do campo. */
.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: var(--space-4);
  flex-wrap: wrap;
  padding: var(--space-4);
  margin: var(--space-6) 0 var(--space-4);
}

.filter-field { display: flex; flex-direction: column; gap: var(--space-2); }
.filter-field .label { margin: 0; }
.filter-field .input { width: 320px; max-width: 100%; }
.filter-check { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) 0; color: var(--text-muted); font-weight: 500; cursor: pointer; }
.filter-check input { width: 16px; height: 16px; accent-color: var(--jcb-yellow); }
.filter-actions { display: flex; gap: var(--space-2); }

.dealer-form { max-width: var(--form-max); }
.dealer-form .section-title { margin-top: 8px; }
.dealer-grid-inner { gap: 12px; }
.form-actions { display: flex; gap: var(--space-2); margin-top: var(--space-2); }

/* Linha de tabela: segunda linha em caption; inativo esmaecido. */
.cell-sub { display: block; color: var(--text-muted); font-size: 12px; line-height: 16px; }
.dash { color: var(--text-muted); }
table.data tr.is-inactive td { opacity: .55; }
.row-actions { display: flex; justify-content: center; align-items: center; gap: var(--space-1); }
.row-actions form { margin: 0; }

.checkbox-row { display: flex; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-4); }

.checkbox-row label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

.checkbox-row input { width: 16px; height: 16px; accent-color: var(--jcb-yellow); }

.flow-type-card { margin-bottom: var(--space-4); }
.flow-type-card .name { font-size: 16px; line-height: 24px; font-weight: 600; display: flex; align-items: center; gap: var(--space-3); }
.flow-type-card .description { color: var(--text-muted); margin-top: var(--space-1); margin-bottom: var(--space-4); }
.flow-type-card .chips { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.flow-type-card .actions { margin-top: var(--space-4); }

.hint { font-size: 12px; line-height: 16px; color: var(--text-muted); margin-top: var(--space-2); }

.icon-picker { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.icon-option input { position: absolute; opacity: 0; width: 0; height: 0; }

.icon-swatch {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
}

.icon-option input:checked + .icon-swatch {
  border-color: var(--action);
  box-shadow: 0 0 0 1px var(--action);
  color: var(--text);
}

.icon-option input:focus-visible + .icon-swatch { box-shadow: 0 0 0 2px var(--focus-ring); }

.chip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--gray-100);
  border-radius: var(--radius-full);
  padding: var(--space-1) var(--space-3);
  font-weight: 500;
}

.chip .order {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Detalhe da solicitacao ---------- */

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: start;
}

.detail-main { min-width: 0; }

.request-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: var(--space-4); margin-bottom: var(--space-6); }
.request-head .section-title { margin-bottom: var(--space-1); }
.request-meta { font-size: 12px; line-height: 16px; color: var(--text-muted); }

.detail-list { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); margin: 0; }
.detail-list dt { color: var(--text-muted); font-weight: 500; }
.detail-list dd { margin: var(--space-1) 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.detail-list .full { grid-column: 1 / -1; }
.detail-list .full dd { font-weight: 400; }

/* ---------- Mensagens ---------- */

/* Alert: retorno de acao abaixo do header, par fundo 100 / texto 800. */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-6);
}

.alert .ui-icon { margin-top: 0; }
.alert ul { margin: 0; padding-left: var(--space-4); }
.alert-success { background: var(--green-100); color: var(--green-800); }
.alert-error   { background: var(--red-100);   color: var(--red-800); }
.alert-warn    { background: var(--amber-100); color: var(--amber-800); }
.alert-info    { background: var(--blue-100);  color: var(--blue-800); }

.bare-flash { position: absolute; top: var(--space-6); left: 0; right: 0; width: var(--login-max); max-width: calc(100% - 2 * var(--space-4)); margin: 0 auto; z-index: 1; }

/* ---------- Responsivo ---------- */

@media (max-width: 1080px) {
  .request-layout, .detail-layout { grid-template-columns: minmax(0, 1fr); }
}

/* Abaixo de 1024px a navegacao desce para uma segunda linha da navbar;
   metricas e cards de area vao de 4 para 2 colunas (1 abaixo de 640px). */
@media (max-width: 1023px) {
  .metrics, .area-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .header-inner { height: auto; flex-wrap: wrap; padding-top: var(--space-3); padding-bottom: var(--space-3); row-gap: var(--space-2); }
  /* Uma linha so de itens; se nao couber, rola na horizontal em vez de
     quebrar em tres linhas (celular). */
  .header-nav { order: 3; width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .header-nav::-webkit-scrollbar { display: none; }
  .header-nav a { flex-shrink: 0; }
  .header-sep { display: none; }
}

@media (max-width: 639px) {
  .metrics, .metrics.is-three, .area-grid { grid-template-columns: minmax(0, 1fr); }
  .page-header .wrap { flex-wrap: wrap; }
  .field-inline { flex-direction: column; }
}

@media (max-width: 767px) {
  .user-name { display: none; }
  .wrap { padding-left: var(--space-4); padding-right: var(--space-4); }
  .form-grid, .detail-list { grid-template-columns: minmax(0, 1fr); }

  /* Aprovacao no celular: a fila vira lista e a decisao fica na pagina do
     pedido; alvo de toque com 44px e campo a 16px (o iOS da zoom abaixo). */
  .queue-card { padding: var(--space-4); margin-bottom: var(--space-3); }
  .queue-decision { display: none; }
  .queue-open { display: flex; width: 100%; min-height: 44px; margin-top: var(--space-3); }
  .decision-actions { flex-direction: column; }
  .decision-actions .btn { width: 100%; min-height: 44px; }
  .input, .textarea, .select { font-size: 16px; line-height: 24px; }
}

/* ---------- Meu perfil ---------- */

.profile { max-width: var(--form-max); display: flex; flex-direction: column; gap: var(--space-6); }
.profile-title { margin: 0; font-size: 16px; line-height: 24px; font-weight: 600; }
.profile-title + .detail-list { margin-top: var(--space-4); }
.profile-hint { margin: var(--space-1) 0 var(--space-4); font-size: 12px; line-height: 16px; color: var(--text-muted); }
.profile-badges { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.profile-password { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.profile-password .profile-hint { margin-bottom: 0; }

/* ---------- Nota de credito: wizard "Nova emissao" ---------- */

/* Stepper em barra no cabecalho preto (proposta de 28/09/2026). Barra de 4px
   continua acima de cada passo: action ate o passo atual, gray-800 nos
   pendentes, red-500 no erro. Estados: done | current | pending | error |
   partial. Concluido e link sem sublinhado. */
.page-header .wrap.page-header-extra { display: block; padding-top: 0; padding-bottom: var(--space-6); }
.stepper { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.stepper-step { display: flex; flex-direction: column; gap: var(--space-3); }
.stepper-step::before { content: ""; height: 4px; border-radius: var(--radius-full); background: var(--gray-800); }
.stepper-step.is-done::before, .stepper-step.is-current::before, .stepper-step.is-partial::before { background: var(--action); }
.stepper-step.is-error::before { background: var(--red-500); }
.stepper-link { display: flex; align-items: center; gap: var(--space-3); color: var(--text-on-inverse); text-decoration: none; }
a.stepper-link:hover .stepper-label { color: var(--action); }
.stepper-dot { flex: none; width: 28px; height: 28px; border-radius: var(--radius-full); display: grid; place-items: center; font-size: 14px; font-weight: 700; border: 1.5px solid var(--gray-500); color: var(--text-on-inverse-muted); }
.stepper-step.is-done .stepper-dot, .stepper-step.is-partial .stepper-dot { background: var(--action); border-color: var(--action); color: var(--on-action); }
.stepper-step.is-current .stepper-dot { background: var(--white); border-color: var(--white); color: var(--on-action); box-shadow: 0 0 0 3px var(--action); }
.stepper-step.is-error .stepper-dot { background: var(--red-700); border-color: var(--red-700); color: var(--white); }
.stepper-text { display: flex; flex-direction: column; min-width: 0; }
.stepper-label { font-size: 14px; line-height: 20px; font-weight: 600; transition: color .15s; }
.stepper-step.is-current .stepper-label { font-weight: 700; }
.stepper-step.is-pending .stepper-label { color: var(--text-on-inverse-muted); }
.stepper-summary { font-size: 12px; line-height: 16px; color: var(--text-on-inverse-muted); }
.stepper-step.is-current .stepper-summary { color: var(--action); }
.stepper-step.is-error .stepper-summary { color: var(--red-100); }

/* Barra de acoes fixa no rodape do wizard: voltar/cancelar, resumo ou motivo,
   continuar. Continuar desabilitado sempre vem com o motivo ao lado. */
.action-bar { position: sticky; bottom: 0; z-index: 2; margin: var(--space-8) calc(-1 * var(--space-6)) 0; background: var(--surface-inverse); color: var(--text-on-inverse); border-top: 1px solid var(--gray-800); }
.action-bar-inner { display: flex; align-items: center; gap: var(--space-4); padding-top: var(--space-3); padding-bottom: var(--space-3); flex-wrap: wrap; }
.action-bar-summary { margin-left: auto; font-size: 14px; line-height: 20px; }
.action-bar-reason { color: var(--text-on-inverse-muted); font-size: 12px; line-height: 16px; }
.action-bar .btn[disabled] { background: var(--gray-800); color: var(--text-on-inverse-muted); opacity: 1; }

/* Passo 1: resultado */
.result-alert { align-items: center; flex-wrap: wrap; }
.result-alert-text { display: flex; flex-direction: column; gap: var(--space-1); flex: 1; min-width: 260px; }
.result-alert-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.result-summary { display: flex; align-items: center; gap: var(--space-6); flex-wrap: wrap; margin-bottom: var(--space-6); }
.result-counts { display: flex; gap: var(--space-8); margin: 0; }
.result-counts dt { font-size: 12px; line-height: 16px; color: var(--text-muted); }
.result-counts dd { margin: 0; font-size: 20px; line-height: 28px; font-weight: 700; }
.result-counts .is-rejected dd, .result-counts .is-rejected dt { color: var(--metric-alert); }
progress.result-bar, progress.reason-bar { appearance: none; -webkit-appearance: none; border: 0; height: 8px; border-radius: var(--radius-full); background: var(--red-100); overflow: hidden; }
progress.result-bar { flex: 1; min-width: 160px; }
progress.result-bar::-webkit-progress-bar { background: var(--red-100); }
progress.result-bar::-webkit-progress-value { background: var(--green-700); }
progress.result-bar::-moz-progress-bar { background: var(--green-700); }
progress.result-bar.is-done { background: var(--green-100); }
.reason-list { list-style: none; margin: 0; padding: 0; }
.reason { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 2fr) 96px; gap: var(--space-4); align-items: center; padding: var(--space-3) var(--space-6); border-bottom: 1px solid var(--divider); }
.reason-label { font-weight: 600; }
progress.reason-bar { width: 100%; height: 6px; background: var(--gray-100); }
progress.reason-bar::-webkit-progress-bar { background: var(--gray-100); }
progress.reason-bar::-webkit-progress-value { background: var(--red-500); }
progress.reason-bar::-moz-progress-bar { background: var(--red-500); }
.reason-count { text-align: right; color: var(--text-muted); }
.rejection-details summary { padding: var(--space-3) var(--space-6); font-weight: 600; cursor: pointer; }
.card-title-inline { margin: 0; font-size: 16px; line-height: 24px; font-weight: 600; }

/* Passo 2: selecao */
.filter-count { margin-left: auto; align-self: center; color: var(--text-muted); }
.selection-rule { margin: 0 0 var(--space-3); font-size: 12px; line-height: 16px; color: var(--text-muted); }
.data th.check, .data td.check { width: 44px; text-align: center; }
.data td.check input, .data th.check input { width: 18px; height: 18px; accent-color: var(--action); }
.data .right { text-align: right; }
.selectable-line.is-blocked td { color: var(--text-muted); background: var(--gray-50); }
.line-block-reason { color: var(--text-muted); }

/* Hub */
.page-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.metric-context.is-alert { color: var(--metric-alert); font-weight: 500; }
.hub-notice { align-items: center; flex-wrap: wrap; }
.hub-notice-text { flex: 1; min-width: 260px; }
.hub-notice-actions { display: flex; gap: var(--space-2); }
.hub-notice { margin-top: var(--space-6); }
.hub-lists { margin-top: var(--space-6); display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: var(--space-4); }
.list-head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-4) var(--space-6); border-bottom: 1px solid var(--divider); }
.recent-list { list-style: none; margin: 0; padding: 0; }
.recent-list li { display: grid; gap: var(--space-3); align-items: center; padding: var(--space-3) var(--space-6); border-bottom: 1px solid var(--divider); }
.recent-list li:last-child { border-bottom: 0; }
.recent-document { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.4fr) minmax(0, 1fr) auto; }
.recent-import { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; }
.recent-list .muted { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-list a.strong { color: var(--text); font-weight: 600; }

/* ---------- Nota de credito: espelho do documento ---------- */

/* Documento no layout do modelo da controladoria (igual ao PDF): faixa cinza
   com logo e emitente, destinatario, vencimento/data e tabela de cabecalho
   amarelo. */
.nc-document { background: var(--surface); border: 2px solid var(--black); max-width: 900px; margin: 0 auto; color: var(--text); }
.nc-header { display: flex; align-items: center; gap: var(--space-6); padding: var(--space-6); background: var(--gray-100); }
.nc-logo { display: block; height: 36px; width: auto; flex: none; }
.nc-issuer { display: flex; flex-direction: column; gap: var(--space-1); margin-right: auto; }
.nc-issuer strong { font-size: 20px; line-height: 28px; }
.nc-issuer span { font-size: 12px; line-height: 16px; }
.nc-title { text-align: right; display: flex; flex-direction: column; gap: var(--space-2); }
.nc-title strong { font-size: 20px; line-height: 28px; }
.nc-title .num { font-weight: 700; }
.nc-parties { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--space-4); padding: var(--space-6); }
.nc-recipient { background: var(--gray-100); border-radius: var(--radius-md); padding: var(--space-4); }
.nc-recipient h2 { margin: 0 0 var(--space-2); font-size: 14px; line-height: 20px; font-weight: 700; }
.nc-recipient p, .nc-dates p { margin: 0 0 var(--space-1); font-size: 12px; line-height: 16px; }
.nc-dates { border: 2px solid var(--border); border-radius: var(--radius-md); padding: var(--space-4); }
.nc-lines { width: calc(100% - 2 * var(--space-6)); margin: 0 var(--space-6) var(--space-6); border-collapse: collapse; font-size: 12px; line-height: 16px; }
.nc-lines th { background: var(--action); color: var(--on-action); font-weight: 700; text-align: center; padding: var(--space-2); border: 1px solid var(--border); }
.nc-lines td { padding: var(--space-2); border: 1px solid var(--border); }
.nc-lines .right { text-align: right; white-space: nowrap; }
.nc-total td { font-weight: 700; background: var(--gray-50); }


/* Permissoes da Nota de Credito */
.role-form { align-items: flex-end; }
.role-user { min-width: 320px; flex: 1; }
.role-choice { border: 0; margin: 0; padding: 0; display: flex; gap: var(--space-4); flex-wrap: wrap; }
.role-choice legend { padding: 0; }
.role-option { display: flex; gap: var(--space-2); align-items: flex-start; cursor: pointer; }
.role-option input { margin-top: 3px; accent-color: var(--action); }
.role-option small { display: block; font-size: 12px; line-height: 16px; color: var(--text-muted); }
.role-member { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; }
.role-member .row-actions { display: flex; gap: var(--space-2); }
.role-member .muted { white-space: normal; }
.role-member .row-actions form { margin: 0; }

/* Nota emitida: espelho + painel lateral (aprovação e registro). */
.document-status { margin-bottom: var(--space-6); }
.document-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--space-6); align-items: start; }
.document-layout .nc-document { max-width: none; margin: 0; }
.document-side { display: flex; flex-direction: column; gap: var(--space-4); }
.document-side .decision-panel { margin-top: 0; }
.document-side .decision-actions { flex-direction: column; }
.document-side .decision-actions .btn { width: 100%; }
.trail { list-style: none; margin: var(--space-3) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.trail li { display: flex; flex-direction: column; padding-left: var(--space-3); border-left: 2px solid var(--action); }
.trail li.is-pending { border-left-color: var(--gray-200); color: var(--text-muted); }
.trail li.is-rejected { border-left-color: var(--red-800); }
.decision-step.is-alert { color: var(--red-800); }
.trail-what { font-weight: 600; }
.trail-who { font-size: 12px; line-height: 16px; color: var(--text-muted); }
.metric-context.is-warn { color: var(--metric-warn); font-weight: 500; }
.wizard-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-6); }

@media (max-width: 1080px) {
  .document-layout { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 767px) {
  .stepper { grid-template-columns: minmax(0, 1fr); gap: var(--space-3); }
  .action-bar { margin-left: calc(-1 * var(--space-4)); margin-right: calc(-1 * var(--space-4)); }
  .action-bar-summary { margin-left: 0; width: 100%; order: -1; }
  .reason { grid-template-columns: minmax(0, 1fr) 80px; }
  .reason progress { display: none; }
  .hub-lists { grid-template-columns: minmax(0, 1fr); }
  .nc-header { flex-wrap: wrap; }
  .nc-title { text-align: left; }
  .nc-parties { grid-template-columns: minmax(0, 1fr); }
}

/* Faixa de QA (APP_ENVIRONMENT_LABEL): nunca aparece em produção. */
.env-banner { padding: var(--space-2) var(--space-4); background: var(--amber-100); color: var(--amber-800); font-size: 12px; line-height: 16px; text-align: center; }
