:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-card: #1e293b;
    
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    
    --border: #334155;
    --shadow: rgba(0, 0, 0, 0.3);
    
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --gradient-danger: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

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

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

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

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 2rem;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo svg {
    width: 40px;
    height: 40px;
    color: var(--primary-light);
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.3;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-nav {
    padding: 1rem;
    flex: 1;
}

.nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: transparent;
    border: none;
    border-radius: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 0.5rem;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transform: translateX(4px);
}

.nav-item.active {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.nav-item svg {
    width: 20px;
    height: 20px;
}

/* Main Content */
.main-content {
    margin-left: 280px;
    flex: 1;
    padding: 2rem;
    width: calc(100% - 280px);
}

.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
}

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    display: flex;
    gap: 1.5rem;
    align-items: center;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--shadow);
    border-color: var(--primary);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon.residents {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.stat-icon.households {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.stat-icon.male {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.stat-icon.female {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.stat-icon svg {
    width: 28px;
    height: 28px;
    color: white;
}

.stat-details h3 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.stat-details p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Chart Container */
.chart-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
}

.chart-card h3 {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
}

.activity-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.activity-item {
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 0.75rem;
    border-left: 4px solid var(--primary);
}

.activity-item p {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.activity-item small {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-danger {
    background: var(--gradient-danger);
    color: white;
}

.btn-success {
    background: var(--gradient-success);
    color: white;
}

/* Search Bar */
.search-bar {
    position: relative;
    margin-bottom: 1.5rem;
}

.search-bar svg {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

.search-bar input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 3rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Table */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--bg-tertiary);
}

.data-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table td {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

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

.data-table tbody tr:hover {
    background: var(--bg-tertiary);
}

.empty-row td {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem;
}

.table-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
}

.btn-icon svg {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

.btn-icon:hover {
    background: var(--border);
}

.btn-icon.delete:hover {
    background: var(--danger);
}

.btn-icon.delete:hover svg {
    color: white;
}

/* Households Grid */
.households-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.household-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.household-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--shadow);
    border-color: var(--primary);
}

.household-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.household-icon {
    width: 50px;
    height: 50px;
    border-radius: 0.75rem;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.household-icon svg {
    width: 24px;
    height: 24px;
    color: white;
}

.household-info h4 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

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

.household-details {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.household-detail {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.household-detail span:first-child {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.household-detail span:last-child {
    font-weight: 600;
}

.household-actions {
    margin-top: 1rem;
    display: flex;
    gap: 0.5rem;
}

/* Records Grid */
.records-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.record-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.record-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--shadow);
    border-color: var(--primary);
}

.record-badge {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    background: var(--gradient-primary);
    color: white;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.record-card h4 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.record-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.record-meta {
    display: flex;
    justify-content: space-between;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.modal.active {
    display: flex;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

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

.modal-close {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-close svg {
    width: 24px;
    height: 24px;
}

.modal form {
    padding: 1.5rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
}

.form-group label {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

.empty-state-large {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-state-large svg {
    width: 80px;
    height: 80px;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.empty-state-large h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.empty-state-large p {
    color: var(--text-muted);
}

/* Mobile Menu Toggle */
.menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.75rem;
    cursor: pointer;
    box-shadow: 0 4px 12px var(--shadow);
}

.menu-toggle svg {
    width: 24px;
    height: 24px;
    color: var(--text-primary);
}

/* Mobile overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.mobile-overlay.active {
    display: block;
}

/* Responsive */
@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }
    
    .sidebar {
        position: fixed;
        left: -280px;
        transition: left 0.3s ease;
        z-index: 1000;
    }
    
    .sidebar.mobile-open {
        left: 0;
        box-shadow: 2px 0 12px var(--shadow);
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 0.75rem;
        padding-top: 4rem;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .page-header h2 {
        font-size: 1.5rem;
    }
    
    .subtitle {
        font-size: 0.85rem;
    }
    
    /* Stats Grid - Mobile */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .stat-card {
        padding: 1.25rem;
        gap: 1rem;
    }
    
    .stat-icon {
        width: 50px;
        height: 50px;
        flex-shrink: 0;
    }
    
    .stat-icon svg {
        width: 24px;
        height: 24px;
    }
    
    .stat-details h3 {
        font-size: 1.75rem;
    }
    
    .stat-details p {
        font-size: 0.85rem;
    }
    
    /* Chart Container - Mobile */
    .chart-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .chart-card {
        padding: 1.25rem;
    }
    
    .chart-card h3 {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }
    
    /* Grids - Mobile */
    .households-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .records-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Forms - Mobile */
    .form-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .form-group {
        margin-bottom: 0.75rem;
    }
    
    .form-group label {
        font-size: 0.85rem;
        margin-bottom: 0.4rem;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 0.65rem;
        font-size: 0.9rem;
    }
    
    /* Modal - Mobile */
    .modal {
        padding: 0;
        align-items: flex-end;
    }
    
    .modal-content {
        margin: 0;
        max-width: 100%;
        width: 100%;
        max-height: 95vh;
        border-radius: 1rem 1rem 0 0;
        border-bottom: none;
    }
    
    .modal-header {
        padding: 1.25rem;
    }
    
    .modal-header h3 {
        font-size: 1.25rem;
    }
    
    .modal form {
        padding: 1.25rem;
    }
    
    .modal-actions {
        margin-top: 1.25rem;
        flex-direction: column-reverse;
    }
    
    .modal-actions .btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Table - Mobile */
    .table-container {
        overflow-x: auto;
        border-radius: 0.75rem;
    }
    
    .data-table {
        min-width: 600px;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.75rem;
        font-size: 0.85rem;
    }
    
    /* Buttons - Mobile */
    .btn {
        padding: 0.65rem 1.25rem;
        font-size: 0.9rem;
    }
    
    .btn svg {
        width: 16px;
        height: 16px;
    }
    
    /* Search Bar - Mobile */
    .search-bar {
        margin-bottom: 1rem;
    }
    
    .search-bar input {
        padding: 0.75rem 1rem 0.75rem 2.75rem;
        font-size: 0.9rem;
    }
    
    .search-bar svg {
        width: 18px;
        height: 18px;
    }
    
    /* Cards - Mobile */
    .household-card,
    .record-card {
        padding: 1.25rem;
    }
    
    .household-header {
        gap: 0.75rem;
    }
    
    .household-icon {
        width: 45px;
        height: 45px;
    }
    
    .household-icon svg {
        width: 22px;
        height: 22px;
    }
    
    .household-info h4 {
        font-size: 1rem;
    }
    
    .household-info p {
        font-size: 0.8rem;
    }
    
    .household-detail,
    .record-meta {
        font-size: 0.85rem;
    }
    
    .record-badge {
        font-size: 0.75rem;
        padding: 0.3rem 0.65rem;
    }
    
    .record-card h4 {
        font-size: 1rem;
    }
    
    .record-card p {
        font-size: 0.85rem;
    }
    
    /* Empty States - Mobile */
    .empty-state-large {
        padding: 3rem 1.5rem;
    }
    
    .empty-state-large svg {
        width: 60px;
        height: 60px;
    }
    
    .empty-state-large h3 {
        font-size: 1.25rem;
    }
    
    .empty-state-large p {
        font-size: 0.9rem;
    }
    
    body.menu-open {
        overflow: hidden;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .main-content {
        padding: 0.5rem;
        padding-top: 3.5rem;
    }
    
    .page-header h2 {
        font-size: 1.35rem;
    }
    
    .stat-details h3 {
        font-size: 1.5rem;
    }
    
    .modal-content {
        max-height: 100vh;
        border-radius: 0;
    }
}
