/* ============================================================
   PAGES · Estilos específicos de cada página
   ------------------------------------------------------------
   Este ficheiro está organizado pela ordem em que o
   utilizador encontra os ecrãs na app:
     1. Login
     2. Biblioteca (filtros, galeria, vista visual)
     3. Detalhe (PDF, atributos, revisões, aprovação)
     4. Q-DAS Export
     5. Operações / Motor de Upload
     6. Erro (página genérica, fora da shell da app)
   ============================================================ */


/* ============================================================
   1 · LOGIN · ecrã de entrada (split 50/50 com arte à esq.)
   ============================================================ */

.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
}

/* Lado esquerdo: arte com gradiente, grelha e blob */
.login-art {
  position: relative;
  background: radial-gradient(120% 100% at 0% 0%, #ffffff 0%, #e9edf2 60%);
  overflow: hidden;
  border-right: 1px solid var(--line-soft);
}
.login-art .grid-bg {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 32px 32px;
  opacity: .5;
  mask-image: radial-gradient(ellipse at 30% 50%, #000 30%, transparent 75%);
}
.login-art .blob {
  position: absolute;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft), transparent 60%);
  filter: blur(20px);
  top: 30%;
  left: -100px;
}
.login-art-content {
  position: relative;
  padding: 60px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.login-tagline h1 {
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -1.2px;
  line-height: 1.1;
  margin: 0 0 14px;
  background: linear-gradient(135deg, var(--text) 30%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.login-tagline p {
  font-size: 15px;
  color: var(--text-dim);
  max-width: 440px;
  line-height: 1.6;
  margin: 0;
}

.login-stats        { display: flex; gap: 30px; margin-top: 32px; }
.login-stats .stat strong { display: block; font-size: 24px; font-weight: 700; color: var(--text); }
.login-stats .stat span   { font-size: 12px; color: var(--text-mute); text-transform: uppercase; letter-spacing: .8px; }

.login-foot         { font-size: 11.5px; color: var(--text-mute); display: flex; justify-content: space-between; }

/* Lado direito: formulário centrado */
.login-form {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
}
.login-form .form-card     { width: 100%; max-width: 380px; }
.login-form h2             { font-size: 24px; font-weight: 700; margin: 0 0 6px; }
.login-form p.lead         { color: var(--text-dim); margin: 0 0 28px; }
.login-form .field         { margin-bottom: 14px; }
.login-form .btn           { width: 100%; justify-content: center; height: 42px; font-size: 14px; }

/* Separador "ou" entre form e SSO */
.login-form .or {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0;
  color: var(--text-mute);
  font-size: 11.5px;
}
.login-form .or::before,
.login-form .or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line-soft);
}
.login-sso { display: flex; flex-direction: column; gap: 8px; }


/* ============================================================
   2 · BIBLIOTECA · barra de meta, filtros, galeria, tabela
   ============================================================ */

/* Meta-bar acima dos filtros: contador + view-toggle + ações */
.biblioteca-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}
.biblioteca-bar .bb-meta            {
  font-size: 13px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
}
.biblioteca-bar .bb-meta strong     { font-size: 18px; color: var(--text); font-weight: 700; }
.biblioteca-bar .dot-sep            {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-mute);
}


/* ----- Linha compacta de filtros principais ----- */
.filter-row {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.filter-row .f-search                 { flex: 1; min-width: 240px; position: relative; }

/* Look base do input vem de components.css (INPUT BASE) */
.filter-row .f-search input {
  width: 100%;
  height: 34px;
  border-radius: 7px;
  padding: 0 12px 0 34px;
  font-size: 13px;
}
.filter-row .f-search .ico {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-mute);
}

/* Selects da filter-row · só dimensões e chevron (look base partilhado) */
.filter-row select {
  height: 34px;
  border-radius: 7px;
  padding: 0 28px 0 10px;
  font-size: 13px;
  min-width: 140px;
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  cursor: pointer;
}

.filter-row .sep {
  width: 1px;
  height: 22px;
  background: var(--line-soft);
  margin: 0 4px;
}

/* Botão de ação na filter-row (filtros avançados, procura visual...) */
.filter-row .adv-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 7px;
  font-size: 12.5px;
  cursor: pointer;
}
.filter-row .adv-btn:hover     { border-color: var(--accent); }
.filter-row .adv-btn .num {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 99px;
  font-weight: 700;
  font-family: var(--mono);
  min-width: 16px;
  text-align: center;
}
.filter-row .adv-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* Painel "legacy" de filtros (vertical, dentro de .modal-body) */
.filter-panel {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.filter-panel .field                  { gap: 4px; }
.filter-panel label                   { font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px; }
.filter-panel input,
.filter-panel select                  { height: 30px; font-size: 12px; }

.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 10px;
  flex-wrap: wrap;
}


/* ----- Galeria visual de cards ----- */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.g-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: .18s;
  display: flex;
  flex-direction: column;
  position: relative;
}
.g-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(15, 23, 42, .10), 0 0 0 1px var(--accent);
}
.g-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent), 0 8px 22px rgba(237, 28, 46, .15);
}

/* Thumbnail · imagem real OU placeholder esquemático */
.g-thumb {
  aspect-ratio: 1.1 / 1;
  background: #f4f4f4;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--line-soft);
}
.g-thumb img      { width: 100%; height: 100%; object-fit: contain; display: block; background: #fff; }
.g-thumb .ph {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(45deg, #fafafa 0, #fafafa 12px, #f0f0f0 12px, #f0f0f0 24px);
  color: #222;
  font-family: var(--mono);
  font-size: 11px;
  text-align: center;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
}
.g-thumb .ph svg  { max-width: 140px; max-height: 120px; }

/* Chips no topo do thumbnail (checkbox + badge IA) */
.g-thumb .top-chips {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
  pointer-events: none;
}
.g-thumb .top-chips > * { pointer-events: auto; }
.g-thumb .check {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: #fff;
  border: 1.5px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #555;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .12);
}
.g-thumb .check.on        { background: var(--accent); color: #fff; border-color: var(--accent); }
.g-thumb .qa-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fff;
  color: #222;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 99px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .12);
}
.g-thumb .qa-badge.ok     { background: var(--ok);   color: #fff; }
.g-thumb .qa-badge.warn   { background: var(--warn); color: #fff; }
.g-thumb .corner {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: #0009;
  color: #fff;
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 3px 7px;
  border-radius: 5px;
  backdrop-filter: blur(4px);
}

/* Corpo do card (atributos extraídos pela IA) */
.g-body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.g-body .g-title {
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}
.g-body .g-title .code {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--accent);
  font-weight: 600;
  background: var(--accent-soft);
  padding: 2px 6px;
  border-radius: 5px;
  flex-shrink: 0;
}
.g-body .g-sub      { font-size: 11.5px; color: var(--text-mute); font-family: var(--mono); }

.g-attrs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  font-size: 11.5px;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}
.g-attrs .k {
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: .4px;
  font-size: 10px;
  font-weight: 600;
}
.g-attrs .v         { color: var(--text); font-family: var(--mono); font-weight: 500; }

.g-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 9px 14px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
  font-size: 11px;
}
.g-foot .left       { display: flex; gap: 5px; align-items: center; }


/* ----- Procura Visual (modal + resultados ordenados por similaridade) ----- */
.visual-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 18px;
  align-items: flex-start;
}
.visual-input {
  position: sticky;
  top: 72px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.visual-drop {
  border: 2px dashed var(--line);
  border-radius: 12px;
  padding: 30px 16px;
  text-align: center;
  background: var(--surface);
  transition: .15s;
  cursor: pointer;
  min-height: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.visual-drop:hover,
.visual-drop.drag    { border-color: var(--accent); background: var(--accent-soft); }
.visual-drop.has-file{ border-style: solid; border-color: var(--accent); background: var(--surface); }

.visual-drop .uploaded-preview {
  width: 100%;
  height: 240px;
  background: #fff;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #222;
  font-family: var(--mono);
  font-size: 11px;
  margin-bottom: 12px;
}
.visual-drop .uploaded-preview .center-art {
  position: absolute;
  inset: 18% 22%;
  border: 2px solid #444;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 11px;
  color: #444;
  text-align: center;
}
.visual-drop .uploaded-preview .annot {
  position: absolute;
  border: 1px dashed var(--accent);
  background: var(--accent-soft);
  color: #222;
  font-family: var(--mono);
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 3px;
}

/* Lista de resultados visuais (com score à direita) */
.visual-results { display: flex; flex-direction: column; gap: 10px; }
.vr-card {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 14px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  transition: .12s;
  cursor: pointer;
  align-items: center;
}
.vr-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(15, 23, 42, .08);
}
.vr-thumb {
  width: 120px;
  height: 120px;
  background: #fff;
  border-radius: 6px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #222;
  font-family: var(--mono);
  font-size: 10px;
  text-align: center;
}
.vr-thumb .art        { position: absolute; inset: 18% 22%; border: 1.5px solid #444; border-radius: 50%; }
.vr-thumb .art.sq     { border-radius: 8px; }
.vr-thumb .art.bar    { border-radius: 0; inset: 35% 8%; border-radius: 4px; }

.vr-meta strong       { display: block; font-size: 14px; margin-bottom: 4px; }
.vr-meta .sub         { font-size: 12px; color: var(--text-mute); margin-bottom: 8px; }
.vr-tags              { display: flex; gap: 5px; flex-wrap: wrap; }

.vr-score             { text-align: right; }
.vr-score .pct        { font-size: 24px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; line-height: 1; }
.vr-score .lbl {
  font-size: 10.5px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: .7px;
  margin-top: 2px;
}
.vr-score .bars       { margin-top: 8px; display: flex; flex-direction: column; gap: 3px; width: 90px; }
.vr-bar               { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-mute); }
.vr-bar .b {
  width: 50px;
  height: 4px;
  background: var(--surface-3);
  border-radius: 99px;
  overflow: hidden;
  align-self: center;
}
.vr-bar .b > span     { display: block; height: 100%; background: var(--accent); }


/* ============================================================
   3 · DETALHE · linha 1 (confiança/reprocessar + PDF, 2 col),
                 linha 2 (os 4 separadores, largura total)
   ============================================================ */

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1.05fr;
  gap: 18px;
  align-items: flex-start;
}
.detail-left  { min-width: 0; }
.detail-right {
  position: sticky;
  top: 72px;
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 90px);
}
.detail-right .pdf-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Separadores (Atributos/Revisões/Q-DAS/Notas): fora da grelha acima, a toda a largura — a tabela
   de características em particular precisa do espaço que uma coluna a meia largura nunca lhe deu. */
