/* Bela Vista II — Financeiro */
:root {
  --navy: #0d2b3e;
  --navy-700: #133a52;
  --navy-600: #1d4d6b;
  --teal: #15534d;
  --teal-600: #1f6b64;
  --teal-500: #2a857d;
  --bg: #f4f1ea;
  --bg-2: #ebe6db;
  --panel: #ffffff;
  --panel-2: #faf8f3;
  --line: #e3ddd0;
  --line-strong: #cfc7b4;
  --ink: #0d2b3e;
  --ink-2: #2c4252;
  --muted: #6b7c87;
  --muted-2: #95a1aa;
  --accent: #15534d;
  --warn: #b9701a;
  --warn-bg: #fbeed4;
  --danger: #a3331f;
  --danger-bg: #f6dcd6;
  --ok: #1f6b4e;
  --ok-bg: #d8ebd9;
  --info: #1d4d6b;
  --info-bg: #d8e3eb;
  --shadow-sm: 0 1px 2px rgba(13, 43, 62, 0.06);
  --shadow: 0 4px 16px -8px rgba(13, 43, 62, 0.18), 0 1px 2px rgba(13, 43, 62, 0.04);
  --shadow-lg: 0 24px 48px -16px rgba(13, 43, 62, 0.25);
  --radius: 10px;
  --radius-lg: 14px;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.45;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal); outline-offset: 1px; }

.tabular { font-variant-numeric: tabular-nums; }
.font-display { font-family: 'Fraunces', Georgia, serif; font-weight: 500; letter-spacing: -0.01em; }

