:root {
  --bg-app: #F3F4F6;
  --bg-surface: #FFFFFF;
  --bg-brand: #1E40AF;
  --text: #1F2937;
  --text-muted: #6B7280;
  --border: #E5E7EB;
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-light: #EFF6FF;
  --dropzone-bg: #DBEAFE;
  --danger: #DC2626;
  --danger-bg: #FEF2F2;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  --font-display: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-display);
  background: var(--bg-app);
  color: var(--text);
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--bg-brand);
  color: #fff;
  box-shadow: var(--shadow);
}
.topbar-brand {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.brand-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  line-height: 0;
}
.logo-topbar {
  height: 44px;
  width: auto;
  max-width: 220px;
  object-fit: contain;
  background: transparent;
}
.topbar-nav { display: flex; align-items: center; gap: 0.15rem; flex: 1; }
.topbar-nav-link,
.nav-menu-trigger {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  font-size: 0.92rem;
  font-family: inherit;
  border: none;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.topbar-nav-link:hover,
.topbar-nav-link.active,
.nav-menu-trigger:hover,
.nav-menu-trigger.active,
.nav-menu-trigger[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}
.topbar-nav-sep {
  color: rgba(255, 255, 255, 0.35);
  font-size: 0.85rem;
  user-select: none;
  padding: 0 0.1rem;
}

.nav-menu {
  position: relative;
}

.nav-menu-chevron {
  opacity: 0.85;
  transition: transform 0.15s;
}

.nav-menu-trigger[aria-expanded="true"] .nav-menu-chevron {
  transform: rotate(180deg);
}

.nav-menu-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  min-width: 280px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
  padding: 0.4rem;
  z-index: 200;
}

.nav-menu-dropdown.hidden {
  display: none;
}

.nav-menu-dropdown-header {
  padding: 0.45rem 0.65rem 0.35rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.nav-menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.7rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  transition: background 0.12s;
}

.nav-menu-item:hover {
  background: #f1f5f9;
}

.nav-menu-item.active {
  background: var(--primary-light);
}

.nav-menu-item-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #f1f5f9;
  color: var(--primary);
  flex-shrink: 0;
}

.nav-menu-item.active .nav-menu-item-icon {
  background: #dbeafe;
}

.nav-menu-item-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.nav-menu-item-text strong {
  font-size: 0.9rem;
  font-weight: 600;
}

.nav-menu-item-text small {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.home-page {
  max-width: 900px;
}

.home-header h1 {
  margin: 0 0 0.35rem;
}

.home-section {
  margin-top: 2rem;
}

.home-section-title {
  margin: 0 0 0.85rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.home-tiles {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.home-tile {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}

.home-tile:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.12);
  transform: translateY(-1px);
}

.home-tile-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: var(--primary-light);
  color: var(--primary);
  flex-shrink: 0;
}

.home-tile-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
  min-width: 0;
}

.home-tile-body strong {
  font-size: 1.05rem;
}

.home-tile-preview {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary);
  margin-top: 0.15rem;
}

.home-tile-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
}

.page-breadcrumb {
  margin: 0 0 0.25rem;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  position: relative;
}
.topbar-user .btn-ghost {
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.topbar-user .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.22);
}

.user-menu {
  position: relative;
}

.user-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
}

.user-menu-trigger:hover,
.user-menu-trigger[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.2);
}

.user-menu-chevron {
  opacity: 0.85;
  transition: transform 0.15s;
}

.user-menu-trigger[aria-expanded="true"] .user-menu-chevron {
  transform: rotate(180deg);
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  min-width: 190px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
  padding: 0.35rem;
  z-index: 200;
}

.user-menu-dropdown.hidden {
  display: none;
}

