:root {
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 80px;
  --primary-color: #22c55e;
  --primary-gradient: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  --sidebar-bg: #111827;
  --sidebar-hover: #1f2937;
  --main-bg: #f3f4f6;
  --card-bg: rgba(255, 255, 255, 0.9);
  --text-main: #111827;
  --text-muted: #6b7280;
  --transition-speed: 0.3s;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  background: var(--main-bg);
  color: var(--text-main);
  overflow: hidden;
}

.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar Styles */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  transition: width var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  position: relative;
  z-index: 100;
  box-shadow: 4px 0 10px rgba(0,0,0,0.1);
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

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

.logo {
  display: flex;
  flex-direction: column;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.2s;
}

.sidebar.collapsed .logo {
  opacity: 0;
  width: 0;
}

.logo-text {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.logo-subtext {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.sidebar-toggle {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 5px;
  border-radius: 5px;
  transition: background 0.2s;
}

.sidebar-toggle:hover {
  background: var(--sidebar-hover);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
}

.sidebar-content::-webkit-scrollbar {
  width: 4px;
}

.sidebar-content::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
}

.nav-section {
  margin-bottom: 1.5rem;
}

.section-title {
  padding: 0 1.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: #4b5563;
  letter-spacing: 1px;
  margin-bottom: 0.5rem;
  white-space: nowrap;
}

.sidebar.collapsed .section-title {
  display: none;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  white-space: nowrap;
}

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

.nav-item.active {
  color: #fff;
  background: var(--primary-gradient);
  margin: 0 0.75rem;
  width: calc(100% - 1.5rem);
  border-radius: 0.5rem;
  box-shadow: 0 4px 15px rgba(34, 197, 94, 0.3);
}

.sidebar.collapsed .nav-item.active {
    margin: 0 0.5rem;
    width: calc(100% - 1rem);
}

.nav-icon {
  margin-right: 12px;
  font-size: 1.25rem;
}

.sidebar.collapsed .nav-icon {
  margin-right: 0;
}

.nav-label {
  font-weight: 500;
  font-size: 0.95rem;
  transition: opacity 0.2s;
}

.sidebar.collapsed .nav-label {
  opacity: 0;
  width: 0;
  pointer-events: none;
}

.badge-notify {
  /* position: absolute; */
  right: 1rem;
  background: #ef4444;
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 700;
}

.sidebar.collapsed .badge-notify {
  top: 5px;
  right: 5px;
  padding: 2px 4px;
}

/* Main Content Styles */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.top-nav {
  height: 80px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.page-context h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.page-context p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-main);
  background: #f3f4f6;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  cursor: pointer;
}

.content-body {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  background: var(--main-bg);
}

/* Redefining existing classes for the new layout */
.billing-container {
  max-width: 1400px;
  margin: 0 auto;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: #fff;
  padding: 1.5rem;
  border-radius: 1rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  border: 1px solid #e5e7eb;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  border-color: var(--primary-color);
}

.data-card {
  background: #fff;
  border-radius: 1rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  border: 1px solid #e5e7eb;
  margin-bottom: 2rem;
  overflow: hidden;
}

.card-header {
  padding: 1.5rem;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.card-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Utility styles from before, slightly updated */
.badge {
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-paid, .badge-active { background: #dcfce7; color: #166534; }
.badge-pending { background: #fef9c3; color: #854d0e; }
.badge-overdue, .badge-inactive { background: #fee2e2; color: #991b1b; }

.btn {
  padding: 0.6rem 1.25rem;
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
  cursor: pointer;
}

.btn-primary { background: var(--primary-gradient); color: #fff; border: none; }
.btn-primary:hover { opacity: 0.9; transform: scale(1.02); }
.btn-outline { background: #fff; border: 1px solid #d1d5db; color: #374151; }
.btn-outline:hover { background: #f9fafb; border-color: #9ca3af; }
.btn-success { background: #22c55e; color: #fff; border: none; }

.form-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.5rem;
  display: block;
}

.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

/* Modal and Alert Polishing */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: #fff;
  border-radius: 1.5rem;
  padding: 2rem;
  width: 90%;
  max-width: 600px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.alert {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 1rem 1.5rem;
  border-radius: 1rem;
  color: #fff;
  z-index: 1100;
  font-weight: 600;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  display: none;
  animation: slideInUp 0.3s ease;
}

@keyframes slideInUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.alert-success { background: #10b981; }
.alert-error { background: #ef4444; }

/* Grid and Tables updated for new main content space */
.resident-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 1rem;
}

.resident-card {
  padding: 1rem;
  border-radius: 0.75rem;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  text-align: center;
  transition: all 0.2s;
}

.resident-card.active {
  background: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
}

.tariff-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

@media (max-width: 1100px) {
  .tariff-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .tariff-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

@media (max-width: 1100px) {
  .settings-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .settings-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

/* Table Management System */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  margin-top: 1rem;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}

.data-table th {
  background: #f9fafb;
  padding: 1rem;
  text-align: left;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: #6b7280;
  border-bottom: 2px solid #f3f4f6;
  white-space: nowrap;
}

.data-table td {
  padding: 1rem;
  border-bottom: 1px solid #f3f4f6;
  color: #374151;
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background 0.2s;
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

.data-table tr:last-child td {
  border-bottom: none;
}

/* Tab Content Padding Fixes */
.card-body {
  padding: 1.5rem;
}

.data-card {
  margin-bottom: 2rem;
}

/* Spacing Helpers */
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }

/* Icons */
.ui-icon { vertical-align: middle; }
.nav-icon { vertical-align: middle; }

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: #f1f1f1;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Financial Timeline & Month Cards */
.bill-timeline {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding: 0.5rem 0.25rem 1.5rem 0.25rem;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.bill-timeline::-webkit-scrollbar {
  height: 6px;
}

.bill-timeline::-webkit-scrollbar-thumb {
  background: #e2e8f0;
  border-radius: 10px;
}

.bill-month {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.85rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.bill-month:hover {
  transform: translateY(-3px);
  border-color: var(--primary-color);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.bill-month.selected {
  border: 2px solid var(--primary-color);
  background: #f0fdf4;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.15);
}

.bill-month.paid { border-top: 4px solid #22c55e; }
.bill-month.pending { border-top: 4px solid #f59e0b; }
.bill-month.overdue { border-top: 4px solid #ef4444; }

.badge-paid { background: #dcfce7; color: #166534; }
.badge-pending { background: #fef9c3; color: #854d0e; }
.badge-overdue { background: #fee2e2; color: #991b1b; }

@media (max-width: 768px) {
  .sidebar { width: 0; position: absolute; }
  .sidebar.collapsed { width: 0; }
  .sidebar-toggle { position: fixed; left: 1rem; top: 1.5rem; z-index: 1001; background: var(--sidebar-bg); }
  .main-content { margin-left: 0; width: 100vw; }
}
/* End of Stylesheet */
