/* =============================================
   MEU PATRIMÔNIO - CSS Principal
   ============================================= */

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --secondary: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #0ea5e9;
  --bg: #f8fafc;
  --bg2: #ffffff;
  --bg3: #f1f5f9;
  --text: #1e293b;
  --text2: #64748b;
  --text3: #94a3b8;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --sidebar-w: 260px;
  --header-h: 64px;
  --transition: .2s ease;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg2: #1e293b;
  --bg3: #162032;
  --text: #f1f5f9;
  --text2: #94a3b8;
  --text3: #64748b;
  --border: #334155;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.4);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.4);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background var(--transition), color var(--transition);
}

/* LAYOUT */
#app { display:flex; height:100vh; overflow:hidden; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition), width var(--transition);
  z-index: 100;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-logo {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--header-h);
}

.logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
  flex-shrink: 0;
}

.logo-text h1 { font-size:16px; font-weight:700; color:var(--text); line-height:1.2; }
.logo-text span { font-size:11px; color:var(--text2); }

.sidebar-nav { flex:1; overflow-y:auto; padding:12px 0; }

.nav-section { padding:8px 16px 4px; }
.nav-section-label { font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:.08em; color:var(--text3); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  margin: 2px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text2);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  border: none;
  background: transparent;
  width: calc(100% - 16px);
  text-align: left;
}

.nav-item:hover { background:var(--bg3); color:var(--text); }
.nav-item.active { background:linear-gradient(135deg, var(--primary)15, var(--primary)25); color:var(--primary); font-weight:600; }
.nav-item.active i { color:var(--primary); }
.nav-item i { width:18px; text-align:center; font-size:15px; transition:color var(--transition); }
.nav-badge { margin-left:auto; background:var(--danger); color:white; font-size:10px; font-weight:700; padding:2px 6px; border-radius:999px; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.sidebar-user:hover { background:var(--bg3); }
.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.user-info h4 { font-size:13px; font-weight:600; color:var(--text); }
.user-info span { font-size:11px; color:var(--text2); }

/* MAIN CONTENT */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.topbar {
  height: var(--header-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
}

.topbar-title { font-size:18px; font-weight:700; color:var(--text); flex:1; }
.topbar-subtitle { font-size:13px; color:var(--text2); }

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

.btn-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--bg3);
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  position: relative;
  font-size: 14px;
}
.btn-icon:hover { background:var(--primary); color:white; }
.btn-icon .badge { position:absolute; top:-2px; right:-2px; background:var(--danger); color:white; font-size:9px; font-weight:700; padding:1px 4px; border-radius:999px; }

.page { flex:1; overflow-y:auto; padding:24px; }

