/* Orlando Borges - Design System Mobile-First (Alta Legibilidade & Toque Grande) */
:root {
  --bg-main: #080c16;
  --bg-card: #101728;
  --bg-card-hover: #18233c;
  --bg-input: #090e1a;
  --border: #1e293b;
  --border-focus: #0284c7;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;

  --success: #10b981;
  --success-bg: #064e3b;
  --whatsapp: #25d366;
  --whatsapp-hover: #1eb857;

  --warning: #f59e0b;
  --warning-bg: #78350f;
  --danger: #ef4444;
  --danger-bg: #7f1d1d;
  --purple: #8b5cf6;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 95px; /* Espaço para barra inferior */
}

/* Header Superior */
.top-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.brand-box {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-avatar {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #0284c7, #0f766e);
  color: white;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 20px;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4);
}
.brand-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: #f1f5f9;
}
.brand-sub {
  font-size: 12px;
  color: #38bdf8;
  font-weight: 600;
}
.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Barra de Busca Global Instantânea */
.search-bar-wrap {
  background: #0b1120;
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  position: relative;
}
.search-input-box {
  position: relative;
  max-width: 960px;
  margin: 0 auto;
}
.search-input-box input {
  width: 100%;
  background: var(--bg-input);
  border: 1.5px solid #22304d;
  border-radius: var(--radius-full);
  color: white;
  padding: 10px 18px 10px 42px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}
.search-input-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(2, 132, 199, 0.3);
}
.search-icon-left {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
  font-size: 16px;
  pointer-events: none;
}
.search-results-dropdown {
  display: none;
  position: absolute;
  top: 105%;
  left: 0;
  right: 0;
  background: #111a30;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 400px;
  overflow-y: auto;
  z-index: 90;
  padding: 8px;
}
.search-results-dropdown.active {
  display: block;
}
.search-item {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border-bottom: 1px solid #1a2642;
  cursor: pointer;
  transition: background 0.15s;
}
.search-item:hover {
  background: #192644;
}
.search-item:last-child {
  border-bottom: none;
}

/* Navegação por Abas */
.nav-bar {
  display: flex;
  background: #090e1b;
  border-bottom: 1px solid var(--border);
  padding: 8px 12px;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky;
  top: 68px;
  z-index: 35;
}
.nav-bar::-webkit-scrollbar { display: none; }
.nav-btn {
  padding: 9px 16px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}
.nav-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 2px 10px rgba(2, 132, 199, 0.4);
}

/* Container Principal */
.main-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}

/* Grid de Métricas Principais */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.metric-card.destaque {
  border-color: #0369a1;
  background: linear-gradient(145deg, #101728, #0a2138);
}
.metric-card.alerta {
  border-color: #7f1d1d;
  background: linear-gradient(145deg, #101728, #260f15);
}
.metric-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.metric-val {
  font-size: 23px;
  font-weight: 900;
  color: white;
  letter-spacing: -0.5px;
}
.metric-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* Banner de Patrimônio Líquido */
.patrimonio-hero {
  background: linear-gradient(135deg, #09172e, #06312a);
  border: 1.5px solid #0284c7;
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 10px 30px rgba(2, 132, 199, 0.15);
  position: relative;
}
.patrimonio-titulo {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #38bdf8;
  margin-bottom: 6px;
}
.patrimonio-valor-total {
  font-size: 34px;
  font-weight: 900;
  color: #ffffff;
  letter-spacing: -1px;
}
.patrimonio-bar-track {
  height: 10px;
  border-radius: 9999px;
  background: #0f172a;
  display: flex;
  overflow: hidden;
  margin: 16px 0 12px 0;
  border: 1px solid #1e293b;
}
.patrimonio-bar-seg {
  height: 100%;
  transition: width 0.3s;
}

/* Gráfico de Barras Responsivo */
.chart-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 24px;
}
.chart-bars-wrap {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: 10px;
  height: 180px;
  padding: 10px 0 25px 0;
  border-bottom: 1px solid #1e293b;
  position: relative;
}
.chart-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  height: 100%;
  justify-content: flex-end;
  position: relative;
}
.chart-bar-pillar {
  width: 70%;
  max-width: 38px;
  background: linear-gradient(180deg, #38bdf8, #0284c7);
  border-radius: 6px 6px 0 0;
  transition: height 0.5s ease-out;
  position: relative;
  min-height: 4px;
}
.chart-bar-pillar:hover {
  background: linear-gradient(180deg, #7dd3fc, #0369a1);
}
.chart-bar-val {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 800;
  color: #e2e8f0;
  white-space: nowrap;
}
.chart-bar-label {
  position: absolute;
  bottom: -24px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
}

/* Cartões de Registros e Listas */
.card-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.card-title {
  font-size: 17.5px;
  font-weight: 800;
  color: #f8fafc;
}
.card-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}
.card-details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  background: #090e1c;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  border: 1px solid #162035;
}
.detail-box .d-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  font-weight: 700;
}
.detail-box .d-val {
  font-size: 15px;
  font-weight: 800;
  color: #e2e8f0;
}
.detail-box .d-val.verde { color: var(--success); }
.detail-box .d-val.vermelho { color: var(--danger); }
.detail-box .d-val.amarelo { color: var(--warning); }
.detail-box .d-val.azul { color: #38bdf8; }

/* Badges e Pílulas */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 800;
}
.badge-sucesso { background: var(--success-bg); color: #6ee7b7; border: 1px solid #059669; }
.badge-alerta { background: var(--warning-bg); color: #fde68a; border: 1px solid #b45309; }
.badge-perigo { background: var(--danger-bg); color: #fca5a5; border: 1px solid #dc2626; }
.badge-azul { background: #0c4a6e; color: #7dd3fc; border: 1px solid #0284c7; }
.badge-cinza { background: #1e293b; color: #94a3b8; border: 1px solid #334155; }
.badge-roxo { background: #3b1d6e; color: #c4b5fd; border: 1px solid #7c3aed; }

/* Botões de Ação */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  min-height: 48px;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-whatsapp {
  background: var(--whatsapp);
  color: #064e3b;
  font-weight: 800;
}
.btn-whatsapp:hover { background: var(--whatsapp-hover); color: #022c22; }
.btn-secondary { background: #1a233a; color: #cbd5e1; border: 1px solid #283758; }
.btn-secondary:hover { background: #233152; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { min-height: 38px; padding: 6px 12px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-block { width: 100%; }

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

/* Modais */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.active {
  display: flex;
}
.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}
.modal-header h2 { font-size: 20px; color: white; }
.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 26px;
  cursor: pointer;
  line-height: 1;
}

/* Formulários */
.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
}
.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: white;
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}
.form-control:focus {
  border-color: var(--border-focus);
}
.form-help {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* Pré-visualização de Cálculo */
.calc-preview {
  background: #081122;
  border: 1.5px dashed #0284c7;
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 16px;
}
.calc-preview-title {
  font-size: 12.5px;
  font-weight: 800;
  color: #38bdf8;
  margin-bottom: 8px;
  text-transform: uppercase;
}
.calc-preview-line {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  padding: 3px 0;
  color: #cbd5e1;
}
.calc-preview-line strong {
  color: white;
}
