/* =============================================
   FINCONTROL – style.css (v2)
   Compatível com Chrome/Firefox no Windows 7
   ============================================= */

   :root {
    --bg: #f0f4f8;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1a202c;
    --text-muted: #718096;
    --primary: #10b981;
    --primary-dark: #059669;
    --primary-light: rgba(16,185,129,0.1);
    --income: #10b981;
    --expense: #ef4444;
    --warning: #f59e0b;
    --sidebar-bg: #ffffff;
    --sidebar-width: 250px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --radius: 14px;
    --radius-sm: 8px;
    --transition: 0.25s ease;
  }
  
  body.theme-dark {
    --bg: #0f172a;
    --surface: #1e293b;
    --border: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --sidebar-bg: #1e293b;
    --shadow: 0 2px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
    --primary-light: rgba(16,185,129,0.15);
  }
  
  /* --- RESET --- */
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  body {
    font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px;
    background: var(--bg); color: var(--text);
    transition: background var(--transition), color var(--transition);
  }
  a { text-decoration: none; color: inherit; }
  button { cursor: pointer; font-family: inherit; }
  
  /* --- SCROLLBAR --- */
  ::-webkit-scrollbar { width: 6px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
  
  /* ============ SIDEBAR ============ */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    z-index: 100; transition: transform var(--transition);
    box-shadow: var(--shadow);
  }
  .sidebar-logo {
    display: flex; align-items: center; gap: 12px;
    padding: 22px 20px 16px;
    font-size: 20px; font-weight: 800;
    border-bottom: 1px solid var(--border);
  }
  .logo-icon { font-size: 26px; }
  
  /* Perfil na sidebar */
  .sidebar-profile {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 20px; cursor: pointer;
    border-bottom: 1px solid var(--border);
  }
  .profile-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--primary-light);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; overflow: hidden; flex-shrink: 0;
    border: 2px solid var(--primary);
  }
  .profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
  .profile-name { font-size: 13px; font-weight: 600; }
  
  .sidebar-nav { list-style: none; padding: 12px; flex: 1; overflow-y: auto; }
  .sidebar-nav li { margin-bottom: 4px; }
  .nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 16px; border-radius: 10px;
    color: var(--text-muted); font-weight: 500; font-size: 14px;
    transition: all var(--transition);
  }
  .nav-link:hover { background: var(--bg); color: var(--text); transform: translateX(2px); }
  .nav-link.active { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(16,185,129,0.3); }
  
  /* ============ MOBILE HEADER ============ */
  .mobile-header {
    display: none; position: fixed; top: 0; left: 0; right: 0; z-index: 200;
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 12px 16px; align-items: center; justify-content: space-between;
    box-shadow: var(--shadow);
  }
  .menu-btn, .theme-btn-mobile { background: none; border: none; font-size: 22px; color: var(--text); }
  
  /* ============ OVERLAY ============ */
  .overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 99; }
  .overlay.show { display: block; }
  
  /* ============ MAIN ============ */
  .main-content { margin-left: var(--sidebar-width); min-height: 100vh; padding: 0 0 60px; }
  
  /* ============ PAGES ============ */
  .page { display: none; padding: 32px; max-width: 1100px; margin: 0 auto; animation: fadeIn 0.3s ease; }
  .page.active { display: block; }
  @keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
  
  .page-header {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 12px; margin-bottom: 28px;
  }
  .page-header h1 { font-size: 26px; font-weight: 800; }
  .subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
  .header-actions { display: flex; gap: 10px; flex-wrap: wrap; }
  
  /* ============ CARDS ============ */
  .cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
  .card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px;
    display: flex; align-items: center; gap: 16px;
    box-shadow: var(--shadow); transition: transform var(--transition), box-shadow var(--transition);
  }
  .card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
  .card-icon { font-size: 34px; }
  .card-label { font-size: 12px; color: var(--text-muted); font-weight: 500; display: block; }
  .card-value { font-size: 22px; font-weight: 800; display: block; margin-top: 4px; }
  .income-value { color: var(--income); }
  .expense-value { color: var(--expense); }
  .card-balance .card-value { color: var(--primary); }
  .balance-negative .card-value { color: var(--expense) !important; }
  .card-compare .card-value { font-size: 16px; }
  
  /* ============ ALERTAS ============ */
  .alerts-box {
    background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.4);
    border-radius: var(--radius); padding: 14px 18px; margin-bottom: 20px;
  }
  .alert-item { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 13px; }
  .alert-item span { color: var(--warning); font-weight: 700; font-size: 16px; }
  
  /* Top categoria */
  .top-cat-bar {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px 18px; margin-bottom: 20px;
    font-size: 13px; color: var(--text-muted);
    box-shadow: var(--shadow);
  }
  .top-cat-bar strong { color: var(--expense); }
  
  /* ============ BOXES ============ */
  .box {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 22px;
    box-shadow: var(--shadow);
  }
  .box h3 { font-size: 15px; font-weight: 700; margin-bottom: 16px; }
  .box-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
  .box-header h3 { margin-bottom: 0; }
  .link { color: var(--primary); font-size: 13px; font-weight: 600; transition: opacity var(--transition); }
  .link:hover { opacity: 0.7; }
  .box-header-icon { font-size: 30px; margin-bottom: 8px; }
  .box-danger { border-color: rgba(239,68,68,0.3); }
  
  .dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
  
  /* ============ TRANSACTIONS ============ */
  .transaction-list { display: flex; flex-direction: column; gap: 8px; }
  .tx-item {
    display: flex; align-items: center; gap: 12px;
    padding: 13px 16px; border-radius: 12px;
    background: var(--surface); border: 1px solid var(--border);
    transition: box-shadow var(--transition), transform var(--transition);
    animation: slideIn 0.2s ease;
  }
  @keyframes slideIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: translateX(0); } }
  .tx-item:hover { box-shadow: var(--shadow); transform: translateX(2px); }
  .tx-icon { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
  .tx-icon.receita { background: rgba(16,185,129,0.1); }
  .tx-icon.despesa { background: rgba(239,68,68,0.1); }
  .tx-info { flex: 1; min-width: 0; }
  .tx-desc { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tx-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
  .tx-amount { font-weight: 700; font-size: 14px; white-space: nowrap; margin-right: 8px; }
  .tx-amount.receita { color: var(--income); }
  .tx-amount.despesa { color: var(--expense); }
  .tx-actions { display: flex; gap: 4px; }
  .tx-btn { background: none; border: none; width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 15px; color: var(--text-muted); transition: background var(--transition); }
  .tx-btn:hover { background: var(--bg); color: var(--text); }
  .tx-btn.delete:hover { color: var(--expense); }
  
  .empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); font-size: 14px; }
  
  /* ============ FILTROS ============ */
  .filters-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
  .search-wrap { position: relative; flex: 1; min-width: 200px; }
  .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; }
  .search-wrap .input { padding-left: 36px; }
  
  /* ============ INPUTS / SELECTS ============ */
  .input {
    background: var(--surface); border: 1px solid var(--border); color: var(--text);
    border-radius: var(--radius-sm); padding: 9px 13px; font-size: 14px;
    font-family: inherit; width: 100%; outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
  }
  .input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
  .select { cursor: pointer; }
  .input-row { display: flex; gap: 10px; margin-top: 8px; }
  .input-row .input { flex: 1; }
  
  /* ============ BUTTONS ============ */
  .btn { padding: 9px 20px; border-radius: 10px; font-size: 14px; font-weight: 600; border: none; transition: all var(--transition); white-space: nowrap; }
  .btn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(16,185,129,0.25); }
  .btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(16,185,129,0.35); }
  .btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
  .btn-outline:hover { background: var(--bg); }
  .btn-danger { background: var(--expense); color: #fff; }
  .btn-danger:hover { background: #dc2626; }
  .btn-full { width: 100%; margin-top: 8px; }
  .btn-sm { padding: 6px 14px; font-size: 12px; border-radius: 8px; }
  
  /* ============ METAS ============ */
  .goals-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
  .goal-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px;
    box-shadow: var(--shadow); transition: transform var(--transition);
  }
  .goal-card:hover { transform: translateY(-3px); }
  .goal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
  .goal-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
  .goal-icon { font-size: 24px; }
  .goal-values { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 8px; }
  .goal-current { font-weight: 700; color: var(--primary); }
  .goal-target { color: var(--text-muted); }
  .progress-bar-wrap { background: var(--bg); border-radius: 99px; height: 10px; overflow: hidden; margin-bottom: 8px; }
  .progress-bar { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--primary), #059669); transition: width 0.5s ease; }
  .progress-bar.complete { background: linear-gradient(90deg, #10b981, #34d399); }
  .goal-pct { font-size: 12px; color: var(--text-muted); text-align: right; font-weight: 600; }
  
  /* ============ RECORRENTES ============ */
  .recur-badge {
    padding: 3px 10px; border-radius: 99px; font-size: 11px; font-weight: 700;
  }
  .recur-badge.ok { background: rgba(16,185,129,0.12); color: var(--income); }
  .recur-badge.warn { background: rgba(245,158,11,0.12); color: var(--warning); }
  .recur-badge.late { background: rgba(239,68,68,0.12); color: var(--expense); }
  
  /* ============ MODAL ============ */
  .modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 300; align-items: center; justify-content: center; }
  .modal-backdrop.show { display: flex; }
  .modal { background: var(--surface); border-radius: 18px; padding: 30px; width: 100%; max-width: 490px; max-height: 90vh; overflow-y: auto; box-shadow: 0 24px 64px rgba(0,0,0,0.3); animation: slideUp 0.25s ease; }
  .modal-sm { max-width: 360px; }
  @keyframes slideUp { from { transform: translateY(32px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
  .modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
  .modal-header h2 { font-size: 18px; font-weight: 800; }
  .modal-close { background: none; border: none; font-size: 18px; color: var(--text-muted); cursor: pointer; transition: color var(--transition); }
  .modal-close:hover { color: var(--expense); }
  .modal-form { display: flex; flex-direction: column; gap: 14px; }
  .form-group { display: flex; flex-direction: column; gap: 6px; }
  .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .label { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
  .confirm-msg { color: var(--text-muted); margin-bottom: 20px; font-size: 14px; line-height: 1.6; }
  
  /* ============ TOGGLE ============ */
  .toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; }
  .toggle-label { font-weight: 600; font-size: 14px; }
  .toggle-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
  .toggle { position: relative; display: inline-block; width: 50px; height: 28px; }
  .toggle input { opacity: 0; width: 0; height: 0; }
  .toggle-slider { position: absolute; cursor: pointer; inset: 0; background: var(--border); border-radius: 28px; transition: 0.3s; }
  .toggle-slider::before { content: ""; position: absolute; height: 22px; width: 22px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: 0.3s; }
  .toggle input:checked + .toggle-slider { background: var(--primary); }
  .toggle input:checked + .toggle-slider::before { transform: translateX(22px); }
  
  /* ============ CHARTS ============ */
  canvas { display: block; max-width: 100%; }
  .chart-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
  .legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
  .legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
  
  /* ============ SETTINGS ============ */
  .settings-grid { display: flex; flex-direction: column; gap: 20px; }
  
  /* Foto de perfil */
  .profile-section { margin: 10px 0; }
  .profile-pic-wrap { display: flex; align-items: center; gap: 16px; }
  .profile-pic-large {
    width: 80px; height: 80px; border-radius: 50%; font-size: 36px;
    background: var(--primary-light); display: flex; align-items: center; justify-content: center;
    overflow: hidden; border: 3px solid var(--primary); flex-shrink: 0;
  }
  .profile-pic-large img { width: 100%; height: 100%; object-fit: cover; }
  .profile-pic-actions { display: flex; flex-direction: column; gap: 8px; }
  
  /* Categorias */
  .cat-list { display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; }
  .cat-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); }
  .cat-item-icon { font-size: 18px; width: 28px; text-align: center; }
  .cat-item-name { flex: 1; font-size: 13px; font-weight: 500; }
  .cat-delete { background: none; border: none; font-size: 14px; color: var(--text-muted); cursor: pointer; transition: color var(--transition); }
  .cat-delete:hover { color: var(--expense); }
  
  /* Relatório detalhe */
  .rpt-cat-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .rpt-cat-row:last-child { border-bottom: none; }
  .rpt-cat-name { flex: 1; font-size: 13px; }
  .rpt-cat-bar-wrap { flex: 2; background: var(--bg); border-radius: 99px; height: 8px; overflow: hidden; }
  .rpt-cat-bar { height: 100%; border-radius: 99px; background: var(--expense); }
  .rpt-cat-val { font-weight: 700; font-size: 13px; min-width: 90px; text-align: right; }
  
  /* ============ RESPONSIVE ============ */
  @media (max-width: 900px) { .dashboard-grid { grid-template-columns: 1fr; } }
  @media (max-width: 700px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .mobile-header { display: flex; }
    .main-content { margin-left: 0; padding-top: 62px; }
    .page { padding: 16px; }
    .page-header h1 { font-size: 20px; }
    .cards-grid { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .goals-grid { grid-template-columns: 1fr; }
  }
  @media (max-width: 420px) { .cards-grid { grid-template-columns: 1fr; } }