/* ─── RESET & BASE ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1729;
  --bg2:       #1a2540;
  --surface:   #1e2d45;
  --surface2:  #243352;
  --border:    #2a3a55;
  --text:      #e2e8f0;
  --text-muted:#7a8ba8;
  --primary:   #00c6ff;
  --primary-d: #0099cc;
  --success:   #00e5a0;
  --warning:   #f59e0b;
  --danger:    #ff4d6a;
  --purple:    #8b5cf6;
  --radius:    10px;
  --shadow:    0 4px 20px rgba(0,0,0,.3);
  --topbar-h:  58px;
  --tabs-h:    46px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02","cv03","cv04","cv11","ss01";
}

/* Números alinhados e refinados */
.num, td.num, .card-value, .adv-kpi-value {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum","cv03","cv04";
}

a { color: var(--primary); text-decoration: none; }
button { cursor: pointer; font-family: inherit; font-size: 14px; }

/* ─── LOGIN ──────────────────────────────────────────────── */
#login-screen {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: #f8fafc;
}
.login-brand { text-align: center; margin-bottom: 2rem; }
.login-brand .brand-name {
  font-size: 2.5rem; font-weight: 800; color: #1e293b; letter-spacing: -1px;
}
.login-brand .brand-name span { color: var(--primary-d); }
.login-brand p { color: #64748b; font-size: .9375rem; margin-top: .25rem; letter-spacing: .05em; }

.login-box {
  background: linear-gradient(145deg, #1e3a6e, #1a2d5a);
  border-radius: 20px; padding: 2.5rem; width: 420px;
  box-shadow: 0 25px 60px rgba(0,0,0,.25), 0 0 0 1px rgba(255,255,255,.05);
}
.login-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.75rem; }
.login-icon {
  width: 48px; height: 48px; background: rgba(0,198,255,.15); border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 1.5rem;
}
.login-header h2 { font-size: 1.25rem; font-weight: 700; color: #fff; }
.login-header p  { font-size: .8125rem; color: rgba(255,255,255,.5); margin-top: .125rem; }

.field { margin-bottom: 1.25rem; }
.field label { display: block; font-size: .8125rem; font-weight: 500;
               color: rgba(255,255,255,.6); margin-bottom: .5rem; }
.field input {
  width: 100%; padding: .75rem 1rem;
  background: rgba(0,0,0,.25); color: #fff;
  border: 1.5px solid rgba(255,255,255,.1);
  border-radius: var(--radius); font-size: .9375rem; transition: border-color .15s;
}
.field input::placeholder { color: rgba(255,255,255,.25); }
.field input:focus { outline: none; border-color: var(--primary); }

.login-box button[type=submit] {
  width: 100%; padding: .875rem;
  background: linear-gradient(90deg, #00c6ff, #0072ff);
  color: #fff; border: none; border-radius: var(--radius);
  font-size: 1rem; font-weight: 700; margin-top: .5rem;
  transition: opacity .15s; letter-spacing: .03em;
}
.login-box button[type=submit]:hover { opacity: .9; }
.mfa-info { text-align: center; color: rgba(255,255,255,.6); margin-bottom: 1rem; font-size: .875rem; }

.error-msg { background: rgba(255,77,106,.15); color: #ff8fa3;
             border: 1px solid rgba(255,77,106,.3); border-radius: var(--radius);
             padding: .625rem .875rem; font-size: .8125rem; margin-bottom: .75rem; }

.login-footer { text-align: center; margin-top: 1.5rem; color: #94a3b8; font-size: .75rem; }

/* ─── TOPBAR ─────────────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  background: #0d1b2e; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 1.25rem; gap: 1rem; z-index: 100;
  box-shadow: 0 2px 20px rgba(0,0,0,.4);
}
.topbar-logo { display: flex; flex-direction: column; line-height: 1.1; }
.topbar-logo .logo-main { font-size: 1.1rem; font-weight: 800; color: #fff; letter-spacing: -.5px; }
.topbar-logo .logo-main span { color: var(--primary); }
.topbar-logo .logo-sub  { font-size: .65rem; color: var(--text-muted); letter-spacing: .08em; text-transform: uppercase; }

.topbar-center { flex: 1; display: flex; justify-content: center; }
.topbar-center select {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 20px; padding: .4rem 1rem; font-size: .875rem; max-width: 260px; width: 100%;
}
.topbar-right  { display: flex; align-items: center; gap: .625rem; flex: 1; justify-content: flex-end; }

.user-chip {
  display: flex; align-items: center; gap: .625rem;
  background: var(--surface); border-radius: 20px; padding: .3rem .75rem .3rem .3rem;
  border: 1px solid var(--border);
}
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .75rem; color: #000; flex-shrink: 0;
}
.user-nome   { font-size: .8125rem; font-weight: 600; color: var(--text); }
.user-perfil { font-size: .65rem; color: var(--primary); font-weight: 600; text-transform: uppercase; }
.btn-icon { background: transparent; border: none; color: var(--text-muted);
            font-size: 1.125rem; padding: .375rem; transition: color .15s; border-radius: 6px; }
.btn-icon:hover { color: var(--text); background: var(--surface); }

/* ─── TABS ───────────────────────────────────────────────── */
.tabs {
  position: fixed; top: var(--topbar-h); left: 0; right: 0; height: var(--tabs-h);
  background: #0d1b2e; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 1rem; gap: .125rem;
  overflow-x: auto; z-index: 99;
}
.tabs::-webkit-scrollbar { height: 0; }

.tab {
  padding: .5rem 1rem; border: none; background: transparent; color: var(--text-muted);
  font-weight: 500; font-size: .875rem; border-radius: 6px; white-space: nowrap;
  transition: all .15s; display: flex; align-items: center; gap: .375rem;
}
.tab:hover  { background: var(--surface); color: var(--text); }
.tab.active { background: var(--primary); color: #000; font-weight: 700; }
.tab-admin  { margin-left: auto; }
.tab-icon   { font-size: .9375rem; }

/* ─── SUBTABS ────────────────────────────────────────────── */
.tab-sub { display: flex; gap: .375rem; }
.subtab {
  padding: .375rem .875rem; border: 1.5px solid var(--border); background: transparent;
  color: var(--text-muted); border-radius: 20px; font-size: .8125rem; font-weight: 500; transition: all .15s;
}
.subtab:hover  { border-color: var(--primary); color: var(--primary); }
.subtab.active { border-color: var(--primary); background: var(--primary); color: #000; font-weight: 700; }
.subtab-content { display: none; }
.subtab-content.active { display: block; }

/* ─── MAIN CONTENT ───────────────────────────────────────── */
.content {
  margin-top: calc(var(--topbar-h) + var(--tabs-h));
  padding: 1.5rem; min-height: calc(100vh - var(--topbar-h) - var(--tabs-h));
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── SECTION HEADER ─────────────────────────────────────── */
.section-header {
  display: flex; align-items: center; gap: .75rem; margin-bottom: 1.25rem; flex-wrap: wrap;
}
.section-header h2 { font-size: 1.0625rem; font-weight: 600; color: var(--text); letter-spacing: -.02em; }

/* ─── BUTTONS ────────────────────────────────────────────── */
.btn-primary {
  padding: .5rem 1.125rem; background: var(--primary); color: #000;
  border: none; border-radius: var(--radius); font-weight: 700; transition: opacity .15s;
}
.btn-primary:hover { opacity: .85; }

.btn-secondary {
  padding: .5rem 1rem; background: var(--surface); color: var(--text);
  border: 1.5px solid var(--border); border-radius: var(--radius);
  font-weight: 500; transition: all .15s; display: inline-block; cursor: pointer;
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

.btn-refresh {
  padding: .4375rem .875rem; background: transparent; color: var(--text-muted);
  border: 1.5px solid var(--border); border-radius: var(--radius); font-size: .8125rem;
  transition: all .15s;
}
.btn-refresh:hover { border-color: var(--primary); color: var(--primary); }

.btn-sm {
  padding: .25rem .625rem; font-size: .75rem; border-radius: 5px;
  border: 1px solid var(--border); background: var(--surface2); color: var(--text); cursor: pointer;
}
.btn-sm:hover { border-color: var(--primary); }
.btn-danger { border-color: var(--danger) !important; color: var(--danger) !important; }
.btn-danger:hover { background: rgba(255,77,106,.1) !important; }

/* ─── TOOLBAR ────────────────────────────────────────────── */
.toolbar {
  display: flex; align-items: center; gap: .625rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.toolbar select {
  padding: .4375rem .75rem; border: 1.5px solid var(--border);
  border-radius: var(--radius); font-size: .875rem;
  background: var(--surface); color: var(--text);
}

/* ─── PANEL ──────────────────────────────────────────────── */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow);
}
.panel h3 { font-size: .875rem; font-weight: 600; margin-bottom: 1rem; color: var(--text); letter-spacing: -.01em; }

/* ─── CARDS GRID ─────────────────────────────────────────── */
.cards-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem; margin-bottom: 1rem;
}
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--primary);
}
.card.success::before { background: var(--success); }
.card.warning::before { background: var(--warning); }
.card.danger::before  { background: var(--danger);  }
.card.purple::before  { background: var(--purple);  }
.card-icon  { font-size: 1.375rem; float: right; opacity: .55; }
.card-label { font-size: .68rem; font-weight: 500; color: var(--text-muted);
              text-transform: uppercase; letter-spacing: .07em; margin-bottom: .5rem; }
.card-value { font-size: 1.375rem; font-weight: 700; color: var(--text); line-height: 1.1; }
.card.success .card-value { color: var(--success); }
.card.danger  .card-value { color: var(--danger);  }
.card.warning .card-value { color: var(--warning); }
.card-sub   { font-size: .68rem; color: var(--text-muted); margin-top: .375rem; }
.card-delta { font-size: .68rem; margin-top: .375rem; font-weight: 600; }
.delta-pos  { color: var(--success); }
.delta-neg  { color: var(--danger);  }

/* KPI cards (DSO, DPO, etc.) */
.card-kpi .card-value { font-size: 2rem; color: var(--warning); }
.card-kpi .card-unit  { font-size: .8125rem; color: var(--text-muted); margin-top: .125rem; }

/* ─── STATS ROW ──────────────────────────────────────────── */
.stats-row { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.stat-pill {
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: .375rem 1rem; font-size: .8125rem; display: flex; align-items: center; gap: .375rem;
}
.stat-pill strong { font-weight: 700; }

/* ─── ROW 2 COL ──────────────────────────────────────────── */
.row-2col { display: flex; gap: 1rem; flex-wrap: wrap; }
.row-2col > * { flex: 1; min-width: 280px; }

/* ─── TABLE ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
thead { background: var(--bg2); }
th { padding: .625rem .875rem; text-align: left; font-size: .67rem; font-weight: 500;
     color: var(--text-muted); text-transform: uppercase; letter-spacing: .055em;
     border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: .625rem .875rem; border-bottom: 1px solid var(--border); color: var(--text);
     vertical-align: middle; font-size: .875rem; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }
td .actions { display: flex; gap: .25rem; }

/* ─── BADGES ESTADO ──────────────────────────────────────── */
.estado {
  display: inline-block; padding: .1875rem .625rem; border-radius: 20px;
  font-size: .65rem; font-weight: 700; text-transform: uppercase; white-space: nowrap;
}
.estado-pendente  { background: rgba(245,158,11,.15);  color: #f59e0b; }
.estado-vencida   { background: rgba(255,77,106,.15);  color: var(--danger); }
.estado-pago      { background: rgba(0,229,160,.15);   color: var(--success); }
.estado-ativo     { background: rgba(0,198,255,.15);   color: var(--primary); }
.estado-inativo   { background: rgba(122,139,168,.15); color: var(--text-muted); }
.estado-concluido { background: rgba(0,229,160,.15);   color: var(--success); }
.estado-agendado  { background: rgba(0,198,255,.15);   color: var(--primary); }
.estado-conciliado{ background: rgba(0,229,160,.15);   color: var(--success); }
.estado-rejeitado { background: rgba(255,77,106,.15);  color: var(--danger); }

/* ─── EMPRESA CARDS ──────────────────────────────────────── */
.empresas-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem;
  margin-bottom: 0;
}
.empresa-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow);
  border-top: 3px solid var(--primary);
}
.empresa-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1rem; }
.empresa-card h4 { font-size: 1rem; font-weight: 700; color: var(--text); }
.empresa-card .empresa-sub { font-size: .7rem; color: var(--text-muted); }
.empresa-status { font-size: 1.25rem; }

.empresa-row { display: flex; justify-content: space-between; align-items: center;
               padding: .3125rem 0; font-size: .8125rem; }
.empresa-row + .empresa-row { border-top: 1px solid var(--border); }
.empresa-row span:first-child { color: var(--text-muted); }

/* ─── ALERTS ─────────────────────────────────────────────── */
.alert-item {
  display: flex; align-items: flex-start; gap: .625rem;
  padding: .625rem; border-radius: 6px; background: rgba(255,77,106,.08);
  border-left: 3px solid var(--danger); margin-bottom: .5rem;
}
.alert-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); flex-shrink: 0; margin-top: 3px; }
.alert-text { font-size: .75rem; color: var(--text); }
.alert-text strong { display: block; font-weight: 600; }