.user-menu-item {
  display: block;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.user-menu-item:hover:not(:disabled) {
  background: #f1f5f9;
}

.user-menu-item--disabled {
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.65;
}

.user-menu-item--sair {
  color: #b91c1c;
  font-weight: 600;
}

.user-menu-item--sair:hover {
  background: #fef2f2;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.form-stack label span {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.form-stack input {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}

.form-erro {
  margin: 0;
  padding: 0.55rem 0.65rem;
  border-radius: 6px;
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  font-size: 0.88rem;
}

.form-erro.hidden {
  display: none;
}

.form-acoes {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.25rem;
}
.online-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #22c55e;
  display: inline-block;
}

.app-shell {
  display: flex;
  align-items: flex-start;
}

.app-nav {
  position: sticky;
  top: 0;
  align-self: stretch;
  flex-shrink: 0;
  width: 252px;
  min-height: calc(100vh - 68px);
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 1rem 0.75rem;
  z-index: 50;
}

.app-nav-group {
  margin-bottom: 0.35rem;
}

.app-nav-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  border-radius: 8px;
}

.app-nav-trigger:hover {
  background: #f1f5f9;
}

.app-nav-chevron {
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.app-nav-trigger[aria-expanded="false"] .app-nav-chevron {
  transform: rotate(-90deg);
}

.app-nav-sub {
  display: flex;
  flex-direction: column;
  padding: 0.15rem 0 0.4rem;
}

.app-nav-sub.hidden {
  display: none;
}

.app-nav-subitem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 1.6rem;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.88rem;
  color: var(--text);
  text-decoration: none;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
}

.app-nav-subitem:hover {
  background: #f8fafc;
}

.app-nav-subitem.active {
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 600;
}

.app-nav-trigger-label,
.app-nav-subitem-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.app-nav-alerta {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #f59e0b;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  cursor: help;
  flex-shrink: 0;
}

.app-nav-alerta--vermelho {
  background: #dc2626;
}

.app-nav-alerta::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  width: max-content;
  max-width: 220px;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  background: #1f2937;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.35;
  white-space: normal;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.22);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease;
  z-index: 500;
  pointer-events: none;
}

.app-nav-alerta:hover::after,
.app-nav-alerta:focus-visible::after {
  opacity: 1;
  visibility: visible;
}

.app-nav-caret {
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.app-nav-subitem--flyout[aria-expanded="true"] .app-nav-caret {
  transform: rotate(90deg);
}

.app-nav-flyout-wrap {
  position: relative;
}

.app-nav-flyout {
  position: absolute;
  top: -0.25rem;
  left: calc(100% + 0.4rem);
  min-width: 264px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
  padding: 0.4rem;
  z-index: 300;
}

.app-nav-flyout.hidden {
  display: none;
}

.app-nav-flyout-vazio {
  padding: 0.5rem 0.7rem 0.65rem;
}

.tarefas-placeholder {
  text-align: center;
  padding: 3rem 1.5rem;
}

.tarefas-placeholder-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 16px;
  background: #f1f5f9;
  color: var(--primary);
  margin-bottom: 1rem;
}

.tarefas-placeholder h2 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
}

.main-app { flex: 1 1 auto; min-width: 0; padding: 1.5rem; max-width: 1180px; margin: 0 auto; }

@media (max-width: 820px) {
  .app-shell {
    flex-direction: column;
  }
  .app-nav {
    position: static;
    width: 100%;
    min-height: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 0.5rem;
  }
  .app-nav-group {
    flex: 1;
    margin-bottom: 0;
  }
  .app-nav-flyout {
    left: 0;
    top: calc(100% + 0.4rem);
  }
}
.main-auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.page-header { margin-bottom: 1.25rem; }
.page-header.row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}
.header-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.alert-success {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}
.page-header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
}
.page-header p { margin: 0; color: var(--text-muted); }

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.card-narrow { max-width: 560px; }

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  transition: opacity 0.2s ease;
}
.auth-card.auth-pending {
  opacity: 0;
  pointer-events: none;
}
.auth-header { text-align: center; margin-bottom: 1.25rem; }
.auth-hint {
  margin: 1rem 0 0;
  font-size: 0.85rem;
  text-align: center;
  line-height: 1.45;
}
.auth-hint a { word-break: break-all; }
.logo-auth {
  display: block;
  width: min(100%, 340px);
  height: auto;
  margin: 0 auto;
  background: transparent;
}
.logo-loading {
  width: min(100%, 280px);
}

