/* ==========================================================================
   BIOGRAN ENTERPRISE DASHBOARD COMPONENTS
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. GLOBAL RESET & LAYOUT BASE
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  background-color: var(--bg-main);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Typography Tabular Numerals Utility */
.num-tabular, .metric-value, .table-data-num, .time-stamp {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* Focus Ring Specification */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: var(--radius-full);
}

/* --------------------------------------------------------------------------
   2. APP SHELL LAYOUT
   -------------------------------------------------------------------------- */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
  transition: grid-template-columns var(--transition-normal);
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 64px 1fr;
}

/* --------------------------------------------------------------------------
   3. SIDEBAR NAVIGATION
   -------------------------------------------------------------------------- */
.app-sidebar {
  grid-area: sidebar;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  z-index: 40;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  user-select: none;
}

.sidebar-header {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--text-primary);
  font-weight: var(--weight-bold);
  font-size: var(--text-base);
  letter-spacing: -0.02em;
}

.brand-icon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(2, 132, 197, 0.25);
}

.brand-text {
  white-space: nowrap;
  opacity: 1;
  transition: opacity var(--transition-fast);
}

.sidebar-toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast), background var(--transition-fast);
}

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

.sidebar-nav {
  padding: var(--space-4) 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: 0 var(--space-3);
}

.nav-group-title {
  font-size: var(--text-micro);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0 var(--space-3) var(--space-2) var(--space-3);
  white-space: nowrap;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 8px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-sm);
  position: relative;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

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

.nav-item.active {
  color: var(--primary);
  background-color: var(--primary-subtle);
  font-weight: var(--weight-semibold);
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background-color: var(--primary);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-label {
  white-space: nowrap;
}

.nav-badge {
  margin-left: auto;
  font-size: var(--text-micro);
  font-family: var(--font-mono);
  font-weight: var(--weight-semibold);
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background-color: var(--bg-hover);
  color: var(--text-muted);
}

.nav-item.active .nav-badge {
  background-color: rgba(2, 132, 197, 0.15);
  color: var(--primary);
}

/* Sidebar Collapsed State */
.sidebar-collapsed .brand-text,
.sidebar-collapsed .nav-group-title,
.sidebar-collapsed .nav-label,
.sidebar-collapsed .nav-badge,
.sidebar-collapsed .sidebar-footer-text {
  display: none;
}

.sidebar-collapsed .nav-group {
  padding: 0 var(--space-2);
}

.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 10px;
}

.sidebar-collapsed .nav-item.active::before {
  left: 0;
}

/* --------------------------------------------------------------------------
   4. TOPBAR
   -------------------------------------------------------------------------- */
.app-topbar {
  grid-area: topbar;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.breadcrumb-item {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.breadcrumb-item:hover {
  color: var(--text-primary);
}

.breadcrumb-item.active {
  color: var(--text-primary);
  font-weight: var(--weight-semibold);
}

.breadcrumb-separator {
  color: var(--text-disabled);
  font-size: 12px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Search Trigger Button */
.search-trigger-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 6px 12px;
  background-color: var(--bg-main);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--text-xs);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
  min-width: 220px;
}

.search-trigger-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
  background-color: var(--bg-hover);
}

.kbd-shortcut {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--text-nano);
  padding: 2px 5px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xs);
  color: var(--text-muted);
}

/* Header Action Buttons */
.topbar-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
}

.topbar-icon-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.notification-badge-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background-color: var(--primary);
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-surface);
}

/* User Profile Menu Trigger */
.user-profile-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px var(--space-2);
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.user-profile-btn:hover {
  background-color: var(--bg-hover);
}

.avatar-img {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background-color: var(--primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--weight-bold);
  font-size: 12px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

/* --------------------------------------------------------------------------
   5. MAIN CONTENT & DASHBOARD GRID
   -------------------------------------------------------------------------- */
.app-main {
  grid-area: main;
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.page-title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: 2px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Metric Cards Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-4);
}

/* Compact variant — Transações processing popup's summary row. Small
   footprint, all cards on one row, numbers still readable at a glance. */
.metrics-grid-compact {
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--space-2);
}

.metrics-grid-compact .app-card {
  padding: var(--space-2) var(--space-3);
  gap: 2px;
}

.metrics-grid-compact .metric-label {
  font-size: var(--text-micro);
  white-space: normal;
  line-height: 1.2;
}

.metrics-grid-compact .metric-value {
  font-size: 22px;
  line-height: 1.15;
}

@media (max-width: 960px) {
  .metrics-grid-compact {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }
}

/* --------------------------------------------------------------------------
   6. CARDS SYSTEM
   -------------------------------------------------------------------------- */
.app-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  position: relative;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.app-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

/* Metric Card Specifics */
.metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.metric-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.metric-icon-box {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-main);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.metric-body {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
}

.metric-value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  line-height: 1;
}

.metric-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: var(--weight-semibold);
  font-family: var(--font-mono);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
}

.metric-trend.up {
  background-color: var(--success-subtle);
  color: var(--success-text);
}

.metric-trend.down {
  background-color: var(--error-subtle);
  color: var(--error-text);
}

.metric-trend.neutral {
  background-color: var(--bg-hover);
  color: var(--text-muted);
}

.metric-footer {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-subtle);
}

/* Chart Card Layout */
.chart-card {
  grid-column: span 12;
}

@media (min-width: 1024px) {
  .chart-card.span-8 { grid-column: span 8; }
  .chart-card.span-4 { grid-column: span 4; }
  .chart-card.span-6 { grid-column: span 6; }
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

.chart-title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.chart-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.chart-container {
  width: 100%;
  height: 280px;
  position: relative;
  margin-top: var(--space-3);
}

/* --------------------------------------------------------------------------
   7. ENTERPRISE APP TABLE
   -------------------------------------------------------------------------- */
.table-card {
  padding: 0;
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-default);
  flex-wrap: wrap;
}

.table-search-box {
  position: relative;
  width: 280px;
}

.table-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.table-search-input {
  width: 100%;
  padding: 7px 10px 7px 34px;
  background-color: var(--bg-main);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--text-primary);
  transition: border-color var(--transition-fast);
}

.table-search-input:focus {
  border-color: var(--primary);
  outline: none;
  background-color: var(--bg-surface);
}

.table-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.table-wrapper {
  width: 100%;
  overflow-x: auto;
}

.app-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: var(--text-sm);
}

.app-table th {
  background-color: var(--bg-subtle);
  color: var(--text-muted);
  font-size: var(--text-micro);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
  user-select: none;
}

.app-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: middle;
}

.app-table tbody tr {
  transition: background-color var(--transition-fast);
}

.app-table tbody tr:hover {
  background-color: var(--bg-hover);
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  background-color: var(--bg-subtle);
  border-top: 1px solid var(--border-default);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   8. STATUS BADGES & PILLS
   -------------------------------------------------------------------------- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-micro);
  font-weight: var(--weight-medium);
  line-height: 1;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.status-active, .status-success {
  background-color: var(--success-subtle);
  color: var(--success-text);
}
.status-active .status-dot, .status-success .status-dot {
  background-color: var(--success);
}

.status-warning, .status-processing {
  background-color: var(--warning-subtle);
  color: var(--warning-text);
}
.status-warning .status-dot, .status-processing .status-dot {
  background-color: var(--warning);
}

.status-error, .status-failed {
  background-color: var(--error-subtle);
  color: var(--error-text);
}
.status-error .status-dot, .status-failed .status-dot {
  background-color: var(--error);
}

.status-info, .status-pending {
  background-color: var(--info-subtle);
  color: var(--info-text);
}
.status-info .status-dot, .status-pending .status-dot {
  background-color: var(--info);
}

.status-neutral, .status-disabled {
  background-color: var(--bg-hover);
  color: var(--text-muted);
}
.status-neutral .status-dot, .status-disabled .status-dot {
  background-color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   9. BUTTONS & CONTROLS
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 8px 14px;
  font-family: inherit;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 1px 2px rgba(2, 132, 197, 0.2);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.btn-secondary:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-strong);
}

.btn-danger {
  background-color: var(--error);
  color: #ffffff;
  border-color: var(--error);
}

.btn-danger:hover {
  filter: brightness(0.92);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
}

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

.btn-sm {
  padding: 4px 8px;
  font-size: var(--text-micro);
}

.btn-icon-only {
  padding: 6px;
  width: 32px;
  height: 32px;
}

/* Filter Pills Group */
.filter-pills-group {
  display: inline-flex;
  background-color: var(--bg-main);
  padding: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
}

.filter-pill {
  padding: 4px 10px;
  font-size: var(--text-micro);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-pill.active {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-weight: var(--weight-semibold);
  box-shadow: var(--shadow-sm);
}

/* --------------------------------------------------------------------------
   10. OVERLAYS: MODAL & DRAWER
   -------------------------------------------------------------------------- */
.overlay-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.overlay-backdrop.open {
  opacity: 1;
  visibility: visible;
}

/* Search Command Modal */
.command-modal {
  width: 100%;
  max-width: 560px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-overlay);
  overflow: hidden;
  transform: scale(0.95);
  transition: transform var(--transition-normal);
}

.overlay-backdrop.open .command-modal {
  transform: scale(1);
}

.command-header {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.command-input {
  width: 100%;
  background: transparent;
  border: none;
  font-size: var(--text-base);
  color: var(--text-primary);
  outline: none;
}

.command-list {
  max-height: 320px;
  overflow-y: auto;
  padding: var(--space-2);
}

.command-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  cursor: pointer;
}

.command-item:hover, .command-item.selected {
  background-color: var(--primary-subtle);
  color: var(--primary);
}

/* Notification Drawer */
.app-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  background-color: var(--bg-surface);
  border-left: 1px solid var(--border-default);
  box-shadow: var(--shadow-overlay);
  z-index: 110;
  transform: translateX(100%);
  transition: transform var(--transition-normal);
  display: flex;
  flex-direction: column;
}

.app-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.activity-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background-color: var(--bg-main);
  border: 1px solid var(--border-subtle);
}

/* --------------------------------------------------------------------------
   11. SKELETON LOADING
   -------------------------------------------------------------------------- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-hover) 25%, var(--bg-subtle) 50%, var(--bg-hover) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius-xs);
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* --------------------------------------------------------------------------
   12. RESPONSIVE BREAKPOINTS
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }

  .app-sidebar {
    position: fixed;
    left: -240px;
    transition: left var(--transition-normal);
  }

  .app-sidebar.mobile-open {
    left: 0;
  }

  .search-trigger-btn {
    min-width: 140px;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------------------------
   13. FORM CONTROLS
   Additive — extends the existing token/component vocabulary above for
   screens that need inputs, selects and file-path pickers (Motores de
   Comparação, Auditoria Biométrica). Nothing above this line was changed.
   -------------------------------------------------------------------------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

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

.form-row .form-group {
  flex: 1;
  min-width: 220px;
}

.form-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
}

.form-control,
.form-select {
  width: 100%;
  height: 38px;
  padding: 0 var(--space-3);
  background-color: var(--bg-main);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: var(--text-sm);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-control:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary);
  background-color: var(--bg-surface);
}

.form-control:disabled,
.form-select:disabled {
  color: var(--text-disabled);
  cursor: not-allowed;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-8);
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* File / folder path picker row: read-only path display + trigger button */
.path-picker {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.path-picker-display {
  flex: 1;
  min-width: 0;
  height: 38px;
  display: flex;
  align-items: center;
  padding: 0 var(--space-3);
  background-color: var(--bg-main);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.path-picker-display.has-value {
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   14. MODAL DIALOG
   Reuses .overlay-backdrop (already defined above) as the backdrop/open
   toggle mechanism — this only adds the centered dialog surface itself.
   -------------------------------------------------------------------------- */
.app-modal {
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-overlay);
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  transition: transform var(--transition-normal);
  overflow: hidden;
}

.overlay-backdrop.open .app-modal {
  transform: scale(1);
}

.app-modal.modal-lg {
  max-width: 800px;
}

/* Fills the viewport with a safe gutter on every side — used by the
   Transações processing popup, which needs room for the tree + summary
   instead of a small centered dialog. */
.app-modal.modal-fullbleed {
  width: calc(100vw - var(--space-8) * 2);
  max-width: calc(100vw - var(--space-8) * 2);
  height: calc(100vh - var(--space-8) * 2);
  max-height: calc(100vh - var(--space-8) * 2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-default);
  flex-shrink: 0;
}

.modal-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.modal-body {
  padding: var(--space-5);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  flex: 1 1 auto;
  min-height: 0;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-default);
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   15. PROGRESS BAR
   -------------------------------------------------------------------------- */
.app-progress-container {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.app-progress {
  flex: 1;
  height: 6px;
  background-color: var(--bg-hover);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.app-progress-fill {
  width: 100%;
  height: 100%;
  background-color: var(--primary);
  border-radius: var(--radius-full);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--transition-normal);
}

.app-progress-fill.success { background-color: var(--success); }
.app-progress-fill.error { background-color: var(--error); }

/* Larger, more prominent variant — Transações processing popup. */
.app-progress.app-progress-lg {
  height: 12px;
}

.app-progress-lg .app-progress-fill {
  background-image: linear-gradient(90deg, var(--primary) 0%, var(--primary-hover) 100%);
}

.progress-meta-badge {
  font-family: var(--font-mono);
  font-size: var(--text-micro);
  color: var(--text-muted);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   16. SCORE / METRIC BADGES
   -------------------------------------------------------------------------- */
.badge-score {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   17. ENGINE INFO PANEL (details disclosure inside a card)
   -------------------------------------------------------------------------- */
.engine-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
}

.engine-info-row:last-child {
  border-bottom: none;
}

.engine-info-label {
  color: var(--text-muted);
}

.engine-info-value {
  color: var(--text-primary);
  font-weight: var(--weight-medium);
  text-align: right;
}

/* --------------------------------------------------------------------------
   18. EMPTY STATE
   -------------------------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--space-3);
  padding: var(--space-12) var(--space-6);
  color: var(--text-muted);
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  color: var(--text-disabled);
}

.empty-state-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
}

.empty-state-description {
  font-size: var(--text-xs);
  max-width: 360px;
}

/* --------------------------------------------------------------------------
   19. FIELD HELP TOOLTIP (Configurações screen)
   Shown by src/js/pages/settings.js on mousemove-stop, not plain :hover —
   see the .tooltip-visible toggle class.
   -------------------------------------------------------------------------- */
.field-label-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.field-help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background-color: var(--bg-hover);
  color: var(--text-muted);
  font-size: var(--text-nano);
  font-weight: var(--weight-semibold);
  cursor: help;
  flex-shrink: 0;
  position: relative;
  user-select: none;
}

.field-help-icon.tooltip-visible {
  background-color: var(--primary-subtle);
  color: var(--primary);
}

.field-help-tooltip {
  position: absolute;
  z-index: 60;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  width: 260px;
  padding: var(--space-3);
  background-color: var(--text-primary);
  color: var(--bg-surface);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: 1.5;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-overlay);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.field-help-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--text-primary);
}

.field-help-icon.tooltip-visible .field-help-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* --------------------------------------------------------------------------
   20. SECTION DIVIDER (Configurações screen groups fields into named blocks)
   -------------------------------------------------------------------------- */
.settings-section-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}

.settings-section-description {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: -4px;
}

.engine-checkbox-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.engine-checkbox-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background-color: var(--bg-main);
}

/* --------------------------------------------------------------------------
   19. TRANSAÇÕES TREE VIEW (cadastro/transação hierarchy + final report)
   -------------------------------------------------------------------------- */
.tree-row-group td {
  background-color: var(--bg-subtle);
  font-weight: var(--weight-semibold);
}

.tree-row-child td {
  font-size: var(--text-xs);
}

.tree-row-child.tree-row-hidden {
  display: none;
}

/* "Cursor" — the row currently being processed, so the user can follow the
   run line by line as it descends the tree. */
.tree-row-child.tree-row-active td {
  background-color: var(--primary-subtle);
}

td[data-engine-cell] {
  text-align: center;
}

.tree-engine-name-cell {
  text-align: center;
  font-size: var(--text-micro);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.tree-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: transform var(--transition-fast), background-color var(--transition-fast);
}

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

.tree-toggle-btn.collapsed svg {
  transform: rotate(-90deg);
}

.tree-toggle-btn svg {
  transition: transform var(--transition-fast);
}

.tree-cell-indent {
  padding-left: var(--space-6);
  color: var(--text-muted);
}

.engine-score-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.engine-score-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-size: var(--text-micro);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
  white-space: nowrap;
}

.report-summary-line {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  white-space: pre-wrap;
  line-height: 1.7;
  color: var(--text-secondary);
}

.report-textarea {
  width: 100%;
  flex: 1 1 auto;
  min-height: 320px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.7;
  color: var(--text-primary);
  background-color: var(--bg-main);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
}

.report-group-block {
  margin-top: var(--space-3);
}

.report-group-header {
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.report-line-item {
  padding-left: var(--space-5);
  color: var(--text-secondary);
}

.engine-score-cell {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-micro);
}

.image-compare-row {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.image-compare-col {
  flex: 1 1 260px;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.image-compare-col img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background-color: var(--bg-subtle);
}
