/* ATENÇÃO: design-tokens.css deve ser carregado ANTES deste arquivo.
   <link rel="stylesheet" href="/assets/css/design-tokens.css"> */

/* ============================================================
   FerruciSegMed SST SaaS — Design System v2
   Modern Clean Dashboard — Pure CSS, zero dependencies
   ============================================================ */

/* ─── CSS Variables ──────────────────────────────────────── */
/* LEGADO: Variáveis mantidas para compatibilidade. Novas variáveis devem ser definidas em design-tokens.css */
:root {
  --primary:        #30477a;
  --primary-dark:   #263862;
  --primary-light:  #e9ecf3;
  --success:        #10b981;
  --success-light:  #d1fae5;
  --danger:         #ef4444;
  --danger-light:   #fee2e2;
  --warning:        #f59e0b;
  --warning-light:  #fef3c7;
  --info:           #3b82f6;
  --info-light:     #dbeafe;
  --secondary:      #64748b;
  --dark:           #0f172a;
  --white:          #ffffff;
  --bg:             #f8fafc;
  --border:         #e2e8f0;
  --border-light:   #f1f5f9;

  --sidebar-w:      248px;
  --sidebar-collapsed: 64px;
  --topbar-h:       60px;

  --radius-sm:      6px;
  --radius:         10px;
  --radius-lg:      14px;
  --radius-xl:      20px;

  --shadow-xs:  0 1px 2px rgba(0,0,0,.05);
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow:     0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.04);
  --shadow-md:  0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.04);
  --shadow-lg:  0 20px 25px -5px rgba(0,0,0,.08), 0 10px 10px -5px rgba(0,0,0,.03);

  --font:       -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono:  'SF Mono', 'Fira Code', 'Consolas', monospace;
  --transition: 0.18s cubic-bezier(0.4,0,0.2,1);
}

/* ─── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
body { font-family: var(--font); color: var(--dark); background: var(--bg); line-height: 1.6; overflow-x: hidden; }
a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }
table { border-collapse: collapse; width: 100%; }
ul { list-style: none; }

/* ─── App Layout ─────────────────────────────────────────── */
.app-body { display: flex; min-height: 100vh; }

/* ─── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1000;
  transition: width var(--transition);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.08) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

/* Sidebar Header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  height: 64px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-logo { display: flex; align-items: center; gap: .6rem; overflow: hidden; }
.logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--primary) 0%, #4a6aa5 100%);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(48,71,122,.4);
}
.logo-text {
  font-size: .9rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.3px;
  white-space: nowrap;
}

.sidebar-toggle {
  color: #475569;
  font-size: 1rem;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: rgba(255,255,255,.08); color: #fff; }

/* Sidebar User — REMOVED (moved to topbar) */

/* Sidebar Nav */
.sidebar-nav { padding: .5rem 0 1rem; flex: 1; }

.nav-group-title {
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: #334155;
  padding: 1.1rem 1.25rem .3rem;
  white-space: nowrap;
  overflow: hidden;
}

.nav-item { margin: 1px .5rem; }

.nav-link {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .52rem .75rem;
  color: #94a3b8;
  font-size: .825rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  white-space: nowrap;
  overflow: hidden;
}
.nav-link:hover { color: #f1f5f9; background: rgba(255,255,255,.07); }
.nav-item.active .nav-link {
  color: #fff;
  background: rgba(48,71,122,.25);
  box-shadow: inset 3px 0 0 var(--primary);
}
.nav-icon {
  font-size: 1rem;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}
.nav-text { flex: 1; }
.nav-link-danger { color: #f87171; }
.nav-link-danger:hover { color: #fff; background: rgba(239,68,68,.2); }

/* ─── Main Content ───────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin var(--transition);
}

/* ─── Topbar ─────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-xs);
  overflow: visible;
}
.topbar-left { display: flex; align-items: center; gap: 1rem; }
.topbar-right { display: flex; align-items: center; gap: .6rem; }
.topbar-toggle { font-size: 1.1rem; color: var(--secondary); display: none; padding: .35rem; border-radius: var(--radius-sm); }
.topbar-toggle:hover { background: var(--bg); }

/* Breadcrumb */
.breadcrumb { display: flex; align-items: center; gap: .35rem; font-size: .82rem; }
.breadcrumb-link { color: #94a3b8; font-weight: 400; }
.breadcrumb-link:hover { color: var(--primary); }
.breadcrumb-current { color: var(--dark); font-weight: 600; }
.breadcrumb-sep { color: #cbd5e1; font-size: .7rem; }

/* ─── Profile Menu (top-right) ────────────────────────── */
.topbar-profile { position: relative; margin-left: .25rem; }
.profile-btn {
  display: flex; align-items: center; gap: .5rem;
  padding: .3rem .65rem .3rem .3rem;
  border-radius: 100px;
  background: var(--white); border: 1.5px solid var(--border);
  cursor: pointer; transition: all .2s ease;
  font-family: inherit; outline: none;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.profile-btn:hover { border-color: var(--primary); background: var(--primary-light); box-shadow: 0 2px 8px rgba(48,71,122,.1); }
.profile-btn:focus-visible { box-shadow: 0 0 0 3px rgba(48,71,122,.15); border-color: var(--primary); }
.profile-avatar-img {
  width: 34px; height: 34px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
  border: 2px solid var(--primary-light);
}
.profile-avatar-initial {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, #4a6aa5 100%);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .82rem; color: #fff; flex-shrink: 0;
  border: 2px solid var(--primary-light);
}
.profile-name { font-size: .82rem; font-weight: 600; color: var(--dark); max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.2; }
.profile-chevron { font-size: .5rem; color: var(--secondary); transition: transform .25s ease; margin-left: -.1rem; }
#profileBtn[aria-expanded="true"] .profile-chevron { transform: rotate(180deg); }

.profile-dropdown {
  display: none; position: absolute; top: calc(100% + 10px); right: -8px;
  width: min(260px, calc(100vw - 1rem)); background: var(--white);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,.12), 0 2px 10px rgba(0,0,0,.06);
  z-index: 9990; overflow: hidden;
}
.profile-dropdown.open { display: block; animation: profileSlideDown .2s ease; }
@keyframes profileSlideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

.profile-dropdown-header {
  display: flex; align-items: center; gap: .75rem;
  padding: 1rem 1.1rem; border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, var(--bg) 0%, var(--white) 100%);
}
.profile-dropdown-avatar {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  overflow: hidden; background: linear-gradient(135deg, var(--primary), #4a6aa5);
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--primary-light);
  box-shadow: 0 2px 8px rgba(48,71,122,.15);
}
.profile-dropdown-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.profile-dropdown-avatar span { font-weight: 700; font-size: 1rem; color: #fff; }
.profile-dropdown-name { font-size: .88rem; font-weight: 700; color: var(--dark); line-height: 1.3; }
.profile-dropdown-role { font-size: .72rem; color: var(--secondary); margin-top: 1px; font-weight: 500; }
.profile-dropdown-body { padding: .4rem 0; }
.profile-dropdown-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem 1.1rem; font-size: .84rem; color: var(--dark);
  transition: all .15s ease; text-decoration: none;
  font-weight: 500;
}
.profile-dropdown-item:hover { background: var(--primary-light); color: var(--primary); }
.profile-dropdown-item span { font-size: 1.05rem; width: 22px; text-align: center; flex-shrink: 0; }
.profile-dropdown-danger { color: var(--danger); }
.profile-dropdown-danger:hover { background: #fef2f2; color: var(--danger); }
.profile-dropdown-divider { border: none; border-top: 1px solid var(--border); margin: .3rem .75rem; }

/* Notifications */
.notif-btn {
  position: relative;
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  color: var(--secondary);
  transition: all .2s ease;
  background: var(--bg);
  border: 1.5px solid var(--border);
  cursor: pointer;
}
.notif-btn:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); box-shadow: 0 2px 8px rgba(48,71,122,.1); }
.notif-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--danger);
  color: #fff;
  font-size: .62rem;
  font-weight: 700;
  width: 17px; height: 17px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--white);
}
.notif-dropdown {
  position: absolute;
  top: calc(var(--topbar-h) - 4px);
  right: 1rem;
  width: 360px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,.12), 0 2px 10px rgba(0,0,0,.06);
  z-index: 9990;
  overflow: hidden;
}
.notif-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: .875rem;
  font-weight: 600;
}
.notif-header button { color: var(--primary); font-size: .78rem; font-weight: 500; }
.notif-list { max-height: 300px; overflow-y: auto; }
.notif-view-all { display: block; text-align: center; padding: .6rem; font-size: .8rem; border-top: 1px solid var(--border); color: var(--primary); font-weight: 500; }
.notif-item { padding: .75rem 1rem; border-bottom: 1px solid var(--border-light); font-size: .82rem; cursor: pointer; transition: background var(--transition); }
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: #f0f4ff; }
.notif-item-title { font-weight: 600; color: var(--dark); }
.notif-item-body { color: var(--secondary); margin-top: .1rem; }
.notif-item-time { color: #94a3b8; font-size: .72rem; margin-top: .2rem; }

/* ─── Page Content ───────────────────────────────────────── */
.page-content { flex: 1; padding: 1.75rem 1.5rem; }

.page-header {
  margin-bottom: 1.5rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}
.page-title { font-size: 1.4rem; font-weight: 700; color: var(--dark); line-height: 1.2; }
.page-sub { color: var(--secondary); font-size: .875rem; margin-top: .25rem; }

.page-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--white);
  color: #94a3b8;
  text-align: center;
  font-size: .78rem;
}

