/* Microcrédito — tema personalizado sobre Bootstrap 5
   Paleta: Navy profundo + Verde esmeralda + Dourado suave */
:root {
  --brand-900: #0b1d3a;
  --brand-800: #10284f;
  --brand-700: #163365;
  --brand-500: #2f6bd6;
  --brand-300: #7aa8ec;
  --accent: #10b981;
  --accent-dark: #059669;
  --gold: #d4a84c;
  --danger: #e11d48;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e5e9f2;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.05);
  --shadow-md: 0 10px 30px -12px rgba(11,29,58,.25);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* ============ Layout ============ */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

/* Sidebar (desktop) / Offcanvas (mobile) */
.app-sidebar {
  width: 260px;
  background: linear-gradient(180deg, var(--brand-900) 0%, var(--brand-800) 100%);
  color: #dbe4f3;
  display: flex; flex-direction: column;
  padding: 1.25rem 0.75rem;
  position: sticky; top: 0; height: 100vh;
}
.app-sidebar .brand {
  display: flex; align-items: center; gap: .6rem;
  color: #fff; font-weight: 700; font-size: 1.15rem;
  padding: .25rem .75rem 1.25rem;
  letter-spacing: .2px;
}
.app-sidebar .brand .logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--gold) 100%);
  display: grid; place-items: center; color: #06231a; font-weight: 800;
  box-shadow: 0 6px 16px -6px rgba(16,185,129,.6);
}
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
  display: flex; align-items: center; gap: .7rem;
  color: #cfd8ec; text-decoration: none;
  padding: .65rem .85rem; border-radius: 10px;
  font-weight: 500; font-size: .95rem;
  transition: background .15s, color .15s, transform .15s;
}
.side-nav a i { font-size: 1.05rem; opacity: .9; }
.side-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-nav a.active {
  background: linear-gradient(90deg, rgba(16,185,129,.25), rgba(16,185,129,.05));
  color: #fff;
  box-shadow: inset 3px 0 0 var(--accent);
}
.side-foot { margin-top: auto; padding: .75rem; color: #94a3b8; font-size: .8rem; }
.side-foot .user-chip {
  background: rgba(255,255,255,.06); border-radius: 10px;
  padding: .6rem .75rem; margin-bottom: .5rem; color: #e2e8f0;
}
.side-foot .user-chip small { display: block; color: #94a3b8; }

/* Layout structure */
.app-body { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.app-topbar {
  background: #fff; border-bottom: 1px solid var(--border);
  padding: .75rem 1rem; display: flex; align-items: center; gap: .75rem;
  position: sticky; top: 0; z-index: 20;
}
.app-topbar .page-title { font-weight: 700; font-size: 1.05rem; margin: 0; }
.app-topbar .user-badge {
  margin-left: auto; display: flex; align-items: center; gap: .55rem;
  color: var(--muted); font-size: .9rem;
}
.app-topbar .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-500), var(--accent));
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .85rem;
}
.app-content { padding: 1.25rem; }

/* Mobile: hide desktop sidebar, show hamburger */
.btn-menu { display: none; }
@media (max-width: 991.98px) {
  .app-sidebar.desktop { display: none; }
  .btn-menu { display: inline-flex; }
}

