/* ============================================================
   CNE — Código Eleitoral Digital — style.css
   Dark premium theme com estilos para leitura e editor Word-like
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,200..900;1,8..60,200..900&family=IBM+Plex+Sans:wght@300;400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200');

/* ── Variáveis ─────────────────────────────────────────────── */
:root {
  --bg-base: #080E1F;
  --bg-surface: #0F1A2E;
  --bg-elevated: #152035;
  --bg-border: #1E2E48;
  --bg-hover: #1A2840;

  --blue-600: #2563EB;
  --blue-500: #3B82F6;
  --blue-400: #60A5FA;
  --blue-glow: rgba(37, 99, 235, 0.35);

  --text-primary: #E8EDF5;
  --text-secondary: #8892A4;
  --text-muted: #4B5A70;

  --success: #10B981;
  --warning: #F59E0B;
  --error: #EF4444;

  --sidebar-w: 220px;
  --border-r: 4px;
  --transition: 0.15s ease;

  /* Doc viewer */
  --doc-bg: #FAFAF8;
  --doc-text: #1A1A1A;
  --doc-accent: #003087;
  --doc-border: #D4D4CC;
}

/* ── Reset ──────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  height: 100%;
}

body {
  font-family: 'IBM Plex Sans', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── APP SHELL ──────────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--bg-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--bg-border);
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  transition: all var(--transition);
}

.brand-logo:hover {
  opacity: 0.8;
}

.sidebar-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-logo-fallback {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, #003087, #2563EB);
  color: white;
  font-weight: 800;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-cne {
  font-family: 'Source Serif 4', serif;
  font-size: 1.1rem;
  color: #fff;
  font-weight: 700;
}

.brand-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  color: #fff;
}

/* Sidebar nav */
.sidebar-nav {
  padding: 12px 8px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  position: relative;
}

.nav-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-link.active {
  background: var(--blue-glow);
  color: var(--blue-400);
  border: 1px solid rgba(37, 99, 235, 0.4);
}

.nav-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
}

.nav-icon .material-symbols-rounded {
  font-size: 1.25rem;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.nav-link.active .nav-icon .material-symbols-rounded {
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.nav-label {
  flex: 1;
}

.nav-badge {
  font-size: 0.6rem;
  background: var(--blue-600);
  color: #fff;
  padding: 2px 6px;
  border-radius: 10px;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--bg-border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  overflow: hidden;
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: var(--blue-600);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.user-info {
  overflow: hidden;
}

.user-name {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.btn-logout {
  padding: 6px 8px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--bg-border);
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
  font-size: 0.875rem;
  transition: all var(--transition);
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #FCA5A5;
  border-color: rgba(239, 68, 68, 0.4);
}

/* ── Login Logo ─────────────────────────────────────────────── */
.login-logo {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 20px;
  height: 60px;
}

.login-logo-img {
  max-height: 140px;
  /* Um pouco maior para ser imponente mas controlado */
  max-width: 100%;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.3));
}

.login-header h1 {
  font-family: 'Source Serif 4', serif;
  font-size: 2rem;
  color: #F5C518;
  /* Amarelo premium da CNE */
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 10px;
  margin-bottom: 2px;
  letter-spacing: 0.05em;
}

.login-header p {
  color: var(--text-secondary);
  font-family: 'Source Serif 4', serif;
  font-size: 1.4rem;
  margin-bottom: 16px;
}

/* ── MAIN AREA ───────────────────────────────────────────────── */
.main-area {
  flex: 1;
  overflow-y: auto;
  min-width: 0;
}

/* ────────────────────────────────────────────────────────────── */
/*  DOCUMENTO — Leitura do Código Eleitoral                       */
/* ────────────────────────────────────────────────────────────── */
.doc-view {
  background: var(--doc-bg);
  min-height: 100vh;
  color: var(--doc-text);
}

/* Faixa de topo nas cores de Cabo Verde */
.cv-top-bar {
  height: 4px;
  background: linear-gradient(90deg,
      #003087 0%, #003087 33%,
      #fff 33%, #fff 37%,
      #ce1126 37%, #ce1126 50%,
      #003087 50%, #003087 67%,
      #fff 67%, #fff 71%,
      #003087 71%, #003087 100%);
}

.doc-header {
  text-align: center;
  padding: 36px 40px 28px;
  background: #fff;
  position: relative;
}

.doc-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 160px;
  background: radial-gradient(ellipse at 50% 0%, rgba(0, 48, 135, 0.04) 0%, transparent 70%);
  pointer-events: none;
}

.doc-emblem {
  margin-bottom: 16px;
  display: flex;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.doc-logo {
  height: 90px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0, 48, 135, 0.15));
}

.doc-institution {
  font-size: 0.78rem;
  color: #003087;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 10px;
  opacity: 0.85;
}

.doc-title {
  font-family: 'Source Serif 4', serif;
  font-size: 2.4rem;
  color: #0f172a;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 10px;
  letter-spacing: 0.04em;
  line-height: 1.1;
}

.doc-version {
  font-family: 'Source Serif 4', serif;
  font-size: 0.9rem;
  color: #64748b;
  font-style: italic;
  margin-bottom: 14px;
}

.doc-aviso {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fffbeb;
  border: 1px solid #fbbf24;
  border-left: 3px solid #f59e0b;
  color: #92400e;
  font-size: 0.78rem;
  padding: 7px 14px;
  border-radius: 6px;
  margin-top: 4px;
}

.doc-aviso .material-symbols-rounded {
  font-size: 1rem !important;
  color: #f59e0b;
  margin-right: 0 !important;
  vertical-align: unset !important;
}

