/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 7px 14px;
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--text);
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease);
  white-space: nowrap;
  min-height: 36px;
  user-select: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; stroke-width: 2; }

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

.btn-secondary, .btn.btn-outline-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover, .btn.btn-outline-secondary:hover { background: var(--surface-2); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger, .btn.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover, .btn.btn-danger:hover { filter: brightness(0.95); }

.btn-success, .btn.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.btn-success:hover, .btn.btn-success:hover { filter: brightness(0.95); }

.btn.btn-warning {
  background: var(--warning);
  color: #fff;
  border-color: var(--warning);
}

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

.btn.btn-outline-success {
  background: transparent;
  color: var(--success-text);
  border-color: var(--success);
}
.btn.btn-outline-success:hover { background: var(--success-soft); }

.btn-sm, .btn.btn-sm {
  padding: 4px 10px;
  font-size: var(--text-xs);
  min-height: 28px;
}
.btn-lg {
  padding: 10px 20px;
  font-size: var(--text-md);
  min-height: 44px;
}
.btn-block, .w-100 { width: 100%; justify-content: center; }
.d-inline { display: inline-flex; }

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-body {
  padding: var(--space-5);
}
.card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.card-header h3, .card-header h4 { margin: 0; }
.card-title {
  font-size: var(--text-md);
  font-weight: 600;
  margin: 0 0 var(--space-2);
}

/* KPI Cards */
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  transition: border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.kpi-card[href]:hover, a.kpi-card:hover {
  border-color: var(--border-strong);
  text-decoration: none;
}
.kpi-card .kpi-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  display: flex; align-items: center; gap: var(--space-2);
}
.kpi-card .kpi-label svg { width: 14px; height: 14px; }
.kpi-card .kpi-value {
  font-size: var(--text-3xl);
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
}
.kpi-card .kpi-foot {
  font-size: var(--text-xs);
  color: var(--text-muted);
  display: flex; align-items: center; gap: 4px;
}
.kpi-card.tone-warning { border-left: 3px solid var(--warning); }
.kpi-card.tone-danger  { border-left: 3px solid var(--danger); }
.kpi-card.tone-success { border-left: 3px solid var(--success); }
.kpi-card.tone-info    { border-left: 3px solid var(--info); }
.kpi-card.tone-primary { border-left: 3px solid var(--primary); }

/* Old Bootstrap border-* compat */
.card.border-warning { border-left: 3px solid var(--warning); }
.card.border-danger  { border-left: 3px solid var(--danger); }
.card.border-success { border-left: 3px solid var(--success); }
.card.border-info    { border-left: 3px solid var(--info); }
.card.border-primary { border-left: 3px solid var(--primary); }
.display-6 { font-size: var(--text-3xl); font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; color: var(--text); }
.card-body h5, .card-body h6 { color: var(--text-muted); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; margin-bottom: var(--space-2); }

/* ===== Tables ===== */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-sm);
}
.table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table.table-striped tbody tr:nth-child(odd) { background: transparent; }
.table.table-striped tbody tr:nth-child(odd):hover { background: var(--surface-2); }
.table.table-sm thead th { padding: var(--space-2) var(--space-3); }
.table.table-sm tbody td { padding: var(--space-2) var(--space-3); }
.table .text-nowrap { white-space: nowrap; }
.table code { color: var(--text); background: var(--surface-2); padding: 2px 6px; border-radius: var(--radius-sm); }
.table small { color: var(--text-muted); }
.table-empty {
  padding: var(--space-12) var(--space-4);
  text-align: center;
  color: var(--text-muted);
}
.align-middle td, .align-middle th { vertical-align: middle; }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: var(--text-xs);
  font-weight: 500;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  color: var(--text);
  white-space: nowrap;
  line-height: 1.5;
}
.badge.bg-success, .badge-success {
  background: var(--success-soft);
  color: var(--success-text);
}
.badge.bg-danger, .badge-danger {
  background: var(--danger-soft);
  color: var(--danger-text);
}
.badge.bg-warning, .badge-warning {
  background: var(--warning-soft);
  color: var(--warning-text);
}
.badge.bg-info, .badge-info {
  background: var(--info-soft);
  color: var(--info-text);
}
.badge.bg-secondary, .badge-secondary {
  background: var(--surface-3);
  color: var(--text-muted);
}
.badge.bg-dark { background: var(--surface-3); color: var(--text); }
.badge.bg-light { background: var(--surface-2); color: var(--text-muted); }

