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

:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --success: #0f9d58;
  --warning: #f4b400;
  --danger: #d93025;
  --bg: #f0f2f5;
  --card: #fff;
  --text: #202124;
  --text-secondary: #5f6368;
  --border: #dadce0;
  --sidebar-bg: #1a1a2e;
  --sidebar-text: #e0e0e0;
  --sidebar-hover: #16213e;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow-x: hidden;
}

.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 250px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 1000;
  transition: transform .3s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h1 { font-size: 1.2rem; font-weight: 700; }

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
  overflow: hidden;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-name {
  font-size: .875rem;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-email {
  font-size: .75rem;
  color: rgba(255,255,255,0.6);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding: 8px 0;
}

.sidebar-footer .nav-item {
  font-size: .85rem;
  opacity: .8;
}

.sidebar-footer .nav-item:hover {
  opacity: 1;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 10px 0;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  transition: background .2s, color .2s;
  font-size: .95rem;
}

.nav-item:hover, .nav-item.active {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-item.active {
  border-left: 3px solid var(--primary);
}

.nav-icon { font-size: 1.1rem; width: 24px; text-align: center; }

/* Main Content */
.main-content {
  flex: 1;
  margin-left: 250px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text);
}

.topbar h2 { font-size: 1.3rem; font-weight: 600; }

.current-date { color: var(--text-secondary); font-size: .9rem; }

.content-area {
  padding: 24px;
  flex: 1;
}

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-header h3 { font-size: 1.05rem; font-weight: 600; }

/* Grids */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  margin: 8px 0;
}

.stat-card .stat-label {
  font-size: .85rem;
  color: var(--text-secondary);
}

.stat-card.positive .stat-value { color: var(--success); }
.stat-card.negative .stat-value { color: var(--danger); }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.info .stat-value { color: var(--primary); }

/* Tables */
.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

table th {
  text-align: left;
  padding: 12px 8px;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  white-space: nowrap;
  color: var(--text-secondary);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .5px;
}

table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}

table tr:hover { background: #f8f9fa; }

/* Status badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-pendente { background: #fff3cd; color: #856404; }
.badge-pago, .badge-recebido { background: #d4edda; color: #155724; }
.badge-atrasado, .badge-vencido { background: #f8d7da; color: #721c24; }
.badge-cancelado { background: #e2e3e5; color: #383d41; }
.badge-info { background: #cce5ff; color: #004085; }
table td.positive { color: var(--success); font-weight: 600; }
table td.negative { color: var(--danger); font-weight: 600; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
  text-decoration: none;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: .9; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .9; }
.btn-warning { background: var(--warning); color: #333; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: #f8f9fa; }
.btn-sm { padding: 4px 10px; font-size: .8rem; }
.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 4px;
  font-weight: 500;
  font-size: .875rem;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  transition: border-color .2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(26,115,232,0.15);
}

select.form-control { appearance: auto; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; }
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 550px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

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

.modal-header h3 { font-size: 1.1rem; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
}

.modal-body { padding: 20px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

/* Charts area */
.chart-area {
  max-width: 100%;
  height: 300px;
  position: relative;
}

.chart-area canvas {
  max-height: 300px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h3 { margin-bottom: 8px; color: var(--text); }
.empty-state p { font-size: .9rem; }

/* Search/filter bar */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-bar .form-control {
  width: auto;
  min-width: 150px;
}

/* Two column layouts */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle { display: block; }

  .main-content {
    margin-left: 0;
  }

  .menu-btn { display: block; }

  .topbar h2 { font-size: 1.1rem; }

  .content-area { padding: 16px; }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-card .stat-value { font-size: 1.4rem; }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-bar .form-control {
    width: 100%;
    min-width: unset;
  }
}

@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr; }
  .modal { margin: 10px; }
}

/* Animations */
.fade-in { animation: fadeIn .3s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.pagination .btn { min-width: 40px; }

.pagination .current-page {
  padding: 6px 12px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
  font-weight: 600;
}

/* Report summary */
.report-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px 0;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--border);
  font-size: .85rem;
}

.report-summary span {
  background: #f8f9fa;
  padding: 6px 12px;
  border-radius: var(--radius);
}

/* Admin Tabs */
.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

/* Print styles */
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .sidebar-toggle, .menu-btn, .btn, .filter-bar,
  .stats-grid, .two-col, .chart-area, #reportDetailCard .card-header .btn-group { display: none !important; }
  .main-content { margin-left: 0 !important; padding: 0 !important; }
  .content-area { padding: 0 !important; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  .report-table { font-size: .8rem; }
  .report-table th { background: #f0f0f0 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .report-summary span { background: #f0f0f0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .empty-state { display: none; }
  #reportDetailCard { border: none !important; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }
