/* ============================================================
   EF BI Acqua Inn — Identidade visual
   ============================================================ */
:root {
  --navy-900: #0A1F3D;
  --navy-700: #142d52;
  --navy-500: #2a4a7a;
  --gold-700: #a36b1e;
  --gold-600: #b8935a;
  --gold-500: #c9a366;
  --gold-100: #f5ecd8;
  --bg: #fafaf7;
  --bg-soft: #f4f1eb;
  --bg-card: #ffffff;
  --border: #e8e3d8;
  --border-strong: #d8d0bf;
  --text: #1a1a1a;
  --text-soft: #555;
  --text-mute: #888;
  --success: #2D7A4F;
  --success-bg: #e7f5ec;
  --warning: #B57A1E;
  --warning-bg: #fdf4e2;
  --danger: #B53939;
  --danger-bg: #fce8e8;
  --info: #2A6FAB;
  --info-bg: #e6f0f8;
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter Tight', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }

/* Splash */
.splash {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100vh;
  background: var(--bg);
}
.splash-logo {
  font-family: var(--font-display);
  font-size: 36px;
  color: var(--navy-900);
  letter-spacing: 8px;
  margin-bottom: 24px;
}
.splash-loader {
  width: 40px; height: 40px;
  border: 3px solid var(--gold-100);
  border-top-color: var(--gold-600);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== LOGIN ===== */
.login-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
  background: linear-gradient(135deg, var(--bg) 0%, var(--gold-100) 100%);
}
.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 48px 40px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(10, 31, 61, 0.08);
}
.login-logo {
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--navy-900);
  letter-spacing: 4px;
  text-align: center;
  margin-bottom: 8px;
}
.login-subtitle {
  text-align: center;
  font-size: 12px;
  color: var(--text-mute);
  margin-bottom: 36px;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.login-title {
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--navy-900);
  margin-bottom: 4px;
}
.login-hint {
  font-size: 12px;
  color: var(--text-mute);
  margin-bottom: 24px;
}
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-mute);
  margin-bottom: 6px;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
  transition: border-color 0.15s;
}
.form-group input:focus { outline: none; border-color: var(--gold-600); }
.form-error {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13px;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  background: var(--navy-900);
  color: #fff;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover { background: var(--navy-700); }
.btn-block { width: 100%; justify-content: center; }
.btn-ghost { background: transparent; color: var(--navy-900); }
.btn-ghost:hover { background: var(--bg-soft); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-gold { background: var(--gold-600); }
.btn-gold:hover { background: var(--gold-700); }

/* ===== APP LAYOUT ===== */
.app-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--navy-900);
  color: #fff;
  padding: 20px 14px;
  overflow-y: auto;
  height: 100vh;
  position: sticky;
  top: 0;
}
.sidebar-logo {
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 4px;
  color: var(--gold-500);
  padding: 4px 8px 20px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 16px;
}
.nav-section { margin-bottom: 18px; }
.nav-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: rgba(255,255,255,0.4);
  padding: 0 8px 8px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 9px 10px;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.75);
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s;
}
.nav-item i { font-size: 16px; width: 18px; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active {
  background: var(--gold-600);
  color: var(--navy-900);
}

.main-area {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff;
  padding: 0 24px;
  height: 64px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px;
  color: var(--text-mute);
}
.breadcrumb .current { color: var(--navy-900); font-weight: 500; }
.topbar-actions {
  display: flex; align-items: center; gap: 12px;
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px 6px 6px;
  background: var(--bg-soft);
  border-radius: 30px;
}
.user-chip .avatar {
  width: 28px; height: 28px;
  background: var(--navy-700); color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
}
.user-chip .meta { font-size: 12px; }
.user-chip .meta small { display: block; color: var(--text-mute); font-size: 10px; }

.content { padding: 32px; flex: 1; overflow-x: hidden; }

.page-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 500;
  color: var(--navy-900);
  margin-bottom: 4px;
}
.page-title .accent { color: var(--gold-600); }
.page-subtitle {
  font-size: 13px;
  color: var(--text-mute);
  margin-bottom: 24px;
}