/* ===== Forms ===== */
.form-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.form-control, .form-select, input.form-control, select.form-select, textarea.form-control,
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], textarea, select {
  display: block;
  width: 100%;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: var(--text-sm);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.form-control:focus, .form-select:focus,
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}
.form-control::placeholder { color: var(--text-subtle); }
.form-control.form-control-sm, input.form-control-sm, .form-select-sm {
  padding: 4px 8px;
  font-size: var(--text-xs);
}
.form-helper { margin-top: 4px; color: var(--text-muted); font-size: var(--text-xs); }
.form-error { color: var(--danger); font-size: var(--text-xs); margin-top: 4px; }
.col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-8, .col-md-12 { display: flex; flex-direction: column; }

/* Bootstrap row/col compat (mínimo) */
.row { display: flex; flex-wrap: wrap; gap: var(--space-3); margin: 0; }
.row > [class^="col-"] { flex: 1 1 auto; padding: 0; }
.row.g-2 { gap: var(--space-2); }
.row.g-3 { gap: var(--space-3); }
.col-md-1 { flex-basis: calc(8.333% - var(--space-3)); }
.col-md-2 { flex-basis: calc(16.66% - var(--space-3)); }
.col-md-3 { flex-basis: calc(25% - var(--space-3)); }
.col-md-4 { flex-basis: calc(33.33% - var(--space-3)); }
.col-md-5 { flex-basis: calc(41.66% - var(--space-3)); }
.col-md-6 { flex-basis: calc(50% - var(--space-3)); }
.col-md-8 { flex-basis: calc(66.66% - var(--space-3)); }
.col-md-12 { flex-basis: 100%; }
@media (max-width: 700px) {
  .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-8 { flex-basis: 100%; }
}

/* ===== Alerts ===== */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid;
  display: flex; align-items: flex-start; gap: var(--space-3);
  font-size: var(--text-sm);
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; }
.alert.alert-info, .alert-info {
  background: var(--info-soft);
  border-color: transparent;
  color: var(--info-text);
}
.alert.alert-warning, .alert-warning {
  background: var(--warning-soft);
  border-color: transparent;
  color: var(--warning-text);
}
.alert.alert-danger {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger-text);
}
.alert.alert-success {
  background: var(--success-soft);
  border-color: transparent;
  color: var(--success-text);
}
.alert.py-1 { padding: 4px var(--space-3); }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base) var(--ease);
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.modal-dialog {
  background: var(--surface);
  border-radius: var(--radius-xl);
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border);
  transform: scale(0.96) translateY(8px);
  opacity: 0;
  transition: transform var(--t-base) var(--ease-out), opacity var(--t-base) var(--ease);
}
.modal-overlay.open .modal-dialog {
  transform: scale(1) translateY(0);
  opacity: 1;
}
.modal-header {
  padding: var(--space-5) var(--space-5) 0;
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3);
}
.modal-header h3 { font-size: var(--text-lg); margin: 0; }
.modal-body {
  padding: var(--space-3) var(--space-5) var(--space-5);
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}
.modal-footer {
  padding: var(--space-3) var(--space-5) var(--space-5);
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
}
.modal-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-bottom: var(--space-3);
}
.modal-icon.danger { background: var(--danger-soft); color: var(--danger); }
.modal-icon.warning { background: var(--warning-soft); color: var(--warning); }
.modal-icon.primary { background: var(--primary-soft); color: var(--primary); }
.modal-icon svg { width: 20px; height: 20px; }

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  z-index: var(--z-toast);
  display: flex; flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
  max-width: 420px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-3) var(--space-4);
  display: flex; align-items: flex-start; gap: var(--space-3);
  font-size: var(--text-sm);
  pointer-events: auto;
  transform: translateX(110%);
  opacity: 0;
  transition: transform var(--t-base) var(--ease-out), opacity var(--t-base) var(--ease);
  min-width: 280px;
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast.hide { transform: translateX(110%); opacity: 0; }
.toast-icon {
  width: 22px; height: 22px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
}
.toast-icon svg { width: 16px; height: 16px; }
.toast.success .toast-icon { background: var(--success-soft); color: var(--success); }
.toast.error   .toast-icon { background: var(--danger-soft); color: var(--danger); }
.toast.warning .toast-icon { background: var(--warning-soft); color: var(--warning); }
.toast.info    .toast-icon { background: var(--info-soft); color: var(--info); }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-weight: 600; color: var(--text); margin-bottom: 2px; }
.toast-message { color: var(--text-muted); font-size: var(--text-xs); line-height: var(--leading-snug); }
.toast-close {
  color: var(--text-subtle);
  padding: 2px;
  line-height: 1;
}
.toast-close:hover { color: var(--text); }
.toast-close svg { width: 14px; height: 14px; }