/* ─── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  gap: .75rem;
}
.card-title { font-size: .95rem; font-weight: 600; color: var(--dark); }
.card-action { font-size: .82rem; color: var(--primary); font-weight: 500; }
.card-body { padding: 1.25rem; }
.card-body.p-0 { padding: 0; }
.card-ai { border-left: 3px solid var(--primary); }
.card-danger { border-left: 3px solid var(--danger); }
.card-success { border-left: 3px solid var(--success); }
.card-warning { border-left: 3px solid var(--warning); }

/* ─── Spacing utilities ──────────────────────────────────── */
.mt-0  { margin-top: 0 !important; }
.mt-4  { margin-top: 1rem !important; }
.mt-6  { margin-top: 1.5rem !important; }
.mb-0  { margin-bottom: 0 !important; }
.mb-4  { margin-bottom: 1rem !important; }
.mb-6  { margin-bottom: 1.5rem !important; }

/* ─── KPI Grid ───────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.kpi-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  transition: box-shadow var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.kpi-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.kpi-blue::before  { background: linear-gradient(90deg, var(--primary), #818cf8); }
.kpi-green::before { background: linear-gradient(90deg, var(--success), #34d399); }
.kpi-red::before   { background: linear-gradient(90deg, var(--danger), #fb7185); }
.kpi-orange::before{ background: linear-gradient(90deg, var(--warning), #fbbf24); }
.kpi-purple::before{ background: linear-gradient(90deg, #8b5cf6, #a78bfa); }

.kpi-icon {
  font-size: 1.75rem;
  line-height: 1;
  flex-shrink: 0;
}
.kpi-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.kpi-value { font-size: 1.65rem; font-weight: 800; color: var(--dark); line-height: 1.1; letter-spacing: -1px; }
.kpi-label { font-size: .78rem; color: var(--secondary); margin-top: .3rem; font-weight: 500; }
.kpi-link  { font-size: .73rem; color: var(--primary); margin-top: .4rem; display: inline-block; font-weight: 500; line-height: 1; }
.kpi-link:hover { text-decoration: underline; }

/* ─── AI Feature Cards ───────────────────────────────────── */
.ai-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; }
.ai-feature-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.25rem;
  text-align: center;
  transition: all var(--transition);
  color: var(--dark);
}
.ai-feature-card:hover {
  background: var(--primary);
  color: #fff;
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}
.ai-icon { font-size: 2rem; margin-bottom: .6rem; display: block; }
.ai-title { font-weight: 600; font-size: .875rem; }
.ai-desc { font-size: .78rem; color: var(--secondary); margin-top: .3rem; }
.ai-feature-card:hover .ai-desc { color: rgba(255,255,255,.75); }

/* ─── Tables ─────────────────────────────────────────────── */
.table { width: 100%; font-size: .85rem; }
.table thead th {
  background: var(--bg);
  padding: .75rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--dark);
  vertical-align: middle;
}
.table tbody tr:hover td { background: var(--border-light); }
.table tbody tr:last-child td { border-bottom: none; }
.table-sm th, .table-sm td { padding: .5rem .85rem; font-size: .8rem; }

.text-center { text-align: center; }
.text-muted   { color: var(--secondary) !important; }
.text-right   { text-align: right; }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }

/* ─── Forms ──────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .825rem;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: .4rem;
}
.form-label-link { font-weight: 400; font-size: .8rem; color: var(--primary); }

.form-control,
.form-select,
.form-input,
.form-textarea {
  width: 100%;
  padding: .55rem .875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--dark);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  font-family: inherit;
}
.form-control:focus,
.form-select:focus,
.form-input:focus,
.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(48,71,122,.12);
}
.form-control.error,
.form-input.error { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(239,68,68,.1); }
.form-textarea { resize: vertical; min-height: 100px; }
.form-hint { font-size: .78rem; color: var(--secondary); margin-top: .3rem; }

.input-group { display: flex; }
.input-group .form-control,
.input-group .form-input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-addon {
  padding: .55rem .875rem;
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--bg);
  color: var(--secondary);
  font-size: .875rem;
  white-space: nowrap;
}
.form-grid { display: grid; gap: 1rem; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-check-label { display: flex; align-items: center; gap: .5rem; font-size: .875rem; font-weight: 500; cursor: pointer; }
.form-actions {
  display: flex;
  gap: .75rem;
  align-items: center;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-light);
  margin-top: 1.25rem;
  flex-wrap: wrap;
}
.required { color: var(--danger); }

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  border: 1px solid transparent;
  font-family: inherit;
  line-height: 1.5;
  min-height: 38px;
}
.btn-primary   { background: var(--primary); color: var(--white); border-color: var(--primary); }
.btn-primary:hover  { background: var(--primary-dark); border-color: var(--primary-dark); color: var(--white); box-shadow: 0 4px 10px rgba(48,71,122,.35); }
.btn-primary:active { background: var(--primary-dark); transform: translateY(1px); box-shadow: none; }
.btn-success   { background: var(--success); color: var(--white); border-color: var(--success); }
.btn-success:hover  { background: var(--color-success-600, #059669); color: var(--white); box-shadow: 0 4px 10px rgba(16,185,129,.3); }
.btn-success:active { background: var(--color-success-700, #047857); transform: translateY(1px); box-shadow: none; }
.btn-danger    { background: var(--danger); color: var(--white); border-color: var(--danger); }
.btn-danger:hover  { background: var(--color-danger-600, #dc2626); color: var(--white); }
.btn-danger:active { background: var(--color-danger-700, #b91c1c); transform: translateY(1px); }
.btn-warning   { background: var(--warning); color: var(--white); border-color: var(--warning); }
.btn-warning:hover  { background: var(--color-warning-600, #d97706); color: var(--white); }
.btn-warning:active { background: var(--color-warning-600, #d97706); transform: translateY(1px); }
.btn-outline   { background: transparent; color: var(--primary); border-color: var(--border); }
.btn-outline:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.btn-secondary { background: var(--bg); color: var(--dark); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-sm  { padding: .3rem .7rem; font-size: .78rem; }
.btn-lg  { padding: .7rem 1.5rem; font-size: .95rem; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }

/* ─── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .2em .65em;
  font-size: .72em;
  font-weight: 700;
  border-radius: 20px;
  white-space: nowrap;
  letter-spacing: .3px;
  text-transform: uppercase;
}
.badge-primary   { background: var(--primary-light); color: var(--primary-dark); }
.badge-success   { background: var(--success-light); color: var(--color-success-700, #065f46); }
.badge-danger    { background: var(--danger-light);  color: var(--color-danger-700, #991b1b); }
.badge-warning   { background: var(--warning-light); color: var(--color-warning-600, #92400e); }
.badge-info      { background: var(--info-light);    color: var(--color-info-600, #1e40af); }
.badge-secondary { background: var(--border-light);  color: var(--secondary); }

/* ─── Alerts ─────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .875rem 1.1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}
.alert-success { background: var(--success-light); color: var(--color-success-700, #065f46); border-color: var(--color-success-100, #a7f3d0); }
.alert-danger  { background: var(--danger-light);  color: var(--color-danger-700, #991b1b); border-color: var(--color-danger-100, #fecaca); }
.alert-warning { background: var(--warning-light); color: var(--color-warning-600, #92400e); border-color: var(--color-warning-100, #fde68a); }
.alert-info    { background: var(--info-light);    color: var(--color-info-600, #1e40af); border-color: var(--color-info-100, #bfdbfe); }

/* ─── Pagination ─────────────────────────────────────────── */
.pagination, .pagination-wrap {
  display: flex;
  align-items: center;
  gap: .3rem;
  padding: .875rem 1.25rem;
  border-top: 1px solid var(--border-light);
  flex-wrap: wrap;
}
.pagination-info { color: var(--secondary); margin-right: auto; font-size: .82rem; }
.page-btn, .page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px; height: 40px;
  padding: 0 .5rem;
  border-radius: var(--radius-sm);
  color: var(--secondary);
  font-size: .825rem;
  font-weight: 500;
  border: 1px solid var(--border);
  transition: all var(--transition);
  text-decoration: none;
}
.page-btn:hover, .page-btn.active,
.page-link:hover, .page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ─── Risk & Progress ────────────────────────────────────── */
.risk-score { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; }
.risk-bar { width: 100%; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.risk-bar-fill { height: 100%; border-radius: 3px; transition: width .5s ease; }

/* ─── Toasts ─────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  background: var(--dark);
  color: #fff;
  padding: .8rem 1.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: .875rem;
  font-weight: 500;
  animation: toastIn .25s ease;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: .75rem;
}
.toast-success { background: #064e3b; border-left: 3px solid var(--success); }
.toast-error   { background: #7f1d1d; border-left: 3px solid var(--danger); }
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── Filter Bar ─────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: .75rem;
  align-items: center;
  flex-wrap: wrap;
}
.search-input {
  flex: 1;
  min-width: min(220px, 100%);
  max-width: 380px;
  padding: .5rem .875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-family: inherit;
}
.search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(48,71,122,.1); }

/* ─── Stat Boxes ─────────────────────────────────────────── */
.stat-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.stat-box { flex: 1; min-width: 120px; background: var(--bg); border-radius: var(--radius); padding: 1rem; text-align: center; border: 1px solid var(--border); }
.stat-box-value { font-size: 1.5rem; font-weight: 800; }
.stat-box-label { font-size: .75rem; color: var(--secondary); margin-top: .2rem; }
.stat-box-danger { background: color-mix(in srgb, var(--danger) 8%, var(--bg)); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.stat-box-warning { background: color-mix(in srgb, var(--warning) 8%, var(--bg)); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.stat-val-danger  { color: var(--danger); }
.stat-val-warning { color: var(--warning); }
/* QR code frame */
.qr-frame { display: inline-block; padding: 12px; background: #fff; border-radius: 8px; border: 1px solid var(--border); }

/* ─── Grid Layout ────────────────────────────────────────── */
.row { display: grid; gap: 1.25rem; }
.row-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr)); margin-bottom: 1.25rem; }
.row-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); margin-bottom: 1.25rem; }
.col-md-4 { width: 100%; }
.col-md-8 { width: 100%; }
@media (min-width: 768px) {
  .row.row-cols-auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .col-wrapper { display: grid; grid-template-columns: 1fr 2fr; gap: 1.5rem; }
  .col-wrapper-half { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
}

/* ─── Page Header Bar ────────────────────────────────────── */
.page-header-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.page-header-bar h2 { font-size: 1.3rem; font-weight: 700; color: var(--dark); margin-bottom: .2rem; }
.page-header-bar .text-muted { font-size: .85rem; }

/* ─── Page Header Actions (botões) ─────────────────────── */
.page-header-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
}