/* Divisor suave abaixo do header */
.header-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, #e2e8f0 20%, #e2e8f0 80%, transparent);
  margin: 0 24px;
}

/* Secção da barra de pesquisa */
.doc-search-section {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 24px;
  background: #fff;
  border-bottom: 1px solid var(--doc-border);
}

.doc-search-section .doc-search-bar {
  max-width: 680px;
}

/* Barra de pesquisa — caixa interna */
.doc-search-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: #f8faff;
  border: 1.5px solid #dde3f0;
  border-radius: 10px;
  position: relative;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.doc-search-bar:focus-within {
  border-color: #003087;
  box-shadow: 0 0 0 3px rgba(0, 48, 135, 0.08);
}

.search-icon {
  font-size: 1.1rem;
  color: #94a3b8;
  flex-shrink: 0;
}

.doc-search-bar input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 0.88rem;
  font-family: 'IBM Plex Sans', sans-serif;
  background: transparent;
  color: var(--doc-text);
}

.search-kbd {
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

.search-kbd .kbd {
  display: inline-block;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.68rem;
  color: #64748b;
  line-height: 1.5;
  font-family: 'IBM Plex Sans', sans-serif;
}

.search-results-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--doc-border);
  border-top: none;
  max-height: 400px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
  border-radius: 0 0 8px 8px;
}

.search-result-item {
  padding: 14px 20px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.search-result-item:hover {
  background: #f8faff;
  padding-left: 24px;
}

.search-result-item.sri-theme {
  border-left: 4px solid var(--doc-accent);
}

.sri-type {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
  color: var(--doc-accent);
}

.sri-titulo {
  color: #7C3AED;
}

.sri-capitulo {
  color: #2563EB;
}

.sri-seccao {
  color: #059669;
}

.sri-subseccao {
  color: #64748b;
}

.sri-artigo {
  color: var(--doc-accent);
}

.search-result-item:has(.sri-titulo) {
  border-left-color: #7C3AED;
}

.search-result-item:has(.sri-capitulo) {
  border-left-color: #2563EB;
}

.search-result-item:has(.sri-seccao) {
  border-left-color: #059669;
}

.search-result-item:has(.sri-subseccao) {
  border-left-color: #64748b;
}

.sri-num {
  font-weight: 700;
  color: #1a1a1a;
  font-size: 0.9rem;
}

.sri-epigafe {
  font-style: italic;
  font-size: 0.85rem;
  color: #444;
  margin-top: 2px;
}

.sri-preview,
.sri-designacao {
  font-size: 0.82rem;
  color: #666;
  margin-top: 4px;
  line-height: 1.4;
}

.search-highlight {
  background: #fffde7;
  color: var(--doc-accent);
  font-weight: 700;
  padding: 0 2px;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 48, 135, 0.1);
}

/* Tabs de Partes */
.doc-parts-tabs {
  display: flex;
  justify-content: center;
  gap: 0;
  padding: 0 16px;
  background: var(--doc-accent);
  overflow-x: auto;
  scrollbar-width: none;
}

.doc-parts-tabs::-webkit-scrollbar {
  display: none;
}

.part-tab {
  padding: 11px 18px;
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  letter-spacing: 0.04em;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  text-transform: capitalize;
}

.part-tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.part-tab.active {
  color: #fff;
  border-bottom-color: #F5C518;
  background: rgba(255, 255, 255, 0.12);
}

.parts-tab-loading {
  color: rgba(255, 255, 255, 0.5);
  padding: 12px 24px;
  font-size: 0.85rem;
}

/* Conteúdo do documento */
.doc-content {
  max-width: 820px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.doc-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 80px 24px;
  color: #888;
}

/* Títulos dentro do documento */
.doc-parte-header {
  text-align: center;
  margin: 60px 0 32px;
  padding-bottom: 24px;
  border-bottom: 2px solid var(--doc-border);
}

.doc-parte-label {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.85rem;
  letter-spacing: 0.3em;
  color: #1a1a1a;
  text-transform: uppercase;
  font-weight: 700;
}

.doc-parte-titulo {
  font-family: 'Source Serif 4', serif;
  font-size: 1.4rem;
  color: var(--doc-accent);
  font-weight: 800;
  margin-top: 12px;
  text-transform: uppercase;
  line-height: 1.1;
}

.doc-titulo-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 30px 0 20px;
}

.titulo-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.05);
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s;
}

.titulo-nav-btn:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.1);
  color: var(--doc-accent);
}

.titulo-nav-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.titulo-nav-btn .material-symbols-rounded {
  font-size: 20px;
}