@media (max-width: 540px) {
  .toast-container { left: var(--space-3); right: var(--space-3); max-width: none; bottom: var(--space-3); }
}

/* ===== Vertical rhythm para templates legacy (sem section/card wrapper) ===== */
.main-content > h1 + table,
.main-content > h1 + .table,
.main-content > h1 + .alert,
.main-content > h1 + form,
.main-content > h1 + p,
.main-content > h1 + .row,
.main-content > h2 + table,
.main-content > h2 + .alert,
.main-content > h2 + form,
.main-content > h2 + p { margin-top: 0; }

/* tabelas e alerts soltos no main devem ter respiração se vier outro depois */
.main-content > .alert + .alert,
.main-content > .alert + table,
.main-content > .alert + .card,
.main-content > p + table,
.main-content > p + .table,
.main-content > p + .card { margin-top: 0; }

/* parágrafos descritivos próximos aos títulos */
.main-content > p.text-muted,
.main-content > p { color: var(--text-muted); font-size: var(--text-sm); margin: 0; }

/* Tabela solta no main = empacotar visualmente */
.main-content > table,
.main-content > .table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* ===== Sync Widget (topbar global) ===== */
.sync-widget { position: relative; }
.sync-widget-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
.sync-widget-toggle:hover { background: var(--surface-2); color: var(--text); }
.sync-widget-toggle.is-active {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
}
.sync-widget-toggle.is-active span { color: var(--on-primary); }
.sync-widget-toggle .spinner {
  width: 12px; height: 12px;
  border-width: 1.5px;
  border-color: rgba(255,255,255,.4);
  border-top-color: #ffffff;
}
.sync-widget-pop {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-overlay);
  display: none;
  max-height: 70vh;
  overflow-y: auto;
}
.sync-widget.open .sync-widget-pop { display: block; }
.sync-widget-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--surface);
}
.sync-widget-list {
  padding: var(--space-2);
  display: flex; flex-direction: column; gap: var(--space-2);
}
.sync-widget-item {
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.sync-widget-empty {
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
}
.sync-widget-empty svg { color: var(--success); }
.sync-widget-empty p { margin: 0; }

/* Barra de progresso */
.progress-bar-wrap {
  width: 100%;
  height: 6px;
  background: var(--surface-3);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--info));
  border-radius: var(--radius-full);
  transition: width var(--t-slow) var(--ease);
  min-width: 2%;
}

@media (max-width: 540px) {
  .sync-widget-pop { width: calc(100vw - 24px); right: -12px; }
}

/* ===== Misc ===== */
.divider { height: 1px; background: var(--border); border: 0; margin: var(--space-4) 0; }
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--surface-3);
  border-top-color: var(--primary);
  border-radius: var(--radius-full);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.text-success { color: var(--success-text); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning-text); }
.text-info { color: var(--info-text); }
.text-center { text-align: center; }
.text-end { text-align: right; }
.text-decoration-none, .text-decoration-none:hover { text-decoration: none; }
.display-6 { color: var(--text); }

/* ===== Stat tiles (KPI grid) ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  transition: border-color .15s, background .15s;
}
.stat-tile:hover { border-color: var(--border-strong, var(--border)); }
.stat-tile .stat-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  font-weight: 500;
}
.stat-tile .stat-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: var(--leading-tight);
}
.stat-tile .stat-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.stat-tile.is-success { border-left: 3px solid var(--success); }
.stat-tile.is-warning { border-left: 3px solid var(--warning); }
.stat-tile.is-danger  { border-left: 3px solid var(--danger); }
.stat-tile.is-info    { border-left: 3px solid var(--info); }
.stat-tile.is-muted   { border-left: 3px solid var(--border); }
.stat-tile.is-primary { border-left: 3px solid var(--primary); }
.stat-tile .stat-value.is-success { color: var(--success-text); }
.stat-tile .stat-value.is-danger  { color: var(--danger-text); }
.stat-tile .stat-value.is-warning { color: var(--warning-text); }

/* ===== Filter bar ===== */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  align-items: end;
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-3);
}
.filter-bar .filter-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 140px;
}
.filter-bar .filter-field label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.filter-bar select,
.filter-bar input[type="text"],
.filter-bar input[type="date"] {
  height: 34px;
  padding: 0 var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--text-sm);
}
.filter-bar .filter-actions {
  display: flex;
  gap: var(--space-2);
  margin-left: auto;
}