/* App shell */
.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--navy);
  color: #cfd9e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid #0a2233;
}
.sidebar .brand {
  padding: 22px 22px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar .brand .mark {
  width: 36px; height: 36px;
  background: #fff;
  border-radius: 8px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.sidebar .brand .mark img { width: 28px; height: 28px; object-fit: contain; }
.sidebar .brand .label { line-height: 1.1; }
.sidebar .brand .label .t1 { color: #fff; font-weight: 700; font-size: 13px; letter-spacing: 0.06em; }
.sidebar .brand .label .t2 { color: #7fa39c; font-size: 11px; letter-spacing: 0.05em; }

.nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-section { color: #7a8d99; font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: #b8c5cd;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active::before {
  content: ''; position: absolute; left: -4px; top: 8px; bottom: 8px; width: 3px;
  background: var(--teal-500); border-radius: 2px;
}
.nav-item .badge {
  margin-left: auto;
  background: var(--teal-500);
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 600;
}
.nav-item .ic { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }
.nav-item.active .ic { opacity: 1; }

.sidebar .foot {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--teal-500), var(--navy-600));
  color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 12px;
  flex-shrink: 0;
}
.foot .meta { line-height: 1.2; min-width: 0; flex: 1; }
.foot .meta .n { color: #fff; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.foot .meta .e { color: #7a8d99; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Main */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 28px;
  background: rgba(244, 241, 234, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.topbar .crumb { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.topbar .spacer { flex: 1; }
.topbar .search {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px 7px 32px;
  font-size: 13px;
  width: 240px;
  position: relative;
}
.topbar .search-wrap { position: relative; }
.topbar .search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }

.content { padding: 28px; max-width: 1400px; width: 100%; }

/* Cards */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-head {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
}
.card-head h3 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.005em; }
.card-head .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card-body { padding: 20px; }

/* KPI */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin-top: 6px; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .value.money { font-family: 'Fraunces', Georgia, serif; font-weight: 500; }
.kpi .label { min-width: 0; }
.kpi-grid.dense .kpi { padding: 14px 16px; }
.kpi-grid.dense .kpi .value { font-size: 22px; }
.kpi-grid.dense .kpi .label { font-size: 11.5px; }
.kpi-grid.dense .kpi .icon-bg { width: 26px; height: 26px; top: 12px; right: 12px; }
.kpi .delta { font-size: 12px; color: var(--muted); margin-top: 8px; }
.kpi .delta .up { color: var(--ok); font-weight: 600; }
.kpi .delta .dn { color: var(--danger); font-weight: 600; }
.kpi.accent-navy { background: var(--navy); color: #fff; border-color: var(--navy); }
.kpi.accent-navy .label { color: #8ea7b3; }
.kpi.accent-navy .delta { color: #8ea7b3; }
.kpi.accent-teal { background: var(--teal); color: #fff; border-color: var(--teal); }
.kpi.accent-teal .label { color: #9bbfba; }
.kpi.accent-teal .delta { color: #9bbfba; }

.kpi .icon-bg {
  position: absolute; top: 14px; right: 16px;
  width: 32px; height: 32px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: var(--panel-2);
  color: var(--teal);
}
.kpi.accent-navy .icon-bg, .kpi.accent-teal .icon-bg { background: rgba(255,255,255,0.12); color: #fff; }
.kpi.clickable { cursor: pointer; transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease; }
.kpi.clickable:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(11,47,79,0.08); border-color: var(--teal-500); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
  transition: all 0.12s;
}
.btn:hover { background: var(--panel-2); border-color: var(--ink-2); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-700); }
.btn.teal { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.teal:hover { background: var(--teal-600); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--bg-2); color: var(--ink); }
.btn.sm { padding: 4px 8px; font-size: 12px; gap: 4px; }
.btn.icon { padding: 6px; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-bg); border-color: var(--danger); }

/* Pills / status */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.danger { background: var(--danger-bg); color: var(--danger); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.neutral { background: var(--bg-2); color: var(--muted); border-color: var(--line); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

/* Table */
.table-wrap {
  overflow-x: auto;
}
table.t {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.t th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  white-space: nowrap;
}
table.t td {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.t tr:hover td { background: var(--panel-2); }
table.t tr:last-child td { border-bottom: 0; }
table.t .num { font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 4px; opacity: 0.4; transition: opacity 0.12s; }
table.t tr:hover .row-actions { opacity: 1; }

/* Filters */
.filters {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  align-items: center;
}
.input, .select {
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--ink);
}
.input:hover, .select:hover { border-color: var(--ink-2); }
.input.lg { padding: 9px 12px; font-size: 14px; }
.input.sm { padding: 5px 8px; font-size: 12px; }
.filter-range {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
}
.filter-range .input.sm { border: none; padding: 2px 4px; background: transparent; }
.filter-range .input.sm:focus { outline: 1px solid var(--teal-500); border-radius: 4px; }

/* Chart bars */
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 12px; }
.bar-chart .bar {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; justify-content: flex-end;
  position: relative;
  cursor: pointer;
}
.bar-chart .bar .fill {
  width: 100%;
  background: linear-gradient(180deg, var(--teal-500), var(--teal));
  border-radius: 4px 4px 0 0;
  transition: opacity 0.15s;
}
.bar-chart .bar .fill.muted { background: var(--bg-2); border: 1px solid var(--line); }
.bar-chart .bar .lbl { font-size: 10px; color: var(--muted); text-align: center; margin-top: 4px; font-variant-numeric: tabular-nums; }
.bar-chart .bar:hover .fill { opacity: 0.85; }
.bar-chart .bar .tip {
  position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff;
  padding: 4px 8px; border-radius: 6px;
  font-size: 11px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity 0.15s;
  z-index: 5;
}
.bar-chart .bar:hover .tip { opacity: 1; }

/* Legend */
.legend { display: flex; gap: 16px; align-items: center; font-size: 12px; color: var(--muted); }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: middle; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(13, 43, 62, 0.4);
  backdrop-filter: blur(2px);
  display: grid; place-items: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 0.15s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--panel);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: pop 0.18s;
}
@keyframes pop { from { transform: translateY(8px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center;
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px 22px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line); background: var(--panel-2); display: flex; gap: 8px; justify-content: flex-end; }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 20px; background: var(--panel-2); }
.tab {
  padding: 12px 14px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--navy); border-bottom-color: var(--teal); font-weight: 600; }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
}
.login-left {
  background: var(--navy);
  color: #fff;
  padding: 60px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.login-left::before {
  content: '';
  position: absolute;
  bottom: -120px; right: -120px;
  width: 360px; height: 360px;
  background: radial-gradient(circle, var(--teal) 0%, transparent 70%);
  opacity: 0.5;
}
.login-left .logo-block { display: flex; align-items: center; gap: 14px; z-index: 1; }
.login-left .logo-block .mark { width: 56px; height: 56px; background: #fff; border-radius: 12px; display: grid; place-items: center; }
.login-left .logo-block .mark img { width: 44px; height: 44px; object-fit: contain; }
.login-left .pitch { z-index: 1; }
.login-left .pitch h2 { font-family: 'Fraunces', Georgia, serif; font-weight: 400; font-size: 36px; line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 12px; }
.login-left .pitch p { color: #9bbfba; font-size: 14px; max-width: 380px; }
.login-left .stamp { color: #5b7280; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; z-index: 1; }
.login-right {
  display: grid;
  place-items: center;
  padding: 60px;
}
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { font-family: 'Fraunces', Georgia, serif; font-weight: 500; font-size: 28px; margin: 0 0 6px; letter-spacing: -0.02em; }
.login-card p.sub { color: var(--muted); margin: 0 0 28px; font-size: 13px; }
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: #fff; color: var(--ink); border: 1px solid var(--line-strong);
  padding: 12px 16px; border-radius: 10px; font-weight: 500; font-size: 14px; width: 100%;
  box-shadow: var(--shadow-sm);
}
.google-btn:hover { background: var(--panel-2); }
.login-meta { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.login-meta strong { color: var(--ink); font-weight: 600; }

/* Workflow row */
.wf-row {
  display: grid; grid-template-columns: 24px 1fr auto auto;
  align-items: center; gap: 14px;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
}
.wf-row:last-child { border-bottom: 0; }
.wf-row .name { font-weight: 600; }
.wf-row .desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.wf-row .tick { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* utility */
.flex { display: flex; }
.between { justify-content: space-between; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.muted { color: var(--muted); }
.text-sm { font-size: 12px; }
.fw-600 { font-weight: 600; }
.no-bd { border: 0 !important; }

/* Donut */
.donut-wrap { display: flex; gap: 24px; align-items: center; }
.donut { width: 120px; height: 120px; flex-shrink: 0; }

/* Mobile */
.mobile-toggle { display: none; }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 50;
    transform: translateX(-100%); transition: transform 0.2s;
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-toggle { display: inline-flex; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
  .topbar { padding: 14px 16px; }
  .content { padding: 16px; }
  .topbar .search { width: 140px; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-left { display: none; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }

/* Focus management */
.btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.nav-item:focus-visible { outline: 2px solid var(--teal-500); outline-offset: -2px; }

.empty {
  text-align: center; padding: 60px 20px; color: var(--muted);
}
.empty .ico { font-size: 36px; margin-bottom: 8px; opacity: 0.4; }

.attach {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px;
  background: var(--info-bg); color: var(--info);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
}

.doc-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid transparent;
}
.doc-chip.nf { background: rgba(11, 47, 79, 0.08); color: var(--navy); border-color: rgba(11, 47, 79, 0.18); }
.doc-chip.boleto { background: var(--warn-bg); color: var(--warn); border-color: rgba(180, 100, 0, 0.18); }
.doc-chip.comprovante { background: rgba(20, 86, 78, 0.08); color: var(--teal); border-color: rgba(20, 86, 78, 0.2); }
.doc-chip.empty { background: var(--bg-2); color: var(--ink-3); border-color: var(--line); border-style: dashed; cursor: pointer; }
.doc-chip.empty:hover { background: var(--panel-2); color: var(--ink-2); }