.doc-titulo-tabs {
  display: flex;
  justify-content: center;
  flex: 1;
  gap: 4px;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 12px;
  padding: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.doc-titulo-tabs::-webkit-scrollbar {
  display: none;
}

.titulo-tab {
  padding: 8px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  border: none;
  border-radius: 9px;
  background: none;
  white-space: nowrap;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-family: 'IBM Plex Sans', sans-serif;
  transition: all 0.2s;
}

.titulo-tab.active {
  background: #fff;
  color: var(--doc-accent);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  font-weight: 700;
}

.titulo-content {
  display: none;
}

.titulo-content.active {
  display: block;
}

.titulo-header {
  margin: 40px 0 24px;
  text-align: center;
}

.titulo-label {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.85rem;
  color: #1a1a1a;
  letter-spacing: 0.2em;
  font-weight: 700;
  text-transform: uppercase;
}

.titulo-nome {
  font-family: 'Source Serif 4', serif;
  font-size: 1.8rem;
  color: #1a1a1a;
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 8px;
  line-height: 1.2;
}

.capitulo-header {
  margin: 48px 0 24px;
  text-align: center;
}

.capitulo-label {
  font-family: 'Source Serif 4', serif;
  font-weight: 800;
  font-size: 1.3rem;
  color: #1a1a1a;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.capitulo-nome {
  font-family: 'Source Serif 4', serif;
  font-weight: 600;
  font-size: 1.3rem;
  font-style: italic;
  color: #1a1a1a;
  margin-top: 6px;
}

/* Secção */
.seccao-header {
  margin: 40px 0 20px;
  text-align: center;
}

.seccao-label {
  font-family: 'Source Serif 4', serif;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--doc-accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.seccao-nome {
  font-family: 'Source Serif 4', serif;
  font-weight: 400;
  font-size: 1.15rem;
  color: #1a1a1a;
  margin-top: 4px;
  font-style: italic;
}

/* Sub-Secção (sobrepõe seccao-header para reduzir margens e tamanho) */
.subseccao-header {
  margin: 24px 0 12px;
}

.subseccao-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: #64748b;
  letter-spacing: 0.06em;
}

/* Índice: Sub-Secção */
.it-subseccao-label {
  background: rgba(100, 116, 139, 0.08);
  border-color: rgba(100, 116, 139, 0.2);
  color: #64748b;
}

/* Artigo */
.artigo-block {
  margin: 20px 0;
  padding: 0 0 20px;
  border-bottom: 1px solid #EAEAE6;
}

.artigo-block:last-child {
  border-bottom: none;
}

.artigo-numero {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--doc-accent);
  margin-bottom: 2px;
}

.artigo-numero {
  text-align: center;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: #1d4ed8;
  letter-spacing: -0.01em;
}

.artigo-epigafe {
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 24px;
  font-family: 'IBM Plex Sans', sans-serif;
}

.artigo-conteudo {
  font-size: 1.05rem;
  line-height: 1.6;
  color: #334155;
  white-space: pre-line;
  font-family: 'Source Serif 4', serif;
  margin-bottom: 20px;
}

/* Números e Alíneas estruturados */
.artigo-numeros-list {
  margin-top: 15px;
  display: block !important;
  width: 100%;
}

.artigo-numero-item {
  display: flex !important;
  flex-direction: row !important;
  align-items: baseline !important;
  gap: 12px !important;
  margin-bottom: 20px !important;
}

.num-ident {
  font-family: 'IBM Plex Sans', sans-serif;
  font-weight: 800;
  color: #1d4ed8;
  font-size: 1.05rem;
  min-width: 28px;
  flex-shrink: 0;
  text-align: left;
}

.num-text.artigo-conteudo {
  flex: 1;
  text-align: justify;
  font-family: 'Source Serif 4', serif;
  line-height: 1.6;
  color: #334155;
  margin-bottom: 0;
  display: block;
  /* Garante que pre-line funciona corretamente mas dentro do flex item */
}

.alineas-list {
  margin-top: 10px;
  display: flex !important;
  flex-direction: column !important;
  gap: 12px;
}

.alinea-item {
  display: flex !important;
  gap: 15px !important;
  align-items: baseline !important;
}

.alinea-text {
  flex: 1;
  text-align: justify;
}

.alinea-text.artigo-conteudo {
  margin-bottom: 0;
}

.alinea-letra {
  font-family: 'IBM Plex Sans', sans-serif;
  font-weight: 700;
  min-width: 32px;
  flex-shrink: 0;
  color: #1d4ed8;
}

.direct-alineas {
  margin-top: 10px;
}

/* Highlight de navegação */
/* Logos */
.sidebar-logo-img,
.doc-logo,
.login-logo-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.doc-logo {
  height: 60px;
  margin: 0 auto;
}

.artigo-block.highlight-active {
  background: #FFFDE8;
  box-shadow: 0 0 0 8px #FFFDE8;
  border-radius: 4px;
  transition: background 0.5s ease, box-shadow 0.5s ease;
}

/* ────────────────────────────────────────────────────────────── */
/*  CONSULTA IA                                                    */
/* ────────────────────────────────────────────────────────────── */
.consulta-view {
  padding: 32px;
  max-width: 90%;
  margin: auto;
}

.consulta-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
}

.consulta-icon {
  font-size: 1.8rem;
}

.consulta-header h2 {
  /*font-family: 'Source Serif 4', serif;*/
  font-size: 1.25rem;
  color: var(--text-primary);
}

.consulta-header p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Tipo nav */
.tipo-nav {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tipo-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--bg-border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.tipo-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.tipo-btn.active {
  background: var(--blue-glow);
  color: var(--blue-400);
  border-color: rgba(37, 99, 235, 0.4);
}

/* Consulta forms */
.consulta-forms {
  margin-bottom: 24px;
}

.cform {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cform label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cform-row {
  display: flex;
  gap: 10px;
}

.cform-input {
  flex: 1;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--bg-border);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: 'IBM Plex Sans', sans-serif;
  transition: border var(--transition);
}

.cform-input:focus {
  outline: none;
  border-color: var(--blue-500);
}

.cform-textarea {
  width: 100%;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--bg-border);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.9rem;
  resize: vertical;
  font-family: 'IBM Plex Sans', sans-serif;
  transition: border var(--transition);
}

.cform-textarea:focus {
  outline: none;
  border-color: var(--blue-500);
}

.btn-consultar {
  padding: 12px 24px;
  border-radius: 6px;
  background: var(--blue-600);
  color: #fff;
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition);
}

.btn-consultar:hover {
  background: var(--blue-500);
}

.btn-consultar:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.compare-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.compare-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.compare-vs {
  font-weight: 700;
  color: var(--text-muted);
  padding-bottom: 10px;
}

/* Resultado */
.result-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px;
}