/* KPI cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
}
.kpi.gold { border-left: 3px solid var(--gold-600); }
.kpi.success { border-left: 3px solid var(--success); }
.kpi-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-mute);
  margin-bottom: 6px;
}
.kpi-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 500;
  color: var(--navy-900);
}
.kpi-delta { font-size: 11px; color: var(--text-soft); margin-top: 4px; }
.kpi-delta.positive, .kpi-delta .positive { color: var(--success); font-weight: 500; }
.kpi-delta.negative, .kpi-delta .negative { color: var(--danger); font-weight: 500; }
.periodo-selector select:focus { outline: none; }
.periodo-selector { transition: border-color .15s; }
.periodo-selector:hover { border-color: var(--gold-600); }

/* Card padrão */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px;
  margin-bottom: 18px;
}
.card-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  color: var(--navy-900);
  margin-bottom: 14px;
}

/* Insight cards */
.insight {
  background: var(--gold-100);
  border-left: 3px solid var(--gold-600);
  padding: 14px 18px;
  border-radius: 0 6px 6px 0;
  margin-bottom: 12px;
}
.insight.success { background: var(--success-bg); border-color: var(--success); }
.insight.warning { background: var(--warning-bg); border-color: var(--warning); }
.insight.critical { background: var(--danger-bg); border-color: var(--danger); }
.insight-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  color: var(--navy-900);
  margin-bottom: 6px;
}
.insight-body { font-size: 13px; color: var(--text-soft); }
.insight-meta {
  font-size: 11px;
  color: var(--text-mute);
  margin-top: 6px;
}

/* Tabela */
table.dre {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.dre th, table.dre td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
table.dre th {
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-mute);
}
table.dre td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.dre tr.group td { background: var(--gold-100); font-weight: 600; color: var(--navy-900); }
table.dre tr.total td {
  background: var(--navy-900); color: #fff;
  font-weight: 600;
}