/* ===== Form sections (grouped fieldsets) ===== */
.form-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5) var(--space-5);
  margin: 0 0 var(--space-4);
  background: var(--surface);
}
.form-section legend {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  padding: 0 var(--space-2);
  margin-left: calc(-1 * var(--space-2));
}
.form-section .section-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin: 0 0 var(--space-4);
  line-height: var(--leading-snug);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-3) var(--space-4);
}
.form-grid .form-group.col-span-2 { grid-column: span 2; }
@media (max-width: 720px) {
  .form-grid .form-group.col-span-2 { grid-column: span 1; }
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  gap: var(--space-3);
  flex-wrap: wrap;
}
.pagination .pagination-info {
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}
.pagination .pagination-controls {
  display: flex;
  gap: var(--space-1);
}
.pagination .pagination-controls a,
.pagination .pagination-controls span {
  min-width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text);
  text-decoration: none;
  background: var(--surface);
  font-variant-numeric: tabular-nums;
}
.pagination .pagination-controls a:hover { background: var(--surface-2); border-color: var(--text-muted); }
.pagination .pagination-controls .is-active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  font-weight: 600;
}
.pagination .pagination-controls .is-disabled {
  opacity: .4;
  pointer-events: none;
}
.pagination .pagination-controls .gap { border: none; background: none; cursor: default; }

/* ===== Compact metric row ===== */
.metric-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.metric-row .metric {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-1);
}
.metric-row .metric strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* Status badges com cor semântica */
.badge.status-RECEIVED   { background: var(--info-soft); color: var(--info-text); }
.badge.status-PROCESSING { background: var(--warning-soft); color: var(--warning-text); }
.badge.status-DONE       { background: var(--success-soft); color: var(--success-text); }
.badge.status-IGNORED    { background: var(--surface-2, #f1f5f9); color: var(--text-muted); }
.badge.status-FAILED     { background: var(--danger-soft); color: var(--danger-text); }

/* Truncate */
.truncate-md { max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: inline-block; vertical-align: middle; }

/* ===== Date Range Picker (componente custom) ===== */
.drp-host { position: relative; display: inline-block; }
.drp-trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 34px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: border-color .15s;
  min-width: 220px;
}
.drp-trigger:hover { border-color: var(--text-muted); }
.drp-trigger:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.drp-trigger .drp-icon { color: var(--text-muted); flex-shrink: 0; }
.drp-trigger .drp-label { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drp-trigger .drp-clear {
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
  border-radius: var(--radius-sm);
  transition: background .15s;
}
.drp-trigger .drp-clear:hover { background: var(--surface-2, #f1f5f9); color: var(--danger); }

.drp-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 1000;
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  overflow: hidden;
  min-width: 580px;
}
/* HTML attribute [hidden] precisa sobrescrever o display:flex acima */
.drp-popover[hidden] { display: none; }

.drp-presets {
  display: flex;
  flex-direction: column;
  width: 160px;
  background: var(--surface-2, #f8fafc);
  border-right: 1px solid var(--border);
  padding: var(--space-2);
  gap: 2px;
}
.drp-preset-btn {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--text);
  transition: background .12s, color .12s;
}
.drp-preset-btn:hover { background: var(--surface); }
.drp-preset-btn.is-active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
.drp-preset-custom {
  margin-top: var(--space-2);
  border-top: 1px solid var(--border);
  padding-top: var(--space-3);
  border-radius: 0;
}

.drp-calendar {
  flex: 1;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  min-width: 360px;
}
.drp-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}
.drp-cal-header .drp-month-label {
  font-weight: 600;
  font-size: var(--text-md);
  color: var(--text);
}
.drp-nav {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: var(--text-muted);
  transition: all .12s;
}
.drp-nav:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }

.drp-cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: var(--space-1);
}
.drp-cal-weekdays span {
  text-align: center;
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 500;
  padding: 4px 0;
}