/* ─── MODAL ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: 0 30px 80px rgba(0,0,0,.5);
  width: 100%; max-width: 560px; max-height: 90vh; display: flex; flex-direction: column;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.0625rem; font-weight: 700; color: var(--text); }
.modal-close { background: transparent; border: none; font-size: 1.25rem;
               color: var(--text-muted); padding: .25rem; line-height: 1; border-radius: 4px; }
.modal-close:hover { color: var(--text); background: var(--surface2); }
.modal-body { padding: 1.5rem; overflow-y: auto; flex: 1; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border);
                display: flex; justify-content: flex-end; gap: .5rem; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid .full { grid-column: 1/-1; }
.form-field { display: flex; flex-direction: column; gap: .375rem; }
.form-field label { font-size: .7875rem; font-weight: 600; color: var(--text-muted); }
.form-field input, .form-field select, .form-field textarea {
  padding: .5625rem .75rem; border: 1.5px solid var(--border);
  border-radius: 6px; font-size: .9375rem; font-family: inherit;
  background: var(--bg2); color: var(--text); transition: border-color .15s;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  outline: none; border-color: var(--primary);
}
.form-field textarea { resize: vertical; min-height: 80px; }
.form-field select option { background: var(--surface); }

/* ─── TOAST ──────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 300;
  display: flex; flex-direction: column; gap: .5rem;
}
.toast {
  padding: .75rem 1.25rem; border-radius: var(--radius); font-size: .875rem;
  font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,.3);
  animation: slideIn .2s ease; max-width: 360px;
  border: 1px solid rgba(255,255,255,.1);
}
.toast-success { background: #064e3b; color: var(--success); border-color: var(--success); }
.toast-error   { background: #450a0a; color: var(--danger);  border-color: var(--danger);  }
.toast-info    { background: #0c1a2e; color: var(--primary); border-color: var(--primary); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── LOADING ────────────────────────────────────────────── */
.loading { display: flex; align-items: center; justify-content: center;
           padding: 3rem; color: var(--text-muted); gap: .5rem; }
.spinner { width: 20px; height: 20px; border: 2px solid var(--border);
           border-top-color: var(--primary); border-radius: 50%;
           animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 3rem; color: var(--text-muted); font-size: .9375rem; }

/* ─── VERSÃO / STATUS ────────────────────────────────────── */
.version-badge {
  position: fixed; bottom: .75rem; left: .75rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: .25rem .75rem; font-size: .7rem; color: var(--text-muted); z-index: 50;
}
.online-badge {
  position: fixed; bottom: .75rem; right: .75rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: .25rem .75rem; font-size: .7rem; color: var(--success);
  display: flex; align-items: center; gap: .375rem; z-index: 50;
}
.online-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success);
              animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .content { padding: 1rem; }
  .form-grid { grid-template-columns: 1fr; }
  .cards-grid { grid-template-columns: 1fr 1fr; }
  .topbar-center { display: none; }
}

/* ─── NÚMERO ─────────────────────────────────────────────── */
.num-pos { color: var(--success) !important; font-weight: 600; }
.num-neg { color: var(--danger)  !important; font-weight: 600; }
.num         { font-variant-numeric: tabular-nums; }
td.num, th.num { text-align: right; }

/* ─── DASHBOARD LAYOUT ───────────────────────────────────── */
.dashboard-main-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1rem;
  align-items: start;
}
.dashboard-sidebar { position: sticky; top: calc(var(--topbar-h) + var(--tabs-h) + 1rem); }
.dashboard-charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: .75rem;
}
.alertas-full { margin-top: 1rem; }
.alertas-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: .375rem;
}
.alertas-panel { padding: 1rem 1.125rem; }
.alertas-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .875rem; padding-bottom: .625rem; border-bottom: 1px solid var(--border);
}
.alertas-panel-header h3 { font-size: .9rem; font-weight: 700; }
.alertas-badge {
  background: var(--danger); color: #fff; border-radius: 20px;
  padding: .1rem .5rem; font-size: .7rem; font-weight: 700; min-width: 22px; text-align: center;
}
.alertas-list { max-height: 460px; overflow-y: auto; }
.alertas-more {
  text-align: center; padding: .625rem; font-size: .75rem;
  color: var(--primary); cursor: pointer; border-top: 1px solid var(--border); margin-top: .5rem;
}
.alertas-more:hover { text-decoration: underline; }

/* Alerta items — nivéis */
.alerta-item { display: flex; align-items: center; gap: .625rem;
               padding: .75rem 1rem; border-radius: 8px; margin-bottom: .5rem; }
.alerta-item.alerta-danger  { background: rgba(239,68,68,.10); border-left: 4px solid var(--danger); }
.alerta-item.alerta-warning { background: rgba(245,158,11,.10); border-left: 4px solid var(--warning); }
.alerta-item.alerta-info    { background: rgba(0,198,255,.08);  border-left: 4px solid var(--primary); }
.alerta-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.alerta-dot-danger  { background: var(--danger);  box-shadow: 0 0 6px var(--danger); }
.alerta-dot-warning { background: var(--warning); box-shadow: 0 0 6px var(--warning); }
.alerta-dot-info    { background: var(--primary); box-shadow: 0 0 6px var(--primary); }
.alerta-text { font-size: .8125rem; color: var(--text); line-height: 1.4; font-weight: 500; }
.alerta-text strong { font-weight: 700; }

/* ─── ADVANCED KPI GRID ──────────────────────────────────── */
.kpi-advanced-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem;
}
.adv-kpi-card {
  background: linear-gradient(145deg, var(--surface), var(--bg2));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.125rem 1.25rem; box-shadow: var(--shadow); text-align: center;
}
.adv-kpi-label { font-size: .65rem; font-weight: 500; color: var(--text-muted);
                 text-transform: uppercase; letter-spacing: .08em; margin-bottom: .4rem; }
.adv-kpi-value { font-size: 1.875rem; font-weight: 700; line-height: 1; }
.adv-kpi-unit  { font-size: .72rem; color: var(--text-muted); margin-top: .175rem; }
.adv-kpi-desc  { font-size: .68rem; color: var(--text-muted); margin-top: .3rem; }
.adv-warn    { color: var(--warning); }
.adv-success { color: var(--success); }
.adv-danger  { color: var(--danger); }