.loading-screen {
  text-align: center;
  padding: 2rem 1rem;
  max-width: 420px;
  margin: 0 auto;
}
.loading-label { color: var(--text-muted); margin: 1rem 0 0.75rem; }
.loading-pct { font-size: 0.9rem; color: var(--text-muted); margin-top: 0.5rem; }
.progress-track {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.converter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
@media (max-width: 720px) {
  .converter-grid { grid-template-columns: 1fr; }
}
.dropzone-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.45;
}
.drop-status { margin: 0.75rem 0 0; min-height: 1.25rem; font-size: 0.88rem; }
.dropzone.ativo {
  border-color: var(--primary);
  background: #BFDBFE;
}
.dropzone {
  border: 2px dashed #93C5FD;
  border-radius: var(--radius);
  padding: 2.75rem 1.5rem;
  text-align: center;
  cursor: pointer;
  background: var(--dropzone-bg);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.dropzone:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.15);
}
.dropzone.dragover { border-color: var(--primary); background: #BFDBFE; }

.form label, .field-select { display: block; margin-bottom: 1rem; }
.form label span, .field-select span {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text-muted);
}
.form input, .form select, .field-select select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  background: transparent;
  color: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { border-color: var(--border); background: #fff; }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }
.btn-block { width: 100%; }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.82rem; }
.form-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }

.alert { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }

.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td { padding: 0.65rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
.table th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }
.table .actions { white-space: nowrap; text-align: right; }
.table .empty { text-align: center; color: var(--text-muted); padding: 2rem; }
form.inline { display: inline; }

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}
.tile {
  display: block;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.tile:hover { border-color: var(--primary); box-shadow: 0 4px 12px rgba(37, 99, 235, 0.12); }
.tile-static { cursor: default; }
.tile-icon { font-size: 1.75rem; margin-bottom: 0.5rem; }
.tile h3 { margin: 0 0 0.35rem; }
.tile p { margin: 0; color: var(--text-muted); font-size: 0.9rem; }
.tile-count { font-size: 2rem; font-weight: 700; color: var(--primary); margin: 0.25rem 0; }
.online-list { margin: 0.5rem 0 0; padding-left: 1.1rem; font-size: 0.88rem; color: var(--text-muted); }
.muted { color: var(--text-muted); }
.muted-sm { font-size: 0.85rem; color: var(--text-muted); }
.lista-resumo .ok { margin-bottom: 0.65rem; }

.resultado, .pendentes { margin-top: 1.25rem; }
.hidden { display: none !important; }
.lista-resumo { font-size: 0.9rem; }
.lista-resumo li { margin-bottom: 0.35rem; }
.lista-resumo .ok { color: #15803d; }
.lista-resumo .err { color: var(--danger); }

.analise-status { margin-top: 1rem; }
.resultado-linha {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}
.resultado-linha-texto { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.ok-text { color: #15803d; font-weight: 600; }
.err-text { color: var(--danger); font-weight: 600; }
.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--primary);
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
}
.detalhes-box {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fafafa;
  max-height: 320px;
  overflow-y: auto;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal-overlay.hidden { display: none; }
.modal-card {
  background: var(--bg-surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: min(100%, 520px);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}
.modal-card h2 { margin: 0 0 0.35rem; font-size: 1.25rem; }
.modal-sub { margin: 0 0 0.25rem; font-weight: 600; }
.modal-progress { margin: 0 0 1rem; font-size: 0.88rem; }