.detail-tabs-row { margin-top: 18px; min-width: 0; }


/* ----- Painel do PDF (preview à direita) ----- */
.pdf-pane {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
}
.pdf-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface-2);
  font-size: 12px;
  color: var(--text-dim);
}

.pdf-canvas {
  flex: 1;
  min-height: 0;
  aspect-ratio: 1 / 1.25;
  background: #fff;
  position: relative;
  overflow: hidden;
}
.pdf-canvas.portrait  { aspect-ratio: 1 / 1.414;  max-height: calc(100vh - 130px); }
.pdf-canvas.landscape { aspect-ratio: 1.414 / 1;  max-height: calc(100vh - 130px); }
.pdf-canvas iframe,
.pdf-canvas embed     { width: 100%; height: 100%; border: 0; display: block; }

.pdf-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(45deg, #f5f5f5 0, #f5f5f5 10px, #ececec 10px, #ececec 20px);
  color: #333;
  text-align: center;
  padding: 30px;
  font-size: 12px;
  line-height: 1.6;
}
.pdf-fallback strong  { color: #111; font-size: 14px; margin-bottom: 6px; }
.pdf-fallback code {
  background: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--mono);
  color: var(--accent);
  border: 1px solid #ddd;
  margin-top: 8px;
}

/* Hotspots (pontos clicáveis sobrepostos ao PDF) */
.hotspots             { position: absolute; inset: 0; pointer-events: none; }
.hotspots .h {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--accent), 0 2px 6px rgba(15, 23, 42, .15);
  font-size: 9px;
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: pointer;
  animation: pulse 2s infinite;
}


/* ----- Atributos extraídos pela IA (matriz BLANK/FINAL) ----- */
.attr-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
}
.attr-cell      { background: var(--surface); padding: 11px 13px; }
.attr-key {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-mute);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.attr-val             { font-size: 14px; color: var(--text); font-family: var(--mono); font-weight: 500; }
.attr-val.muted       { color: var(--text-mute); font-style: italic; font-weight: 400; }

/* Etiqueta ISO (Q-DAS) ao lado do nome do atributo */
.iso-tag {
  font-size: 10px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 6px;
  font-family: var(--mono);
}

/* Matriz de atributos por secção (Geometria, Ângulos, etc.) */
.attr-sections        { display: flex; flex-direction: column; gap: 14px; }
.attr-section {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
}
.attr-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface-2);
  font-size: 13px;
}
.attr-section-head .ico { font-size: 14px; }