.loading-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.result-content {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--border-r);
  padding: 20px;
  margin-bottom: 20px;
}

.result-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.result-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(37, 99, 235, 0.2);
  color: var(--blue-400);
}

.result-stats {
  display: flex;
  gap: 8px;
}

.stat-pill {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 2px 8px;
  border-radius: 20px;
}

.result-body {
  font-size: 0.9rem;
  line-height: 1.8;
  color: var(--text-primary);
  white-space: pre-wrap;
}

.result-error {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: rgba(239, 68, 68, 0.1);
  border-radius: 8px;
  color: #FCA5A5;
  font-size: 0.85rem;
}

/* Histórico */
.history-section {
  margin-top: 32px;
  margin: auto;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.btn-icon-sm {
  background: none;
  border: 1px solid var(--bg-border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-empty {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  padding: 16px;
}

.history-item {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  transition: all var(--transition);
}

.history-item:hover {
  background: var(--bg-hover);
  border-color: var(--blue-600);
}

.artigo-numero-item {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.num-ident {
  color: var(--blue-500);
  font-weight: 700;
  min-width: 24px;
  flex-shrink: 0;
  line-height: 1.6;
}

.num-text {
  flex: 1;
  margin-top: 0;
}

/* Logos */
.sidebar-logo-img,
.doc-logo,
.login-logo-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.doc-logo {
  height: 60px;
  margin: 0 auto;
}

.history-tipo {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--blue-400);
  font-weight: 700;
  margin-bottom: 2px;
}

.history-input {
  font-size: 0.82rem;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-date {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Editor: Structural Headers (Título/Capítulo) with Actions */
.wd-structural-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 30px;
  border-bottom: 2px solid rgba(0, 48, 135, 0.1);
  padding-bottom: 8px;
}

/* Editor Specific Section Styling */
.wd-seccao-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin: 30px 0 15px;
  padding: 10px;
  background: rgba(0, 48, 135, 0.03);
  border-radius: 8px;
  position: relative;
}

.wd-seccao-header .wd-header-actions {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
}

.wd-seccao {
  font-family: 'Source Serif 4', serif;
  font-weight: 700;
  color: var(--doc-accent);
  text-transform: uppercase;
  font-size: 0.9rem;
}

.wd-seccao-nom {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.95rem;
  color: #1a1a1a;
}

.wd-header-actions {
  display: flex;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.2s;
}

.wd-structural-header:hover .wd-header-actions {
  opacity: 1;
}

.wd-btn-header {
  background: none;
  border: 1px solid #ccc;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 4px 8px;
  border-radius: 4px;
  background: #fff;
  transition: all 0.2s;
}

.wd-btn-header:hover {
  border-color: var(--blue-600);
  background: var(--blue-50);
}

.wd-capitulo-header {
  margin-top: 24px;
  border-bottom-width: 1px;
}

/* ────────────────────────────────────────────────────────────── */
/*  ADMIN — EDITOR WORD-LIKE                                       */
/* ────────────────────────────────────────────────────────────── */
.editor-view {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--bg-border);
  flex-shrink: 0;
}

.toolbar-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.toolbar-actions {
  display: flex;
  gap: 8px;
}

.tbtn {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  border: 1px solid var(--bg-border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition);
}

.tbtn:hover {
  background: var(--blue-glow);
  border-color: var(--blue-600);
  color: var(--blue-400);
}

.editor-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Árvore */
.editor-tree {
  width: 280px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--bg-border);
  overflow-y: auto;
  padding: 12px 10px;
}

.tree-loading {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 20px 12px;
}

.tree-parte {
  margin-bottom: 4px;
  border-radius: 8px;
  overflow: hidden;
}

.tree-parte-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  cursor: pointer;
  background: var(--bg-elevated);
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
  transition: background var(--transition);
}

.tree-parte-header:hover {
  background: var(--bg-hover);
}

.tree-parte-header.active {
  background: var(--blue-glow);
  color: var(--blue-400);
}

.tree-parte-label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.tree-parte-num {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  font-weight: 600;
  opacity: 0.7;
}

.tree-parte-titulo {
  word-break: break-word;
}

.tree-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--transition);
}

.tree-parte-header:hover .tree-actions {
  opacity: 1;
}

.tree-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 2px 4px;
  border-radius: 4px;
}

.tree-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.tree-titulos {
  padding: 4px 0 4px 12px;
}

.tree-titulo {
  border-radius: 6px;
  margin-bottom: 4px;
  transition: all var(--transition);
}

.tree-titulo-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 6px 8px;
  cursor: pointer;
}

.tree-titulo:hover .tree-titulo-row {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-radius: 6px;
}

.tree-titulo.active>.tree-titulo-row {
  background: rgba(37, 99, 235, 0.15);
  color: var(--blue-400);
  border-radius: 6px;
}

.tree-titulo-label {
  flex: 1;
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.4;
  word-break: break-word;
}

.tree-titulo-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
}

.tree-titulos {
  padding: 4px 0 4px 12px;
}

.tree-capitulos {
  padding-left: 16px;
  border-left: 1px solid rgba(255, 255, 255, 0.05);
  margin-left: 8px;
}

.tree-seccoes {
  padding-left: 16px;
  border-left: 1px solid rgba(255, 255, 255, 0.05);
  margin-left: 8px;
}

.tree-titulo:hover .tree-titulo-actions {
  opacity: 1;
}

.tree-add-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
  background: none;
  border: 1px dashed var(--bg-border);
  width: 100%;
  transition: all var(--transition);
}

.tree-add-btn:hover {
  border-color: var(--blue-600);
  color: var(--blue-400);
  background: var(--blue-glow);
}