/* Profile switcher */
.profile-switcher {
  display: flex;
  background: var(--bg-soft);
  border-radius: 6px;
  padding: 3px;
  gap: 2px;
}
.profile-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
}
.profile-btn.active { background: var(--navy-900); color: #fff; }

body.profile-investidor .admin-only { display: none !important; }

/* Mobile menu */
.mobile-menu-toggle { display: none; background: transparent; border: none; color: var(--navy-900); font-size: 24px; cursor: pointer; }
.mobile-overlay { display: none; position: fixed; inset: 0; background: rgba(10,31,61,0.5); z-index: 999; }
.mobile-overlay.active { display: block; }

/* Responsivo */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .content { padding: 24px 20px; }
}
@media (max-width: 768px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: -260px; top: 0; bottom: 0; width: 260px;
    z-index: 1000;
    transition: left 0.25s ease;
  }
  .sidebar.mobile-open { left: 0; }
  .mobile-menu-toggle { display: inline-flex; align-items: center; margin-right: 8px; }
  .topbar { padding: 0 12px; height: 56px; }
  .content { padding: 16px 12px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 20px; }
  .page-title { font-size: 22px; }
  .user-chip .meta { display: none; }
  .profile-btn span { display: none; }
}
@media (max-width: 420px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

/* ============ Financeiro (F6): DRE, estrutura, lançamentos ============ */
.delta.positive { color: var(--success); font-weight: 500; }
.delta.negative { color: var(--danger); font-weight: 500; }

table.dre.dre-fin { font-size: 12px; }
table.dre.dre-fin th, table.dre.dre-fin td { padding: 7px 10px; white-space: nowrap; }
table.dre.dre-fin th.th-per { text-align: right; border-left: 1px solid var(--border); background: var(--bg-soft); }
table.dre.dre-fin th.th-tot { background: var(--gold-100); }
table.dre.dre-fin td.tot { background: #faf8f2; font-weight: 600; }
table.dre.dre-fin tr, table.dre.dre-fin td:first-child { position: relative; }
table.dre.dre-fin th:first-child, table.dre.dre-fin td:first-child {
  position: sticky; left: 0; background: #fff; z-index: 1; text-align: left;
}
tr.dre-tipo td { background: var(--navy-900); color: #fff; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; font-size: 11px; }
tr.dre-tipo td:first-child { background: var(--navy-900); color: #fff; }
tr.dre-grupo td { background: var(--gold-100); font-weight: 600; }
tr.dre-grupo td:first-child { background: var(--gold-100); }
tr.dre-subgrupo td { font-weight: 500; color: var(--navy-900); }
tr.dre-subgrupo td:first-child { background: #fff; }
tr.dre-cat td:first-child { background: #fff; color: var(--text-soft); }
tr.dre-total-tipo td { background: #eef1f6; font-weight: 600; }
tr.dre-total-tipo td:first-child { background: #eef1f6; }
tr.dre-resultado td { background: var(--navy-900); color: #fff; font-weight: 700; }
tr.dre-resultado td:first-child { background: var(--navy-900); color: #fff; }
tr.dre-calc td, tr.dre-calc-sub td { background: #f5f3ff; color: #6d28d9; font-weight: 600; }
tr.dre-calc td:first-child, tr.dre-calc-sub td:first-child { background: #f5f3ff; }
tr.dre-calc-sub td { font-size: 11px; color: #7c3aed; }
tr.dre-gap td { height: 6px; background: #f1f5f9; padding: 0 !important; }
.dre-tg { display: inline-block; width: 14px; font-weight: 700; color: var(--gold-600); }
.dre-head { cursor: pointer; }
.dre-drill { cursor: pointer; }
.dre-drill:hover { background: rgba(184,147,90,.12) !important; text-decoration: underline; }
.fx { font-size: 10px; color: #7c3aed; font-style: italic; }

/* Tabs genéricas */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 18px; }
.tab { padding: 9px 16px; background: transparent; border: none; border-bottom: 2px solid transparent; margin-bottom: -2px; cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 500; color: var(--text-soft); }
.tab.active { color: var(--navy-900); border-bottom-color: var(--gold-600); }

/* Árvore estrutura */
.fin-grupo { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 14px; overflow: hidden; }
.fin-grupo-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--gold-100); }
.fin-grupo-head .nome { font-weight: 600; flex: 1; }
.fin-sub { border-top: 1px solid var(--border); padding: 8px 14px 8px 28px; }
.fin-sub-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.fin-sub-head .nome { font-weight: 500; flex: 1; }
.fin-cats { display: flex; flex-wrap: wrap; gap: 6px; min-height: 26px; padding: 4px; border: 1px dashed transparent; border-radius: 6px; }
.fin-cats.drop-hover { border-color: var(--gold-600); background: var(--gold-100); }
.fin-cat { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 14px; padding: 3px 6px 3px 10px; font-size: 12px; cursor: grab; }
.fin-cat.dragging { opacity: .4; }
.fin-cat .x { cursor: pointer; color: var(--text-mute); font-weight: 700; padding: 0 3px; }
.fin-cat .x:hover { color: var(--danger); }
.badge-tipo { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; padding: 2px 7px; border-radius: 10px; font-weight: 600; }
.badge-tipo.receita { background: var(--success-bg); color: var(--success); }
.badge-tipo.despesa { background: var(--danger-bg); color: var(--danger); }
.badge-tipo.resultado { background: #f5f3ff; color: #6d28d9; }
.icon-btn { background: transparent; border: none; cursor: pointer; color: var(--text-mute); padding: 2px 5px; border-radius: 4px; font-size: 14px; }
.icon-btn:hover { background: rgba(0,0,0,.06); color: var(--navy-900); }

/* Grid orçamento */
.orc-grid { width: 100%; border-collapse: collapse; font-size: 12px; }
.orc-grid th, .orc-grid td { border: 1px solid var(--border); padding: 4px 6px; text-align: right; }
.orc-grid th:first-child, .orc-grid td:first-child { text-align: left; position: sticky; left: 0; background: #fff; }
.orc-grid th { background: var(--bg-soft); font-size: 11px; }
.orc-grid input { width: 78px; border: 1px solid transparent; background: transparent; text-align: right; font-family: inherit; font-size: 12px; padding: 3px; border-radius: 4px; }
.orc-grid input:focus { outline: none; border-color: var(--gold-600); background: #fffdf7; }
