/* ==========================================================================
   Tema escuro premium - Sistema de Gestão de Empréstimos
   ========================================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --graphite-950: #0b0d10;
  --graphite-900: #111418;
  --graphite-850: #161a20;
  --graphite-800: #1b2027;
  --graphite-700: #252b34;
  --graphite-600: #323945;
  --emerald: #10b981;
  --emerald-400: #34d399;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --muted2: #64748b;
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--graphite-950);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(900px circle at 100% 0%, rgba(16,185,129,.05), transparent 40%),
    radial-gradient(700px circle at 0% 100%, rgba(56,189,248,.04), transparent 40%);
  background-attachment: fixed;
}

a { color: inherit; text-decoration: none; }
.tabular { font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

/* ---- Layout com sidebar ---- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 256px; flex-shrink: 0;
  border-right: 1px solid rgba(37,43,52,.7);
  background: rgba(17,20,24,.7);
  display: flex; flex-direction: column;
}
.sidebar .logo { display: flex; align-items: center; gap: 12px; padding: 22px 20px; }
.sidebar .logo .mark {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, #10b981, #047857);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: 18px;
  box-shadow: 0 8px 20px -6px rgba(4,120,87,.6);
}
.sidebar .logo .titulo { font-size: 14px; font-weight: 600; color: #fff; }
.sidebar .logo .sub { font-size: 11px; color: var(--muted2); }

.nav-grupo { padding: 8px 12px; }
.nav-grupo .grupo-titulo {
  padding: 8px 12px 6px; font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .12em; color: var(--muted2);
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px; font-size: 14px;
  color: var(--muted); transition: all .15s; position: relative;
}
.nav-item:hover { background: rgba(27,32,39,.7); color: var(--text); }
.nav-item.ativo { background: rgba(16,185,129,.1); color: var(--emerald-400); font-weight: 500; }
.nav-item.ativo::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 4px; height: 20px; border-radius: 0 4px 4px 0; background: var(--emerald-400);
}
.nav-item svg { width: 18px; height: 18px; }

.sidebar .rodape { margin-top: auto; padding: 12px; border-top: 1px solid rgba(37,43,52,.7); }
.sidebar .user {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px; margin-bottom: 8px;
}
.sidebar .user .avatar {
  width: 32px; height: 32px; border-radius: 999px; background: var(--graphite-700);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600;
}
.sidebar .user .nome { font-size: 14px; color: var(--text); }
.sidebar .user .cargo { font-size: 11px; color: var(--muted2); }

/* ---- Conteúdo ---- */
.conteudo { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  border-bottom: 1px solid rgba(37,43,52,.7);
  background: rgba(11,13,16,.8); backdrop-filter: blur(8px);
  padding: 12px 24px;
}
.topbar .busca { position: relative; width: 100%; max-width: 420px; }
.topbar .busca input {
  width: 100%; border: 1px solid rgba(50,57,69,.7); border-radius: 12px;
  background: rgba(17,20,24,.6); padding: 10px 12px 10px 38px;
  font-size: 14px; color: var(--text); outline: none;
}
.topbar .busca input:focus { border-color: rgba(16,185,129,.6); }
.topbar .busca svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted2); }
.topbar .sino {
  margin-left: auto; position: relative; border: 1px solid rgba(37,43,52,.7);
  background: rgba(17,20,24,.6); border-radius: 12px; padding: 10px; color: var(--muted);
}
.topbar .sino .contador {
  position: absolute; top: -6px; right: -6px; min-width: 16px; height: 16px;
  background: #ef4444; color: #fff; border-radius: 999px; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.main { padding: 32px 24px; max-width: 1200px; margin: 0 auto; width: 100%; }

/* ---- Header de página ---- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.page-head h1 { font-size: 26px; font-weight: 600; color: #fff; letter-spacing: -.02em; }
.page-head .desc { margin-top: 4px; font-size: 14px; color: var(--muted); }

/* ---- Cards / Stats ---- */
.card {
  border-radius: 16px; border: 1px solid rgba(37,43,52,.7);
  background: rgba(22,26,32,.8); padding: 20px;
  box-shadow: inset 0 1px 0 0 rgba(255,255,255,.03), 0 10px 30px -15px rgba(0,0,0,.6);
}
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.stat .rotulo { font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.stat .valor { margin-top: 12px; font-size: 26px; font-weight: 600; line-height: 1; }
.stat .dica { margin-top: 8px; font-size: 12px; color: var(--muted2); }
.c-verde { color: var(--emerald-400); }
.c-amarelo { color: #fbbf24; }
.c-vermelho { color: #f87171; }
.c-azul { color: #38bdf8; }
.c-neutro { color: #f1f5f9; }

/* ---- Badge ---- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid; border-radius: 999px; padding: 3px 10px;
  font-size: 12px; font-weight: 500;
}

/* ---- Tabela ---- */
.tabela-wrap { border-radius: 16px; border: 1px solid rgba(37,43,52,.7); background: rgba(22,26,32,.8); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; background: var(--graphite-800); color: var(--muted);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  padding: 12px 16px;
}
tbody td { padding: 12px 16px; border-top: 1px solid rgba(37,43,52,.6); }
tbody tr:hover { background: rgba(27,32,39,.5); }
td.dir, th.dir { text-align: right; font-variant-numeric: tabular-nums; }
.link-verde { color: var(--emerald-400); font-weight: 500; }

/* ---- Botões ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 12px; padding: 10px 16px; font-size: 14px; font-weight: 600;
  cursor: pointer; border: none; transition: all .15s; text-align: center;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--emerald); color: #fff; box-shadow: 0 8px 20px -8px rgba(4,120,87,.5); }
.btn-primary:hover { background: #0ea371; }
.btn-ghost { border: 1px solid rgba(50,57,69,.8); background: rgba(27,32,39,.6); color: var(--text); }
.btn-ghost:hover { background: rgba(37,43,52,.7); }
.btn-danger { background: rgba(220,38,38,.9); color: #fff; }
.btn-danger:hover { background: #ef4444; }
.btn-full { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

/* ---- Formulário ---- */
.label { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid rgba(50,57,69,.8); border-radius: 12px;
  background: rgba(17,20,24,.7); padding: 10px 14px; font-size: 14px; color: var(--text);
  outline: none; transition: all .15s; font-family: inherit;
}
.input:focus { border-color: rgba(16,185,129,.7); box-shadow: 0 0 0 3px rgba(16,185,129,.15); }
.campo { margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

.aviso { border-radius: 12px; padding: 10px 14px; font-size: 14px; margin-bottom: 8px; }
.aviso-erro { border: 1px solid rgba(239,68,68,.4); background: rgba(239,68,68,.1); color: #fca5a5; }
.aviso-ok { border: 1px solid rgba(16,185,129,.4); background: rgba(16,185,129,.1); color: #6ee7b7; }

/* ---- Alerta de calote (destaque) ---- */
.alerta-calote {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  border-radius: 16px; border: 1px solid rgba(239,68,68,.3); background: rgba(239,68,68,.1);
  padding: 16px 20px; margin-bottom: 24px;
}
.alerta-calote .icone {
  width: 40px; height: 40px; border-radius: 12px; background: rgba(239,68,68,.2);
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.alerta-calote .t { font-size: 14px; font-weight: 600; color: #fecaca; }
.alerta-calote .s { font-size: 12px; color: rgba(252,165,165,.7); }

/* ---- Login ---- */
.login-wrap { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 16px; }
.login-box { width: 100%; max-width: 380px; }
.login-logo {
  margin: 0 auto 16px; width: 56px; height: 56px; border-radius: 16px;
  background: linear-gradient(135deg, #10b981, #047857);
  display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 700; color: #fff;
  box-shadow: 0 12px 30px -8px rgba(4,120,87,.6);
}

.sec-titulo { font-size: 16px; font-weight: 600; color: #fff; margin: 24px 0 12px; }
.mt-6 { margin-top: 24px; } .mt-4 { margin-top: 16px; } .mb-4 { margin-bottom: 16px; }
.muted { color: var(--muted); font-size: 13px; }
.flex { display: flex; } .gap-2 { gap: 8px; } .items-center { align-items: center; }
.toggle-btn { border: 1px solid rgba(50,57,69,.8); background: rgba(17,20,24,.7); color: var(--muted); padding: 8px 16px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; }
.toggle-btn.ativo { background: var(--emerald); color: #fff; border-color: var(--emerald); }
