@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Cormorant+Garamond:wght@600;700&display=swap');

:root {
  --navy: #162745;
  --navy-light: #24365c;
  --navy-950: #080f1c;
  --gold: #b8994f;
  --gold-dark: #a07d3a;
  --gold-light: #e1cc9f;
  --bg: #edf1f7;
  --card: #ffffff;
  --text: #162745;
  --muted: rgba(22,39,69,0.45);
  --muted-2: rgba(22,39,69,0.3);
  --green: #1f7a5c;
  --green-bg: rgba(45,138,110,0.08);
  --red: #b83a40;
  --red-bg: rgba(196,68,74,0.07);
  --amber: #7d612d;
  --amber-bg: rgba(184,153,79,0.08);
  --border: #dde3ed;
  --hover: rgba(184,153,79,0.04);
  --neutral-bg: rgba(22,39,69,0.05);
  --input-bg: #f4f7fa;
  --emphasis: var(--navy);
  --shadow-card: 0 2px 8px rgba(22,39,69,0.05);
  --radius: 16px;
  --radius-sm: 10px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --chart-primary: var(--navy);
  --chart-primary-light: var(--navy-light);
  --chart-tint: #e1cc9f;
}

[data-theme="dark"] {
  --navy-light: #24365c;
  --gold: #c9a860;
  --gold-dark: #b8994f;
  --gold-light: #4a3f28;
  --bg: #0d1929;
  --card: #111d33;
  --text: #e8ecf2;
  --muted: rgba(255,255,255,0.4);
  --muted-2: rgba(255,255,255,0.25);
  --green: #3daa86;
  --green-bg: rgba(45,138,110,0.14);
  --red: #e05a60;
  --red-bg: rgba(196,68,74,0.14);
  --amber: #d2b36f;
  --amber-bg: rgba(184,153,79,0.14);
  --border: rgba(255,255,255,0.07);
  --hover: rgba(184,153,79,0.04);
  --neutral-bg: rgba(255,255,255,0.05);
  --input-bg: rgba(255,255,255,0.025);
  --emphasis: var(--gold);
  --shadow-card: 0 12px 40px rgba(0,0,0,0.25);
  --chart-primary: #5a8ec4;
  --chart-primary-light: #4f6db8;
  --chart-tint: #8a7550;
}

* { box-sizing: border-box; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(184,153,79,0.25); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(184,153,79,0.45); }

body {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}

