:root {
  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  --color-primary-light: #dbeafe;
  --color-secondary: #6d28d9;
  --color-secondary-light: #ede9fe;
  --color-gray-50: #f9fafb;
  --color-gray-100: #f3f4f6;
  --color-gray-200: #e5e7eb;
  --color-gray-300: #d1d5db;
  --color-gray-400: #9ca3af;
  --color-gray-500: #6b7280;
  --color-gray-600: #4b5563;
  --color-gray-700: #374151;
  --color-gray-800: #1f2937;
  --color-gray-900: #111827;
  --color-success: #10b981;
  --color-success-light: #d1fae5;
  --color-danger: #ef4444;
  --color-danger-light: #fee2e2;
  --color-warning: #f59e0b;
  --color-warning-light: #fef3c7;
  --color-white: #ffffff;
  --border-radius-sm: 6px;
  --border-radius-md: 8px;
  --border-radius-lg: 8px;
  --spacing-1: 0.25rem;
  --spacing-2: 0.5rem;
  --spacing-3: 0.75rem;
  --spacing-4: 1rem;
  --surface-page: #f6f8fb;
  --surface-card: #ffffff;
  --surface-card-muted: #f9fafb;
  --surface-input: #ffffff;
  --surface-menu: #111827;
  --border-subtle: #e5e7eb;
  --border-strong: #d1d5db;
  --text-main: #111827;
  --text-soft: #4b5563;
  --text-muted: #6b7280;
  --focus-ring: rgba(37, 99, 235, 0.18);
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 24px rgba(15, 23, 42, 0.06);
  --shadow-card-hover: 0 14px 30px rgba(15, 23, 42, 0.09);
  --shadow-menu: 0 18px 40px rgba(15, 23, 42, 0.18);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --color-gray-50: #0f172a;
  --color-gray-100: #111827;
  --color-gray-200: #1f2937;
  --color-gray-300: #334155;
  --color-gray-400: #64748b;
  --color-gray-500: #94a3b8;
  --color-gray-600: #cbd5e1;
  --color-gray-700: #e2e8f0;
  --color-gray-800: #f1f5f9;
  --color-gray-900: #f8fafc;
  --color-primary-light: rgba(59, 130, 246, 0.18);
  --color-secondary-light: rgba(109, 40, 217, 0.18);
  --color-success-light: rgba(16, 185, 129, 0.16);
  --color-danger-light: rgba(239, 68, 68, 0.16);
  --color-warning-light: rgba(245, 158, 11, 0.16);
  --surface-page: #0b1120;
  --surface-card: #111827;
  --surface-card-muted: #0f172a;
  --surface-input: #0f172a;
  --surface-menu: #111827;
  --border-subtle: #243044;
  --border-strong: #334155;
  --text-main: #f8fafc;
  --text-soft: #cbd5e1;
  --text-muted: #94a3b8;
  --focus-ring: rgba(96, 165, 250, 0.22);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.2), 0 18px 34px rgba(0, 0, 0, 0.22);
  --shadow-card-hover: 0 20px 42px rgba(0, 0, 0, 0.28);
  --shadow-menu: 0 24px 48px rgba(0, 0, 0, 0.34);
}

html,
body {
  background: var(--surface-page) !important;
  color: var(--text-main);
}

body {
  transition: background-color 180ms ease, color 180ms ease;
}

.main-content,
.content-wrapper,
.container {
  color: var(--text-main);
}

.navbar-shiai {
  background: #111827 !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16) !important;
}

.navbar-shiai .nav-link {
  border-radius: 8px !important;
}

.navbar-shiai .dropdown-menu,
.dropdown-menu {
  background: var(--surface-menu) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 14px !important;
  box-shadow: var(--shadow-menu) !important;
  padding: 8px !important;
  overflow: hidden;
}

.navbar-shiai .dropdown-item,
.dropdown-item {
  border-radius: 10px !important;
  color: rgba(255, 255, 255, 0.9) !important;
  margin: 2px 0;
  padding: 10px 12px !important;
}

.navbar-shiai .dropdown-item:hover,
.navbar-shiai .dropdown-item:focus,
.dropdown-item:hover,
.dropdown-item:focus {
  background: rgba(59, 130, 246, 0.18) !important;
  color: #ffffff !important;
}