/* ─── Btn AI (gradiente) ─────────────────────────────── */
.btn-ai {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  border-color: transparent;
}
.btn-ai:hover { background: linear-gradient(135deg, #4338ca, #6d28d9); color: #fff; }

/* ─── Empty State ────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3.5rem 1rem; color: var(--secondary); }
.empty-state p { font-size: .95rem; margin-bottom: .5rem; }

/* ─── Code ───────────────────────────────────────────────── */
code {
  background: var(--border-light);
  color: #4a6aa5;
  font-family: var(--font-mono);
  font-size: .82em;
  padding: .15em .45em;
  border-radius: 4px;
}

/* ─── HR ─────────────────────────────────────────────────── */
hr { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }

/* ─── Utilities ──────────────────────────────────────────── */
.d-flex          { display: flex !important; }
.d-grid          { display: grid !important; }
.align-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }
.flex-wrap       { flex-wrap: wrap; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: .75rem; }
.gap-3 { gap: 1rem; }
.h-100 { height: 100%; }
.w-100 { width: 100%; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: .25rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.p-0  { padding: 0 !important; }
.p-1  { padding: .5rem; }
.p-2  { padding: 1rem; }
.p-3  { padding: 1.5rem; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fs-sm  { font-size: .8rem; }

/* ─── Login Page ─────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.login-card {
  background: rgba(255,255,255,.97);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,.1);
}
.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.login-logo-icon {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--primary) 0%, #4a6aa5 100%);
  border-radius: var(--radius-lg);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.75rem;
  box-shadow: 0 8px 20px rgba(48,71,122,.35);
  margin-bottom: .75rem;
}
.login-logo h1 { font-size: 1.35rem; font-weight: 800; color: var(--dark); }
.login-logo p { font-size: .82rem; color: var(--secondary); margin-top: .2rem; }

/* ─── Sidebar Close button (mobile only) ─────────────────── */
.sidebar-close {
  display: none;
  color: #94a3b8;
  font-size: 1.1rem;
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  align-items: center; justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.sidebar-close:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ─── Sidebar Overlay (mobile) ───────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 999;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  transition: opacity .25s;
}
.sidebar-overlay.active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ─── Responsive Table Wrapper ───────────────────────────── */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-responsive .table { min-width: 600px; }

/* ─── Responsive ─────────────────────────────────────────── */

/* Tablet landscape */
@media (max-width: 1024px) {
  .row-3 { grid-template-columns: 1fr 1fr; }
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
  .ai-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .col-wrapper { grid-template-columns: 1fr !important; }
  .col-wrapper-half { grid-template-columns: 1fr !important; }
}

/* Tablet portrait */
@media (max-width: 768px) {
  /* Sidebar mobile drawer */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
    transition: transform .3s cubic-bezier(0.4,0,0.2,1);
    width: min(280px, 85vw);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.3);
  }
  .sidebar-close { display: flex; }
  .sidebar-toggle { display: none; }
  .main-content { margin-left: 0; }
  .topbar-toggle { display: flex; }

  /* Grid layouts */
  .row-2, .row-3 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .ai-grid { grid-template-columns: repeat(2, 1fr); }

  /* Notification dropdown full width */
  .notif-dropdown { right: .5rem; width: calc(100vw - 1rem); max-width: 400px; }

  /* Page layout */
  .page-content { padding: 1.25rem 1rem; }
  .page-header {
    flex-direction: column !important;
    align-items: flex-start !important;
  }
  .page-header > div:last-child {
    width: 100%;
    display: flex !important;
    flex-wrap: wrap;
    gap: .5rem;
  }
  .page-header > div:last-child .btn,
  .page-header > div:last-child a.btn {
    flex: 1;
    min-width: 110px;
    justify-content: center;
    text-align: center;
  }
  .page-header .btn { justify-content: center; }
  .page-header-bar { flex-direction: column; }
  .page-header-actions { width: 100%; }
  .page-header-actions .btn { flex: 1; min-width: 100px; justify-content: center; text-align: center; }

  /* Garante que body e main-content não causem overflow horizontal */
  .app-body { overflow-x: hidden; max-width: 100vw; }
  .main-content { max-width: 100%; overflow-x: hidden; }
  .page-content { max-width: 100%; }

  /* Filter bar */
  .filter-bar { flex-direction: row; flex-wrap: wrap; align-items: center; gap: .4rem; }
  .filter-bar .search-input,
  .filter-bar input[type="text"],
  .filter-bar input[type="search"],
  .filter-bar input[type="date"],
  .filter-bar select,
  .filter-bar .form-control { flex: 1 1 100%; min-width: 0; }
  .filter-bar .btn, .filter-bar .btn-sm { flex: 0 0 auto; }
  .search-input { max-width: 100%; }

  /* Topbar */
  .topbar { padding: 0 .75rem; }
  .profile-name { display: none; }
  .profile-chevron { display: none; }
  .profile-btn { padding: .25rem; border-radius: 50%; }
  .profile-dropdown { right: -8px; width: 240px; }
  .breadcrumb { font-size: .75rem; }
  .breadcrumb-current { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    /* ─── Tables: scroll horizontal em mobile ───────────────── */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
  }
  /* Todo card-body com tabela ganha scroll */
  .card-body.p-0,
  .card-body:has(> .table),
  .card-body:has(> .table-responsive) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* min-width padrão para tabelas sem wrapper */
  .table { min-width: 600px; }

  /* ─── Cards ──────────────────────────────────────────────── */
  .card-header { flex-wrap: wrap; gap: .5rem; }
  .card-body { padding: 1rem; }
  /* Card-body rows com display:flex;justify-content:space-between → empilha */
  .card-body[style*="display:flex"][style*="justify-content:space-between"],
  .card-body[style*="display: flex"][style*="justify-content: space-between"] {
    flex-wrap: wrap !important;
    gap: .5rem !important;
  }
  /* Sombra mais leve em mobile */
  .card { box-shadow: var(--shadow-xs); }
  /* max-width inline em cards não deve restringir em mobile */
  .card[style*="max-width"] { max-width: 100% !important; }

  /* ─── Forms ──────────────────────────────────────────────── */
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; justify-content: center; }

  /* Todos inputs/selects com max-width inline ficam full-width */
  input[style*="max-width"],
  select[style*="max-width"],
  textarea[style*="max-width"],
  .form-control[style*="max-width"],
  .form-input[style*="max-width"],
  .form-select[style*="max-width"] {
    max-width: 100% !important;
    width: 100% !important;
  }

  /* Filter bar: inputs full-width, buttons wrap */
  .filter-bar { flex-direction: row; flex-wrap: wrap; align-items: center; gap: .5rem; }
  .filter-bar input,
  .filter-bar select,
  .filter-bar .form-control,
  .filter-bar .form-input,
  .filter-bar .form-select,
  .filter-bar .form-select-sm,
  .filter-bar .search-input { flex: 1 1 100%; min-width: 0; max-width: 100% !important; }
  .filter-bar .btn,
  .filter-bar .btn-sm { flex: 0 0 auto; text-align: center; }

  /* ─── Prevent iOS input zoom (< 16px triggers zoom) ─────── */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  input[type="number"],
  input[type="tel"],
  input[type="url"],
  input[type="date"],
  input[type="time"],
  input[type="month"],
  input[type="datetime-local"],
  select,
  textarea,
  .form-control,
  .form-input,
  .form-select,
  .form-textarea { font-size: 16px !important; }

  /* ─── white-space:nowrap em células de tabela ─────────────── */
  td[style*="white-space:nowrap"],
  th[style*="white-space:nowrap"] { white-space: normal !important; }

  /* ─── Inline grid 2 colunas → 1 coluna ──────────────────── */
  div[style*="grid-template-columns:1fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  /* Inline grid 3 colunas → 1 coluna */
  div[style*="grid-template-columns:1fr 1fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  /* Settings / auto-fill grids → 2 colunas */
  div[style*="grid-template-columns:repeat(auto-fill,minmax(220px,1fr))"],
  div[style*="grid-template-columns:repeat(auto-fill, minmax(220px, 1fr))"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* ─── Stat boxes ─────────────────────────────────────────── */
  .stat-row { gap: .75rem; }
  .stat-box { min-width: 100px; }

  /* ─── Page header buttons ────────────────────────────────── */
  .page-header > div[style*="display:flex"],
  .page-header > div[style*="display: flex"] {
    width: 100% !important;
    flex-wrap: wrap !important;
  }
  .page-header > div[style*="display:flex"] .btn,
  .page-header > div[style*="display: flex"] .btn,
  .page-header > div[style*="display:flex"] > a,
  .page-header > div[style*="display: flex"] > a {
    flex: 1;
    min-width: 110px;
    justify-content: center;
    text-align: center;
  }

  /* ─── Overflow guard ─────────────────────────────────────── */
  .app-body { overflow-x: hidden; max-width: 100vw; }
  .main-content { max-width: 100%; overflow-x: hidden; }
  .page-content { max-width: 100%; overflow-x: hidden; }
}

/* ─── Mobile ≤480px ──────────────────────────────────────── */
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr !important; }
  .page-content { padding: .875rem .75rem; }
  .login-card { padding: 1.75rem 1.25rem; }
  .login-page { padding: 1rem; }
  .page-title { font-size: 1.15rem; }
  .page-sub { font-size: .8rem; }
  .btn { font-size: .82rem; padding: .5rem .9rem; min-height: 44px; }
  .btn-sm { padding: .4rem .65rem; font-size: .75rem; min-height: 36px; }
  .btn-lg { padding: .65rem 1.2rem; font-size: .9rem; min-height: 48px; }
  .stat-row { flex-direction: column; }
  .ai-grid { grid-template-columns: 1fr !important; }
  .card-header { padding: .75rem 1rem; }
  .card-body { padding: .875rem; }
  .topbar-right { gap: .4rem; }
  .theme-toggle-admin { width: 32px; height: 32px; font-size: 1rem; }
  .notif-btn { width: 32px; height: 32px; font-size: 1rem; }
  .profile-avatar-initial, .profile-avatar-img { width: 30px; height: 30px; font-size: .72rem; border-width: 1.5px; }

  /* Tables: padding reduzido */
  .table thead th { padding: .6rem .7rem; font-size: .68rem; }
  .table tbody td { padding: .6rem .7rem; font-size: .8rem; }

  /* Inline grids → 1 coluna em mobile */
  div[style*="grid-template-columns:repeat(auto-fill,minmax(220px,1fr))"],
  div[style*="grid-template-columns:repeat(auto-fill, minmax(220px, 1fr))"],
  div[style*="grid-template-columns:repeat(auto-fill,minmax(200px,1fr))"],
  div[style*="grid-template-columns:repeat(auto-fill, minmax(200px, 1fr))"] {
    grid-template-columns: 1fr !important;
  }

  /* Filter bar: botões menores */
  .filter-bar { gap: .4rem; }

  /* page-header-actions: botões em coluna */
  .page-header-actions { flex-direction: column; }
  .page-header-actions .btn { width: 100%; }

  /* Toast */
  .toast-container { right: .75rem; left: .75rem; bottom: 1rem; }
  .toast { max-width: 100%; }

  /* Notif dropdown */
  .notif-dropdown { right: 0; left: 0; width: 100vw; border-radius: 0; }

  /* Sidebar */
  .sidebar { width: 100vw; max-width: 320px; }

  /* Search input */
  .search-input { min-width: 0; max-width: 100%; width: 100%; }

  /* Pagination */
  .page-btn, .page-link { min-width: 36px; height: 36px; font-size: .75rem; }
  .pagination-info { font-size: .75rem; width: 100%; text-align: center; margin-right: 0; }

  /* Inline flex page-header → coluna */
  .page-header[style*="display:flex"],
  .page-header[style*="display: flex"] {
    flex-direction: column !important;
  }
}

/* ─── Extra small ≤360px ─────────────────────────────────── */
@media (max-width: 360px) {
  .page-content { padding: .75rem .5rem; }
  .topbar { height: 50px; padding: 0 .5rem; }
  .kpi-value { font-size: 1.4rem; }
  .kpi-label { font-size: .72rem; }
  .login-card { padding: 1.5rem 1rem; }
  .login-logo h1 { font-size: 1.15rem; }
  .card-body { padding: .75rem; }
  .card-header { padding: .6rem .75rem; font-size: .8rem; }
  .btn { font-size: .78rem; padding: .4rem .7rem; }
  .profile-dropdown { width: calc(100vw - 1rem); right: 0; }
  .table thead th { padding: .5rem .5rem; font-size: .65rem; }
  .table tbody td { padding: .5rem .5rem; font-size: .78rem; }
  .page-header-actions .btn { font-size: .75rem; }
}

/* ─── Sidebar Collapsed (JS toggle — desktop) ────────────── */
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-group-title { display: none; }
.sidebar.collapsed + .main-content { margin-left: var(--sidebar-collapsed); }
.sidebar.collapsed .nav-link { justify-content: center; padding: .52rem; }
.sidebar.collapsed .nav-icon { width: auto; }

/* ─── Dark Mode ──────────────────────────────────────────── */
[data-theme="dark"] {
  --primary:        #5b7fc7;
  --primary-dark:   #7b9de0;
  --primary-light:  #1e2a42;
  --success:        #34d399;
  --success-light:  #0d3326;
  --danger:         #f87171;
  --danger-light:   #3b1515;
  --warning:        #fbbf24;
  --warning-light:  #3d2e0a;
  --info:           #60a5fa;
  --info-light:     #172554;
  --secondary:      #94a3b8;
  --dark:           #e2e8f0;
  --white:          #0f172a;
  --bg:             #0b1120;
  --border:         #1e293b;
  --border-light:   #1a2332;
  --card-bg:        #0f172a;
}

[data-theme="dark"] body { background: #0b1120; color: #cbd5e1; }

/* Sidebar stays dark — no changes needed */

[data-theme="dark"] .topbar { background: #0f172a; border-bottom-color: #1e293b; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
[data-theme="dark"] .notif-btn { background: #1e293b; border-color: #334155; color: #94a3b8; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
[data-theme="dark"] .notif-btn:hover { background: #263862; color: #7b9de0; border-color: #5b7fc7; box-shadow: 0 2px 8px rgba(91,127,199,.15); }
[data-theme="dark"] .theme-toggle-admin { background: #1e293b; border-color: #334155; color: #94a3b8; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
[data-theme="dark"] .theme-toggle-admin:hover { background: #263862; color: #fbbf24; border-color: #5b7fc7; box-shadow: 0 2px 8px rgba(91,127,199,.15); }
[data-theme="dark"] .notif-dropdown { background: #0f172a; border-color: #1e293b; box-shadow: 0 12px 48px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.03); }
[data-theme="dark"] .notif-header { border-bottom-color: #1e293b; }
[data-theme="dark"] .notif-item:hover { background: #1e293b; }
[data-theme="dark"] .notif-item.unread { background: #1e2a42; }
[data-theme="dark"] .notif-view-all { border-top-color: #1e293b; }
[data-theme="dark"] .breadcrumb-link { color: #64748b; }
[data-theme="dark"] .breadcrumb-sep { color: #334155; }

/* Dark mode profile dropdown */
[data-theme="dark"] .profile-btn { background: #1e293b; border-color: #334155; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
[data-theme="dark"] .profile-btn:hover { background: #263862; border-color: #5b7fc7; box-shadow: 0 2px 8px rgba(91,127,199,.15); }
[data-theme="dark"] .profile-btn:focus-visible { box-shadow: 0 0 0 3px rgba(91,127,199,.2); border-color: #5b7fc7; }
[data-theme="dark"] .profile-name { color: #e2e8f0; }
[data-theme="dark"] .profile-avatar-img { border-color: #334155; }
[data-theme="dark"] .profile-avatar-initial { border-color: #334155; }
[data-theme="dark"] .profile-dropdown { background: #0f172a; border-color: #1e293b; box-shadow: 0 12px 48px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.03); }
[data-theme="dark"] .profile-dropdown-header { background: linear-gradient(135deg, #1e293b, #0f172a); border-bottom-color: #334155; }
[data-theme="dark"] .profile-dropdown-avatar { border-color: #334155; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
[data-theme="dark"] .profile-dropdown-name { color: #f1f5f9; }
[data-theme="dark"] .profile-dropdown-role { color: #64748b; }
[data-theme="dark"] .profile-dropdown-item { color: #cbd5e1; }
[data-theme="dark"] .profile-dropdown-item:hover { background: #1e293b; color: #7b9de0; }
[data-theme="dark"] .profile-dropdown-danger { color: #f87171; }
[data-theme="dark"] .profile-dropdown-danger:hover { background: #2d1111; color: #f87171; }
[data-theme="dark"] .profile-dropdown-divider { border-top-color: #1e293b; }

[data-theme="dark"] .page-footer { background: #0f172a; border-top-color: #1e293b; color: #64748b; }

[data-theme="dark"] .card { background: #0f172a; border-color: #1e293b; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
[data-theme="dark"] .card-header { border-bottom-color: #1e293b; }

[data-theme="dark"] .kpi-card { background: #0f172a; border-color: #1e293b; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
[data-theme="dark"] .kpi-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.3); }

[data-theme="dark"] .ai-feature-card { background: #0f172a; border-color: #1e293b; }

[data-theme="dark"] .table thead th { background: #0b1120; color: #64748b; border-bottom-color: #1e293b; }
[data-theme="dark"] .table tbody td { border-bottom-color: #1a2332; color: #cbd5e1; }
[data-theme="dark"] .table tbody tr:hover td { background: #1e293b; }

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] .form-input,
[data-theme="dark"] .form-textarea { background: #1e293b; border-color: #334155; color: #e2e8f0; }
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus,
[data-theme="dark"] .form-input:focus,
[data-theme="dark"] .form-textarea:focus { border-color: #5b7fc7; box-shadow: 0 0 0 3px rgba(91,127,199,.15); }
[data-theme="dark"] .input-addon { background: #0f172a; border-color: #334155; color: #94a3b8; }

[data-theme="dark"] .btn-primary { background: #5b7fc7; border-color: #5b7fc7; }
[data-theme="dark"] .btn-primary:hover { background: #7b9de0; border-color: #7b9de0; box-shadow: 0 4px 10px rgba(91,127,199,.35); }
[data-theme="dark"] .btn-outline { background: transparent; color: #5b7fc7; border-color: #334155; }
[data-theme="dark"] .btn-outline:hover { background: #1e2a42; border-color: #5b7fc7; }
[data-theme="dark"] .btn-secondary { background: #1e293b; border-color: #334155; color: #e2e8f0; }
[data-theme="dark"] .btn-secondary:hover { background: #334155; }

[data-theme="dark"] .badge-primary { background: #1e2a42; color: #7b9de0; }
[data-theme="dark"] .badge-success { background: #0d3326; color: #34d399; }
[data-theme="dark"] .badge-danger { background: #3b1515; color: #f87171; }
[data-theme="dark"] .badge-warning { background: #3d2e0a; color: #fbbf24; }
[data-theme="dark"] .badge-info { background: #172554; color: #60a5fa; }
[data-theme="dark"] .badge-secondary { background: #1a2332; color: #94a3b8; }

[data-theme="dark"] .alert-success { background: #0d3326; color: #34d399; border-color: #065f46; }
[data-theme="dark"] .alert-danger { background: #3b1515; color: #f87171; border-color: #991b1b; }
[data-theme="dark"] .alert-warning { background: #3d2e0a; color: #fbbf24; border-color: #92400e; }
[data-theme="dark"] .alert-info { background: #172554; color: #60a5fa; border-color: #1e40af; }

[data-theme="dark"] .page-btn, [data-theme="dark"] .page-link { border-color: #334155; color: #94a3b8; }
[data-theme="dark"] .page-btn.active, [data-theme="dark"] .page-link.active { background: #5b7fc7; color: #fff; border-color: #5b7fc7; }

[data-theme="dark"] .search-input { background: #1e293b; border-color: #334155; color: #e2e8f0; }
[data-theme="dark"] .search-input:focus { border-color: #5b7fc7; box-shadow: 0 0 0 3px rgba(91,127,199,.1); }

[data-theme="dark"] .stat-box { background: #0f172a; border-color: #1e293b; }

[data-theme="dark"] .toast { background: #1e293b; border-color: #334155; color: #e2e8f0; box-shadow: 0 4px 16px rgba(0,0,0,.4); }

[data-theme="dark"] code { background: #1e293b; color: #5b7fc7; }
[data-theme="dark"] hr { border-top-color: #1e293b; }

[data-theme="dark"] .login-page { background: linear-gradient(135deg, #0b1120 0%, #1e2a42 50%, #0b1120 100%); }
[data-theme="dark"] .login-card { background: #0f172a; border: 1px solid #1e293b; box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,.03); }
[data-theme="dark"] .login-logo h1 { color: #e2e8f0; }
[data-theme="dark"] .login-logo p { color: #94a3b8; }
[data-theme="dark"] .login-logo-icon { box-shadow: 0 8px 20px rgba(48,71,122,.35); }

[data-theme="dark"] .filter-bar .form-select { background: #1e293b; border-color: #334155; color: #e2e8f0; }

[data-theme="dark"] .topbar-toggle:hover { background: #1e293b; }

/* Dark mode — detail grids, labels, misc */
[data-theme="dark"] .detail-label { color: #64748b; }
[data-theme="dark"] .detail-value { color: #e2e8f0; }
[data-theme="dark"] .form-label { color: #cbd5e1; }
[data-theme="dark"] .form-hint { color: #64748b; }
[data-theme="dark"] .form-check-label span { color: #cbd5e1; }
[data-theme="dark"] .page-title { color: #f1f5f9; }
[data-theme="dark"] .page-sub { color: #94a3b8; }
[data-theme="dark"] .text-muted { color: #64748b !important; }
[data-theme="dark"] .badge-dark { background: #334155; color: #e2e8f0; }
[data-theme="dark"] .pagination { border-top-color: #1e293b; }
[data-theme="dark"] .pagination-info { color: #64748b; }
[data-theme="dark"] .module-toggle { background: #0f172a; border-color: #1e293b; }
[data-theme="dark"] .module-toggle:hover { border-color: #5b7fc7; }
[data-theme="dark"] .module-toggle.active { background: #1e2a42; border-color: #5b7fc7; }
[data-theme="dark"] .module-label { color: #e2e8f0; }
[data-theme="dark"] #ai-fab-panel { background: #1e293b; box-shadow: 0 8px 32px rgba(0,0,0,.4); }
[data-theme="dark"] .row-2 > .card, [data-theme="dark"] .row-3 > .card { background: #0f172a; border-color: #1e293b; }

/* ─── Dark Mode: Inline Style Overrides ──────────────────── */
/* Dashboard KPI cards */
[data-theme="dark"] .comp-kpi-card,
[data-theme="dark"] .acc-kpi-card,
[data-theme="dark"] .emp-kpi-card,
[data-theme="dark"] .fin-kpi-card { background: #0f172a !important; border-color: #1e293b !important; }
[data-theme="dark"] .comp-kpi-val,
[data-theme="dark"] .acc-kpi-val,
[data-theme="dark"] .emp-kpi-val,
[data-theme="dark"] .fin-kpi-value { color: #e2e8f0 !important; }
[data-theme="dark"] .comp-kpi-lbl,
[data-theme="dark"] .acc-kpi-lbl,
[data-theme="dark"] .emp-kpi-lbl,
[data-theme="dark"] .fin-kpi-label { color: #94a3b8 !important; }

/* Generic inline background overrides */
[data-theme="dark"] [style*="background:#f8f9fa"],
[data-theme="dark"] [style*="background: #f8f9fa"],
[data-theme="dark"] [style*="background:#f1f5f9"],
[data-theme="dark"] [style*="background: #f1f5f9"],
[data-theme="dark"] [style*="background:#f0f2f5"],
[data-theme="dark"] [style*="background: #f0f2f5"],
[data-theme="dark"] [style*="background:#f8fafc"],
[data-theme="dark"] [style*="background: #f8fafc"],
[data-theme="dark"] [style*="background:#f8f9ff"],
[data-theme="dark"] [style*="background: #f8f9ff"] { background: #1e293b !important; }

[data-theme="dark"] [style*="background:#fff"],
[data-theme="dark"] [style*="background: #fff"],
[data-theme="dark"] [style*="background:white"],
[data-theme="dark"] [style*="background: white"] { background: #0f172a !important; }

/* Text color overrides for hardcoded dark text */
[data-theme="dark"] [style*="color:#0f172a"],
[data-theme="dark"] [style*="color: #0f172a"],
[data-theme="dark"] [style*="color:#1a1a2e"],
[data-theme="dark"] [style*="color: #1a1a2e"],
[data-theme="dark"] [style*="color:#212529"],
[data-theme="dark"] [style*="color: #212529"],
[data-theme="dark"] [style*="color:#374151"],
[data-theme="dark"] [style*="color: #374151"] { color: #e2e8f0 !important; }

[data-theme="dark"] [style*="color:#6c757d"],
[data-theme="dark"] [style*="color: #6c757d"],
[data-theme="dark"] [style*="color:#64748b"],
[data-theme="dark"] [style*="color: #64748b"],
[data-theme="dark"] [style*="color:#495057"],
[data-theme="dark"] [style*="color: #495057"] { color: #94a3b8 !important; }

[data-theme="dark"] [style*="color:#666"],
[data-theme="dark"] [style*="color: #666"],
[data-theme="dark"] [style*="color:#999"],
[data-theme="dark"] [style*="color: #999"] { color: #94a3b8 !important; }

/* Border color overrides */
[data-theme="dark"] [style*="border-bottom:1px solid #e"],
[data-theme="dark"] [style*="border-bottom:1px solid #d"],
[data-theme="dark"] [style*="border:1px solid #ced4da"],
[data-theme="dark"] [style*="border:1px solid #dee2e6"] { border-color: #1e293b !important; }

/* Conditional status background overrides */
[data-theme="dark"] [style*="background:#fee2e2"] { background: #3b1515 !important; }
[data-theme="dark"] [style*="background:#fff3cd"] { background: #3d2e0a !important; }
[data-theme="dark"] [style*="background:#d1fae5"] { background: #0d3326 !important; }
[data-theme="dark"] [style*="background:#dbeafe"] { background: #172554 !important; }
[data-theme="dark"] [style*="background:#fef3c7"] { background: #3d2e0a !important; }

/* Signature canvas dark mode */
[data-theme="dark"] canvas[style*="background:#fff"] { background: #1e293b !important; }

/* Error pages */
[data-theme="dark"] .error-page { background: #0b1120; color: #cbd5e1; }
[data-theme="dark"] .error-page h1 { color: #e2e8f0; }

/* Progress bars background */
[data-theme="dark"] [style*="background:var(--bg)"] { background: #1e293b !important; }

/* Theme toggle in topbar */
.theme-toggle-admin {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  color: var(--secondary);
  background: var(--bg);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: all .2s ease;
}
.theme-toggle-admin:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); box-shadow: 0 2px 8px rgba(48,71,122,.1); }

/* ─── Print ──────────────────────────────────────────────── */
/* ─── AI FAB (Quick Config) ──────────────────────────── */
.ai-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
}
.ai-fab-btn {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: none;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition), box-shadow var(--transition);
}
.ai-fab-btn:hover  { transform: scale(1.08); box-shadow: 0 6px 20px rgba(0,0,0,.3); }
.ai-fab-btn:focus-visible { outline: 3px solid #818cf8; outline-offset: 2px; }
.ai-fab-btn--active   { background: linear-gradient(135deg,#6366f1,#8b5cf6); }
.ai-fab-btn--inactive { background: #6b7280; }

.ai-fab-panel {
  position: fixed;
  bottom: 80px;
  right: 1rem;
  width: min(320px, calc(100vw - 2rem));
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: fcSlideUp .2s ease;
}
.ai-fab-header {
  background: linear-gradient(135deg,#6366f1,#8b5cf6);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ai-fab-title  { font-weight: 600; font-size: .9rem; }
.ai-fab-close  { background: none; border: none; color: #fff; cursor: pointer; font-size: 1.1rem; opacity: .8; line-height: 1; }
.ai-fab-close:hover { opacity: 1; }
.ai-fab-form   { padding: 14px 16px; }
.ai-fab-field  { margin-bottom: 10px; }
.ai-fab-field:last-of-type { margin-bottom: 12px; }
.ai-fab-label  { font-size: .78rem; color: var(--secondary); display: block; margin-bottom: 4px; font-weight: 500; }
.ai-fab-input  { font-size: .82rem; padding: 6px 10px; }
.ai-fab-check-label {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; font-size: .85rem; font-weight: 600;
}
.ai-fab-checkbox { width: 18px; height: 18px; cursor: pointer; }
.ai-fab-status      { font-size: .72rem; display: block; margin-top: 3px; }
.ai-fab-status--ok  { color: var(--success); }
.ai-fab-status--err { color: var(--danger); }
.ai-fab-actions { display: flex; gap: 8px; }
.ai-fab-save    { flex: 1; }

[data-theme="dark"] .ai-fab-panel { background: #0f172a; }
[data-theme="dark"] .ai-fab-label { color: #94a3b8; }

/* ─── AI Agent Panel ─────────────────────────────────── */
.ai-agent-card {
  border: 1.5px solid var(--primary-light);
  border-radius: var(--radius);
  background: var(--white);
  overflow: hidden;
}
.ai-agent-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem; background: linear-gradient(135deg, var(--primary-light), #f0f4ff);
  cursor: pointer; user-select: none; gap: .5rem;
}
.ai-agent-title {
  display: flex; align-items: center; gap: .5rem;
  font-weight: 600; font-size: .9rem; color: var(--primary);
}
.ai-agent-icon { font-size: 1.3rem; }
.ai-agent-actions { display: flex; align-items: center; gap: .5rem; }
.ai-agent-chevron { font-size: .7rem; color: var(--secondary); transition: transform .2s; }
.ai-agent-card.collapsed .ai-agent-body { display: none; }
.ai-agent-card.collapsed .ai-agent-chevron { transform: rotate(-90deg); }
.ai-agent-body { padding: 1rem; }
.ai-agent-placeholder { text-align: center; color: var(--secondary); padding: 1rem; font-size: .85rem; }
.ai-agent-loading { text-align: center; padding: 2rem; color: var(--secondary); }
.ai-pulse {
  width: 40px; height: 40px; margin: 0 auto 1rem;
  border-radius: 50%; background: var(--primary);
  animation: aiPulse 1.2s ease-in-out infinite;
}
@keyframes aiPulse {
  0%, 100% { transform: scale(.8); opacity: .5; }
  50% { transform: scale(1.1); opacity: 1; }
}
.ai-spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .6s linear infinite; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
.ai-agent-result { font-size: .875rem; line-height: 1.6; }
.ai-result-content h2, .ai-result-content h3, .ai-result-content h4 {
  margin-top: 1rem; margin-bottom: .5rem; color: var(--primary);
}
.ai-result-content ul { margin: .5rem 0; padding-left: 1.25rem; }
.ai-result-content li { margin-bottom: .3rem; }
.ai-result-content strong { color: var(--dark); }
.ai-result-meta {
  margin-top: 1rem; padding-top: .75rem; border-top: 1px solid var(--border);
  font-size: .75rem; color: var(--secondary); text-align: right;
}
.ai-agent-error {
  padding: 1rem; background: #fff5f5; border: 1px solid #fcc; border-radius: 6px;
  color: #dc3545; font-size: .85rem;
}
.ai-analyze-btn { font-size: .78rem !important; white-space: nowrap; }

/* Dark mode AI */
[data-theme="dark"] .ai-agent-card { border-color: #333; background: var(--dark); }
[data-theme="dark"] .ai-agent-header { background: linear-gradient(135deg, #1a2744, #222); }
[data-theme="dark"] .ai-agent-error { background: #2a1a1a; border-color: #5a2020; }
[data-theme="dark"] .ai-result-content h2,
[data-theme="dark"] .ai-result-content h3,
[data-theme="dark"] .ai-result-content h4 { color: #7da6e8; }

/* ─── Chart with side legend (responsive) ────────────────── */
.chart-with-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: center;
}
.chart-legend-list {
  font-size: .82rem;
  line-height: 1.8;
}
@media (max-width: 768px) {
  .chart-with-legend {
    grid-template-columns: 1fr;
  }
}

/* ─── Notification utility classes (added by refactor) ───── */
.notif-empty {
  padding: 1rem;
  text-align: center;
  color: var(--secondary);
  font-size: .85rem;
}
.notif-error {
  padding: 1rem;
  text-align: center;
  color: var(--danger);
  font-size: .85rem;
}
[data-theme="dark"] .notif-empty { color: #64748b; }
[data-theme="dark"] .notif-error  { color: #f87171; }

/* ─── Spinner (form loading state) ───────────────────────── */
.spinner-sm {
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
  opacity: .8;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Dark mode: select native arrow ─────────────────────── */
[data-theme="dark"] select option {
  background: #1e293b;
  color: #e2e8f0;
}

/* ─── Dark mode: scrollbars ──────────────────────────────── */
[data-theme="dark"] {
  scrollbar-color: #334155 #0f172a;
}
[data-theme="dark"] ::-webkit-scrollbar-track { background: #0f172a; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #475569; }

/* ─── Dark mode: placeholder text ───────────────────────── */
[data-theme="dark"] ::placeholder { color: #475569; opacity: 1; }

/* ─── Dark mode: bg-card token (used by JS chartColors) ──── */
[data-theme="dark"] { --bg-card: #0f172a; }

/* ─── View utility classes ───────────────────────────────── */
.card-body--border-bottom  { border-bottom: 1px solid var(--border-color, #f0f2f5); }
.card-body--flex-between   { display: flex; justify-content: space-between; align-items: center; }
.form-control--compact     { max-width: 220px; }
.table-empty-state         { padding: 2rem; }
.btn-group-wrap            { display: flex; gap: .5rem; flex-wrap: wrap; }
.th-checkbox               { width: 36px; }
.card-section-title        { font-size: .9rem; font-weight: 700; color: var(--text-color, #1a1f2e); margin-bottom: 1rem; }
[data-theme="dark"] .card-body--border-bottom { border-bottom-color: rgba(255,255,255,.07); }
[data-theme="dark"] .card-section-title       { color: var(--text-color, #e2e8f0); }

/* ─── Bulk action bar ────────────────────────────────────── */
.bulk-bar {
  display: flex;
  padding: .6rem 1rem;
  background: #eff6ff;
  border-bottom: 1px solid #bfdbfe;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}
.bulk-bar__count {
  font-size: .85rem;
  font-weight: 600;
  color: #1d4ed8;
}
[data-theme="dark"] .bulk-bar { background: #1e2a42; border-bottom-color: #2d4a7a; }
[data-theme="dark"] .bulk-bar__count { color: #7b9de0; }

/* ─── Faixa P8W ──────────────────────────────────────────── */
.p8w-bar {
  width: 100%;
  background: #0b1120;
  color: #64748b;
  text-align: center;
  font-size: .72rem;
  padding: .45rem 1rem;
  letter-spacing: .02em;
}
.p8w-bar a {
  color: #5b7fc7;
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition);
}
.p8w-bar a:hover { color: #7b9de0; text-decoration: underline; }

[data-theme="dark"] .p8w-bar { background: #060c18; color: #475569; }
[data-theme="dark"] .p8w-bar a { color: #5b7fc7; }

/* ─── Account / Profile ─────────────────────────────────── */
.account-edit-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; max-width: 900px;
}
@media (max-width: 768px) { .account-edit-grid { grid-template-columns: 1fr; } }

/* ─── KPI alias classes (variante alternativa usada em outros módulos) ─── */
.kpi-val { font-size: 1.8rem; font-weight: 700; color: var(--dark); }
.kpi-lbl { font-size: .82rem; color: var(--secondary); margin-top: .2rem; }
[data-theme="dark"] .kpi-val { color: #e2e8f0; }
[data-theme="dark"] .kpi-lbl { color: #94a3b8; }

/* Dashboard 2-col grid */
.dash-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-bottom: 1.5rem; }
.dash-grid-21 { display: grid; grid-template-columns: 2fr 1fr; gap: 1.25rem; margin-bottom: 1.5rem; }
@media (max-width: 768px) { .dash-grid-2, .dash-grid-21 { grid-template-columns: 1fr; } }

/* Risk badges for company grau de risco */
.risk-badge { display: inline-block; padding: .2rem .6rem; border-radius: 10px; font-size: .78rem; font-weight: 600; color: #fff; }
.risk-1 { background: var(--success); }
.risk-2 { background: var(--info); }
.risk-3 { background: var(--warning); }
.risk-4 { background: var(--danger); }

/* ─── Settings — Module Toggles ─────────────────────────── */
.module-toggle {
  display: flex; align-items: center; gap: .6rem;
  padding: .65rem .85rem; border: 1.5px solid var(--border);
  border-radius: var(--radius); cursor: pointer; transition: all .18s;
  background: var(--white); user-select: none;
}
.module-toggle:hover       { border-color: var(--primary); }
.module-toggle.active      { border-color: var(--primary); background: var(--primary-light); }
.module-toggle input       { display: none; }
.module-icon               { font-size: 1.2rem; flex-shrink: 0; }
.module-label              { font-size: .85rem; font-weight: 500; color: var(--dark); }
.ai-agent-toggle           { flex-direction: column; align-items: flex-start; padding: .75rem .85rem; }
.ai-agent-toggle .module-icon { font-size: 1rem; }
[data-theme="dark"] .module-toggle        { background: #0f172a; border-color: #1e293b; }
[data-theme="dark"] .module-toggle.active { background: #1e2d4a; border-color: var(--primary); }
[data-theme="dark"] .module-label         { color: var(--white); }

/* ─── Financial Dashboard ────────────────────────────────── */
.fin-kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.fin-kpi {
  background: var(--white); border-radius: 12px; padding: 1.25rem;
  border: 1px solid var(--border); box-shadow: 0 1px 3px rgba(0,0,0,.04);
  transition: all .2s; position: relative; overflow: hidden;
}
.fin-kpi:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); transform: translateY(-1px); }
.fin-kpi-stripe             { position: absolute; top: 0; left: 0; right: 0; height: 3px; }
.fin-kpi-stripe--success    { background: linear-gradient(90deg, var(--success, #10b981), #34d399); }
.fin-kpi-stripe--danger     { background: linear-gradient(90deg, var(--danger,  #ef4444), #f87171); }
.fin-kpi-stripe--warning    { background: linear-gradient(90deg, var(--warning, #f59e0b), #fbbf24); }
.fin-kpi-stripe--indigo     { background: linear-gradient(90deg, #6366f1, #818cf8); }
.fin-kpi-stripe--sky        { background: linear-gradient(90deg, #0ea5e9, #38bdf8); }
.fin-kpi-stripe--violet     { background: linear-gradient(90deg, #8b5cf6, #a78bfa); }
.fin-kpi-stripe--pink       { background: linear-gradient(90deg, #ec4899, #f472b6); }
.fin-kpi-label    { font-size: .75rem; color: var(--secondary); text-transform: uppercase; font-weight: 600; letter-spacing: .3px; margin-bottom: .4rem; }
.fin-kpi-value              { font-size: 1.4rem; font-weight: 800; line-height: 1.2; }
.fin-kpi-value--success     { color: var(--success, #10b981); }
.fin-kpi-value--danger      { color: var(--danger,  #ef4444); }
.fin-kpi-value--warning     { color: var(--warning, #f59e0b); }
.fin-kpi-value--indigo      { color: #6366f1; }
.fin-kpi-value--sky         { color: #0ea5e9; }
.fin-kpi-value--violet      { color: #8b5cf6; }
.fin-kpi-value--pink        { color: #ec4899; }
.card-title--danger         { color: var(--danger,  #ef4444); }
.card-title--warning        { color: var(--warning, #f59e0b); }
.fin-kpi-sub      { font-size: .72rem; color: var(--secondary); margin-top: .3rem; }
.fin-kpi-link     { font-size: .72rem; color: var(--primary); text-decoration: none; margin-top: .5rem; display: inline-block; font-weight: 600; }
.fin-kpi-link:hover { text-decoration: underline; }
.fin-kpi .fin-kpi-icon { font-size: 1.3rem; position: absolute; top: 1rem; right: 1rem; opacity: .6; }
.fin-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-bottom: 1.5rem; }
.fin-tables { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-bottom: 1.5rem; }
.fin-bottom { display: grid; grid-template-columns: 2fr 1fr; gap: 1.25rem; margin-bottom: 1.5rem; }
@media (max-width: 900px) { .fin-charts, .fin-tables, .fin-bottom { grid-template-columns: 1fr; } }
@media (max-width: 600px) { .fin-kpi-grid { grid-template-columns: 1fr 1fr; } .fin-kpi-value { font-size: 1.1rem; } }
[data-theme="dark"] .fin-kpi { background: #0f172a; border-color: #1e293b; }
[data-theme="dark"] .fin-kpi:hover { box-shadow: 0 4px 12px rgba(0,0,0,.3); }
[data-theme="dark"] .fin-kpi-label { color: #64748b; }

/* ─── Company Form — CNPJ Lookup ─────────────────────────── */
.lookup-spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .6s linear infinite;
  margin-left: .5rem; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
.lookup-status { font-size: .75rem; margin-top: .3rem; min-height: 1.2em; }
.lookup-status.success { color: var(--success); }
.lookup-status.error   { color: var(--danger); }
.lookup-btn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: var(--primary); color: #fff; border: none;
  border-radius: var(--radius); padding: .3rem .6rem;
  font-size: .75rem; cursor: pointer; font-weight: 600; transition: all .15s;
}
.lookup-btn:hover    { background: var(--primary-dark); }
.lookup-btn:disabled { opacity: .5; cursor: not-allowed; }
.field-highlight { animation: fieldFlash .8s ease; }
@keyframes fieldFlash { 0%,100% { background: inherit; } 30% { background: color-mix(in srgb, var(--success) 10%, transparent); } }
.form-section { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.form-section h4 { font-size: .95rem; margin-bottom: 1rem; color: var(--text-primary); }
.readonly-field { background: var(--bg); opacity: .85; }
.lock-indicator {
  display: inline-flex; align-items: center; gap: .25rem;
  font-size: .72rem; color: var(--info); background: var(--info-light);
  padding: .15rem .4rem; border-radius: 4px; margin-left: .4rem;
  cursor: pointer; border: 1px solid color-mix(in srgb, var(--info) 40%, transparent);
  transition: all .15s;
}
.lock-indicator:hover    { background: color-mix(in srgb, var(--info-light) 80%, var(--info)); }
.lock-indicator.unlocked { color: var(--success); background: var(--success-light); border-color: color-mix(in srgb, var(--success) 40%, transparent); }
[data-theme="dark"] .lock-indicator         { color: #7db4f5; background: #1e3a5f; border-color: #2d5a8a; }
[data-theme="dark"] .lock-indicator.unlocked{ color: #34d399; background: #064e3b; border-color: #065f46; }

/* ── Notification items ──────────────────────────────────────────────────── */
.notif-item {
  display: flex; align-items: flex-start; gap: 1rem;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
  background: var(--white); transition: background .15s;
}
.notif-item:last-child { border-bottom: none; }
.notif-item-unread     { background: color-mix(in srgb, var(--primary) 6%, var(--white)); }
.notif-icon  { font-size: 1.5rem; flex-shrink: 0; line-height: 1; }
.notif-body  { flex: 1; min-width: 0; }
.notif-title { font-size: .9rem; color: var(--text-primary); font-weight: 400; }
.notif-title-unread { font-weight: 600; }
.notif-message { font-size: .85rem; color: var(--text-secondary); margin-top: .2rem; }
.notif-time    { font-size: .75rem; color: var(--text-muted); margin-top: .3rem; }
.notif-action  { flex-shrink: 0; }
[data-theme="dark"] .notif-item         { background: var(--white); }
[data-theme="dark"] .notif-item-unread  { background: color-mix(in srgb, var(--primary) 12%, var(--white)); }

@media print {
  .sidebar, .topbar, .sidebar-overlay, .toast-container, .theme-toggle-admin, .ai-agent-card, .p8w-bar { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 0; }
}