/* ===== SIDEBAR (sempre navy escuro, nos dois temas) ===== */
.sidebar {
  width: 262px;
  background: linear-gradient(180deg, #0a1422 0%, #0d1929 100%);
  border-right: 1px solid rgba(184,153,79,0.08);
  color: #fff;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 22px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 50;
}

.sidebar .brand {
  padding: 4px 22px 14px;
}

.sidebar .brand-logo {
  display: block;
  width: 168px;
  height: auto;
}

.sidebar .brand small {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: 9.5px;
  color: rgba(255,255,255,0.22);
  font-weight: 600;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  margin-top: 10px;
}

.sidebar nav {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.nav-section-label {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: rgba(184,153,79,0.32);
  padding: 14px 24px 6px;
}
.nav-section-label:first-child { padding-top: 4px; }

.nav-item {
  position: relative;
  padding: 11px 16px 11px 22px;
  margin-right: 14px;
  border-radius: 0 12px 12px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255,255,255,0.45);
  text-decoration: none;
  transition: all 0.2s var(--ease);
}
.nav-item::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  border-radius: 0 4px 4px 0;
  background: #b8994f;
  opacity: 0;
  transform: scaleY(0);
  transition: all 0.25s var(--ease);
}
.nav-item:hover { color: rgba(255,255,255,0.85); background: rgba(255,255,255,0.03); }
.nav-item.active { color: #ffffff; background: rgba(184,153,79,0.08); font-weight: 600; }
.nav-item.active::before { opacity: 1; transform: scaleY(1); }
.nav-icon { width: 20px; text-align: center; font-size: 14px; flex-shrink: 0; }
.nav-item.active .nav-icon { color: #d2b36f; }
.nav-item .help-dot { margin-left: auto; }

.sidebar-footer { padding: 14px 18px 0; border-top: 1px solid rgba(184,153,79,0.1); margin-top: 10px; }
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 12px;
  font-size: 13px;
  color: #cdd5e4;
}
.sidebar-avatar {
  position: relative;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c4a45a, #a07d3a);
  display: flex; align-items: center; justify-content: center;
  color: #080f1c;
  font-size: 12px;
  flex-shrink: 0;
}
.sidebar-avatar::after {
  content: '';
  position: absolute; bottom: -1px; right: -1px;
  width: 9px; height: 9px;
  background: #3daa86;
  border-radius: 50%;
  border: 2px solid #0a1422;
}
.sidebar-user-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.sidebar-logout {
  background: none; border: none; cursor: pointer; padding: 4px;
  color: rgba(255,255,255,0.25); font-size: 13px; transition: color 0.15s;
}
.sidebar-logout:hover { color: #e05a60; }

.theme-toggle {
  width: 100%;
  margin: 0 0 6px;
  padding: 10px 16px;
  background: transparent;
  border: 1px solid rgba(184,153,79,0.15);
  border-radius: var(--radius-sm);
  color: #cdd5e4;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s var(--ease);
}
.theme-toggle:hover { background: rgba(184,153,79,0.08); border-color: rgba(184,153,79,0.3); }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.55); backdrop-filter: blur(3px); z-index: 45; }
.sidebar-overlay.visible { display: block; }
.mobile-menu-btn { display: none; }

/* ===== MAIN ===== */
.main {
  flex: 1;
  padding: 30px 40px 60px;
  max-width: 1300px;
  position: relative;
}

h1 { font-family: 'Cormorant Garamond', serif; font-size: 32px; margin: 0 0 4px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.15; color: var(--text); }
h2 { font-size: 15px; margin: 0 0 14px; font-weight: 700; color: var(--text); }
.subtitle { color: var(--muted); font-size: 13px; margin-bottom: 24px; line-height: 1.6; }

.edit-toggle {
  list-style: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.edit-toggle::-webkit-details-marker { display: none; }
.edit-toggle:hover { color: var(--gold); background: rgba(184,153,79,0.12); }
.edit-toggle svg { width: 14px; height: 14px; display: block; }
.edit-panel { margin-top: 10px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 28px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.25s var(--ease);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 18px;
  margin-bottom: 26px;
}

.kpi {
  position: relative;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 26px 22px;
  box-shadow: var(--shadow-card);
  transition: transform 0.25s var(--ease), border-color 0.25s var(--ease);
}
.kpi::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, #b8994f, #d2b36f);
  opacity: 0.7;
}
.kpi:hover { transform: translateY(-3px); border-color: rgba(184,153,79,0.25); }

.kpi .label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.kpi .value {
  /* tamanho fixo (não 28px como antes) — cabe com folga até valores na casa dos
     milhões (ex: "R$ 1.234.567,89") sem quebrar linha; se algum dia passar disso,
     trunca com "…" em vez de estourar o card. */
  font-size: 20px;
  font-weight: 800;
  margin-top: 10px;
  color: var(--text);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.kpi .value.warn { color: var(--red); }

table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
th { text-align: left; padding: 16px 20px; color: var(--gold); opacity: 0.75; font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; border-bottom: 1px solid var(--border); }
td { padding: 16px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--hover); }
tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--gold); }

