/* ============================================================
   AUDITUS — Frente 1 (CNAB) — Tokens e estilos compartilhados
   ============================================================ */

:root {
  /* Marca */
  --brand-900: #1a3947;  --brand-800: #234c5e;  --brand-700: #2c6079;
  --brand-600: #3b7a96;  --brand-500: #5599b8;  --brand-50:  #eef5f9;

  /* Neutros */
  --ink-900: #0f1f28;  --ink-700: #2d4452;  --ink-500: #5b7280;
  --ink-400: #8a9ba6;  --ink-300: #b8c5cd;  --ink-200: #dde4e9;
  --ink-100: #eef2f5;  --ink-50:  #f7f9fa;  --white:   #ffffff;

  /* Semânticos */
  --success-700: #1e7a3d;  --success-600: #2c9a52;  --success-50: #e6f4ec;
  --warn-700:    #a86b00;  --warn-600:    #d18800;  --warn-50:    #fef4e0;
  --danger-700:  #b53034;  --danger-600:  #d63a3f;  --danger-50:  #fdeaeb;
  --info-700:    #1a5fa8;  --info-600:    #2a7bcf;  --info-50:    #e7f1fc;
  --purple-700:  #523794;  --purple-600:  #7a5cc7;  --purple-50:  #ede8f8;

  /* Status CNAB */
  --cnab-success: var(--success-600);
  --cnab-pending: var(--warn-600);
  --cnab-error:   var(--danger-600);
  --cnab-info:    var(--info-600);

  /* Raios e sombras */
  --r-sm: 6px;  --r-md: 10px;  --r-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15,31,40,0.04), 0 1px 1px rgba(15,31,40,0.03);
  --shadow-md: 0 4px 12px rgba(15,31,40,0.06), 0 2px 4px rgba(15,31,40,0.04);
  --shadow-lg: 0 12px 32px rgba(15,31,40,0.10), 0 4px 8px rgba(15,31,40,0.05);

  --sidebar-w: 232px;  --header-h: 56px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 14px; color: var(--ink-900); background: var(--ink-50);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
input, select, textarea { outline: none; }
a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; }

.tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; }

/* =========================== APP SHELL =========================== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  grid-template-areas: "topbar topbar" "sidebar main";
  height: 100vh;
}

.topbar {
  grid-area: topbar; background: var(--brand-900); color: var(--white);
  display: flex; align-items: center; padding: 0 20px; gap: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.topbar-logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; letter-spacing: -0.01em;
}
.topbar-logo-mark {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, #4ea5c8, #7fc4e0);
  border-radius: 6px; display: grid; place-items: center;
  font-size: 14px; font-weight: 800; color: var(--brand-900);
}
.breadcrumb {
  display: flex; align-items: center; gap: 8px;
  color: rgba(255,255,255,0.7); font-size: 13px; margin-left: 12px;
}
.breadcrumb b { color: var(--white); font-weight: 600; }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 8px;
  display: grid; place-items: center;
  color: rgba(255,255,255,0.85); transition: background 0.15s;
}
.icon-btn:hover { background: rgba(255,255,255,0.08); }
.user-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 12px 4px 4px; background: rgba(255,255,255,0.06);
  border-radius: 999px; font-size: 13px;
}
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, #6e9bb5, #3d7a99);
  display: grid; place-items: center; font-weight: 600; font-size: 11px;
}

/* Sidebar */
.sidebar {
  grid-area: sidebar; background: var(--white);
  border-right: 1px solid var(--ink-200);
  overflow-y: auto; padding: 14px 0;
}
.sidebar-section { padding: 0 12px; margin-bottom: 4px; }
.sidebar-group-label {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  font-size: 13px; font-weight: 600; color: var(--ink-700);
  border-radius: var(--r-sm); cursor: pointer;
}
.sidebar-group-label:hover { background: var(--ink-50); }
.sidebar-group-label .chev { margin-left: auto; transition: transform 0.2s; }
.sidebar-group.open .chev { transform: rotate(180deg); }