/* Documento principal */
.editor-doc {
  flex: 1;
  overflow-y: auto;
  background: #E8E8E4;
  padding: 24px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.word-doc {
  width: 100%;
  max-width: 800px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 2px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  min-height: 600px;
  padding: 60px 72px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.9rem;
  line-height: 1.8;
  color: #1A1A1A;
}

.word-doc-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  color: #999;
  text-align: center;
  gap: 12px;
}

/* Elements within word doc */
.wd-parte-titulo {
  font-family: 'Source Serif 4', serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--doc-accent);
  text-align: center;
  margin: 8px 0 4px;
}

.wd-parte-subtitulo {
  font-size: 0.95rem;
  color: #1a1a1a;
  text-align: center;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 30px;
}

.wd-titulo {
  font-family: 'Source Serif 4', serif;
  font-weight: 700;
  font-size: 1.15rem;
  text-align: center;
  color: var(--doc-accent);
  margin: 40px 0 8px;
  text-transform: uppercase;
}

.wd-titulo-nom {
  font-family: 'Source Serif 4', serif;
  font-weight: 700;
  font-size: 1.15rem;
  text-align: center;
  margin-bottom: 30px;
  text-transform: uppercase;
  line-height: 1.4;
  color: #1a1a1a;
}

.wd-capitulo {
  font-family: 'Source Serif 4', serif;
  font-weight: 700;
  font-size: 1.05rem;
  text-transform: uppercase;
  text-align: center;
  color: #1a1a1a;
  margin: 30px 0 8px;
  letter-spacing: 0.02em;
}

.wd-capitulo-nom {
  font-family: 'IBM Plex Sans', sans-serif;
  font-weight: 400;
  text-align: center;
  font-size: 1.05rem;
  margin-bottom: 24px;
  color: #333;
}

.wd-artigo {
  margin: 40px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.wd-artigo-num {
  font-weight: 700;
  font-size: 1rem;
  color: var(--doc-accent);
  text-align: center;
  margin-bottom: 4px;
}

.wd-artigo-epig {
  font-weight: 700;
  color: #1a1a1a;
  text-align: center;
  margin-bottom: 20px;
  font-size: 0.95rem;
  font-style: italic;
}

.wd-artigo-body {
  width: 100%;
  text-align: justify;
  text-justify: inter-word;
  white-space: pre-line;
  font-size: 1rem;
}

.wd-hr {
  border: none;
  border-top: 1px solid #ddd;
  margin: 16px 0;
}

.wd-artigo-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity var(--transition);
}

.wd-artigo:hover .wd-artigo-actions {
  opacity: 1;
}

.wd-btn {
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid;
  transition: all var(--transition);
}

.wd-btn-edit {
  border-color: var(--blue-600);
  color: var(--blue-600);
  background: none;
}

.wd-btn-edit:hover {
  background: var(--blue-600);
  color: #fff;
}

.wd-btn-del {
  border-color: #ccc;
  color: #c00;
  background: none;
}

.wd-btn-del:hover {
  background: #c00;
  color: #fff;
  border-color: #c00;
}

.wd-add-artigo-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px dashed #ccc;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.82rem;
  color: #888;
  background: none;
  margin: 12px 0;
  width: 100%;
  transition: all var(--transition);
}

.wd-add-artigo-btn:hover {
  border-color: var(--doc-accent);
  color: var(--doc-accent);
  background: #EEF2FF;
}

/* ────────────────────────────────────────────────────────────── */
/*  MODALS                                                         */
/* ────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--border-r);
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-box-lg {
  max-width: 720px;
}

.modal-fullscreen .modal-box-lg {
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-box-sm {
  max-width: 450px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--bg-border);
  border-radius: 6px;
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--bg-border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}

.field-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field-group small {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.artigo-form-grid {
  display: flex;
  gap: 12px;
}

.modal-input {
  width: 100%;
  padding: 9px 12px;
  border-radius: 6px;
  border: 1px solid var(--bg-border);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: 'IBM Plex Sans', sans-serif;
}

.modal-input:focus {
  outline: none;
  border-color: var(--blue-500);
}

.btn-cancel {
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--bg-border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-save {
  padding: 8px 20px;
  border-radius: 6px;
  background: var(--blue-600);
  color: #fff;
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-save:hover {
  background: var(--blue-500);
}

/* Editor de artigo */
.word-preview-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.word-editor-wrap {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--bg-border);
  border-radius: 6px;
  overflow: hidden;
}

.word-editor-toolbar {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--bg-border);
}

.word-editor-toolbar button {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.78rem;
  border: 1px solid var(--bg-border);
  background: var(--bg-surface);
  color: var(--text-primary);
  cursor: pointer;
}

.word-editor-toolbar button:hover {
  background: var(--bg-hover);
}

.artigo-textarea {
  width: 100%;
  padding: 12px;
  min-height: 160px;
  border: none;
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: 'IBM Plex Mono', monospace;
  line-height: 1.7;
  resize: vertical;
}

.artigo-textarea:focus {
  outline: none;
}