.navbar-shiai .dropdown-item.active,
.dropdown-item.active {
  background: rgba(59, 130, 246, 0.26) !important;
  color: #ffffff !important;
}

.dropdown-divider {
  border-color: rgba(255, 255, 255, 0.1) !important;
  margin: 8px 4px !important;
}

.theme-toggle {
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  font-size: 0.875rem;
  font-weight: 700;
  gap: 8px;
  min-height: 38px;
  padding: 8px 12px;
  transition: background 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.26);
  transform: translateY(-1px);
}

.theme-toggle svg {
  height: 16px;
  width: 16px;
}

.theme-toggle .theme-toggle-night,
html[data-theme="dark"] .theme-toggle .theme-toggle-day {
  display: inline-flex;
}

.theme-toggle .theme-toggle-day,
html[data-theme="dark"] .theme-toggle .theme-toggle-night {
  display: none;
}

.sidebar .theme-toggle {
  justify-content: flex-start;
  margin: 10px 12px;
  width: calc(100% - 24px);
}

.card,
.stat-card,
.table-container,
.modal,
.commercial-metric,
.pricing-card,
.faq-item,
.dash-card,
.status-meta-card,
.ranking-item,
.empty-box {
  background: var(--surface-card) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 8px !important;
  box-shadow: var(--shadow-card) !important;
}

.card:hover,
.stat-card:hover,
.pricing-card:hover,
.faq-item:hover,
.dash-card:hover {
  box-shadow: var(--shadow-card-hover) !important;
  transform: none !important;
}

.card-header,
.modal-header {
  background: var(--surface-card) !important;
  border-bottom: 1px solid var(--border-subtle) !important;
}

.card-footer,
.modal-footer,
.table thead {
  background: var(--surface-card-muted) !important;
  border-color: var(--border-subtle) !important;
}

.card-title,
.page-title,
.modal-title,
.stat-card-value,
.empty-state-title,
.font-bold,
.dash-title,
.kpi-value,
.flow-title,
.section-title,
.status-meta-value,
.ranking-name,
h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--text-main) !important;
}

.page-description,
.empty-state-description,
.text-gray-600,
.text-gray-500,
.stat-card-title,
.stat-card-change,
.dash-subtitle,
.dash-profile-role,
.kpi-label,
.flow-desc,
.status-meta-label,
.ranking-meta,
.dash-footer,
small {
  color: var(--text-muted) !important;
}

.dash-profile-name,
.status-row,
.ranking-item,
.sem-chave-meta {
  color: var(--text-soft) !important;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea,
.form-input,
.form-select,
.form-textarea,
.form-control {
  background-color: var(--surface-input) !important;
  border: 1px solid var(--border-strong) !important;
  border-radius: 8px !important;
  color: var(--text-main) !important;
  box-shadow: none !important;
}

select,
.form-select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 13px) calc(50% - 3px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 42px !important;
}

input:focus,
select:focus,
textarea:focus,
.form-control:focus,
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--color-primary) !important;
  box-shadow: 0 0 0 4px var(--focus-ring) !important;
  outline: none !important;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted) !important;
}

.btn {
  border-radius: 8px !important;
  font-weight: 700 !important;
}

.btn-secondary,
.btn-ghost {
  background: var(--surface-card-muted) !important;
  border: 1px solid var(--border-subtle) !important;
  color: var(--text-soft) !important;
}

.btn-secondary:hover,
.btn-ghost:hover {
  background: var(--color-primary-light) !important;
  color: var(--text-main) !important;
}

.table {
  color: var(--text-main);
}

.table th {
  border-color: var(--border-subtle) !important;
  color: var(--text-muted) !important;
}

.table td {
  border-color: var(--border-subtle) !important;
  color: var(--text-soft) !important;
}

.table tbody tr:hover {
  background: var(--surface-card-muted) !important;
}

.dash-logo,
.kpi-icon,
.flow-icon,
.ranking-rank {
  background: var(--color-primary-light) !important;
  border-color: var(--border-subtle) !important;
  color: var(--color-primary) !important;
}

.progress-bar {
  background: var(--surface-card-muted) !important;
}