/* Offcanvas sidebar reuses same style */
.offcanvas-sidebar { background: linear-gradient(180deg, var(--brand-900), var(--brand-800)); color: #dbe4f3; width: 280px; }
.offcanvas-sidebar .btn-close { filter: invert(1) brightness(1.5); }

/* ============ Components ============ */
.card-soft {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-soft .card-header {
  background: transparent; border-bottom: 1px solid var(--border);
  font-weight: 600; padding: 1rem 1.1rem;
}
.card-soft .card-body { padding: 1.1rem; }

/* KPI cards */
.kpi-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.kpi {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem;
  box-shadow: var(--shadow-sm);
}
.kpi .lbl { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.kpi .val { font-size: 1.75rem; font-weight: 800; margin-top: .25rem; color: var(--brand-900); }
.kpi small { color: var(--muted); font-size: .78rem; }
.kpi .ico {
  position: absolute; top: 12px; right: 12px;
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; color: #fff; font-size: 1.15rem;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
}
.kpi.kpi-accent .ico { background: linear-gradient(135deg, var(--accent), var(--accent-dark)); }
.kpi.kpi-gold .ico { background: linear-gradient(135deg, var(--gold), #b8892a); }
.kpi.kpi-danger .ico { background: linear-gradient(135deg, #f43f5e, #be123c); }
.kpi.highlight {
  background: linear-gradient(135deg, var(--brand-900) 0%, var(--brand-700) 100%);
  color: #f8fafc; border-color: transparent;
}
.kpi.highlight .lbl { color: #a3b8dc; }
.kpi.highlight .val { color: #fff; }
.kpi.highlight small { color: #cbd5e1; }

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  border: none;
  box-shadow: 0 4px 14px -6px rgba(47,107,214,.55);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--brand-700), var(--brand-900)); }
.btn-accent {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff; border: none;
}
.btn-accent:hover { background: var(--accent-dark); color: #fff; }

/* Tables */
.table-clean {
  width: 100%; background: var(--surface);
  border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.table-clean thead th {
  background: #f8fafc; color: var(--muted);
  font-size: .78rem; letter-spacing: .5px; text-transform: uppercase;
  padding: .75rem 1rem; border-bottom: 1px solid var(--border);
  font-weight: 700;
}
.table-clean tbody td {
  padding: .8rem 1rem; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table-clean tbody tr:last-child td { border-bottom: none; }
.table-clean tbody tr:hover { background: #f8fbff; }

/* Status badges */
.status {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .3rem .65rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600; letter-spacing: .3px;
}
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-PENDENTE { color: #a16207; background: #fef3c7; }
.status-APROVADA { color: #065f46; background: #d1fae5; }
.status-REJEITADA { color: #9f1239; background: #ffe4e6; }
.status-DESEMBOLSADA { color: #1e40af; background: #dbeafe; }
.status-LIQUIDADA { color: #14532d; background: #bbf7d0; }

/* Chips / filters */
.chip {
  display: inline-block; padding: .4rem .85rem; border-radius: 999px;
  border: 1px solid var(--border); background: #fff;
  color: var(--text); text-decoration: none; font-size: .85rem; font-weight: 500;
  transition: all .15s;
}
.chip:hover { border-color: var(--brand-500); color: var(--brand-700); }
.chip.active {
  background: var(--brand-900); border-color: var(--brand-900); color: #fff;
}

/* Forms */
.form-label { font-weight: 600; font-size: .85rem; color: var(--text); margin-bottom: .35rem; }
.form-control, .form-select {
  border-radius: 10px; border-color: var(--border); padding: .6rem .8rem;
  font-size: 16px; /* iOS zoom fix */
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(47,107,214,.15);
}

/* Auth screen */
.auth-wrap {
  min-height: 100vh;
  display: grid; place-items: center;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(16,185,129,.18), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(47,107,214,.25), transparent 60%),
    linear-gradient(160deg, var(--brand-900), var(--brand-700));
  padding: 1rem;
}
.auth-card {
  width: 100%; max-width: 420px;
  background: #fff; border-radius: 18px;
  padding: 2rem 1.75rem;
  box-shadow: 0 30px 60px -20px rgba(11,29,58,.55);
}
.auth-card .logo-big {
  width: 56px; height: 56px; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  display: grid; place-items: center; color: #06231a; font-weight: 800; font-size: 1.5rem;
  margin: 0 auto 1rem;
  box-shadow: 0 10px 24px -10px rgba(16,185,129,.6);
}
.auth-card h1 { text-align: center; font-size: 1.4rem; font-weight: 700; margin-bottom: .35rem; }
.auth-card .sub { text-align: center; color: var(--muted); margin-bottom: 1.5rem; font-size: .9rem; }
.auth-card .hint {
  background: #f8fafc; border: 1px dashed var(--border);
  border-radius: 10px; padding: .6rem .75rem;
  color: var(--muted); font-size: .8rem; text-align: center; margin-top: 1rem;
}

/* Flash messages */
.flash-stack { position: fixed; top: 70px; right: 1rem; z-index: 1050; display: flex; flex-direction: column; gap: .5rem; max-width: 380px; }

/* Detail page header */
.page-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap; margin-bottom: 1.25rem;
}
.page-head h1 { font-size: 1.4rem; font-weight: 700; margin: 0; }
.page-head .sub { color: var(--muted); font-size: .9rem; }

/* Progress bar for saldo */
.progress-thin { height: 6px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.progress-thin > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-dark)); border-radius: 999px; }

/* Empty state */
.empty {
  padding: 2.5rem 1rem; text-align: center; color: var(--muted);
}
.empty i { font-size: 2rem; display: block; margin-bottom: .5rem; color: var(--brand-300); }

/* Responsive tweaks */
@media (max-width: 575.98px) {
  .app-content { padding: 1rem .85rem; }
  .kpi .val { font-size: 1.4rem; }
  .page-head h1 { font-size: 1.2rem; }
  .table-clean thead { display: none; }
  .table-clean, .table-clean tbody, .table-clean tr, .table-clean td { display: block; width: 100%; }
  .table-clean tr {
    background: #fff; border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: .75rem; padding: .5rem .25rem;
    box-shadow: var(--shadow-sm);
  }
  .table-clean tbody td {
    border-bottom: 1px dashed var(--border); padding: .55rem .9rem;
    display: flex; justify-content: space-between; align-items: center; gap: .75rem;
  }
  .table-clean tbody td:last-child { border-bottom: none; }
  .table-clean tbody td::before {
    content: attr(data-label);
    color: var(--muted); font-size: .72rem; text-transform: uppercase;
    font-weight: 700; letter-spacing: .5px;
  }
  .table-clean { border: none; box-shadow: none; background: transparent; }
}

/* Logo images */
.app-sidebar .brand .logo-img,
.offcanvas-sidebar .brand .logo-img {
  width: 44px; height: 44px; border-radius: 10px;
  object-fit: contain; background: #fff; padding: 3px;
  box-shadow: 0 6px 16px -6px rgba(0,0,0,.4);
  max-width: 100%;
}

/* Mobile offcanvas: smaller logo and brand spacing */
.offcanvas-sidebar .brand {
  padding: .25rem .5rem .75rem;
}
.offcanvas-sidebar .brand .logo-img {
  width: 34px; height: 34px; border-radius: 8px;
}

@media (max-width: 575.98px) {
  .offcanvas-sidebar .brand .logo-img {
    width: 30px; height: 30px; border-radius: 7px;
  }
}

.auth-card .logo-big-img {
  display: block; margin: 0 auto 1rem;
  width: 96px; height: 96px; object-fit: contain;
  max-width: 100%;
}

