/* KALUZ Finance — Design System */
/* Dark theme, gold accent, mobile-first */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #08080f;
  --surface: #12121c;
  --surface-2: #1a1a28;
  --surface-3: #22222e;
  --border: rgba(201, 168, 76, 0.08);
  --border-accent: rgba(201, 168, 76, 0.2);
  --text: #e8e8ee;
  --text-secondary: #9a9aac;
  --text-muted: #6b6b80;
  --accent: #c9a84c;
  --accent-light: #d4b45e;
  --green: #34d399;
  --red: #f43f5e;
  --blue: #3b82f6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

html { font-size: 16px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

/* ===== LOGIN ===== */
#loginScreen {
  display: none;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius);
  padding: 40px 32px;
  max-width: 380px;
  width: 100%;
}

.login-brand {
  text-align: center;
  margin-bottom: 32px;
}

.login-brand h1 {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  background: linear-gradient(135deg, #c9a84c, #e8d5a3);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-brand p {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 4px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 6px; font-weight: 500; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus { border-color: var(--accent); }

#loginError { color: var(--red); font-size: 0.82rem; margin-bottom: 12px; display: none; }

/* ===== BOTÕES ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 24px; border: none; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer;
  transition: all 0.2s;
}
.btn-primary { background: var(--accent); color: #08080f; }
.btn-primary:hover { background: var(--accent-light); }
.btn-secondary { background: var(--surface-3); color: var(--text); border: 1px solid var(--border-accent); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-sm { padding: 8px 16px; font-size: 0.8rem; }
.btn-full { width: 100%; }

/* ===== APP LAYOUT ===== */
#app {
  display: none;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.app-header .brand {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  background: linear-gradient(135deg, #c9a84c, #e8d5a3);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.app-header .user-info {
  display: flex; align-items: center; gap: 12px;
  font-size: 0.82rem; color: var(--text-secondary);
}

.app-header .btn-logout {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 0.78rem; padding: 4px 8px;
}
.app-header .btn-logout:hover { color: var(--red); }

.app-header .crm-link {
  color: var(--accent); text-decoration: none; font-size: 0.78rem;
  padding: 4px 10px; border: 1px solid var(--border-accent); border-radius: var(--radius-sm);
}

.app-content {
  flex: 1;
  padding: 20px;
  padding-bottom: 80px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 0;
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px;
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s;
  border: none; background: none;
}
.nav-item.active { color: var(--accent); }
.nav-item:hover { color: var(--text); }
.nav-item .nav-icon { font-size: 1.2rem; }

/* ===== PAGES ===== */
.page { display: none; }

.page-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
}
.page-header h2 { font-size: 1.2rem; font-weight: 700; }

/* ===== KPI CARDS ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
}
.kpi-card.accent { border-color: var(--border-accent); }
.kpi-card.accent .kpi-value {
  background: linear-gradient(135deg, #c9a84c, #e8d5a3);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.kpi-card.positive .kpi-value { color: var(--green); }
.kpi-card.negative .kpi-value { color: var(--red); }
.kpi-card.wide { grid-column: 1 / -1; }

.kpi-value { font-size: 1.3rem; font-weight: 800; margin-bottom: 4px; }
.kpi-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-sub { font-size: 0.75rem; color: var(--text-secondary); margin-top: 8px; }

/* ===== PROGRESS BAR ===== */
.progress-bar-container {
  width: 100%; height: 8px;
  background: var(--surface-3); border-radius: 4px;
  overflow: hidden; margin: 8px 0;
}
.progress-bar-fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), #e8d5a3);
  transition: width 0.4s ease;
}

/* ===== QUICK ACTIONS ===== */
.quick-actions {
  display: flex; gap: 12px; margin: 20px 0;
}
.quick-actions .btn { flex: 1; }

/* ===== SECTION ===== */
.section { margin-bottom: 24px; }
.section-title {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--accent); font-weight: 700; margin-bottom: 12px;
}

/* ===== CATEGORIA BARS ===== */
.cat-bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cat-bar-label { font-size: 0.8rem; color: var(--text-secondary); min-width: 100px; }
.cat-bar-track { flex: 1; height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.cat-bar-fill { height: 100%; border-radius: 3px; transition: width 0.4s; }
.cat-bar-value { font-size: 0.75rem; color: var(--text-muted); min-width: 110px; text-align: right; }

/* ===== TRANSACTIONS LIST ===== */
.summary-bar {
  display: flex; gap: 16px; flex-wrap: wrap;
  padding: 12px 16px; background: var(--surface); border-radius: var(--radius-sm);
  margin-bottom: 16px; font-size: 0.8rem;
}
.summary-receita { color: var(--green); }
.summary-despesa { color: var(--red); }
.summary-saldo.positive { color: var(--green); }
.summary-saldo.negative { color: var(--red); }

.transaction-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; background: var(--surface);
  border-radius: var(--radius-sm); margin-bottom: 8px;
  cursor: pointer; transition: background 0.2s;
}
.transaction-item:hover { background: var(--surface-2); }
.transaction-icon { font-size: 1.4rem; }
.transaction-info { flex: 1; }
.transaction-desc { font-size: 0.9rem; font-weight: 500; }
.transaction-cat { font-size: 0.75rem; color: var(--text-muted); }
.transaction-valor { font-weight: 700; font-size: 0.95rem; white-space: nowrap; }
.transaction-valor.positive { color: var(--green); }
.transaction-valor.negative { color: var(--red); }

/* ===== METAS ===== */
.metas-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.meta-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.meta-header { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.meta-icon { font-size: 1.3rem; }
.meta-nome { font-weight: 600; font-size: 1rem; }
.meta-values { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--text-secondary); margin: 4px 0; }
.meta-pct { font-size: 1.5rem; font-weight: 800; color: var(--accent); text-align: center; margin: 8px 0; }

/* ===== INVESTIMENTOS ===== */
.investimentos-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.investimento-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.inv-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.inv-nome { font-weight: 600; }
.inv-tipo { font-size: 0.7rem; padding: 2px 8px; border-radius: 4px; color: #fff; font-weight: 600; }
.inv-instituicao { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 12px; }
.inv-values { display: flex; flex-wrap: wrap; gap: 12px; font-size: 0.85rem; }
.inv-values .positive { color: var(--green); }
.inv-values .negative { color: var(--red); }

/* ===== MODAL ===== */
.modal-overlay {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7); z-index: 200;
  justify-content: center; align-items: flex-end;
}
.modal-overlay.open { display: flex; }
.modal-content {
  background: var(--surface); border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px 20px 32px; width: 100%; max-width: 500px; max-height: 85vh; overflow-y: auto;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.5rem; cursor: pointer; }

/* ===== EMPTY STATE ===== */
.empty-state { color: var(--text-muted); font-size: 0.9rem; text-align: center; padding: 40px 20px; }

/* ===== TOAST ===== */
#toastContainer { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 20px; border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 500;
  color: #fff; transition: all 0.3s;
}
.toast.success { background: #059669; }
.toast.error { background: #dc2626; }
.toast.info { background: #2563eb; }

/* ===== CHECKBOX ===== */
.checkbox-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.checkbox-row input[type="checkbox"] { accent-color: var(--accent); width: 18px; height: 18px; }
.checkbox-row label { font-size: 0.85rem; color: var(--text-secondary); cursor: pointer; }

/* ===== RESPONSIVE ===== */
@media (min-width: 768px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .kpi-grid.secondary { grid-template-columns: 2fr 1fr; }
  .metas-grid { grid-template-columns: 1fr 1fr; }
  .investimentos-grid { grid-template-columns: 1fr 1fr; }
}