html[data-theme="dark"] .status-meta-card.is-remanejado,
html[data-theme="dark"] .sem-chave-item,
html[data-theme="dark"] .alert-item.is-warning {
  background: rgba(245, 158, 11, 0.12) !important;
  border-color: rgba(245, 158, 11, 0.34) !important;
  color: #fbbf24 !important;
}

html[data-theme="dark"] .status-meta-card.is-desclassificado,
html[data-theme="dark"] .alert-item {
  background: rgba(239, 68, 68, 0.12) !important;
  border-color: rgba(239, 68, 68, 0.34) !important;
  color: #fca5a5 !important;
}

html[data-theme="dark"] .alert-item.is-success {
  background: rgba(16, 185, 129, 0.12) !important;
  border-color: rgba(16, 185, 129, 0.34) !important;
  color: #86efac !important;
}

html[data-theme="dark"] .status-meta-card.is-remanejado .status-meta-value,
html[data-theme="dark"] .sem-chave-nome {
  color: #fbbf24 !important;
}

html[data-theme="dark"] .status-meta-card.is-desclassificado .status-meta-value {
  color: #fca5a5 !important;
}

html[data-theme="dark"] .card,
html[data-theme="dark"] .dash-card,
html[data-theme="dark"] .finance-metric,
html[data-theme="dark"] .commercial-metric,
html[data-theme="dark"] .table-container,
html[data-theme="dark"] .ranking-table-wrapper,
html[data-theme="dark"] .scoring-card,
html[data-theme="dark"] .ranking-item,
html[data-theme="dark"] .list-item,
html[data-theme="dark"] .modal,
html[data-theme="dark"] .empty-box {
  background: var(--surface-card) !important;
  border-color: var(--border-subtle) !important;
  color: var(--text-main) !important;
}

html[data-theme="dark"] .card-header,
html[data-theme="dark"] .card-body,
html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-body {
  background: var(--surface-card) !important;
  color: var(--text-main) !important;
}

html[data-theme="dark"] .card-footer,
html[data-theme="dark"] .modal-footer,
html[data-theme="dark"] .ranking-table thead,
html[data-theme="dark"] .table thead,
html[data-theme="dark"] .scoring-item,
html[data-theme="dark"] .status-meta-card,
html[data-theme="dark"] .empty-box {
  background: var(--surface-card-muted) !important;
  border-color: var(--border-subtle) !important;
}

html[data-theme="dark"] table,
html[data-theme="dark"] .table,
html[data-theme="dark"] .ranking-table {
  background: var(--surface-card) !important;
  color: var(--text-main) !important;
}

html[data-theme="dark"] .table th,
html[data-theme="dark"] .table td,
html[data-theme="dark"] .ranking-table th,
html[data-theme="dark"] .ranking-table td {
  border-color: var(--border-subtle) !important;
}

html[data-theme="dark"] .table tbody tr,
html[data-theme="dark"] .table tbody td,
html[data-theme="dark"] .ranking-table tbody tr,
html[data-theme="dark"] .ranking-table tbody td {
  background: var(--surface-card) !important;
}

html[data-theme="dark"] .table thead tr,
html[data-theme="dark"] .table thead th,
html[data-theme="dark"] .ranking-table thead tr,
html[data-theme="dark"] .ranking-table thead th {
  background: var(--surface-card-muted) !important;
}

html[data-theme="dark"] .table th,
html[data-theme="dark"] .ranking-table th {
  color: var(--text-muted) !important;
}

html[data-theme="dark"] .table td,
html[data-theme="dark"] .ranking-table td,
html[data-theme="dark"] .muted-row {
  color: var(--text-soft) !important;
}

html[data-theme="dark"] .table tbody tr,
html[data-theme="dark"] .ranking-table tbody tr {
  border-color: var(--border-subtle) !important;
}

html[data-theme="dark"] .table tbody tr:hover,
html[data-theme="dark"] .ranking-table tbody tr:hover {
  background: var(--surface-card-muted) !important;
}

html[data-theme="dark"] .ranking-title,
html[data-theme="dark"] .ranking-name,
html[data-theme="dark"] .scoring-title,
html[data-theme="dark"] .scoring-label,
html[data-theme="dark"] .finance-metric-value,
html[data-theme="dark"] .finance-metric-label,
html[data-theme="dark"] .card-title,
html[data-theme="dark"] .list-item-title {
  color: var(--text-main) !important;
}