/* ────────────────────────────────────────────────────────────── */
/*  LOGIN PAGE                                                     */
/* ────────────────────────────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 30% 20%, rgba(37, 99, 235, 0.15) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(245, 197, 24, 0.08) 0%, transparent 60%),
    var(--bg-base);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.login-bg-shapes {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.shape {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.12;
}

.shape-1 {
  width: 400px;
  height: 400px;
  background: var(--blue-600);
  top: -100px;
  left: -100px;
  animation: shapeFloat 12s ease-in-out infinite;
}

.shape-2 {
  width: 300px;
  height: 300px;
  background: #F5C518;
  bottom: -80px;
  right: -80px;
  animation: shapeFloat 15s ease-in-out infinite reverse;
}

.shape-3 {
  width: 200px;
  height: 200px;
  background: var(--blue-400);
  top: 50%;
  left: 50%;
  animation: shapeFloat 10s ease-in-out infinite 2s;
}

@keyframes shapeFloat {

  0%,
  100% {
    transform: translate(0, 0);
  }

  50% {
    transform: translate(20px, -20px);
  }
}

.login-card {
  background: rgba(15, 26, 46, 0.9);
  border: 1px solid var(--bg-border);
  border-radius: 8px;
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  backdrop-filter: blur(20px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  position: relative;
  z-index: 1;
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.flag-cv {
  width: 60px;
  height: 40px;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin: 0 auto 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  position: relative;
}

.flag-stripe {
  width: 100%;
}

.flag-stripe.blue.top {
  flex: 4;
  background: #003893;
}

.flag-stripe.white-1 {
  flex: 1;
  background: #fff;
}

.flag-stripe.red {
  flex: 1;
  background: #CC0000;
}

.flag-stripe.white-2 {
  flex: 1;
  background: #fff;
}

.flag-stripe.blue.bottom {
  flex: 3;
  background: #003893;
}

.flag-stars {
  position: absolute;
  left: 25%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  width: 20px;
}

.star {
  width: 3px;
  height: 3px;
  background: #F5C518;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

.login-header h1 {
  font-family: 'Source Serif 4', serif;
  font-size: 2.2rem;
  color: #F5C518;
  margin-bottom: 4px;
  font-weight: 700;
}

.login-header p {
  font-size: 1.4rem;
  color: var(--text-secondary);
  font-weight: 700;
  
}

.login-badge {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 14px;
  border-radius: 20px;
  border: 1px solid var(--blue-600);
  font-size: 0.7rem;
  color: var(--blue-400);
  letter-spacing: 0.05em;
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 0.83rem;
  margin-bottom: 16px;
}

.alert-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #FCA5A5;
}

.alert-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field-group-login {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-group-login label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.input-wrapper input {
  width: 100%;
  padding: 12px 12px 12px 36px;
  border-radius: 8px;
  border: 1px solid var(--bg-border);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: 'IBM Plex Sans', sans-serif;
  transition: border var(--transition);
}

.input-wrapper input:focus {
  outline: none;
  border-color: var(--blue-500);
}

.toggle-pass {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.btn-login {
  padding: 13px;
  border-radius: 8px;
  background: var(--blue-600);
  color: #fff;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  transition: background var(--transition);
}

.btn-login:hover {
  background: var(--blue-500);
}

.btn-login:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.login-footer {
  text-align: center;
  margin-top: 16px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ────────────────────────────────────────────────────────────── */
/* LOADING RING                                                    */
/* ────────────────────────────────────────────────────────────── */
.loading-ring {
  width: 36px;
  height: 36px;
  border: 3px solid var(--bg-border);
  border-top-color: var(--blue-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    width: 64px;
  }

  .nav-label,
  .brand-sub,
  .brand-cne,
  .user-info,
  .nav-badge {
    display: none;
  }

  .brand-text {
    display: none;
  }


  .consulta-view {
    padding: 16px;
  }

  .word-doc {
    padding: 32px 20px;
  }

  .editor-tree {
    width: 200px;
  }
}

/* ────────────────────────────────────────────────────────────── */
/*  ARTIGO ACTIONS (Favoritos & Notas)                            */
/* ────────────────────────────────────────────────────────────── */
.artigo-block {
  position: relative;
  padding-top: 20px;
}

.artigo-actions {
  position: absolute;
  top: 10px;
  right: 15px;
  display: flex !important;
  /* Sempre visível */
  gap: 8px;
  opacity: 0.6;
  /* Semi-transparente por padrão */
  transition: opacity 0.2s ease;
}

.artigo-block:hover .artigo-actions {
  opacity: 1;
}

.artigo-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}

.artigo-action-btn:hover {
  color: var(--text-primary);
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.05);
}

.artigo-action-btn.active {
  color: #EF4444;
  background: rgba(239, 68, 68, 0.08);
}

#btnArchiveConsulta.active {
  color: var(--blue-400);
  background: rgba(37, 99, 235, 0.1);
}

.artigo-action-btn.has-note {
  color: #F5C518 !important;
  opacity: 1;
  /* Notas existentes sempre visíveis */
  border-color: var(--blue-600);
  background: rgba(37, 99, 235, 0.1);
}

