:root {
  --ink: #10192E;
  --ink-soft: #1B2A47;
  --paper: #F5F7FA;
  --card: #FFFFFF;
  --line: #E4E1D8;
  --text: #1B2333;
  --text-mute: #6B7280;
  --azul-inova: #0D47A1;
  --azul-digital: #0288D1;
  --verde-inova: #00BFA5;
  --verde-crescimento: #8BC34A;
  --teal: #0288D1;
  --teal-deep: #00BFA5;
  --coral: #C65D4B;
  --amber: #B8863B;
  --blue: #3866A6;
  --focus: #1C86C9;
  --radius: 10px;
  --mono: "SFMono-Regular", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --sans: "Inter", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Poppins", "Inter", -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Shell layout ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--ink);
  color: #DCE3EF;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 22px; }
.sidebar-close { display: none; margin-left: auto; background: none; border: none; color: #B7C1D6; padding: 6px; }
.sidebar-close .ic { width: 20px; height: 20px; }
.sidebar-backdrop { display: none; }
.brand-mark {
  width: 34px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--teal), var(--teal-deep));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff; font-size: 12.5px; letter-spacing: 0.3px;
}
.brand-mark-img { width: 34px; height: 34px; border-radius: 9px; object-fit: cover; flex-shrink: 0; background: #fff; padding: 2px; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 15.5px; letter-spacing: 0.2px; color: #fff; }
.brand-name em { font-style: normal; color: #7FE0A0; font-weight: 500; }

.nav { display: flex; flex-direction: column; gap: 1px; flex: 1; margin-top: 6px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 8px;
  color: #B7C1D6; font-size: 13.5px; font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav-item .ic { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.85; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: var(--teal); color: #fff; }
.nav-item.active .ic { opacity: 1; }

.nav-group { margin-top: 1px; }
.nav-group-head {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 8px;
  color: #B7C1D6; font-size: 13.5px; font-weight: 500;
  cursor: pointer; list-style: none; user-select: none;
}
.nav-group-head::-webkit-details-marker { display: none; }
.nav-group-head .ic { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.85; }
.nav-group-head .chev { width: 13px; height: 13px; margin-left: auto; opacity: 0.6; transition: transform 0.15s; }
.nav-group[open] .nav-group-head .chev { transform: rotate(90deg); }
.nav-group-head:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-subitems { display: flex; flex-direction: column; padding: 2px 0 4px 30px; }
.nav-subitem {
  padding: 6.5px 10px; border-radius: 6px; font-size: 12.5px; font-weight: 500;
  color: #94A0B8;
}
.nav-subitem:hover { color: #fff; background: rgba(255,255,255,0.05); }
.nav-subitem.active { color: #fff; background: var(--teal); }

.logout { margin-top: auto; padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.08); }
.logout button {
  width: 100%; background: none; border: none; color: #9AA6BC;
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  font-size: 13px; border-radius: 8px;
}
.logout button:hover { background: rgba(255,255,255,0.06); color: #fff; }
.rot { transform: rotate(90deg); width: 15px; height: 15px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 32px;
  gap: 12px;
}
.menu-btn { display: none; background: none; border: none; color: var(--text); padding: 6px; margin-right: -4px; flex-shrink: 0; }
.menu-btn .ic { width: 24px; height: 24px; }
.topbar-title { font-family: var(--display); font-size: 22px; font-weight: 700; letter-spacing: -0.3px; flex: 1; }
.topbar-company { font-size: 12.5px; color: var(--text-mute); font-weight: 500; white-space: nowrap; }
.content { padding: 12px 32px 48px; }

.flash { padding: 11px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13.5px; font-weight: 500; }
.flash.ok { background: #E3F3EE; color: var(--teal-deep); border: 1px solid #BFE3D9; }
.flash.err { background: #FBEAE7; color: #8A3527; border: 1px solid #F0C9C1; }

/* ---------- KPI cards ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.kpi {
  border-radius: var(--radius); padding: 16px 18px; color: #fff;
  display: flex; flex-direction: column; gap: 10px; min-height: 84px;
  position: relative; overflow: hidden;
}
.kpi .label { font-size: 11px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; opacity: 0.85; }
.kpi .value { font-family: var(--mono); font-size: 21px; font-weight: 600; letter-spacing: -0.3px; }
.kpi.vendas { background: linear-gradient(135deg, #1E9E7C, #0F6E56); }
.kpi.despesas { background: linear-gradient(135deg, #C6624F, #9A3E30); }
.kpi.receitas { background: linear-gradient(135deg, #3E76B0, #294F80); }
.kpi.faturamento { background: linear-gradient(135deg, var(--teal), var(--teal-deep)); }

/* ---------- Panels / tables ---------- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h2 { font-size: 15px; margin: 0; font-weight: 700; }
.panel-head .muted { font-size: 12px; color: var(--text-mute); font-weight: 500; }

.grid-2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--text-mute); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px 10px; border-bottom: 1px solid #EFEDE6; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-family: var(--mono); }

.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge.pago, .badge.concluida { background: #E3F3EE; color: var(--teal-deep); }
.badge.pendente { background: #FBF2E2; color: #8A6116; }
.badge.cancelada { background: #FBEAE7; color: #8A3527; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 7px; border: 1px solid var(--line); background: #fff; font-size: 13px; font-weight: 600; color: var(--text); }
.btn:hover { border-color: #C9C5B8; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-deep); }
.btn.danger { color: #9A3E30; }
.btn.small { padding: 5px 10px; font-size: 12px; }

.actions-row { display: flex; gap: 8px; align-items: center; }

/* ---------- Forms ---------- */
.form-panel { max-width: 640px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.contato-row { grid-template-columns: 1.4fr 1fr 1fr 1.4fr auto; align-items: end; }

/* ---------- Modal de instalação do app ---------- */
.install-overlay {
  position: fixed; inset: 0; background: rgba(10,15,30,0.55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  z-index: 100; opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
}
.install-overlay.open { opacity: 1; pointer-events: auto; }
.install-card {
  background: #fff; border-radius: 16px; padding: 32px 28px 24px; max-width: 380px; width: 100%;
  text-align: center; position: relative; box-shadow: 0 24px 60px rgba(0,0,0,0.3);
}
.install-close { position: absolute; top: 12px; right: 14px; background: none; border: none; font-size: 22px; line-height: 1; color: var(--text-mute); padding: 4px; }
.install-icon { width: 64px; height: 64px; border-radius: 16px; margin-bottom: 14px; box-shadow: 0 4px 14px rgba(0,0,0,0.15); }
.install-card h2 { font-family: var(--display); font-size: 18px; margin: 0 0 8px; }
.install-texto { font-size: 13px; color: var(--text-mute); margin: 0 0 16px; line-height: 1.5; }
.install-passos { text-align: left; font-size: 13.5px; line-height: 1.6; margin: 0 0 6px; padding-left: 20px; color: var(--text); }
.install-passos li { margin-bottom: 8px; }
.install-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.install-actions .btn { width: 100%; justify-content: center; }

/* ---------- Paginação ---------- */
.paginacao { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.paginacao .btn.disabled { opacity: 0.4; pointer-events: none; }
.pagina-numeros { display: flex; gap: 4px; }
.pagina-num { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 6px; font-size: 12.5px; font-weight: 600; color: var(--text); }
.pagina-num:hover { background: #EFEDE6; }
.pagina-num.active { background: var(--teal); color: #fff; }

/* ---------- Menu suspenso de ações por linha (tabela) ---------- */
.row-menu { position: relative; display: inline-block; }
.row-menu-btn { display: inline-flex; align-items: center; gap: 4px; }
.row-menu-btn .ic { width: 13px; height: 13px; }
.row-menu-dropdown {
  display: none; position: absolute; right: 0; top: calc(100% + 4px);
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.14); min-width: 150px; z-index: 30; overflow: hidden;
}
.row-menu-dropdown.open { display: block; }
.row-menu-dropdown form { margin: 0; }
.row-menu-dropdown a, .row-menu-dropdown button {
  display: block; width: 100%; text-align: left; padding: 9px 14px; font-size: 13px;
  background: none; border: none; color: var(--text); font-family: inherit;
}
.row-menu-dropdown a:hover, .row-menu-dropdown button:hover { background: #F5F7FA; }
.row-menu-dropdown .item-danger { color: #9A3E30; }
.row-menu-dropdown button:disabled { color: #B0B0B0; cursor: not-allowed; }
.row-menu-dropdown button:disabled:hover { background: none; }

/* ---------- Busca ao vivo (autocomplete) ---------- */
.busca-viva { position: relative; }
.busca-viva-input {
  width: 100%; max-width: 480px; padding: 14px 16px; font-size: 15px;
  border: 1.5px solid var(--line); border-radius: 10px; font-family: inherit;
}
.busca-viva-input:focus { border-color: var(--teal); }
.busca-viva-resultados {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; width: 100%; max-width: 480px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.12);
  max-height: 360px; overflow-y: auto; z-index: 20;
}
.busca-viva-resultados.open { display: block; }
.busca-viva-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid #F0EEE7; color: var(--text);
}
.busca-viva-item:last-child { border-bottom: none; }
.busca-viva-item:hover { background: #F5F7FA; }
.busca-viva-nome { font-weight: 600; font-size: 14px; }
.busca-viva-info { font-size: 12px; color: var(--text-mute); white-space: nowrap; }
.busca-viva-sem-resultado { color: var(--text-mute); font-style: italic; cursor: default; }
.busca-viva-sem-resultado:hover { background: none; }
.busca-viva-vazio { padding: 40px 10px; text-align: center; }
.busca-viva-vazio p { color: var(--text-mute); font-size: 13.5px; margin: 0 0 14px; }
.busca-viva-panel { min-height: 260px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-mute); }
.field input, .field select {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px;
  font-size: 13.5px; font-family: inherit; background: #fff; color: var(--text);
}
.field input:focus, .field select:focus { border-color: var(--teal); }
.form-actions { display: flex; gap: 10px; margin-top: 4px; }

/* ---------- Barra de ações no rodapé (cadastro) ---------- */
.bottom-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: #EEF1F6; border-top: 1px solid var(--line);
  margin: 24px -22px -20px; padding: 14px 22px; border-radius: 0 0 var(--radius) var(--radius);
}
.bottom-bar .bottom-bar-right { display: flex; gap: 10px; }
.btn.outline { background: #fff; border: 1px solid var(--line); color: var(--text); }
.btn.outline:hover { border-color: #C9C5B8; }
.btn.outline.danger-outline { color: #9A3E30; border-color: #E7C3BB; }
.btn.outline.danger-outline:hover { background: #FBEAE7; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:hover { background: #fff; border-color: var(--line); }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 0.9fr; }
.login-side {
  background: linear-gradient(155deg, var(--ink) 0%, #0D2340 45%, var(--teal) 85%, var(--teal-deep) 130%);
  color: #fff; padding: 56px 64px; display: flex; flex-direction: column; justify-content: center;
  position: relative; overflow: hidden;
}
.login-side::before {
  content: ''; position: absolute; width: 480px; height: 480px; border-radius: 50%;
  background: radial-gradient(circle, rgba(47,168,79,0.35), transparent 70%);
  top: -160px; right: -160px;
}
.login-side .brand { padding: 0 0 40px; }
.login-headline { font-family: var(--display); font-size: 42px; font-weight: 800; letter-spacing: -1px; margin: 0 0 16px; line-height: 1.1; }
.login-headline span { color: #7FE0A0; }
.login-sub { font-size: 15px; color: #C3CBDD; max-width: 420px; line-height: 1.6; margin: 0 0 30px; }
.login-checklist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.login-checklist li { display: flex; align-items: center; gap: 12px; font-size: 14px; color: #E3E8F2; font-weight: 500; }
.login-checklist svg { flex-shrink: 0; width: 26px; height: 26px; padding: 5px; border-radius: 50%; background: rgba(127,224,160,0.18); color: #7FE0A0; }

.login-card-wrap { display: flex; align-items: center; justify-content: center; padding: 40px; background: var(--paper); }
.login-card { background: var(--card); width: 100%; max-width: 380px; padding: 38px 34px; border-radius: 14px; border: 1px solid var(--line); box-shadow: 0 12px 40px rgba(16,25,46,0.08); }
.login-card h2 { margin: 0 0 4px; font-size: 21px; font-weight: 700; color: var(--ink); }
.login-card-logo { display: block; max-width: 220px; height: auto; margin: 0 auto 18px; }
.login-card-sub { margin: 0 0 22px; font-size: 13px; color: var(--text-mute); }
.login-hint { font-size: 12px; color: var(--text-mute); text-align: center; margin-top: 16px; line-height: 1.5; }

@media (max-width: 860px) {
  .login-page { grid-template-columns: 1fr; }
  .login-side { padding: 40px 28px; }
  .login-headline { font-size: 32px; }
}

/* ---------- Empty state ---------- */
.empty { padding: 30px 10px; text-align: center; color: var(--text-mute); font-size: 13px; }

/* ---------- Bars (simple chart, no external lib) ---------- */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 140px; padding-top: 10px; }
.bars .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .bar { width: 100%; border-radius: 5px 5px 0 0; background: linear-gradient(180deg, #1E9E7C, #0F6E56); min-height: 3px; }
.bars .bar-label { font-size: 10px; color: var(--text-mute); font-weight: 600; }

.donut-legend { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.donut-legend .item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.donut-legend .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.donut-legend .pct { margin-left: auto; font-family: var(--mono); color: var(--text-mute); }

@media (max-width: 980px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: 1fr; }
}

/* ---------- Mobile: sidebar vira gaveta deslizante ---------- */
@media (max-width: 860px) {
  .menu-btn { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100dvh; z-index: 60;
    transform: translateX(calc(-100% - 60px)); transition: transform 0.22s ease;
    box-shadow: 8px 0 24px rgba(0,0,0,0.25);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(10,15,30,0.5);
    opacity: 0; pointer-events: none; transition: opacity 0.22s ease; z-index: 50;
  }
  .sidebar-backdrop.open { opacity: 1; pointer-events: auto; }
  .topbar { padding: 14px 16px; }
  .topbar-title { font-size: 18px; }
  .topbar-company { display: none; }
  .content { padding: 12px 16px 40px; }
  .panel { padding: 16px; }
}

@media (max-width: 640px) {
  .kpis { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: 1fr; }
  .btn { padding: 10px 16px; font-size: 13.5px; }
  .btn.small { padding: 8px 12px; }
  .field input, .field select { padding: 11px 12px; font-size: 16px; }
  table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .bottom-bar { flex-direction: column-reverse; align-items: stretch; gap: 10px; }
  .bottom-bar-right { flex-direction: column; }
  .bottom-bar-right form, .bottom-bar-right .btn { width: 100%; }
  .bottom-bar .btn { justify-content: center; }
  .tabs-nav { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .tab-btn { flex-shrink: 0; }
  .contato-row { grid-template-columns: 1fr; }
  .contato-row .remove-contato { width: 100%; margin-bottom: 0 !important; }
  .bottom-bar-right { flex-direction: column-reverse; }
}

/* ---------- Configurações Adicionais ---------- */
.cfg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px 20px; align-items: start; }
.cfg-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); padding: 4px 0; }
.cfg-toggle input { width: auto; margin: 0; }

/* ---------- Tabs (formulário de Cliente) ---------- */
.tabs-nav { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 4px 0 20px; flex-wrap: wrap; }
.tab-btn { background: none; border: none; padding: 10px 16px; font-size: 13px; font-weight: 600; color: var(--text-mute); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--teal); border-bottom-color: var(--teal); }
.section-title { font-size: 13px; font-weight: 700; color: var(--text); margin: 22px 0 12px; padding-top: 14px; border-top: 1px solid #EFEDE6; }
.section-title:first-child { margin-top: 0; padding-top: 0; border-top: none; }