.drp-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.drp-day {
  background: transparent;
  border: none;
  height: 36px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text);
  cursor: pointer;
  transition: background .12s, color .12s;
  font-variant-numeric: tabular-nums;
}
.drp-day:hover:not(.is-start):not(.is-end) { background: var(--surface-2, #f1f5f9); }
.drp-day.is-dim { color: var(--text-muted); opacity: .4; }
.drp-day.is-today { font-weight: 700; color: var(--primary); }
.drp-day.is-in-range { background: var(--primary-soft); border-radius: 0; }
.drp-day.is-start {
  background: var(--primary);
  color: white;
  font-weight: 600;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.drp-day.is-end {
  background: var(--primary);
  color: white;
  font-weight: 600;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
.drp-day.is-start.is-end {
  border-radius: var(--radius-md);
}

.drp-footer {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
}
.drp-range-text {
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.drp-apply {
  padding: 6px var(--space-4);
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background .12s;
}
.drp-apply:hover { background: var(--primary-hover); }

@media (max-width: 640px) {
  .drp-popover { flex-direction: column; min-width: 320px; }
  .drp-presets { width: 100%; border-right: none; border-bottom: 1px solid var(--border); flex-direction: row; flex-wrap: wrap; }
  .drp-preset-custom { border-top: none; padding-top: var(--space-2); margin-top: 0; }
  .drp-calendar { min-width: 0; }
}

/* ===== Date preset pills (filtros rápidos de período) ===== */
.date-presets {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-bottom: var(--space-2);
}
.date-presets .preset-btn {
  display: inline-flex;
  align-items: center;
  padding: 4px var(--space-3);
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
  line-height: 1.6;
}
.date-presets .preset-btn:hover {
  background: var(--surface-2, #f1f5f9);
  color: var(--text);
  border-color: var(--text-muted);
}
.date-presets .preset-btn.is-active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  font-weight: 600;
}
.date-range-custom {
  display: flex;
  gap: var(--space-2);
  align-items: end;
}
.date-range-custom > * { flex: 1; }

/* ===== Info tooltip (CSS-only) =====
   Uso: <span class="tip" data-tip="Texto explicativo">{{ icon('info', 12) }}</span>
   Mostra balão no hover/focus. Suporta navegação por teclado (tabindex=0).
*/
.tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: var(--space-1);
  color: var(--text-muted);
  cursor: help;
  vertical-align: middle;
  border-radius: var(--radius-full);
}
.tip:hover, .tip:focus-visible { color: var(--primary); outline: none; }
.tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--text);
  color: var(--surface);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: 400;
  line-height: var(--leading-snug);
  white-space: normal;
  width: max-content;
  max-width: 280px;
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s, transform .15s;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.tip::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
  z-index: 1000;
}
.tip:hover::after, .tip:focus-visible::after,
.tip:hover::before, .tip:focus-visible::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Health pill ===== */
.health-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 500;
  background: var(--success-soft);
  color: var(--success-text);
}
.health-pill.is-warning { background: var(--warning-soft); color: var(--warning-text); }
.health-pill.is-danger  { background: var(--danger-soft); color: var(--danger-text); }
.health-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

/* ===== Filter pills (rótulos compactos pra mostrar filtros aplicados) ===== */
.pill-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  font-family: var(--font-mono);
  line-height: 1.5;
}
.pill .pill-key { color: var(--text-muted); font-weight: 400; }
.pill .pill-sep { color: var(--text-muted); opacity: .6; }

/* Info callout (caixa explicativa "o que é isso?") */
.info-callout {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--info-soft);
  border-left: 3px solid var(--info);
  border-radius: var(--radius-md);
  color: var(--info-text);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}
.info-callout > svg { flex-shrink: 0; margin-top: 2px; }
.info-callout strong { color: var(--text); }
.info-callout code { background: rgba(0,0,0,.06); padding: 0 4px; border-radius: 3px; }

/* ===== Broker mini-card (dashboard) ===== */
.broker-mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-3);
}
.broker-mini {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  transition: border-color .15s, transform .1s;
  text-decoration: none;
  color: inherit;
  display: block;
}
.broker-mini:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}
.broker-mini .mini-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--space-2);
  gap: var(--space-2);
}
.broker-mini .mini-name { font-weight: 600; color: var(--text); font-size: var(--text-md); }
.broker-mini .mini-slug { color: var(--text-muted); font-family: var(--font-mono); font-size: var(--text-xs); }
.broker-mini .mini-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-2);
}
.broker-mini .mini-metric { text-align: center; }
.broker-mini .mini-metric .v {
  display: block;
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.broker-mini .mini-metric .l {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-top: 2px;
}
.broker-mini .mini-foot {
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px dashed var(--border);
  font-size: var(--text-xs);
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}
.text-light { color: var(--text-muted); }