/* ─── EMPRESA CARD — valores coloridos ───────────────────── */
.empresa-card-codigo { font-size: 1rem; font-weight: 800; letter-spacing: -.2px; }
.empresa-card-nome   { font-size: .7rem; color: var(--text-muted); margin-top: .1rem; }
.emp-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: .3rem 0; font-size: .8125rem;
}
.emp-row + .emp-row { border-top: 1px solid rgba(255,255,255,.04); }
.emp-row span  { color: var(--text-muted); font-size: .73rem; text-transform: uppercase;
                 letter-spacing: .05em; }
.emp-row strong { font-variant-numeric: tabular-nums; font-weight: 700; }
.emp-val-pos  { color: var(--success) !important; }
.emp-val-neg  { color: var(--danger)  !important; }
.emp-val-warn { color: var(--warning) !important; }
.emp-row-total {
  border-top: 2px solid var(--border) !important; margin-top: .375rem; padding-top: .375rem !important;
}

/* ─── CONTA ROWS ─────────────────────────────────────────── */
.conta-row { display: flex; justify-content: space-between; align-items: center;
             padding: .5rem 0; border-bottom: 1px solid var(--border); }
.conta-row:last-child { border-bottom: none; }
.conta-banco  { font-weight: 600; font-size: .875rem; }
.conta-sub    { font-size: .7rem; color: var(--text-muted); margin-top: .1rem; }
.conta-saldo  { font-weight: 700; font-size: .9375rem; }
.conta-fonte  { font-size: .65rem; margin-top: .1rem; }
.fonte-ob     { color: var(--success); }
.fonte-manual { color: var(--text-muted); }

/* ─── AGING VISUAL CARDS (Créditos tab) ─────────────────── */
.aging-visual-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: .75rem; margin-bottom: .5rem;
}
.aging-visual-card {
  background: linear-gradient(145deg, var(--surface), var(--bg2));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; text-align: center; transition: transform .15s;
}
.aging-visual-card:hover { transform: translateY(-2px); }
.aging-vc-label { font-size: .7rem; color: var(--text-muted); font-weight: 600;
                  text-transform: uppercase; letter-spacing: .06em; margin-bottom: .5rem; }