/* CARDS */
.card {
  background: var(--bg2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow var(--transition);
}

.card:hover { box-shadow: var(--shadow-md); }
.card-header { padding: 20px 24px 0; display:flex; align-items:center; justify-content:space-between; gap:16px; }
.card-title { font-size:16px; font-weight:700; color:var(--text); display:flex; align-items:center; gap:8px; }
.card-body { padding: 20px 24px; }
.card-footer { padding:12px 24px; border-top:1px solid var(--border); display:flex; align-items:center; gap:8px; }

/* STAT CARDS */
.stat-cards { display:grid; grid-template-columns:repeat(auto-fill, minmax(220px, 1fr)); gap:16px; margin-bottom:24px; }

.stat-card {
  background: var(--bg2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: all var(--transition);
}

.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.stat-card-accent {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}

.stat-card-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:12px; }
.stat-icon { width:40px; height:40px; border-radius:10px; display:flex; align-items:center; justify-content:center; font-size:17px; flex-shrink:0; }
.stat-trend { font-size:11px; font-weight:600; padding:2px 6px; border-radius:999px; }
.trend-up { color:#10b981; background:#10b98115; }
.trend-down { color:#ef4444; background:#ef444415; }
.trend-neutral { color:#64748b; background:#64748b15; }

.stat-value { font-size:24px; font-weight:800; color:var(--text); line-height:1.1; margin-bottom:4px; }
.stat-label { font-size:12px; color:var(--text2); font-weight:500; }
.stat-sub { font-size:11px; color:var(--text3); margin-top:4px; }

/* PROGRESS */
.progress-bar { height:8px; background:var(--bg3); border-radius:999px; overflow:hidden; }
.progress-fill { height:100%; border-radius:999px; transition:width .6s ease; }

/* BUTTONS */
.btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary { background:var(--primary); color:white; }
.btn-primary:hover { background:var(--primary-dark); }
.btn-secondary { background:var(--bg3); color:var(--text); border:1px solid var(--border); }
.btn-secondary:hover { background:var(--border); }
.btn-success { background:var(--secondary); color:white; }
.btn-success:hover { background:#059669; }
.btn-danger { background:var(--danger); color:white; }
.btn-danger:hover { background:#dc2626; }
.btn-warning { background:var(--warning); color:white; }
.btn-sm { padding:6px 12px; font-size:13px; }
.btn-lg { padding:12px 24px; font-size:16px; }

/* FORMS */
.form-group { margin-bottom:16px; }
.form-label { display:block; font-size:13px; font-weight:600; color:var(--text2); margin-bottom:6px; }
.form-control {
  width:100%;
  padding:10px 14px;
  background:var(--bg3);
  border:1px solid var(--border);
  border-radius:var(--radius-sm);
  color:var(--text);
  font-size:14px;
  transition:border-color var(--transition), box-shadow var(--transition);
  outline:none;
}

.form-control:focus { border-color:var(--primary); box-shadow:0 0 0 3px var(--primary)20; background:var(--bg2); }
.form-select { appearance:none; background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:right 12px center; background-size:16px; padding-right:40px; }
.form-row { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
.form-row-3 { display:grid; grid-template-columns:1fr 1fr 1fr; gap:16px; }

/* TABLES */
.table-wrap { overflow-x:auto; }
table { width:100%; border-collapse:collapse; }
th { padding:10px 16px; text-align:left; font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.06em; color:var(--text3); border-bottom:1px solid var(--border); background:var(--bg3); }
td { padding:12px 16px; font-size:14px; color:var(--text); border-bottom:1px solid var(--border); }
tr:last-child td { border-bottom:none; }
tr:hover td { background:var(--bg3); }

/* MODAL */
.modal-overlay {
  position:fixed; inset:0; z-index:1000;
  background:rgba(0,0,0,.5);
  backdrop-filter:blur(4px);
  display:flex; align-items:center; justify-content:center; padding:20px;
  opacity:0; transition:opacity .2s;
}
.modal-overlay.open { opacity:1; }

.modal {
  background:var(--bg2);
  border-radius:var(--radius-lg);
  box-shadow:var(--shadow-lg);
  width:100%;
  max-width:560px;
  max-height:90vh;
  overflow-y:auto;
  transform:scale(.95);
  transition:transform .2s;
}
.modal-overlay.open .modal { transform:scale(1); }
.modal-lg { max-width:800px; }

.modal-header {
  padding:20px 24px;
  border-bottom:1px solid var(--border);
  display:flex; align-items:center; gap:12px;
}
.modal-header h3 { font-size:18px; font-weight:700; color:var(--text); flex:1; }
.modal-close { width:32px; height:32px; border:none; background:var(--bg3); border-radius:var(--radius-sm); cursor:pointer; color:var(--text2); font-size:16px; display:flex; align-items:center; justify-content:center; transition:all var(--transition); }
.modal-close:hover { background:var(--danger); color:white; }
.modal-body { padding:24px; }
.modal-footer { padding:16px 24px; border-top:1px solid var(--border); display:flex; gap:12px; justify-content:flex-end; }

/* TOAST */
.toast-container { position:fixed; bottom:24px; right:24px; z-index:2000; display:flex; flex-direction:column; gap:8px; }
.toast {
  background:var(--bg2);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:12px 16px;
  box-shadow:var(--shadow-lg);
  display:flex; align-items:center; gap:12px;
  min-width:280px;
  animation:slideIn .3s ease;
  font-size:14px;
}
.toast-success { border-left:4px solid var(--secondary); }
.toast-error { border-left:4px solid var(--danger); }
.toast-warning { border-left:4px solid var(--warning); }
.toast-info { border-left:4px solid var(--info); }

@keyframes slideIn {
  from { transform:translateX(100%); opacity:0; }
  to { transform:translateX(0); opacity:1; }
}
@keyframes fadeOut {
  from { opacity:1; }
  to { opacity:0; transform:translateX(100%); }
}
.toast.hiding { animation:fadeOut .3s ease forwards; }

/* CHIPS / TAGS */
.chip { display:inline-flex; align-items:center; gap:6px; padding:4px 10px; border-radius:999px; font-size:12px; font-weight:600; }
.chip-primary { background:var(--primary)20; color:var(--primary); }
.chip-success { background:#10b98120; color:#10b981; }
.chip-danger { background:#ef444420; color:#ef4444; }
.chip-warning { background:#f59e0b20; color:#f59e0b; }
.chip-info { background:#0ea5e920; color:#0ea5e9; }
.chip-neutral { background:var(--bg3); color:var(--text2); }

/* GRID LAYOUTS */
.grid-2 { display:grid; grid-template-columns:1fr 1fr; gap:20px; }
.grid-3 { display:grid; grid-template-columns:1fr 1fr 1fr; gap:20px; }
.grid-4 { display:grid; grid-template-columns:repeat(4,1fr); gap:16px; }

/* CHART CONTAINERS */
.chart-container { position:relative; width:100%; }
.chart-sm { height:180px; }
.chart-md { height:260px; }
.chart-lg { height:320px; }

/* EMPTY STATE */
.empty-state { text-align:center; padding:60px 20px; color:var(--text2); }
.empty-icon { font-size:48px; margin-bottom:16px; opacity:.3; }
.empty-state h3 { font-size:16px; font-weight:600; margin-bottom:8px; color:var(--text); }
.empty-state p { font-size:14px; margin-bottom:20px; }

/* LOADING */
.loading { display:flex; align-items:center; justify-content:center; padding:40px; }
.spinner { width:36px; height:36px; border:3px solid var(--border); border-top-color:var(--primary); border-radius:50%; animation:spin .8s linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }

/* GOAL CARD */
.goal-card {
  background:var(--bg2);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:20px;
  transition:all var(--transition);
}
.goal-card:hover { box-shadow:var(--shadow-md); }
.goal-card-header { display:flex; align-items:flex-start; gap:12px; margin-bottom:16px; }
.goal-icon { width:44px; height:44px; border-radius:12px; display:flex; align-items:center; justify-content:center; font-size:18px; flex-shrink:0; }
.goal-info h4 { font-size:15px; font-weight:700; color:var(--text); }
.goal-info span { font-size:12px; color:var(--text2); }
.goal-amounts { display:flex; justify-content:space-between; margin-bottom:8px; font-size:13px; }
.goal-amounts .current { font-weight:700; color:var(--text); }
.goal-amounts .target { color:var(--text2); }

/* INVESTMENT CARD */
.inv-type-badge { padding:3px 8px; border-radius:6px; font-size:11px; font-weight:700; text-transform:uppercase; }

/* SIDEBAR TOGGLE */
.sidebar-toggle {
  display:none;
  width:36px; height:36px;
  border:none;
  background:var(--bg3);
  border-radius:var(--radius-sm);
  cursor:pointer;
  color:var(--text);
  font-size:16px;
  align-items:center;
  justify-content:center;
}

/* MOBILE OVERLAY */
.sidebar-mobile-overlay {
  display:none;
  position:fixed; inset:0; z-index:99;
  background:rgba(0,0,0,.5);
}

/* ALERT PANEL */
.alert-panel {
  position:fixed; top:0; right:0; bottom:0;
  width:380px;
  background:var(--bg2);
  border-left:1px solid var(--border);
  box-shadow:var(--shadow-lg);
  z-index:500;
  transform:translateX(100%);
  transition:transform var(--transition);
  display:flex; flex-direction:column;
}
.alert-panel.open { transform:translateX(0); }
.alert-panel-header { padding:20px 24px; border-bottom:1px solid var(--border); display:flex; align-items:center; gap:12px; }
.alert-panel-header h3 { flex:1; font-size:16px; font-weight:700; }
.alert-list { flex:1; overflow-y:auto; }
.alert-item { padding:16px 24px; border-bottom:1px solid var(--border); display:flex; gap:12px; cursor:pointer; transition:background var(--transition); }
.alert-item:hover { background:var(--bg3); }
.alert-item.unread { background:var(--primary)08; }
.alert-dot { width:8px; height:8px; border-radius:50%; margin-top:6px; flex-shrink:0; }

/* SIMULATOR */
.simulator-grid { display:grid; grid-template-columns:380px 1fr; gap:24px; }
.input-range { width:100%; accent-color:var(--primary); cursor:pointer; }

/* TABS */
.tabs { display:flex; gap:2px; border-bottom:1px solid var(--border); margin-bottom:20px; }
.tab-btn { padding:10px 16px; border:none; background:transparent; cursor:pointer; color:var(--text2); font-size:14px; font-weight:500; border-bottom:2px solid transparent; transition:all var(--transition); margin-bottom:-1px; }
.tab-btn.active { color:var(--primary); border-bottom-color:var(--primary); font-weight:600; }
.tab-btn:hover:not(.active) { color:var(--text); }

/* RESPONSIVE */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns:repeat(2,1fr); }
  .simulator-grid { grid-template-columns:1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w:260px; }
  
  .sidebar-toggle { display:flex; }
  
  .sidebar {
    position:fixed; top:0; left:0; bottom:0;
    transform:translateX(-100%);
    z-index:200;
    box-shadow:var(--shadow-lg);
  }
  .sidebar.open { transform:translateX(0); }
  .sidebar-mobile-overlay.show { display:block; }
  
  .page { padding:16px; }
  .grid-2, .grid-3 { grid-template-columns:1fr; }
  .form-row, .form-row-3 { grid-template-columns:1fr; }
  .stat-cards { grid-template-columns:repeat(2,1fr); }
  .topbar { padding:0 16px; }
  .modal { max-width:100%; margin:0; border-radius:var(--radius-lg) var(--radius-lg) 0 0; }
  .modal-overlay { align-items:flex-end; padding:0; }
}

@media (max-width: 480px) {
  .stat-cards { grid-template-columns:1fr; }
}

/* SMOOTH ANIMATIONS */
.page > * { animation:pageIn .3s ease; }
@keyframes pageIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

/* SCROLLBAR */
::-webkit-scrollbar { width:6px; height:6px; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-thumb { background:var(--border); border-radius:3px; }
::-webkit-scrollbar-thumb:hover { background:var(--text3); }

/* FAMILY PLAN */
.family-plan-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-lg);
  padding: 32px;
  color: white;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}
.family-plan-header::after {
  content:'';
  position:absolute;
  right:-40px; top:-40px;
  width:200px; height:200px;
  background:white;
  opacity:.05;
  border-radius:50%;
}
.family-plan-header h2 { font-size:24px; font-weight:800; margin-bottom:4px; }
.family-plan-header p { opacity:.85; font-size:14px; }

/* NUMBER FORMAT */
.amount-positive { color:var(--secondary); font-weight:700; }
.amount-negative { color:var(--danger); font-weight:700; }
.amount-neutral { color:var(--text); font-weight:700; }

/* HEALTH INDICATOR */
.health-ring { position:relative; width:120px; height:120px; flex-shrink:0; }
.health-ring svg { width:100%; height:100%; }
.health-ring-center { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; }
.health-score { font-size:28px; font-weight:800; color:var(--text); }
.health-label { font-size:11px; color:var(--text2); }

/* PRIORITY DOTS */
.priority-critical { color:#ef4444; }
.priority-high { color:#f59e0b; }
.priority-medium { color:#6366f1; }
.priority-low { color:#94a3b8; }

/* COLOR PICKER INPUT */
input[type="color"] { width:40px; height:40px; padding:2px; border-radius:8px; border:1px solid var(--border); cursor:pointer; background:var(--bg3); }

/* TOGGLE */
.toggle { position:relative; display:inline-block; width:44px; height:24px; }
.toggle input { opacity:0; width:0; height:0; }
.toggle-slider { position:absolute; cursor:pointer; inset:0; background:var(--border); border-radius:999px; transition:var(--transition); }
.toggle-slider::before { content:''; position:absolute; height:18px; width:18px; left:3px; bottom:3px; background:white; border-radius:50%; transition:var(--transition); box-shadow:0 1px 3px rgba(0,0,0,.3); }
input:checked + .toggle-slider { background:var(--primary); }
input:checked + .toggle-slider::before { transform:translateX(20px); }

/* AVATAR COLORS */
.avatar { width:36px; height:36px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:13px; font-weight:700; color:white; flex-shrink:0; }