.attr-mat             { display: flex; flex-direction: column; }
.attr-mat-head,
.attr-mat-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 60px;
  gap: 10px;
  padding: 8px 14px;
  align-items: center;
}
/* Variante quando há colunas BLANK + FINAL */
.attr-mat.has-variants .attr-mat-head,
.attr-mat.has-variants .attr-mat-row {
  grid-template-columns: 1.4fr .9fr .9fr 60px;
}
.attr-mat-head {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-mute);
  background: var(--surface);
  border-bottom: 1px solid var(--line-soft);
  font-weight: 600;
}
.attr-mat-row                         { border-bottom: 1px solid var(--line-soft); transition: .12s; }
.attr-mat-row:last-child              { border-bottom: none; }
.attr-mat-row:hover                   { background: var(--surface-2); }
.attr-mat-row.is-empty                { opacity: .5; }
.attr-mat-row .k                      { font-size: 12.5px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.attr-mat-row .v                      { font-family: var(--mono); font-size: 12.5px; color: var(--text); font-weight: 500; }
.attr-mat-row .v.muted                { color: var(--text-mute); font-style: italic; font-weight: 400; }
.attr-mat-row .c                      { text-align: right; }

/* Estado em edição (override manual) */
.attr-mat-row.is-editing              { background: linear-gradient(90deg, var(--accent-soft) 0%, transparent 50%); }
.attr-mat-row.is-editing:hover        { background: linear-gradient(90deg, var(--accent-soft) 0%, var(--surface-2) 50%); }
/* Input de edição inline (look base em components.css → INPUT BASE) */
.attr-mat-row .v-edit {
  height: 28px;
  width: 100%;
  border-radius: 5px;
  padding: 0 8px;
  font-family: var(--mono);                    /* override do font-family */
  font-size: 12px;
  font-weight: 500;
}
.attr-mat-row .v-edit:focus {                 /* focus distinto: glow vermelho */
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--accent-soft);
}


/* ----- Trilho de revisões (timeline vertical) ----- */
.rev-trail            { display: flex; flex-direction: column; gap: 0; position: relative; }
.rev-row              {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  padding: 0 0 14px;
  position: relative;
}
.rev-row:last-child   { padding-bottom: 0; }

.rev-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  border: 2px solid var(--surface);
  position: relative;
  z-index: 2;
  background: var(--surface-3);
  color: var(--text-dim);
  grid-row: 1 / 3;
  align-self: start;
}
.rev-dot.info { background: var(--info-soft); color: var(--info); }
.rev-dot.ok   { background: var(--ok-soft);   color: var(--ok); }
.rev-dot.warn { background: var(--warn-soft); color: var(--warn); }

.rev-line {
  position: absolute;
  left: 16px;
  top: 34px;
  bottom: 0;
  width: 2px;
  background: var(--line-soft);
  z-index: 1;
}
.rev-row:last-child .rev-line { display: none; }
.rev-body                     { padding: 5px 0 8px; }


/* ----- Lista compacta de anotações (cotas extraídas) ----- */
.ann-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 10px;
}
.ann-row              { display: flex; align-items: center; gap: 8px; font-size: 11.5px; padding: 3px 0; }
.ann-num {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ann-lbl              { color: var(--text-dim); font-weight: 600; font-size: 11px; }
.ann-val              { color: var(--text); font-family: var(--mono); font-size: 11.5px; margin-left: auto; }


/* ----- Workflow de aprovação (cartão e estado) ----- */
.approval-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 14px;
}
.approval-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 13px;
}
.approval-actions         { display: flex; gap: 8px; }
.approval-actions button  { flex: 1; }

/* Textarea partilhada por approval-card e note-add
   (look base em components.css → INPUT BASE) */
.approval-comment,
.note-add textarea {
  width: 100%;
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 13px;
  resize: vertical;
  min-height: 60px;
}
.approval-comment         { margin-bottom: 10px; }

.approval-history         { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.approval-event {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 12px;
}


/* ----- Notas internas do utilizador ----- */
.notes-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 14px;
}
.note-add                 { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.notes-list               { display: flex; flex-direction: column; gap: 8px; }
.note-item {
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  font-size: 13px;
}
.note-meta                { font-size: 11px; color: var(--text-mute); margin-top: 4px; }


/* ============================================================
   4 · Q-DAS EXPORT · sumário + lista de K-fields
   ============================================================ */

/* Card de sumário (estatísticas + ações no topo) */
.qdas-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 16px;
  padding: 18px 20px;
  flex-wrap: wrap;
}
.qdas-stats               { display: flex; gap: 32px; flex-wrap: wrap; }
.qdas-stats > div         { display: flex; flex-direction: column; }
.qdas-stats strong        { font-size: 24px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.qdas-stats span {
  font-size: 11px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: .6px;
  font-weight: 600;
  margin-top: 4px;
}
.qdas-summary-actions     { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Cabeçalho com ações no detalhe Q-DAS */
.qdas-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 12.5px;
  color: var(--text-dim);
}
.qdas-actions strong      { color: var(--text); font-weight: 700; }

/* Lista vertical de blocos K-field (uma característica = um bloco) */
.qdas-list                { display: flex; flex-direction: column; gap: 12px; }
.qdas-block {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  overflow: hidden;
}
.qdas-block-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-soft);
  font-size: 13.5px;
}
.qdas-num {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--mono);
  display: flex;
  align-items: center;
  justify-content: center;
}