.sidebar-item {
  display: flex; align-items: center; padding: 7px 12px 7px 36px;
  font-size: 13px; color: var(--ink-700);
  border-radius: var(--r-sm); cursor: pointer; position: relative;
}
.sidebar-item:hover { background: var(--ink-50); }
.sidebar-item.active {
  background: var(--brand-50); color: var(--brand-800); font-weight: 600;
}
.sidebar-item.active::before {
  content: ''; position: absolute; left: 22px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 16px; background: var(--brand-700); border-radius: 2px;
}
.sidebar-item .badge {
  margin-left: auto; background: var(--danger-600); color: var(--white);
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 999px;
}
.sidebar-subitem {
  padding-left: 56px; font-size: 12.5px; color: var(--ink-500);
}

/* Main */
.main {
  grid-area: main; display: flex; flex-direction: column;
  overflow: auto; background: var(--ink-50);
}

/* Page header */
.page-header {
  padding: 22px 28px 14px; display: flex;
  align-items: flex-end; justify-content: space-between; gap: 24px;
}
.page-title-block h1 {
  font-size: 22px; font-weight: 700; letter-spacing: -0.02em;
  color: var(--ink-900); margin-bottom: 4px;
}
.page-subtitle { font-size: 13px; color: var(--ink-500); max-width: 720px; }
.page-actions { display: flex; gap: 8px; }

/* =========================== BUTTONS =========================== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 600; transition: all 0.15s;
  border: 1px solid transparent; white-space: nowrap;
}
.btn-primary { background: var(--brand-700); color: var(--white); }
.btn-primary:hover { background: var(--brand-800); }
.btn-secondary { background: var(--white); color: var(--ink-700); border-color: var(--ink-200); }
.btn-secondary:hover { border-color: var(--ink-300); background: var(--ink-50); }
.btn-ghost { color: var(--ink-700); padding: 9px 10px; }
.btn-ghost:hover { background: var(--ink-100); }
.btn-danger { background: var(--danger-600); color: var(--white); }
.btn-danger:hover { background: var(--danger-700); }
.btn-success { background: var(--success-600); color: var(--white); }
.btn-success:hover { background: var(--success-700); }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* =========================== CARDS =========================== */
.card {
  background: var(--white); border: 1px solid var(--ink-200);
  border-radius: var(--r-md); overflow: hidden;
}
.card-header {
  padding: 14px 18px; border-bottom: 1px solid var(--ink-200);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 14px; font-weight: 700; }
.card-body { padding: 18px; }
.card-footer {
  padding: 12px 18px; border-top: 1px solid var(--ink-200);
  background: var(--ink-50); display: flex; align-items: center; justify-content: space-between;
}