a { color: var(--emphasis); text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; }
a.link-muted { color: var(--muted); font-size: 13px; font-weight: 500; }
a.link-muted:hover { color: var(--emphasis); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--navy);
  color: #fff;
  border: 1px solid rgba(184,153,79,0.15);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s var(--ease);
}
.btn:hover { background: var(--navy-light); text-decoration: none; }
.btn.gold {
  background: linear-gradient(135deg, #c4a45a, #b8994f);
  color: #080f1c;
  border: none;
  box-shadow: 0 4px 14px rgba(184,153,79,0.3);
}
.btn.gold:hover { box-shadow: 0 6px 20px rgba(184,153,79,0.45); transform: translateY(-1px); }
.btn.small { padding: 6px 14px; font-size: 12px; border-radius: 8px; }
.btn.outline { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn.outline:hover { background: var(--hover); color: var(--text); }
.btn.danger-outline { background: transparent; color: var(--red); opacity: 0.75; border: 1px solid var(--red-bg); }
.btn.danger-outline:hover { background: var(--red-bg); opacity: 1; }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.btn[disabled]:hover { transform: none; box-shadow: none; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge.pago, .badge.ativo { background: var(--green-bg); color: var(--green); }
.badge.pendente { background: var(--amber-bg); color: var(--amber); }
.badge.atrasado, .badge.inativo, .badge.cancelada, .badge.cancelado { background: var(--red-bg); color: var(--red); }
.badge.neutro { background: var(--neutral-bg); color: var(--muted); }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.toolbar .filters a {
  margin-right: 6px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 20px;
  text-decoration: none;
  color: var(--muted);
  border: 1px solid var(--border);
}
.toolbar .filters a:hover { color: var(--text); text-decoration: none; }
.toolbar .filters a.active { background: linear-gradient(135deg, #b8994f, #a07d3a); color: #080f1c; border-color: transparent; font-weight: 700; }

form.inline { display: inline-flex; vertical-align: middle; margin: 5px 8px 5px 0; }
form.inline:last-child { margin-right: 0; }
td .badge { display: inline-flex; vertical-align: middle; margin: 5px 8px 5px 0; }
td .btn.small { margin: 5px 0; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; max-width: 640px; }
.form-grid.full { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.field.span2 { grid-column: span 2; }
.field label { font-size: 10.5px; font-weight: 700; color: rgba(184,153,79,0.65); text-transform: uppercase; letter-spacing: 0.07em; }
.field input, .field select, .field textarea {
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  background: var(--input-bg);
  color: var(--text);
  outline: none;
  transition: all 0.2s var(--ease);
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(184,153,79,0.1);
}
.field input[type="checkbox"] { accent-color: var(--gold); }

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='rgba(184,153,79,0.6)' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px !important;
  cursor: pointer;
}

/* O <select> fechado pega background/color daqui em cima, mas a LISTA aberta
   (os <option>) é renderizada pelo SO em alguns navegadores — sem isso, o texto
   claro do modo escuro cai num fundo branco padrão do sistema e some. Usa --bg
   (cor sólida) em vez de --input-bg (branco semi-transparente pensado pra ficar
   OVER o fundo escuro da página) — no popup nativo do SO não tem fundo escuro
   por baixo, então uma cor transparente vira branco puro e o texto claro some. */
select option {
  background-color: var(--bg);
  color: var(--text);
}

.search-input { padding: 11px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13.5px; width: 260px; background: var(--input-bg); color: var(--text); outline: none; transition: all 0.2s var(--ease); }
.search-input:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(184,153,79,0.1); }

.kanban { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; align-items: start; overflow-x: auto; }
.kanban-col { background: var(--neutral-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; min-height: 120px; }
.kanban-col h3 { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; margin: 4px 6px 12px; }
.kanban-card { background: var(--card); border-radius: var(--radius-sm); padding: 11px 13px; margin-bottom: 10px; border: 1px solid var(--border); font-size: 13px; box-shadow: var(--shadow-card); }
.kanban-card .valor { font-weight: 800; color: var(--emphasis); margin-top: 6px; font-size: 14.5px; }
.kanban-card select { width: 100%; margin-top: 8px; font-size: 12px; padding: 5px 24px 5px 8px; border-radius: 6px; border: 1px solid var(--border); background-color: var(--input-bg); color: var(--text); }

.dre-table td.valor, .dre-table th.valor { text-align: right; font-variant-numeric: tabular-nums; }
.dre-total-row td { font-weight: 800; border-top: 2px solid rgba(184,153,79,0.35); border-bottom: 2px solid rgba(184,153,79,0.35); background: var(--amber-bg); color: var(--emphasis); padding: 16px 20px; }
.dre-resultado { font-family: 'Cormorant Garamond', serif; font-size: 34px; font-weight: 800; color: var(--emphasis); }
.dre-resultado.negativo { color: var(--red); }

.section-title { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: rgba(184,153,79,0.75); margin: 24px 0 10px; }

.banner {
  background: var(--green-bg);
  color: var(--green);
  padding: 16px 20px;
  border-radius: 12px;
  font-size: 13px;
  margin-bottom: 18px;
  font-weight: 600;
  border: 1px solid rgba(184,153,79,0.1);
  box-shadow: var(--shadow-card);
}

.empty { color: var(--muted); font-size: 13px; padding: 24px 0; text-align: center; }

#flash-container { position: fixed; top: 18px; right: 18px; z-index: 9999; display: flex; flex-direction: column; gap: 12px; max-width: 340px; }
#flash-container .banner { margin-bottom: 0; animation: flashIn 0.3s var(--ease); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); box-shadow: 0 12px 40px rgba(0,0,0,0.3); }
@keyframes flashIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }

.auth-page {
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at top, rgba(184,153,79,0.08), transparent 60%), var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 36px;
  box-shadow: 0 20px 60px rgba(8,15,28,0.12);
}
[data-theme="dark"] .auth-card { box-shadow: 0 20px 60px rgba(0,0,0,0.4); }
.auth-card .brand {
  font-family: 'Cormorant Garamond', serif;
  font-size: 30px;
  font-weight: 700;
  color: var(--gold);
  text-align: center;
  margin-bottom: 4px;
}
.auth-card .subtitle { text-align: center; margin-bottom: 26px; }
.auth-card .field { margin-bottom: 15px; }
.auth-card .btn { width: 100%; margin-top: 8px; justify-content: center; padding: 11px; font-size: 14px; }

.period-nav { display: flex; gap: 10px; align-items: center; margin-bottom: 22px; flex-wrap: wrap; }
.period-nav select { padding: 8px 30px 8px 12px; border-radius: 8px; border: 1px solid var(--border); font-size: 13px; background-color: var(--input-bg); color: var(--text); }

.help-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: rgba(184,153,79,0.2);
  color: var(--gold);
  font-size: 10px;
  font-weight: 700;
  margin-left: 4px;
  cursor: help;
}
.nav-item .help-dot { background: rgba(184,153,79,0.15); color: rgba(210,179,111,0.8); }

@media (max-width: 1023px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu-btn {
    display: flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; margin-bottom: 16px;
    background: var(--card); border: 1px solid var(--border); border-radius: 8px;
    color: var(--text); font-size: 15px; cursor: pointer;
  }
  .main { padding: 20px 20px 50px; }
  .kanban { grid-template-columns: repeat(3, minmax(220px, 1fr)); }
}

@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 11pt !important;
  }
  .sidebar,
  .sidebar-overlay,
  .mobile-menu-btn,
  #flash-container,
  .theme-toggle,
  .period-nav,
  .btn,
  button,
  form,
  .help-dot {
    display: none !important;
  }
  .main {
    margin-left: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }
  .card {
    background: #ffffff !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin-bottom: 24px !important;
  }
  table {
    width: 100% !important;
    border-collapse: collapse !important;
  }
  th, td {
    border-bottom: 1px solid #cccccc !important;
    color: #000000 !important;
    padding: 8px 10px !important;
  }
  .dre-total-row td {
    border-top: 2px solid #000000 !important;
    border-bottom: 2px solid #000000 !important;
    background: #f3f4f6 !important;
    font-weight: bold !important;
  }
  .dre-resultado {
    font-size: 26pt !important;
    color: #000000 !important;
  }
  tr {
    page-break-inside: avoid !important;
  }
  h1, h2, h3, h4 {
    color: #000000 !important;
    page-break-after: avoid !important;
  }
}