.aging-vc-value { font-size: 1.0625rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.aging-vc-count { font-size: .7rem; color: var(--text-muted); margin-top: .375rem; }

.aging-vc-corrente { border-top: 3px solid #10b981; }
.aging-vc-corrente .aging-vc-value { color: #10b981; }
.aging-vc-30 { border-top: 3px solid #0ea5e9; }
.aging-vc-30 .aging-vc-value { color: #0ea5e9; }
.aging-vc-60 { border-top: 3px solid #f59e0b; }
.aging-vc-60 .aging-vc-value { color: #f59e0b; }
.aging-vc-90 { border-top: 3px solid #f97316; }
.aging-vc-90 .aging-vc-value { color: #f97316; }
.aging-vc-90p { border-top: 3px solid #ef4444; }
.aging-vc-90p .aging-vc-value { color: #ef4444; }

/* ─── OPEN BANKING PANEL ─────────────────────────────────── */
.ob-header {
  background: linear-gradient(145deg, var(--surface), var(--bg2));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; margin-bottom: 1.25rem;
}
.ob-brand { display: flex; align-items: center; gap: .875rem; margin-bottom: .75rem; }
.ob-status-pill {
  display: inline-flex; align-items: center; gap: .375rem;
  padding: .25rem .75rem; border-radius: 20px; font-size: .75rem; font-weight: 700;
}
.ob-online  { background: rgba(0,229,160,.15); color: var(--success); }
.ob-offline { background: rgba(255,77,106,.15); color: var(--danger); }
.ob-status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor;
                 animation: pulse 2s infinite; }
.ob-desc { font-size: .8125rem; color: var(--text-muted); line-height: 1.5; }

.ob-empresa-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: .875rem;
  box-shadow: var(--shadow);
}
.ob-empresa-header {
  display: flex; align-items: center; gap: .625rem;
  margin-bottom: .875rem; padding-bottom: .625rem; border-bottom: 1px solid var(--border);
}
.ob-empresa-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.ob-empresa-header strong { font-size: .9375rem; }
.ob-conta-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: .625rem 0; border-bottom: 1px solid rgba(255,255,255,.04);
}
.ob-conta-row:last-child { border-bottom: none; }
.ob-conta-info { display: flex; align-items: center; gap: .75rem; }
.ob-conta-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ob-dot-on  { background: var(--success); box-shadow: 0 0 6px var(--success); }
.ob-dot-off { background: var(--text-muted); }
.ob-conta-banco { font-weight: 600; font-size: .875rem; display: flex; align-items: center; gap: .5rem; }
.ob-conta-saldo { font-variant-numeric: tabular-nums; color: var(--primary); }
.ob-conta-iban  { font-size: .7rem; color: var(--text-muted); margin-top: .1rem; }
.ob-conta-actions { display: flex; gap: .375rem; align-items: center; }
.ob-btn-sync {
  width: 30px; height: 30px; border-radius: 8px; border: none;
  background: rgba(0,198,255,.15); color: var(--primary); cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.ob-btn-sync:hover { background: var(--primary); color: #000; }
.ob-btn-del {
  width: 30px; height: 30px; border-radius: 8px; border: none;
  background: rgba(255,77,106,.15); color: var(--danger); cursor: pointer;
  font-size: .875rem; display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.ob-btn-del:hover { background: var(--danger); color: #fff; }
.ob-manual-badge {
  font-size: .65rem; font-weight: 700; color: var(--text-muted);
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 20px; padding: .15rem .625rem; text-transform: uppercase; letter-spacing: .06em;
}
.ob-footer-note { margin-top: .5rem; padding: .625rem; }

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 1100px) {
  .dashboard-main-grid { grid-template-columns: 1fr; }
  .dashboard-sidebar { position: static; }
  .dashboard-charts-grid { grid-template-columns: 1fr; }
  .empresas-grid { grid-template-columns: repeat(2, 1fr); }
  .alertas-list-grid { grid-template-columns: 1fr; }
  .kpi-advanced-grid { grid-template-columns: repeat(2, 1fr); }
  .aging-visual-grid { grid-template-columns: repeat(3, 1fr); }
  .emp-kpis-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  .aging-visual-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-advanced-grid { grid-template-columns: 1fr 1fr; }
  .emp-kpis-grid { grid-template-columns: repeat(2, 1fr); }
  .emp-tabs { gap: 0; }
  .emp-tab  { font-size: .72rem; padding: .5rem .6rem; }
}

/* ─── EMPRESA CARD CLICKABLE ─────────────────────────────── */
.empresa-card-clickable {
  cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s;
}
.empresa-card-clickable:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 36px rgba(0,0,0,.45);
  border-color: var(--primary);
}

/* ─── EMPRESA CARD — refined ─────────────────────────────── */
.empresa-card {
  background: linear-gradient(145deg, var(--surface), var(--bg2));
}
.empresa-card h4 { font-size: 1.0625rem; letter-spacing: -.2px; }
.empresa-row { font-size: .8125rem; padding: .375rem 0; }
.empresa-row + .empresa-row { border-top: 1px solid rgba(255,255,255,.04); }
.empresa-row span:first-child { color: var(--text-muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
.empresa-row strong { font-variant-numeric: tabular-nums; font-size: .9rem; }

/* ─── EMPRESA DETAIL HEADER ──────────────────────────────── */
.emp-detail-header {
  display: flex; align-items: center; gap: .875rem;
  margin-bottom: 1.25rem;
}
.emp-back-btn { font-size: 1.25rem; flex-shrink: 0; }
.emp-detail-identity { display: flex; flex-direction: column; line-height: 1.2; }
.emp-detail-label { font-size: .65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; }
.emp-detail-nome  { font-size: 1.25rem; font-weight: 700; color: var(--text); letter-spacing: -.02em; }
.emp-detail-codigo {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 20px;
  padding: .2rem .875rem; font-size: .8rem; color: var(--primary); font-weight: 700;
}
.emp-detail-spacer { flex: 1; }

/* ─── EMPRESA KPIs — 6 colunas, largura total ────────────── */
.emp-kpis-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: .875rem;
  margin-bottom: 1.25rem;
}

/* ─── EMPRESA TABS (6 separadores temáticos) ─────────────── */
.emp-tabs {
  display: flex; gap: .25rem; flex-wrap: wrap;
  border-bottom: 2px solid var(--border); margin-bottom: 1.25rem;
  padding-bottom: 0;
}
.emp-tab {
  padding: .625rem 1rem; border: none; background: transparent;
  color: var(--text-muted); font-size: .8125rem; font-weight: 500;
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color .15s, border-color .15s; border-radius: 6px 6px 0 0; white-space: nowrap;
}
.emp-tab:hover  { color: var(--text); background: var(--surface2); }
.emp-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; background: transparent; }
.emp-tab-content         { display: none; }
.emp-tab-content.active  { display: block; }

/* legacy (manter compatibilidade) */
.empresa-subtab-content { display: none; }
.empresa-subtab-content.active { display: block; }

/* ─── KPI CARDS (empresa detail) ────────────────────────── */
.kpi-card {
  background: linear-gradient(145deg, var(--surface), var(--bg2));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.125rem 1.25rem; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--primary);
}
.kpi-card.success::before { background: var(--success); }
.kpi-card.danger::before  { background: var(--danger); }
.kpi-card.warning::before { background: var(--warning); }
.kpi-card-icon  { font-size: 1.25rem; float: right; opacity: .6; margin-top: .125rem; }
.kpi-card-label { font-size: .65rem; font-weight: 700; color: var(--text-muted);
                  text-transform: uppercase; letter-spacing: .1em; margin-bottom: .4rem; }
.kpi-card-value { font-size: 1.3rem; font-weight: 800; color: var(--text);
                  font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi-card.success .kpi-card-value { color: var(--success); }
.kpi-card.danger  .kpi-card-value { color: var(--danger); }
.kpi-card.warning .kpi-card-value { color: var(--warning); }
.kpi-card-sub { font-size: .68rem; color: var(--text-muted); margin-top: .375rem; }

/* ─── DETAIL PANEL ───────────────────────────────────────── */
.detail-panel {
  background: linear-gradient(145deg, var(--surface), var(--bg2));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: var(--shadow);
}
.detail-panel-header {
  display: flex; align-items: center; gap: .625rem; margin-bottom: 1rem;
  padding-bottom: .75rem; border-bottom: 1px solid var(--border);
}
.detail-panel-header h3 { font-size: .875rem; font-weight: 600; color: var(--text); flex: 1; }
.detail-panel-total { font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums;
                      color: var(--primary); }
.detail-panel-actions { display: flex; gap: .375rem; flex-wrap: wrap; align-items: center; }

/* Financiamentos cards */
.fin-card {
  background: var(--bg2); border: 1px solid var(--border); border-left: 3px solid var(--primary);
  border-radius: var(--radius); padding: 1rem; margin-bottom: .625rem;
}
.fin-card-cauc { border-left-color: var(--warning); }
.fin-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: .75rem; }
.fin-card-title { font-size: .875rem; font-weight: 600; color: var(--text); }
.fin-card-sub   { font-size: .7rem; color: var(--text-muted); margin-top: .1rem; }
.fin-card-grid  { display: grid; grid-template-columns: repeat(3,1fr); gap: .5rem; margin-bottom: .5rem; }
.fin-kpi-label  { font-size: .6rem; font-weight: 500; text-transform: uppercase; letter-spacing: .07em;
                  color: var(--text-muted); margin-bottom: .1rem; }
.fin-kpi-val    { font-size: .9375rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.fin-progress-label { display: flex; justify-content: space-between; font-size: .68rem;
                      color: var(--text-muted); margin-bottom: .25rem; }
.fin-progress-bar   { height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; }
.fin-progress-fill  { height: 100%; background: var(--success); border-radius: 3px; transition: width .4s; }
.fin-split-grid     { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }

/* ─── COMPROMISSOS (tab global) ──────────────────────────── */
.comp-kpis-grid {
  display: grid; grid-template-columns: repeat(4,1fr); gap: 1rem; margin-bottom: 1.25rem;
}
.comp-kpi-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.25rem; box-shadow: var(--shadow);
}
.comp-kpi-label { font-size: .65rem; font-weight: 500; text-transform: uppercase;
                  letter-spacing: .07em; color: var(--text-muted); margin-bottom: .25rem; }
.comp-kpi-val   { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.comp-kpi-sub   { font-size: .68rem; color: var(--text-muted); margin-top: .2rem; }
.venc-list      { display: flex; flex-direction: column; gap: .5rem; }
.venc-grid      { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.venc-item {
  display: flex; align-items: center; gap: 1rem;
  padding: .75rem 1rem; background: var(--surface2);
  border-radius: var(--radius); border-left: 3px solid var(--border);
}
.venc-item.urgente  { border-left-color: var(--danger); }
.venc-item.proximo  { border-left-color: var(--warning); }
.venc-item.normal   { border-left-color: var(--primary); }
.venc-data  { font-size: .75rem; font-weight: 700; min-width: 80px; color: var(--text-muted); }
.venc-icon  { font-size: 1.1rem; flex-shrink: 0; }
.venc-info  { flex: 1; min-width: 0; }
.venc-desc  { font-size: .875rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.venc-forn  { font-size: .7rem; color: var(--text-muted); margin-top: .1rem; }
.venc-right { text-align: right; flex-shrink: 0; }
.venc-val   { font-size: .9375rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.venc-emp   { font-size: .68rem; color: var(--text-muted); margin-top: .1rem; }
.btn-pagar  {
  display: inline-block; padding: .25rem .75rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: 20px; font-size: .72rem;
  font-weight: 600; color: var(--text-muted); cursor: pointer;
  transition: all .15s; white-space: nowrap;
}
.btn-pagar:hover { border-color: var(--success); color: var(--success); }
.cat-list { display: flex; flex-direction: column; gap: .5rem; }
.cat-row  { display: flex; align-items: center; justify-content: space-between; padding: .375rem 0; }
.cat-name { display: flex; align-items: center; gap: .5rem; font-size: .875rem; }
.cat-val  { font-size: .875rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--primary); }

/* Btn helpers */
.btn-active { background: var(--primary) !important; color: #000 !important; font-weight: 700; }
.btn-danger-soft { background: rgba(255,77,106,.12); color: var(--danger); border: 1px solid rgba(255,77,106,.3); }
.btn-danger-soft:hover { background: rgba(255,77,106,.25); }

/* Estado badges extras */
.estado-ativo  { background: rgba(0,229,160,.12); color: var(--success); }
.estado-ativa  { background: rgba(245,158,11,.12); color: var(--warning); }
.detail-section-label {
  font-size: .65rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: .1em; margin-bottom: .375rem;
}
.detail-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: .5rem 0; border-bottom: 1px solid rgba(255,255,255,.04);
}
.detail-row:last-child { border-bottom: none; }
.detail-row-title { font-size: .875rem; font-weight: 600; color: var(--text); }
.detail-row-sub   { font-size: .7rem; color: var(--text-muted); margin-top: .1rem; }
.detail-row-value { font-size: .9375rem; font-weight: 700; }
.detail-row-badge {
  display: inline-block; font-size: .65rem; padding: .125rem .5rem;
  border-radius: 20px; margin-top: .2rem;
}
.badge-ob     { background: rgba(0,229,160,.12); color: var(--success); }
.badge-manual { background: rgba(122,139,168,.1); color: var(--text-muted); }
.detail-empty { text-align: center; padding: 1.5rem; color: var(--text-muted); font-size: .875rem; }

/* ─── KPI CARDS GRID (empresa detail) ───────────────────── */
.kpi-cards-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .875rem;
}

/* ─── AGING MAP TABLE ────────────────────────────────────── */
.aging-table-wrap { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.aging-table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .8125rem; }

/* Column headers */
.aging-th-name  { padding: .75rem 1rem; text-align: left; font-size: .7rem; font-weight: 700;
                  color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em;
                  background: var(--bg2); border-bottom: 1px solid var(--border); min-width: 200px; }
.aging-th-count { padding: .75rem .75rem; text-align: center; font-size: .7rem; font-weight: 700;
                  color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em;
                  background: var(--bg2); border-bottom: 1px solid var(--border); width: 70px; }
.aging-th-total { padding: .75rem 1rem; text-align: center; font-size: .7rem; font-weight: 700;
                  color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em;
                  background: var(--bg2); border-bottom: 1px solid var(--border); min-width: 130px; }
.aging-th-pmr   { padding: .75rem .75rem; text-align: center; font-size: .7rem; font-weight: 700;
                  color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em;
                  background: var(--bg2); border-bottom: 1px solid var(--border); width: 65px; }
.aging-th {
  padding: .75rem 1rem; text-align: center; font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--border);
  white-space: nowrap; min-width: 100px;
}
.aging-corrente { background: rgba( 0,198,255,.18); color: #7de8ff; }
.aging-30       { background: rgba( 0,229,160,.15); color: #7dffd8; }
.aging-60       { background: rgba(245,158, 11,.18); color: #fcd34d; }
.aging-90       { background: rgba(251,113, 30,.18); color: #fb923c; }
.aging-90p      { background: rgba(255, 77,106,.18); color: #ff8fa3; }

/* Cells */
.aging-name { padding: .625rem 1rem; font-weight: 600; color: var(--text);
              border-bottom: 1px solid var(--border); }
.aging-count-cell { padding: .625rem .75rem; text-align: center; border-bottom: 1px solid var(--border); }
.aging-count-bubble {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 26px; border-radius: 50%;
  background: var(--surface2); color: var(--text); font-size: .7rem; font-weight: 700;
  padding: 0 4px;
}
.aging-total-cell { padding: .625rem 1rem; text-align: right; border-bottom: 1px solid var(--border); }
.aging-total-val  { display: block; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.aging-total-pct  { display: block; font-size: .7rem; color: var(--text-muted); }
.aging-val { padding: .625rem 1rem; text-align: right; border-bottom: 1px solid var(--border);
             font-variant-numeric: tabular-nums; }
.aging-zero { color: var(--text-muted); }
.aging-corrente-val span:not(.aging-zero) { color: #7de8ff; font-weight: 600; }
.aging-30-val       span:not(.aging-zero) { color: #7dffd8; font-weight: 600; }
.aging-60-val       span:not(.aging-zero) { color: #fcd34d; font-weight: 600; }
.aging-90-val       span:not(.aging-zero) { color: #fb923c; font-weight: 600; }
.aging-90p-val      span:not(.aging-zero) { color: #ff8fa3; font-weight: 600; }
.aging-pmr-cell { padding: .625rem .75rem; text-align: center; border-bottom: 1px solid var(--border); }

.aging-table tbody tr:hover td,
.aging-table tbody tr:hover .aging-name,
.aging-table tbody tr:hover .aging-count-cell,
.aging-table tbody tr:hover .aging-total-cell,
.aging-table tbody tr:hover .aging-val,
.aging-table tbody tr:hover .aging-pmr-cell { background: rgba(255,255,255,.03); }

/* Footer row */
.aging-footer td { background: var(--bg2); border-top: 2px solid var(--border);
                   border-bottom: none; padding: .625rem 1rem; font-variant-numeric: tabular-nums; }
.aging-footer .aging-count-cell,
.aging-footer .aging-pmr-cell  { padding: .625rem .75rem; }
.aging-footer .aging-total-cell { padding: .625rem 1rem; text-align: right; }

/* PMR badges */
.pmr-badge {
  display: inline-block; padding: .175rem .5rem; border-radius: 20px;
  font-size: .75rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.pmr-ok       { background: rgba(0,229,160,.15);  color: var(--success); }
.pmr-warn     { background: rgba(0,198,255,.15);  color: var(--primary); }
.pmr-alert    { background: rgba(245,158,11,.15); color: var(--warning); }
.pmr-danger   { background: rgba(251,113,30,.15); color: #fb923c; }
.pmr-critical { background: rgba(255,77,106,.15); color: var(--danger); }

/* Aging summary pills */
.aging-summary-pills { display: flex; gap: .625rem; flex-wrap: wrap; }
.aging-pill {
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: .375rem 1rem; font-size: .8125rem; display: flex; align-items: center; gap: .5rem;
  color: var(--text-muted);
}

/* ─── MAPA TESOURARIA ────────────────────────────────────── */
.mapa-header {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.mapa-header-left { flex: 1; min-width: 200px; }
.mapa-title    { font-size: 1.1rem; font-weight: 700; color: var(--text); margin: 0 0 .2rem; }
.mapa-subtitle { font-size: .72rem; color: var(--text-muted); }

.mapa-chart-header { margin-bottom: .75rem; }
.mapa-chart-title  { font-size: .875rem; font-weight: 700; color: var(--text); }

.mapa-filters {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
}
.mapa-sel-primary {
  background: linear-gradient(135deg, #6366f1, #0ea5e9) !important;
  color: #fff !important; font-weight: 600 !important;
  border-color: transparent !important;
}
.mapa-filters select {
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: .375rem .75rem; font-size: .8125rem; cursor: pointer;
}
.mapa-filters select:focus { outline: none; border-color: var(--primary); }

/* KPI grid de 6 colunas */
.kpi-grid-3 {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem;
}
.kpi-grid-6 {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 1rem;
}

/* Cenários */
.mapa-cenarios-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem;
}
.cenario-card {
  background: linear-gradient(145deg, var(--surface), var(--bg2)); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem 1rem; text-align: center;
}
.cenario-header { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.cenario-icon   { font-size: 1rem; }
.cenario-nome {
  font-size: .75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; margin-bottom: .5rem;
}
.cenario-saldo {
  font-size: 1.4rem; font-weight: 800; margin-bottom: .25rem;
  font-variant-numeric: tabular-nums;
}
.cenario-sub         { font-size: .7rem; color: var(--text-muted); margin-bottom: .5rem; }
.cenario-alerta      { font-size: .75rem; font-weight: 600; margin-top: .375rem; }
.cenario-alerta-nec  { color: var(--warning); }
.cenario-alerta-ok   { color: var(--success); }

/* Tabela do Mapa */
.mapa-table { width: 100%; border-collapse: collapse; font-size: .8rem; }

.mapa-table thead th {
  padding: .625rem .875rem; text-align: right; font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted);
  background: var(--bg2); border-bottom: 2px solid var(--border); white-space: nowrap;
}
.mapa-table thead th:first-child { text-align: left; min-width: 130px; }
.mapa-table tbody td:first-child,
.mapa-table tfoot td:first-child { text-align: left; }

.mapa-table tbody td {
  padding: .5rem .875rem; border-bottom: 1px solid var(--border); text-align: right;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.mapa-table tbody tr:hover td { background: rgba(255,255,255,.025); }
.mapa-row-deficit td          { background: rgba(239,68,68,.06) !important; }

.mapa-table tfoot td {
  padding: .625rem .875rem; border-top: 2px solid var(--border); border-bottom: none;
  background: rgba(14,165,233,.07); white-space: nowrap; font-variant-numeric: tabular-nums; text-align: right;
}
.mapa-table tfoot td:first-child { text-align: left; }

/* Cabeçalhos coloridos por tipo de fluxo */
.mapa-entradas     { background: rgba(16,185,129,.12) !important; color: #6ee7b7 !important; }
.mapa-saidas       { background: rgba(239,68,68,.12)  !important; color: #fca5a5 !important; }
.mapa-prestacoes   { background: rgba(245,158,11,.12) !important; color: #fcd34d !important; }
.mapa-compromissos { background: rgba(139,92,246,.12) !important; color: #c4b5fd !important; }

/* Valores coloridos nas células */
.mapa-entradas-val     span:not([style*="muted"]) { color: #10b981; }
.mapa-saidas-val       span:not([style*="muted"]) { color: #ef4444; }
.mapa-prestacoes-val   span:not([style*="muted"]) { color: #f59e0b; }
.mapa-compromissos-val span:not([style*="muted"]) { color: #8b5cf6; }

/* Painel de "sem alertas" */
.mapa-ok-panel {
  display: flex; align-items: center; gap: .75rem;
  background: rgba(0,229,160,.06); border: 1px solid rgba(0,229,160,.2);
  border-radius: var(--radius); padding: 1rem 1.25rem; color: var(--success);
  font-size: .875rem;
}

@media (max-width: 1100px) {
  .kpi-grid-6 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 700px) {
  .kpi-grid-6          { grid-template-columns: repeat(2, 1fr); }
  .mapa-cenarios-grid  { grid-template-columns: 1fr; }
}

/* ─── SEMÁFORO CONTAS BANCÁRIAS ──────────────────────────── */
.semaforo {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  flex-shrink: 0; vertical-align: middle; margin-right: 5px;
  box-shadow: 0 0 5px currentColor;
}
.semaforo-green  { background: var(--success); color: var(--success); }
.semaforo-yellow { background: var(--warning); color: var(--warning); }
.semaforo-orange { background: #fb923c;        color: #fb923c; }
.semaforo-red    { background: var(--danger);  color: var(--danger); }

.detail-row-title { display: flex; align-items: center; }
.val-neg { color: var(--danger) !important; }

/* ─── DELTA BADGES NOS KPI CARDS ────────────────────────── */
.card-delta {
  display: inline-block; font-size: .7rem; font-weight: 700;
  padding: .1rem .4rem; border-radius: 20px; margin: .2rem 0 .15rem;
  letter-spacing: .02em;
}
.delta-up   { background: rgba(0,229,160,.15); color: var(--success); }
.delta-down { background: rgba(255,77,106,.15); color: var(--danger); }

/* ─── BOTÃO SNAPSHOT ─────────────────────────────────────── */
.btn-snapshot {
  background: rgba(139,92,246,.15); color: #a78bfa;
  border: 1px solid rgba(139,92,246,.3); border-radius: var(--radius);
  padding: .4rem .875rem; font-size: .8125rem; font-weight: 600;
  transition: background .15s;
}
.btn-snapshot:hover { background: rgba(139,92,246,.25); }
.aging-pill strong { color: var(--text); font-weight: 700; }

/* ─── CRÉDITOS TAB ───────────────────────────────────────── */
.creditos-header {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem;
}
.creditos-header-left { flex: 1; min-width: 200px; }
.creditos-title    { font-size: 1.1rem; font-weight: 700; color: var(--text); margin: 0 0 .2rem; }
.creditos-subtitle { font-size: .72rem; color: var(--text-muted); }
.creditos-header-actions {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
}
.creditos-header-actions select {
  background: var(--surface2); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .375rem .75rem; font-size: .8125rem;
}
.creditos-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem; flex-wrap: wrap; gap: .5rem;
}
.creditos-panel-title { font-size: .875rem; font-weight: 700; color: var(--text); margin: 0; }
.creditos-charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.25rem; }
.creditos-chart-title { font-size: .8125rem; font-weight: 700; color: var(--text); margin-bottom: .75rem; }

/* ─── ADMINISTRAÇÃO ──────────────────────────────────────── */
.admin-subtabs {
  display: flex; gap: .25rem; flex-wrap: wrap; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .375rem; margin-bottom: 1.25rem;
}
.admin-subtabs-spacer { flex: 1; }
.admin-subtab {
  padding: .5rem 1rem; border-radius: calc(var(--radius) - 2px);
  font-size: .8125rem; font-weight: 500; color: var(--text-muted);
  background: transparent; border: none; cursor: pointer;
  transition: all .15s; white-space: nowrap;
}
.admin-subtab:hover  { color: var(--text); background: var(--surface2); }
.admin-subtab.active { color: var(--text); background: var(--surface2);
                       box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.admin-tab-content   { display: none; }
.admin-tab-content.active { display: block; }
.admin-toolbar { display: flex; gap: .5rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.admin-panel-title { font-size: .875rem; font-weight: 700; color: var(--text); margin-bottom: 1rem; }
.admin-split-grid  { display: grid; grid-template-columns: 280px 1fr; gap: 1rem; }

/* Logo */
.admin-logo-wrap { display: flex; flex-direction: column; gap: .75rem; }
.admin-logo-preview-box {
  width: 100%; min-height: 80px; background: var(--surface2);
  border: 2px dashed var(--border); border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}

/* Perfil badge */
.admin-perfil-badge {
  display: inline-block; padding: .2rem .625rem; border-radius: 20px;
  font-size: .7rem; font-weight: 700; border: 1px solid;
}

/* Count badge */
.admin-count-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%; font-size: .75rem; font-weight: 700;
}

/* Checkbox grid (empresas / tabs) */
.admin-check-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: .375rem;
}
/* 2FA toggle row */
.admin-mfa-row {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .625rem .875rem;
}
.admin-mfa-toggle {
  display: flex; align-items: center; gap: .5rem;
  cursor: pointer; flex: 1;
}
.admin-mfa-toggle input[type="checkbox"] {
  width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer;
}
.admin-mfa-label { font-size: .8125rem; color: var(--text); }
.admin-mfa-hint  { font-size: .75rem; color: var(--text-muted); margin-top: .375rem; }
.admin-check-item {
  display: flex; align-items: center; gap: .5rem; padding: .4rem .625rem;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: .8125rem; cursor: pointer;
  transition: border-color .15s;
}
.admin-check-item:hover { border-color: var(--primary); }
.admin-check-item input { accent-color: var(--primary); }
.admin-check-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* Color swatches */
.admin-color-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.admin-color-swatch {
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  position: relative; border: 2px solid transparent; transition: transform .1s;
}
.admin-color-swatch:hover { transform: scale(1.2); }
.swatch-check { font-size: .65rem; color: #fff; font-weight: 700; line-height: 1; }

/* Sistema info cards */
.admin-sys-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.admin-sys-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; text-align: center; box-shadow: var(--shadow);
}
.admin-sys-icon  { font-size: 1.75rem; margin-bottom: .375rem; }
.admin-sys-label { font-size: .68rem; font-weight: 600; text-transform: uppercase;
                   letter-spacing: .07em; color: var(--text-muted); margin-bottom: .375rem; }
.admin-sys-val   { font-size: 1.75rem; font-weight: 800; font-variant-numeric: tabular-nums; }

/* Audit entries */
.audit-entry {
  display: flex; gap: 1rem; padding: .875rem 0;
  border-bottom: 1px solid var(--border);
}
.audit-entry:last-child { border-bottom: none; }
.audit-icon {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: .875rem;
}
.audit-body       { flex: 1; min-width: 0; }
.audit-header-row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .2rem; }
.audit-user       { font-weight: 700; font-size: .875rem; }
.audit-action     { font-size: .8125rem; font-weight: 600; }
.audit-empresa    { font-size: .75rem; color: var(--text-muted); margin-left: auto; }
.audit-details    { font-size: .78rem; color: var(--text-muted); margin-bottom: .2rem;
                    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.audit-time       { font-size: .68rem; color: var(--text-muted); }

/* Integrações */
.admin-integ-ops-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.25rem;
}

/* ─── SYNC MAPAS UPLOAD ──────────────────────────────────── */
.sync-mapas-row {
  display: grid;
  grid-template-columns: 130px 1fr 1fr auto auto;
  gap: .5rem;
  align-items: center;
  padding: .5rem .25rem;
  border-bottom: 1px solid var(--border);
  font-size: .78rem;
}
.sync-mapas-totais {
  display: flex; flex-direction: column; gap: .15rem;
  min-width: 120px; text-align: right;
}
.sync-total-item {
  display: flex; justify-content: space-between; gap: .5rem; align-items: baseline;
}
.sync-total-label {
  font-size: .65rem; color: var(--text-muted); white-space: nowrap; text-transform: uppercase; letter-spacing: .04em;
}
.sync-total-val {
  font-size: .75rem; font-weight: 600; font-variant-numeric: tabular-nums;
}
.sync-total-compras { color: var(--danger); }
.sync-total-vendas  { color: var(--success); }
.sync-mapas-row:last-child { border-bottom: none; }
.sync-mapas-empresa { display: flex; flex-direction: column; gap: .1rem; }
.sync-mapas-sistema { font-size: .68rem; color: var(--text-muted); }
.sync-mapas-inputs  { display: flex; flex-direction: column; gap: .2rem; }
.sync-mapas-label   {
  display: flex; align-items: center; gap: .375rem; cursor: pointer;
}
.sync-mapas-label input[type="file"] { display: none; }
.sync-mapas-label > span:first-child { color: var(--text-muted); font-size: .7rem; width: 42px; }
.sync-mapas-btn {
  font-size: .7rem; padding: .2rem .5rem;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer; white-space: nowrap;
  transition: border-color .15s;
}
.sync-mapas-btn:hover { border-color: var(--primary); }
.sync-mapas-info { font-size: .68rem; color: var(--text-muted); padding-left: 50px; }
.admin-integ-section-title {
  font-size: .72rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .08em;
  margin-bottom: .75rem; padding-top: .25rem;
}

/* ─── CONCILIAÇÃO — subtabs, categorias, histórico ─────────── */
.concil-subtabs {
  display: flex; gap: 0; margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.concil-subtab {
  padding: .45rem 1rem; font-size: .8rem; font-weight: 500;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-muted); cursor: pointer; transition: color .15s, border-color .15s;
}
.concil-subtab:hover  { color: var(--text); }
.concil-subtab.active { color: var(--primary); border-bottom-color: var(--primary); }

.concil-cat-sel,
.concil-sub-sel {
  font-size: .7rem; padding: .15rem .3rem;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); max-width: 120px;
}
.concil-sub-sel { margin-left: .25rem; }

#tbl-movimentos th:nth-child(4),
#tbl-movimentos td:nth-child(4) { min-width: 200px; }

#hist-search {
  flex: 1; min-width: 140px;
  padding: .3rem .6rem;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: .8rem;
}
.admin-integ-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(240px,1fr)); gap: 1rem; margin-bottom: 1rem; }
.admin-integ-card { display: flex; gap: 1rem; align-items: flex-start; }
.admin-integ-icon { font-size: 2rem; flex-shrink: 0; margin-top: .25rem; }
.admin-integ-body { flex: 1; }
.admin-integ-title { font-size: .9375rem; font-weight: 700; margin-bottom: .125rem; }
.admin-integ-sub   { font-size: .72rem; color: var(--text-muted); margin-bottom: .5rem; }
.admin-integ-desc  { font-size: .78rem; color: var(--text-muted); line-height: 1.5; margin-bottom: .75rem; }
.admin-integ-soon  { opacity: .6; }
.admin-integ-badge {
  display: inline-block; padding: .2rem .625rem; border-radius: 20px; font-size: .7rem;
  font-weight: 700; background: var(--surface2); border: 1px solid var(--border); color: var(--text-muted);
}
.btn-danger { background: rgba(239,68,68,.15); color: var(--danger); border: 1px solid rgba(239,68,68,.3); }
.btn-danger:hover { background: var(--danger); color: #fff; }

/* ─── INTERCOMPANY ───────────────────────────────────────── */
.ic-filters {
  display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.ic-filters select {
  background: var(--surface2); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .375rem .75rem; font-size: .8125rem;
}
.ic-emp-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem;
  margin-bottom: 1.25rem;
}
.ic-emp-card {
  background: var(--surface2); border-radius: var(--radius);
  border-left: 4px solid var(--primary); padding: 1rem;
}
.ic-emp-nome { display: flex; align-items: center; gap: .5rem;
               font-size: .875rem; font-weight: 600; margin-bottom: .75rem; }
.ic-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ic-emp-saldos { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; font-size: .75rem; margin-bottom: .75rem; }
.ic-saldo-label { color: var(--text-muted); margin-bottom: .125rem; }
.ic-saldo-val   { font-weight: 700; font-variant-numeric: tabular-nums; }
.ic-emp-footer { border-top: 1px solid var(--border); padding-top: .625rem; font-size: .78rem; }
.ic-liquido-row { display: flex; justify-content: space-between; align-items: center; }
.ic-pos-row     { display: flex; justify-content: space-between; align-items: center;
                  margin-top: .25rem; font-size: .7rem; color: var(--text-muted); }
.ic-summary-bar {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: linear-gradient(135deg, rgba(14,165,233,.1), rgba(139,92,246,.1));
  border-radius: var(--radius); padding: 1rem; text-align: center;
}
.ic-summary-item + .ic-summary-item { border-left: 1px solid var(--border); }
.ic-summary-label { font-size: .68rem; color: var(--text-muted); margin-bottom: .25rem; text-transform: uppercase; letter-spacing: .06em; }
.ic-summary-val   { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ic-matrix-table  { width: 100%; border-collapse: collapse; font-size: .8125rem; }
.ic-matrix-table th, .ic-matrix-table td {
  padding: .625rem 1rem; border: 1px solid var(--border); white-space: nowrap;
}
.ic-matrix-table th     { background: var(--bg2); font-weight: 600; }
.ic-matrix-corner       { background: var(--bg2) !important; }
.ic-matrix-label        { background: var(--bg2); font-weight: 600; }
.ic-matrix-diag         { background: var(--surface2); text-align: center; color: var(--text-muted); }
.ic-matrix-zero         { text-align: right; color: var(--text-muted); }
.ic-matrix-val          { text-align: right; font-weight: 700; }
.ic-matrix-legend       { font-size: .72rem; color: var(--text-muted); margin-top: .625rem; }
.ic-ref { font-size: .75rem; background: var(--bg2); padding: .1rem .4rem;
          border-radius: 4px; font-family: monospace; letter-spacing: .02em; }

/* ─── EXTERNOS ───────────────────────────────────────────── */
.ic-ext-cards-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .75rem;
}
.ic-ext-card {
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .75rem; cursor: pointer; transition: border-color .15s;
  display: flex; flex-direction: column; gap: .2rem;
}
.ic-ext-card:hover { border-color: var(--primary); }
.ic-ext-card-nome { font-weight: 600; font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ic-ext-card-val  { font-size: 1rem; font-weight: 700; color: var(--primary); margin-top: .25rem; }

/* ─── CONTAS SPLIT (50/50) ───────────────────────────────── */
.contas-split-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }

/* ─── COMPROMISSOS POR CATEGORIA (empresa) ───────────────── */
.emp-comp-cat-grid {
  display: grid; grid-template-columns: repeat(3,1fr); gap: .75rem; margin-bottom: 1.25rem;
}
.emp-comp-cat-card {
  background: linear-gradient(145deg, var(--surface), var(--bg2));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: .875rem 1rem; display: flex; flex-direction: column; gap: .25rem;
  align-items: center; text-align: center;
}
.emp-comp-cat-icon  { font-size: 1.25rem; }
.emp-comp-cat-label { font-size: .7rem; font-weight: 600; color: var(--text-muted);
                      text-transform: uppercase; letter-spacing: .06em; }
.emp-comp-cat-val   { font-size: 1.0625rem; font-weight: 800; color: var(--primary);
                      font-variant-numeric: tabular-nums; }
.emp-comp-cat-sub   { font-size: .7rem; color: var(--text-muted); }

/* ─── COLLAPSIBLE SECTIONS (Vendas / Compras) ────────────── */
.collapsible-section {
  background: linear-gradient(145deg, var(--surface), var(--bg2));
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-top: 1rem; overflow: hidden;
}
.collapsible-header {
  display: flex; align-items: center; gap: .75rem;
  padding: .875rem 1.25rem; cursor: pointer; user-select: none;
  border-bottom: 1px solid transparent; transition: background .15s;
}
.collapsible-header:hover { background: rgba(255,255,255,.03); }
.collapsible-section.open .collapsible-header { border-bottom-color: var(--border); }
.collapsible-arrow { font-size: .75rem; color: var(--text-muted); transition: transform .2s; }
.collapsible-section.open .collapsible-arrow { transform: rotate(90deg); }
.collapsible-title { font-size: .875rem; font-weight: 600; color: var(--text); flex: 1; }
.collapsible-body  { display: none; padding: 1rem 1.25rem; }
.collapsible-section.open .collapsible-body { display: block; }

/* ─── RESUMO KPI CARDS (Vendas / Compras) ───────────────── */
.credito-resumo-grid {
  display: grid; grid-template-columns: repeat(3,1fr); gap: .75rem; margin-bottom: 1rem;
}
.credito-resumo-card {
  background: linear-gradient(145deg, var(--surface), var(--bg2));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem;
}
.credito-resumo-label { font-size: .7rem; font-weight: 600; color: var(--text-muted);
                        text-transform: uppercase; letter-spacing: .06em; margin-bottom: .375rem; }
.credito-resumo-val   { font-size: 1.375rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.credito-resumo-sub   { font-size: .75rem; color: var(--text-muted); margin-top: .25rem; }

/* ─── SYNC MAPAS ─────────────────────────────────────────── */
.sync-status { border-radius: 8px; padding: .6rem .8rem; font-size: .85rem; }
.sync-status-loading { background: rgba(14,165,233,.1); color: var(--primary); }
.sync-status-error   { background: rgba(239,68,68,.1);  color: #ef4444; }

.sync-result-box {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--success); border-radius: var(--radius); padding: 1.25rem;
}
.sync-result-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: .4rem;
}
.sync-result-ok { font-weight: 700; color: var(--success); }
.sync-result-grid {
  display: flex; gap: 1rem; flex-wrap: wrap; margin-top: .75rem;
}
.sync-stat {
  background: var(--bg-tertiary); border-radius: 8px;
  padding: .6rem 1rem; min-width: 80px; text-align: center;
}
.sync-stat-val   { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.sync-stat-label { font-size: .7rem; color: var(--text-muted); margin-top: .15rem; }
.sync-stat-imported .sync-stat-val { color: var(--success); }
.sync-stat-errors .sync-stat-val   { color: var(--danger); }
.sync-stat-dupes .sync-stat-val    { color: var(--text-muted); }
.sync-stat-deleted .sync-stat-val  { color: var(--warning); }
.sync-error-detail {
  margin-top: .75rem; padding: .5rem .75rem;
  background: rgba(239,68,68,.08); border-radius: 6px; font-size: .8rem; color: #ef4444;
}
.sync-aviso {
  margin-top: .75rem; padding: .5rem .75rem;
  background: rgba(245,158,11,.08); border-radius: 6px; font-size: .8rem; color: var(--warning);
}
.sync-hist-table {
  width: 100%; font-size: .78rem; border-collapse: collapse;
}
.sync-hist-table th {
  padding: .4rem .6rem; text-align: left; color: var(--text-muted);
  border-bottom: 1px solid var(--border); font-weight: 600;
}
.sync-hist-table td {
  padding: .4rem .6rem; border-bottom: 1px solid var(--border-secondary);
}
.sync-hist-table tr:last-child td { border-bottom: none; }
.sync-hist-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ─── TAB EXTRATOS — Dashboard FinDash-style ────────────── */

/* Barra superior: empresa pills + período */
.ext-topbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: .75rem;
  margin-bottom: .75rem;
}
.ext-emp-pills { display: flex; flex-wrap: wrap; gap: .35rem; flex: 1; }
.ext-emp-pill {
  padding: .3rem .85rem; border-radius: 20px; font-size: .8rem; font-weight: 500;
  border: 1px solid var(--border); background: var(--surface2); color: var(--text-muted);
  cursor: pointer; transition: all .15s;
}
.ext-emp-pill:hover  { border-color: var(--primary); color: var(--text); }
.ext-emp-pill.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

.ext-periodo { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.ext-ano-sel {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius); padding: .3rem .6rem; font-size: .8rem;
}
.ext-mes-btns { display: flex; gap: .2rem; flex-wrap: wrap; }
.ext-mes-btn {
  padding: .25rem .55rem; border-radius: var(--radius); font-size: .75rem; font-weight: 500;
  border: 1px solid transparent; background: none; color: var(--text-muted); cursor: pointer;
  transition: all .15s;
}
.ext-mes-btn:hover  { background: var(--surface2); color: var(--text); }
.ext-mes-btn.active { background: var(--surface2); border-color: var(--primary); color: var(--primary); font-weight: 700; }

.ext-periodo-label {
  font-size: .8rem; color: var(--text-muted); margin-bottom: .75rem;
}

/* KPI cards */
.ext-kpis-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem;
}
@media (max-width: 900px) { .ext-kpis-grid { grid-template-columns: repeat(2,1fr); } }
.ext-kpi-card {
  background: var(--surface2); border-radius: var(--radius); padding: 1.1rem 1.25rem;
  border-left: 4px solid var(--border);
}
.ext-kpi-primary { border-left-color: var(--primary); }
.ext-kpi-success { border-left-color: var(--success); }
.ext-kpi-danger  { border-left-color: var(--danger);  }
.ext-kpi-warning { border-left-color: var(--warning); }
.ext-kpi-muted   { border-left-color: var(--border);  }
.ext-kpi-label { font-size: .68rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: .4rem; }
.ext-kpi-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-bottom: .35rem; }
.ext-kpi-footer { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .75rem; color: var(--text-muted); }
.ext-kpi-pct { font-weight: 700; }
.ext-kpi-pct.pos { color: var(--success); }
.ext-kpi-pct.neg { color: var(--danger);  }
.ext-kpi-sub { color: var(--text-muted); }
.ext-kpi-alert { display: inline-block; background: var(--danger); color: #fff; padding: .1rem .45rem; border-radius: 4px; font-size: .68rem; font-weight: 700; margin-right: .25rem; }

/* Layout rows */
.ext-row { display: flex; gap: 1rem; margin-bottom: 1rem; align-items: flex-start; }
.ext-row-big .ext-panel-evolucao { flex: 3; min-width: 0; }
.ext-row-big .ext-panel-contas   { flex: 1.2; min-width: 200px; }
.ext-row-3col > .panel { flex: 1; min-width: 0; }
@media (max-width: 860px) { .ext-row { flex-direction: column; } }

.ext-panel-title {
  font-size: .68rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .08em; margin-bottom: .75rem;
}

/* Contas table */
.ext-contas-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.ext-contas-table th { font-size: .68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; padding: .3rem .4rem; border-bottom: 1px solid var(--border); }
.ext-contas-table td { padding: .4rem .4rem; border-bottom: 1px solid var(--border-secondary); }
.ext-contas-table tr:last-child td { border-bottom: none; }
.ext-conta-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .5rem; flex-shrink: 0; }

/* Previsão */
.ext-prev-row { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; font-size: .8rem; }
.ext-prev-label { width: 45px; flex-shrink: 0; color: var(--text-muted); }
.ext-prev-bar-wrap { flex: 1; height: 8px; background: var(--surface); border-radius: 4px; overflow: hidden; }
.ext-prev-bar { height: 100%; background: var(--primary); border-radius: 4px; transition: width .4s; }
.ext-prev-val { width: 80px; text-align: right; font-variant-numeric: tabular-nums; font-size: .75rem; }

/* Alertas */
.ext-alerta {
  display: flex; gap: .6rem; align-items: flex-start;
  padding: .55rem .7rem; border-radius: var(--radius); margin-bottom: .4rem;
  font-size: .8rem; border: 1px solid;
}
.ext-alerta-ok      { background: rgba(16,185,129,.08); border-color: rgba(16,185,129,.3); color: var(--success); }
.ext-alerta-warning { background: rgba(245,158,11,.08); border-color: rgba(245,158,11,.3); color: var(--warning); }
.ext-alerta-danger  { background: rgba(239,68,68,.08);  border-color: rgba(239,68,68,.3);  color: var(--danger);  }
.ext-alerta-icon { font-weight: 700; flex-shrink: 0; }
.ext-alerta-msg { font-weight: 600; }
.ext-alerta-sub { font-size: .72rem; opacity: .8; margin-top: .1rem; }

/* TOP Rankings */
.ext-rankings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 700px) { .ext-rankings-grid { grid-template-columns: 1fr; } }
.ext-rank-subtitle { font-size: .68rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .07em; margin-bottom: .6rem; }
.ext-rank-row { display: flex; align-items: center; gap: .5rem; margin-bottom: .45rem; }
.ext-rank-num { width: 18px; text-align: right; font-size: .72rem; color: var(--text-muted); flex-shrink: 0; }
.ext-rank-bar-wrap { flex: 1; position: relative; height: 22px; display: flex; align-items: center; }
.ext-rank-bar { position: absolute; left: 0; top: 0; height: 100%; border-radius: 3px; min-width: 4px; }
.ext-rank-name { position: relative; z-index: 1; font-size: .78rem; padding-left: .4rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ext-rank-val  { font-size: .78rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text-muted); }
.ext-rank-tipo {
  padding: .25rem .75rem; border-radius: 20px; font-size: .75rem; font-weight: 600;
  border: 1px solid var(--border); background: none; color: var(--text-muted); cursor: pointer;
  transition: all .15s;
}
.ext-rank-tipo.active { background: var(--danger); border-color: var(--danger); color: #fff; }
.ext-rank-tipo[data-tipo="credito"].active { background: var(--success); border-color: var(--success); }
.ext-rank-empty { font-size: .8rem; color: var(--text-muted); padding: .5rem 0; }

/* ─── ADMIN › EXTRATOS — categorias e regras ────────────── */
.admin-cats-list { display: flex; flex-direction: column; gap: .75rem; }

.admin-cat-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: .75rem 1rem; background: var(--surface2);
}
.admin-cat-header {
  display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem;
}
.admin-cat-nome { font-weight: 600; font-size: .875rem; flex: 1; }
.admin-cat-edit-btn,
.admin-cat-del-btn {
  background: none; border: none; cursor: pointer; font-size: .85rem;
  color: var(--text-muted); padding: .15rem .35rem; border-radius: 4px;
  transition: color .15s, background .15s;
}
.admin-cat-edit-btn:hover { color: var(--primary); background: rgba(14,165,233,.1); }
.admin-cat-del-btn:hover  { color: var(--danger);  background: rgba(239,68,68,.1); }

.admin-subcat-tags { display: flex; flex-wrap: wrap; gap: .4rem; }
.admin-subcat-tag {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .2rem .55rem; border-radius: 20px; font-size: .75rem;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
}
.admin-subcat-tag button {
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  font-size: .8rem; line-height: 1; padding: 0 .1rem;
  transition: color .15s;
}
.admin-subcat-tag button:hover { color: var(--danger); }
.admin-subcat-add {
  padding: .2rem .55rem; border-radius: 20px; font-size: .75rem;
  border: 1px dashed var(--primary); color: var(--primary); background: none;
  cursor: pointer; transition: background .15s;
}
.admin-subcat-add:hover { background: rgba(14,165,233,.1); }

.admin-rule-row {
  display: flex; align-items: center; gap: .5rem;
  padding: .35rem .6rem; border-radius: var(--radius); font-size: .78rem;
  background: var(--surface2); border: 1px solid var(--border);
}
.admin-rule-kws  { font-family: monospace; color: var(--primary); min-width: 80px; }
.admin-rule-arrow { color: var(--text-muted); flex-shrink: 0; }
.admin-rule-cat  { flex: 1; color: var(--text); }
.admin-rule-del  {
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  font-size: .85rem; padding: .1rem .3rem; border-radius: 4px; flex-shrink: 0;
}
.admin-rule-del:hover { color: var(--danger); background: rgba(239,68,68,.1); }

/* ─── EXTRATO — aba empresa + tab extratos ───────────────── */
.extrato-layout {
  display: flex; gap: 1rem; align-items: flex-start;
}

/* Painel lateral esquerdo */
.extrato-side {
  width: 220px; flex-shrink: 0;
  display: flex; flex-direction: column; gap: .75rem;
}
.extrato-side-section {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .75rem;
}
.extrato-side-title {
  font-size: .68rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .07em; margin-bottom: .5rem;
}

/* Lista de contas no painel lateral */
.extrato-conta-list { display: flex; flex-direction: column; gap: .3rem; }
.extrato-conta-item {
  padding: .45rem .6rem; border-radius: calc(var(--radius) - 2px);
  border: 1px solid transparent; cursor: pointer; transition: all .15s;
}
.extrato-conta-item:hover  { background: var(--surface); border-color: var(--border); }
.extrato-conta-item.active { background: var(--primary); border-color: var(--primary); }
.extrato-conta-item .bank-badge,
.extrato-conta-item .bank-badge-img { flex-shrink: 0; }
.extrato-conta-item-banco  { font-size: .78rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.extrato-conta-item.active .extrato-conta-item-banco,
.extrato-conta-item.active .extrato-conta-item-saldo,
.extrato-conta-item.active .extrato-conta-item-iban { color: #fff !important; }
.extrato-conta-item-saldo  {
  font-size: .8rem; font-weight: 700; font-variant-numeric: tabular-nums;
  white-space: nowrap; flex-shrink: 0;
}
.extrato-conta-item-iban   {
  font-size: .65rem; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Collapsible mês/ano na tabela de extrato */
.extrato-month-header {
  display: flex; align-items: center; gap: .5rem;
  padding: .4rem .6rem; background: var(--surface2);
  border-radius: var(--radius); cursor: pointer;
  font-size: .75rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .05em;
  user-select: none; transition: background .15s;
}
.extrato-month-header:hover { background: var(--border); }
.extrato-month-toggle { font-size: .6rem; transition: transform .2s; }
.extrato-month-toggle.open { transform: rotate(90deg); }
.extrato-month-summary {
  margin-left: auto; display: flex; gap: .75rem; font-size: .72rem; font-weight: 700;
}
.extrato-month-summary .sum-pos { color: var(--success); }
.extrato-month-summary .sum-neg { color: var(--danger); }
.extrato-month-rows { overflow: hidden; transition: max-height .25s ease; }
.extrato-month-rows.collapsed { max-height: 0 !important; }

/* Botões de importação */
.extrato-import-btn {
  display: flex; align-items: center; gap: .4rem;
  width: 100%; padding: .45rem .6rem; margin-bottom: .35rem;
  font-size: .78rem; font-weight: 500; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  transition: background .15s, border-color .15s;
}
.extrato-import-btn:last-of-type { margin-bottom: 0; }
.extrato-import-btn:hover { background: var(--surface2); border-color: var(--primary); color: var(--primary); }

/* Resumo de stats no painel lateral */
.extrato-stats-panel {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .75rem; font-size: .78rem;
}
.extrato-stat-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: .22rem 0; border-bottom: 1px solid var(--border-secondary);
}
.extrato-stat-row:last-child { border-bottom: none; }
.extrato-stat-row span  { color: var(--text-muted); font-size: .72rem; }
.extrato-stat-row strong { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Painel principal direito */
.extrato-main { flex: 1; min-width: 0; }

/* Barra de filtros */
.extrato-filters {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end;
  padding: .65rem .75rem; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: .5rem;
}
.extrato-filter-group { display: flex; flex-direction: column; gap: .2rem; }
.extrato-filter-label { font-size: .67rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }

#tbl-extrato th, #tbl-extrato td { padding: .35rem .6rem; font-size: .77rem; }
#tbl-extrato thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
#tbl-extrato tr.extrato-month-hdr td { padding: .25rem 0; background: transparent; border: none; }
#tbl-extrato tr.extrato-month-hdr:hover td { background: transparent; }

/* ─── LIGHT MODE ──────────────────────────────────────────── */
body.light-mode {
  --bg:        #f0f4f8;
  --bg2:       #e2e8f0;
  --surface:   #ffffff;
  --surface2:  #f8fafc;
  --border:    #cbd5e1;
  --text:      #1e293b;
  --text-muted:#64748b;
  --primary:   #0072cc;
  --primary-d: #005fa3;
  --success:   #059669;
  --warning:   #d97706;
  --danger:    #dc2626;
  --shadow:    0 4px 20px rgba(0,0,0,.1);
}
body.light-mode .topbar,
body.light-mode .tabs { background: #ffffff; border-bottom-color: #cbd5e1; }
body.light-mode .login-box { background: linear-gradient(145deg, #1e3a6e, #1a2d5a); }

body.light-mode .topbar-logo .logo-main { color: #1e293b; }
body.light-mode .tab { color: #475569; }
body.light-mode .tab:hover { background: #f1f5f9; color: #1e293b; }
body.light-mode .tab.active { color: #0072cc; border-bottom-color: #0072cc; }
body.light-mode .card { box-shadow: 0 2px 8px rgba(0,0,0,.08); }
body.light-mode .empresa-card { box-shadow: 0 2px 8px rgba(0,0,0,.08); }
body.light-mode select, body.light-mode input, body.light-mode textarea {
  background: #fff; color: #1e293b; border-color: #cbd5e1;
}
body.light-mode .modal-backdrop { background: rgba(0,0,0,.35); }
body.light-mode .modal-box { background: #fff; }

/* ─── BTN-THEME (toggle dark/light) ──────────────────────── */
#btn-theme {
  font-size: 1.1rem; padding: .35rem .45rem;
  border-radius: 8px; line-height: 1;
  transition: background .15s, transform .2s;
}
#btn-theme:hover { background: var(--surface); transform: rotate(20deg); }

/* ─── EMPRESA LOGO ────────────────────────────────────────── */
.empresa-card-logo {
  width: 42px; height: 42px; object-fit: contain; border-radius: 8px;
  background: rgba(255,255,255,.07); padding: 3px;
}
.empresa-card-logo-placeholder {
  width: 42px; height: 42px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .7rem; flex-shrink: 0;
}
/* Header logo on empresa detail */
.emp-detail-logo {
  width: 52px; height: 52px; object-fit: contain; border-radius: 10px;
  background: rgba(255,255,255,.07); padding: 4px; flex-shrink: 0;
}
.emp-detail-logo-placeholder {
  width: 52px; height: 52px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .85rem; flex-shrink: 0;
}
/* Upload button in admin table */
.btn-logo-upload {
  display: inline-flex; align-items: center; gap: .3rem;
  background: rgba(0,198,255,.1); color: var(--primary);
  border: 1px solid rgba(0,198,255,.25); border-radius: 6px;
  padding: .2rem .5rem; font-size: .72rem; cursor: pointer;
  transition: background .15s;
}
.btn-logo-upload:hover { background: rgba(0,198,255,.2); }
.btn-logo-thumb {
  width: 28px; height: 28px; object-fit: contain; border-radius: 5px;
  vertical-align: middle;
}

/* ─── BANK BADGE ──────────────────────────────────────────── */
.bank-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 7px;
  font-size: .62rem; font-weight: 800; letter-spacing: -.3px;
  flex-shrink: 0; text-transform: uppercase;
}
.bank-badge-lg {
  width: 40px; height: 40px; border-radius: 9px; font-size: .72rem;
}
.bank-badge-img {
  object-fit: contain; background: #fff; padding: 3px;
}
.fin-empresa-sel {
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: .35rem .75rem; font-size: .8125rem; min-width: 160px;
}