/* =========================== PILLS / BADGES =========================== */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; line-height: 1.5; white-space: nowrap;
}
.pill .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill-paid       { background: var(--success-50); color: var(--success-700); }
.pill-success    { background: var(--success-50); color: var(--success-700); }
.pill-pending    { background: var(--warn-50); color: var(--warn-700); }
.pill-error      { background: var(--danger-50); color: var(--danger-700); }
.pill-info       { background: var(--brand-50); color: var(--brand-800); }
.pill-neutral    { background: var(--ink-100); color: var(--ink-700); }
.pill-purple     { background: var(--purple-50); color: var(--purple-700); }
.pill-overdue    { background: var(--danger-50); color: var(--danger-700); }
.pill-overdue-crit { background: #5e1316; color: #ffe4e5; }
.pill-warning    { background: var(--warn-50); color: var(--warn-700); }

/* =========================== FORMS =========================== */
.form-grid {
  display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px;
}
.fg-1 { grid-column: span 1; }   .fg-2 { grid-column: span 2; }
.fg-3 { grid-column: span 3; }   .fg-4 { grid-column: span 4; }
.fg-5 { grid-column: span 5; }   .fg-6 { grid-column: span 6; }
.fg-7 { grid-column: span 7; }   .fg-8 { grid-column: span 8; }
.fg-9 { grid-column: span 9; }   .fg-10 { grid-column: span 10; }
.fg-11 { grid-column: span 11; } .fg-12 { grid-column: span 12; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label {
  font-size: 12px; font-weight: 600; color: var(--ink-700);
  display: flex; align-items: center; gap: 6px;
}
.field-label .required { color: var(--danger-600); }
.field-label .help-icon {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--ink-200); color: var(--ink-500);
  display: grid; place-items: center;
  font-size: 9px; font-weight: 700; cursor: help;
}
.field-input, .field-select {
  width: 100%; padding: 9px 12px;
  background: var(--white); border: 1px solid var(--ink-200);
  border-radius: var(--r-sm); font-size: 13px;
  transition: all 0.15s;
}
.field-input:focus, .field-select:focus {
  border-color: var(--brand-600);
  box-shadow: 0 0 0 3px var(--brand-50);
}
.field-input:disabled {
  background: var(--ink-50); color: var(--ink-500); cursor: not-allowed;
}
.field-input.field-mono { font-family: 'JetBrains Mono', monospace; }
.field-textarea {
  width: 100%; padding: 9px 12px;
  background: var(--white); border: 1px solid var(--ink-200);
  border-radius: var(--r-sm); font-size: 13px; resize: vertical; min-height: 70px;
  font-family: inherit;
}
.field-help {
  font-size: 11.5px; color: var(--ink-500); line-height: 1.4;
}
.field-error {
  font-size: 11.5px; color: var(--danger-700); display: flex; align-items: center; gap: 4px;
}

/* Select com bandeira/banco */
.bank-select {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: var(--white);
  border: 1px solid var(--ink-200); border-radius: var(--r-sm);
  cursor: pointer; transition: all 0.15s;
}
.bank-select:hover { border-color: var(--ink-300); }
.bank-select .bank-code {
  width: 36px; height: 36px; border-radius: 8px;
  display: grid; place-items: center;
  font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 11px;
  flex-shrink: 0;
}
.bank-001 { background: #fef4cc; color: #b58a00; }    /* BB */
.bank-104 { background: #d6e3ff; color: #1e3a8a; }    /* Caixa */
.bank-237 { background: #fcd9d9; color: #991b1b; }    /* Bradesco */
.bank-341 { background: #ffe5cc; color: #c2410c; }    /* Itaú */
.bank-033 { background: #ffd9d9; color: #b53034; }    /* Santander */
.bank-748 { background: #d4f0d4; color: #166534; }    /* Sicredi */
.bank-756 { background: #c8e9d6; color: #1e7a3d; }    /* Sicoob */
.bank-info { flex: 1; min-width: 0; }
.bank-name { font-size: 13px; font-weight: 600; color: var(--ink-900); }
.bank-meta { font-size: 11.5px; color: var(--ink-500); margin-top: 1px; }
.bank-select .chev {
  width: 16px; height: 16px; color: var(--ink-400); flex-shrink: 0;
}

/* =========================== TABS =========================== */
.tabs {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--ink-200);
}
.tab {
  padding: 12px 18px; font-size: 13px; font-weight: 600;
  color: var(--ink-500); border-bottom: 2px solid transparent;
  cursor: pointer; transition: all 0.15s; display: flex; align-items: center; gap: 8px;
  margin-bottom: -1px;
}
.tab:hover { color: var(--ink-700); }
.tab.active { color: var(--brand-700); border-bottom-color: var(--brand-700); }
.tab .tab-badge {
  background: var(--ink-200); color: var(--ink-700);
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 999px;
}
.tab.active .tab-badge { background: var(--brand-700); color: var(--white); }

/* =========================== MODAL =========================== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,31,40,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal {
  background: var(--white); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  max-width: 100%; max-height: 92vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--ink-200);
  background: var(--brand-900); color: var(--white);
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  color: rgba(255,255,255,0.7); width: 28px; height: 28px;
  border-radius: 6px; display: grid; place-items: center;
}
.modal-close:hover { background: rgba(255,255,255,0.1); color: var(--white); }
.modal-body { padding: 22px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 14px 22px; border-top: 1px solid var(--ink-200);
  background: var(--ink-50); display: flex; align-items: center; justify-content: space-between; gap: 10px;
}

/* =========================== TABLES =========================== */
.data-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: 13px;
}
.data-table thead th {
  text-align: left; padding: 10px 14px;
  background: var(--ink-50); border-bottom: 1px solid var(--ink-200);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-500); white-space: nowrap;
}
.data-table thead th.num { text-align: right; }
.data-table tbody td {
  padding: 12px 14px; border-bottom: 1px solid var(--ink-100);
  vertical-align: top;
}
.data-table tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tbody tr:hover { background: var(--ink-50); }

/* =========================== SCROLLBAR =========================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ink-200); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-300); }

/* =========================== ALERTS =========================== */
.alert {
  display: flex; gap: 12px; padding: 12px 16px;
  border-radius: var(--r-sm); border-left: 3px solid;
  font-size: 13px; line-height: 1.5;
}
.alert-icon { flex-shrink: 0; margin-top: 1px; }
.alert-content { flex: 1; }
.alert-title { font-weight: 700; margin-bottom: 2px; }
.alert-info    { background: var(--info-50);    border-left-color: var(--info-600);    color: var(--info-700); }
.alert-success { background: var(--success-50); border-left-color: var(--success-600); color: var(--success-700); }
.alert-warn    { background: var(--warn-50);    border-left-color: var(--warn-600);    color: var(--warn-700); }
.alert-danger  { background: var(--danger-50);  border-left-color: var(--danger-600);  color: var(--danger-700); }
.alert-title-strong { color: var(--ink-900); font-weight: 700; }

/* =========================== TOGGLE =========================== */
.toggle {
  position: relative; width: 38px; height: 22px;
  background: var(--ink-300); border-radius: 999px;
  cursor: pointer; transition: background 0.2s; flex-shrink: 0;
}
.toggle.on { background: var(--brand-600); }
.toggle::after {
  content: ''; position: absolute; left: 2px; top: 2px;
  width: 18px; height: 18px; background: var(--white);
  border-radius: 50%; transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle.on::after { transform: translateX(16px); }

.toggle-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
}
.toggle-row .label-block { flex: 1; }
.toggle-row .label { font-size: 13px; font-weight: 600; color: var(--ink-900); }
.toggle-row .help { font-size: 11.5px; color: var(--ink-500); margin-top: 2px; }

/* =========================== FILE UPLOAD =========================== */
.dropzone {
  border: 2px dashed var(--ink-300); border-radius: var(--r-md);
  padding: 32px 20px; text-align: center;
  background: var(--ink-50); transition: all 0.2s; cursor: pointer;
}
.dropzone:hover, .dropzone.over {
  border-color: var(--brand-600);
  background: var(--brand-50);
}
.dropzone-icon {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--white); border: 1px solid var(--ink-200);
  display: grid; place-items: center; margin: 0 auto 12px;
  color: var(--brand-600);
}
.dropzone-title { font-size: 14px; font-weight: 600; color: var(--ink-900); margin-bottom: 4px; }
.dropzone-help { font-size: 12px; color: var(--ink-500); }
.dropzone-help b { color: var(--brand-700); }

/* =========================== STEPPER (WIZARD) =========================== */
.stepper {
  display: flex; align-items: center; gap: 0;
  padding: 0; margin-bottom: 0;
}
.step {
  flex: 1; display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; position: relative;
}
.step:not(:last-child)::after {
  content: ''; position: absolute; right: -8px; top: 50%;
  width: 16px; height: 1px; background: var(--ink-300);
}
.step-num {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  background: var(--ink-200); color: var(--ink-500);
  flex-shrink: 0; transition: all 0.2s;
}
.step.done .step-num {
  background: var(--success-600); color: var(--white);
}
.step.active .step-num {
  background: var(--brand-700); color: var(--white);
  box-shadow: 0 0 0 3px var(--brand-50);
}
.step-text { min-width: 0; }
.step-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--ink-400);
}
.step.done .step-label { color: var(--success-700); }
.step.active .step-label { color: var(--brand-700); }
.step-title {
  font-size: 13px; font-weight: 600; color: var(--ink-700);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.step.active .step-title { color: var(--ink-900); }

/* =========================== UTIL =========================== */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--ink-500); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }

.section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-500); margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.section-title::after {
  content: ''; flex: 1; height: 1px; background: var(--ink-200);
}