.artigo-action-btn.has-note .material-symbols-rounded {
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.material-symbols-rounded {
  font-family: 'Material Symbols Rounded';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'liga';
}

.artigo-action-btn .material-symbols-rounded {
  font-size: 1.1rem;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.artigo-action-btn.active .material-symbols-rounded {
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* Modais de Alerta/Confirma��o Modernos */
.modal-alert {
  max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  box-shadow: var(--shadow-lg);
}

.modal-alert .modal-body {
  padding: 1rem 1rem 2rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
}

.modal-alert .modal-footer .btn-primary {
  padding: 8px 20px;
}

.modal-alert .modal-footer .btn-secondary {
  padding: 8px 20px;
  background: transparent;
  border: 1px solid var(--bg-border);
  color: var(--text-primary);
}

.modal-alert .modal-footer .btn-secondary:hover {
  background: var(--bg-hover);
}

/* ── Adicionar Artigo (Editor Improvements) ── */
.tree-add-artigo-btn {
  margin: 4px 0 8px 32px;
  font-size: 0.7rem !important;
  color: #60A5FA !important;
  border: 1px dashed rgba(96, 165, 250, 0.3) !important;
  background: rgba(96, 165, 250, 0.05) !important;
  transition: all 0.2s ease;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  display: block;
  width: fit-content;
}

.tree-add-artigo-btn:hover {
  background: rgba(96, 165, 250, 0.1) !important;
  border-color: #60A5FA !important;
  color: #fff !important;
}

.tree-artigo-directo {
  padding: 4px 8px 4px 32px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
}

.tree-artigo-directo:hover {
  background: rgba(37, 99, 235, 0.1);
  color: #93C5FD;
}

.tree-art-label {
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 0.8;
}

.wd-add-artigo-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 10px;
  margin: 12px 0;
  background: rgba(37, 99, 235, 0.06);
  border: 1.5px dashed rgba(37, 99, 235, 0.2);
  border-radius: 8px;
  color: #2563EB;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.wd-add-artigo-btn:hover {
  background: rgba(37, 99, 235, 0.1);
  border-color: #2563EB;
  transform: translateY(-1px);
}

.wd-add-artigo-inline {
  display: inline-block;
  padding: 6px 14px;
  margin: 10px 0 20px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  color: #64748b;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.wd-add-artigo-inline:hover {
  background: #fff;
  color: #2563EB;
  border-color: #93C5FD;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* ══════════════════════════════════════════════════════════════
   ÍNDICE REMISSIVO
══════════════════════════════════════════════════════════════ */
.indice-view {
  max-width: 860px;
  margin: 0 auto;
  padding: 16px 20px 40px;
}

.indice-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.indice-title {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.indice-title .material-symbols-rounded {
  font-size: 1.6rem;
  color: var(--blue-400);
}

.indice-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.indice-btn-codigo {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--blue-600);
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.83rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background var(--transition);
  flex-shrink: 0;
}

.indice-btn-codigo:hover {
  background: #1d4ed8;
}

.indice-btn-codigo .material-symbols-rounded {
  font-size: 1rem;
}

/* Filtro */
.indice-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 16px;
  transition: border-color var(--transition);
}

.indice-filter-bar:focus-within {
  border-color: var(--blue-500);
}

.indice-filter-icon {
  font-size: 1.1rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.indice-filter-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.9rem;
}

.indice-filter-input::placeholder {
  color: var(--text-muted);
}

.indice-filter-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 2px;
  border-radius: 4px;
  transition: color var(--transition);
}

.indice-filter-clear:hover {
  color: var(--text-primary);
}

/* Controlos */
.indice-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.indice-ctrl-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--bg-border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all var(--transition);
}

.indice-ctrl-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--blue-500);
}

.indice-ctrl-btn .material-symbols-rounded {
  font-size: 0.95rem;
}

.indice-count-label {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Loading */
.indice-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 0;
  color: var(--text-muted);
  gap: 14px;
  font-size: 0.9rem;
}

/* ── Árvore ── */
.indice-tree {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* TÍTULO (parte) */
.it-parte {
  border: 1px solid var(--bg-border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-surface);
}

.it-parte-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}

.it-parte-header:hover {
  background: var(--bg-hover);
}

.it-parte-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--blue-400);
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 4px;
  padding: 2px 7px;
  flex-shrink: 0;
}

.it-parte-nome {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.it-toggle-icon {
  font-size: 1.1rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.it-parte.collapsed .it-toggle-icon,
.it-capitulo.collapsed .it-toggle-icon,
.it-seccao.collapsed .it-toggle-icon {
  transform: rotate(-90deg);
}

.it-parte-body {
  border-top: 1px solid var(--bg-border);
  padding: 8px 0;
}

.it-parte.collapsed .it-parte-body,
.it-capitulo.collapsed .it-capitulo-body,
.it-seccao.collapsed .it-seccao-body {
  display: none;
}

/* CAPÍTULO (titulo) */
.it-capitulo {
  margin: 2px 10px;
  border-radius: 8px;
  overflow: hidden;
}

.it-capitulo-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
  border-radius: 6px;
}

.it-capitulo-header:hover {
  background: var(--bg-hover);
}

.it-capitulo-label {
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #10B981;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 4px;
  padding: 2px 7px;
  flex-shrink: 0;
}

.it-capitulo-nome {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
}

.it-capitulo-body {
  padding: 4px 0 4px 24px;
}

/* SECÇÃO (capitulo) */
.it-seccao {
  margin: 2px 0;
  border-radius: 6px;
  overflow: hidden;
}

.it-seccao-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
  border-radius: 6px;
}

.it-seccao-header:hover {
  background: var(--bg-hover);
}

.it-seccao-label {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  color: #F59E0B;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: 4px;
  padding: 2px 7px;
  flex-shrink: 0;
}

.it-seccao-nome {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-secondary);
  flex: 1;
}

.it-seccao-body {
  padding: 2px 0 2px 22px;
}

/* Artigo */
.it-artigo {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 3px 10px;
  border-radius: 4px;
  text-decoration: none;
  transition: background var(--transition);
  color: inherit;
}

.it-artigo:hover {
  background: var(--bg-hover);
}

.it-artigo-num {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--blue-400);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 62px;
}

.it-artigo-epi {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* Sem resultados no filtro */
.indice-no-results {
  text-align: center;
  padding: 48px 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Highlight do filtro */
.indice-highlight {
  background: rgba(251, 191, 36, 0.25);
  border-radius: 2px;
  color: var(--text-primary);
}

/* Esconder itens que não correspondem ao filtro */
.it-hidden {
  display: none !important;
}

.artigo-action-btn.has-note .material-symbols-rounded {
  color: #FBBF24 !important;
}

/* ----------------------------------------------------------
   PESQUISA  Dropdown de Resultados
   ----------------------------------------------------------- */
.doc-search-bar {
  position: relative;
  flex: 1;
}

.search-results-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-card, #0f1623);
  border: 1px solid var(--bg-border, rgba(255,255,255,0.1));
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.55);
  z-index: 9999;
  max-height: 420px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
}