html[data-theme="dark"] .ranking-subtitle,
html[data-theme="dark"] .ranking-meta,
html[data-theme="dark"] .scoring-desc,
html[data-theme="dark"] .finance-metric-note,
html[data-theme="dark"] .list-item-subtitle {
  color: var(--text-muted) !important;
}

.alert {
  border-radius: 8px !important;
  box-shadow: none !important;
}

.alert-info,
.alert-secondary {
  background: var(--color-primary-light) !important;
  border-color: rgba(59, 130, 246, 0.3) !important;
  color: var(--text-main) !important;
}

.badge {
  border-radius: 999px !important;
  font-weight: 700 !important;
}

.status-text {
  letter-spacing: 0;
}

.status-active {
  background: rgba(16, 185, 129, 0.14) !important;
  border: 1px solid rgba(16, 185, 129, 0.24);
  color: #047857 !important;
}

.status-inactive {
  background: rgba(239, 68, 68, 0.12) !important;
  border: 1px solid rgba(239, 68, 68, 0.24);
  color: #b91c1c !important;
}

html[data-theme="dark"] .status-active {
  color: #6ee7b7 !important;
}

html[data-theme="dark"] .status-inactive {
  color: #fca5a5 !important;
}

.cash-flow {
  align-items: center;
  display: inline-flex;
  gap: 0.35rem;
  font-variant-numeric: tabular-nums;
}

.cash-flow::before {
  font-family: "Font Awesome 6 Free";
  font-size: 0.72em;
  font-weight: 900;
  opacity: 0.9;
}

.cash-in {
  color: #059669 !important;
}

.cash-in::before {
  content: "\f063";
}

.cash-out {
  color: #dc2626 !important;
}

.cash-out::before {
  content: "\f062";
}

.cash-pending {
  color: #d97706 !important;
}

.cash-pending::before {
  content: "\f017";
}

html[data-theme="dark"] .cash-in {
  color: #6ee7b7 !important;
}

html[data-theme="dark"] .cash-out {
  color: #fca5a5 !important;
}

html[data-theme="dark"] .cash-pending {
  color: #fbbf24 !important;
}

.table th:last-child,
.table td:last-child {
  text-align: center;
}

.table-action-group,
.chave-acoes,
.list-item-actions {
  align-items: center;
  display: inline-flex !important;
  flex-wrap: wrap;
  gap: 0.5rem !important;
  justify-content: center;
}

.table-action-btn {
  align-items: center !important;
  aspect-ratio: 1;
  border-radius: 8px !important;
  display: inline-flex !important;
  height: 36px !important;
  justify-content: center !important;
  min-height: 36px !important;
  min-width: 36px !important;
  padding: 0 !important;
  width: 36px !important;
}

.table-action-btn i {
  font-size: 0.92rem;
  line-height: 1;
}

.table-action-btn.has-action-text {
  aspect-ratio: auto;
  min-width: 0 !important;
  padding: 0 0.75rem !important;
  width: auto !important;
}

.modal-overlay {
  background: rgba(15, 23, 42, 0.58) !important;
  backdrop-filter: blur(3px);
}

html[data-theme="dark"] .bg-white,
html[data-theme="dark"] [style*="background: #ffffff"],
html[data-theme="dark"] [style*="background:#ffffff"],
html[data-theme="dark"] [style*="background: white"],
html[data-theme="dark"] [style*="background:white"],
html[data-theme="dark"] [style*="background-color: #ffffff"],
html[data-theme="dark"] [style*="background-color:#ffffff"],
html[data-theme="dark"] [style*="background-color: white"],
html[data-theme="dark"] [style*="background-color:white"] {
  background: var(--surface-card) !important;
}

html[data-theme="dark"] .text-dark,
html[data-theme="dark"] .text-gray-700,
html[data-theme="dark"] .text-gray-800,
html[data-theme="dark"] .text-gray-900 {
  color: var(--text-main) !important;
}

@media (max-width: 767px) {
  .theme-toggle-label {
    display: none;
  }

  .sidebar .theme-toggle-label {
    display: inline;
  }
}