.qdas-rows                { display: flex; flex-direction: column; }
.qdas-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line-soft);
  align-items: center;
}
.qdas-row:last-child      { border-bottom: none; }
.qdas-row:hover           { background: var(--surface-2); }
.qdas-row .qk             { font-size: 11.5px; color: var(--text-dim); font-family: var(--mono); }
.qdas-row .qv             { font-size: 13px; color: var(--text); font-family: var(--mono); font-weight: 600; text-align: right; }


/* ============================================================
   5 · OPERAÇÕES (Motor de Upload) · status + upload + lista
   ============================================================ */

.ops-top {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 14px;
  align-items: stretch;
  margin-bottom: 14px;
}

/* Cartão de status do watcher (canto superior esquerdo) */
.ops-status {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  gap: 14px 24px;
  align-items: center;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  height: 100%;
}
.ops-status-watcher       { display: flex; align-items: center; gap: 10px; grid-row: 1; }
.ops-status-path          { grid-row: 2; grid-column: 1 / 3; }
.ops-status-stats         { display: flex; gap: 22px; flex-wrap: wrap; grid-row: 1; grid-column: 2; }
.ops-status-stats > div   { display: flex; flex-direction: column; }
.ops-status-stats strong  { font-size: 18px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.ops-status-stats span {
  font-size: 10.5px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: .7px;
  font-weight: 600;
  margin-top: 3px;
}
.ops-status-actions {
  display: flex;
  align-items: stretch;
  gap: 8px;
  grid-row: 1 / 3;
  grid-column: 3;
  flex-direction: column;
  justify-content: center;
  min-width: 170px;
  border-left: 1px solid var(--line-soft);
  padding-left: 14px;
}

/* Zona de upload (canto superior direito) */
.ops-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  padding: 24px 20px;
  background: var(--surface-2);
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: .15s;
  height: 100%;
}
.ops-upload:hover,
.ops-upload.drag      { border-color: var(--accent); background: var(--accent-soft); }
.ops-upload > svg     { width: 36px; height: 36px; }


/* Lista de ficheiros processados */
.ops-files-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface-2);
}
.ops-files-list           { display: flex; flex-direction: column; }

.ops-file {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-soft);
  transition: .12s;
}
.ops-file:last-child      { border-bottom: none; }
.ops-file.ok              { cursor: pointer; }
.ops-file.ok:hover        { background: var(--surface-2); }

.ops-file-thumb {
  width: 52px;
  height: 52px;
  border-radius: 6px;
  background: #fff;
  flex-shrink: 0;
  overflow: hidden;
  object-fit: contain;
  padding: 2px;
}
.ops-file-icon {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
}
.ops-file-icon.info       { background: var(--info-soft); color: var(--info); }
.ops-file-icon.err        { background: var(--err-soft);  color: var(--err); }

.ops-file-body            { flex: 1; min-width: 0; }
.ops-file-row1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
}
.ops-file-name            { font-family: var(--mono); font-size: 12.5px; color: var(--accent-2); font-weight: 500; }
.ops-file-row2            { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.ops-file-row2 strong     { font-weight: 600; }
.ops-file-row3            { display: flex; align-items: center; gap: 5px; font-size: 10.5px; margin-top: 5px; }


/* Cartão "watcher ativo" reutilizável (status compacto) */
.watcher {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.watcher .led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
  animation: pulse 1.6s infinite;
}
.watcher code {
  font-family: var(--mono);
  background: var(--surface-3);
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 12px;
  color: var(--accent-2);
}


/* ============================================================
   6 · ERRO · página de erro genérica (fora da shell da app —
   sem drawer, para funcionar mesmo quando a sessão/DB falhou)
   ============================================================ */

.error-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.error-card {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px 40px 32px;
  text-align: center;
}

.error-card .brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  border: none;
  padding: 0;
}
.error-card .brand-logo img { width: 28px; height: 28px; }
.error-card .brand-name { font-size: 13px; font-weight: 600; letter-spacing: .02em; }

.error-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--err-soft);
  color: var(--err);
}
.error-icon svg { width: 28px; height: 28px; stroke-width: 1.8; }

.error-code {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-mute);
  letter-spacing: .04em;
  margin-bottom: 6px;
}

.error-card h1 {
  font-size: 20px;
  margin: 0 0 10px;
  color: var(--text);
}

.error-card p.lead {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.6;
  margin: 0 0 28px;
}

.error-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