.search-results-dropdown::-webkit-scrollbar { width: 4px; }
.search-results-dropdown::-webkit-scrollbar-track { background: transparent; }
.search-results-dropdown::-webkit-scrollbar-thumb { background: var(--bg-border, rgba(255,255,255,0.1)); border-radius: 2px; }

.search-result-item {
  display: block;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--bg-border, rgba(255,255,255,0.06));
  transition: background 0.13s ease;
  text-decoration: none;
  color: var(--text-primary, #e8eaf0);
}

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

.search-result-item:hover {
  background: var(--bg-hover, rgba(255,255,255,0.05));
}

.sri-type {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  margin-bottom: 3px;
  border-radius: 3px;
  display: inline-block;
  padding: 1px 6px;
}

.sri-artigo {
  color: #3B82F6;
  background: rgba(59,130,246,0.1);
  border: 1px solid rgba(59,130,246,0.2);
}

.sri-titulo {
  color: #10B981;
  background: rgba(16,185,129,0.1);
  border: 1px solid rgba(16,185,129,0.2);
}

.sri-capitulo {
  color: #F59E0B;
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.2);
}

.sri-seccao {
  color: #8B5CF6;
  background: rgba(139,92,246,0.1);
  border: 1px solid rgba(139,92,246,0.2);
}

.sri-subseccao {
  color: #EC4899;
  background: rgba(236,72,153,0.1);
  border: 1px solid rgba(236,72,153,0.2);
}

.sri-num {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-primary, #e8eaf0);
  margin-bottom: 2px;
}

.sri-epigafe {
  font-size: 0.78rem;
  color: var(--blue-400, #60A5FA);
  font-style: italic;
  margin-bottom: 2px;
}

.sri-preview {
  font-size: 0.75rem;
  color: var(--text-muted, #8892A4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sri-designacao {
  font-size: 0.8rem;
  color: var(--text-secondary, #b0b8c8);
}

.search-highlight {
  background: rgba(251, 191, 36, 0.28);
  color: #FBBF24;
  border-radius: 2px;
  padding: 0 2px;
  font-weight: 600;
}

.kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--bg-border, rgba(255,255,255,0.15));
  border-radius: 4px;
  font-size: 0.68rem;
  font-family: monospace;
  color: var(--text-muted, #8892A4);
  background: var(--bg-surface, rgba(255,255,255,0.04));
}

.search-kbd {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}


/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   PESQUISA â€” Dropdown de Resultados
   â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */
.doc-search-bar {
  position: relative;
  flex: 1;
}

.search-results-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-card, #0f1623);
  border: 1px solid var(--bg-border, rgba(255,255,255,0.1));
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.55);
  z-index: 9999;
  max-height: 420px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
}

.search-results-dropdown::-webkit-scrollbar { width: 4px; }
.search-results-dropdown::-webkit-scrollbar-track { background: transparent; }
.search-results-dropdown::-webkit-scrollbar-thumb {
  background: var(--bg-border, rgba(255,255,255,0.1));
  border-radius: 2px;
}

.search-result-item {
  display: block;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--bg-border, rgba(255,255,255,0.06));
  transition: background 0.13s ease;
  color: var(--text-primary, #e8eaf0);
}

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

.search-result-item:hover {
  background: var(--bg-hover, rgba(255,255,255,0.05));
}

.sri-type {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  margin-bottom: 3px;
  border-radius: 3px;
  display: inline-block;
  padding: 1px 6px;
}

.sri-artigo {
  color: #3B82F6;
  background: rgba(59,130,246,0.1);
  border: 1px solid rgba(59,130,246,0.2);
}

.sri-titulo {
  color: #10B981;
  background: rgba(16,185,129,0.1);
  border: 1px solid rgba(16,185,129,0.2);
}

.sri-capitulo {
  color: #F59E0B;
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.2);
}

.sri-seccao {
  color: #8B5CF6;
  background: rgba(139,92,246,0.1);
  border: 1px solid rgba(139,92,246,0.2);
}

.sri-subseccao {
  color: #EC4899;
  background: rgba(236,72,153,0.1);
  border: 1px solid rgba(236,72,153,0.2);
}

.sri-num {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-primary, #e8eaf0);
  margin-bottom: 2px;
}

.sri-epigafe {
  font-size: 0.78rem;
  color: var(--blue-400, #60A5FA);
  font-style: italic;
  margin-bottom: 2px;
}

.sri-preview {
  font-size: 0.75rem;
  color: var(--text-muted, #8892A4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sri-designacao {
  font-size: 0.8rem;
  color: var(--text-secondary, #b0b8c8);
}

.search-highlight {
  background: rgba(251, 191, 36, 0.28);
  color: #FBBF24;
  border-radius: 2px;
  padding: 0 2px;
  font-weight: 600;
}

.kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--bg-border, rgba(255,255,255,0.15));
  border-radius: 4px;
  font-size: 0.68rem;
  font-family: monospace;
  color: var(--text-muted, #8892A4);
  background: var(--bg-surface, rgba(255,255,255,0.04));
}

.search-kbd {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

/* Artigo com highlight activo apÃ³s navegaÃ§Ã£o da pesquisa */
.artigo-block.highlight-active {
  animation: pulseHighlight 0.6s ease;
  outline: 2px solid rgba(59,130,246,0.6);
  border-radius: 8px;
}

@keyframes pulseHighlight {
  0%   { background: rgba(59,130,246,0.15); }
  100% { background: transparent; }
}
