* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Navbar */
.navbar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand {
    color: white;
    text-decoration: none;
    font-size: 1.5rem;
    font-weight: bold;
}

.navbar-nav {
    display: flex;
    gap: 1.5rem;
}

.nav-link {
    color: white;
    text-decoration: none;
    transition: opacity 0.3s;
}

.nav-link:hover {
    opacity: 0.8;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 4rem 0;
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #667eea;
}

.hero .lead {
    font-size: 1.5rem;
    color: #666;
    margin-bottom: 2rem;
}

.cta-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Features */
.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    padding: 3rem 0;
}

.feature {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    text-align: center;
}

.feature h3 {
    color: #667eea;
    margin-bottom: 1rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 5px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-block {
    display: block;
    width: 100%;
}

/* Auth Pages */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 200px);
    padding: 2rem 0;
}

.auth-card {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    max-width: 400px;
    width: 100%;
}

.auth-card h2 {
    margin-bottom: 1.5rem;
    color: #667eea;
}

.auth-links {
    margin-top: 1rem;
    text-align: center;
}

.auth-links a {
    color: #667eea;
}

/* Forms */
.form-container {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    max-width: 600px;
    margin: 2rem auto;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-check {
    margin-bottom: 1rem;
}

.form-check-input {
    margin-right: 0.5rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 1rem;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 2rem 0;
}

.page-header h1 {
    color: #667eea;
}

/* Bills Grid */
.bills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.bill-card {
    background: white;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border-left: 4px solid #667eea;
}

.bill-card.paid {
    border-left-color: #28a745;
}

.bill-card.unpaid {
    border-left-color: #ffc107;
}

.bill-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.bill-header h3 {
    color: #333;
    font-size: 1.25rem;
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
}

.badge-success {
    background: #28a745;
    color: white;
}

.badge-warning {
    background: #ffc107;
    color: #333;
}

.bill-body p {
    margin-bottom: 0.5rem;
    color: #666;
}

.bill-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Shared Bills */
.bill-card.shared {
    border-left-color: #667eea;
    background: #f8f9ff;
}

.bill-badges {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.badge-shared {
    background: #667eea;
    color: white;
}

.badge-household {
    background: #17a2b8;
    color: white;
}

.badge-individual {
    background: #6f42c1;
    color: white;
}

.badge-shared-name {
    background: #e9ecef;
    color: #495057;
    font-weight: 500;
}

.btn-share {
    background: #667eea;
    color: white;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.75rem;
    border-radius: 5px;
    font-size: 0.875rem;
}

.btn-share:hover {
    background: #5a6fd6;
}

.share-form {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

.share-input-group {
    display: flex;
    gap: 0.5rem;
}

.share-input-group .form-control {
    flex: 1;
}

/* Household */
.household-card {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin: 2rem 0;
}

.household-card h2 {
    color: #667eea;
    margin-bottom: 1.5rem;
}

.household-card h3 {
    color: #555;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

.members-list {
    list-style: none;
    margin-bottom: 2rem;
}

.members-list li {
    padding: 0.75rem;
    background: #f8f9fa;
    margin-bottom: 0.5rem;
    border-radius: 5px;
}

.household-actions {
    border-top: 1px solid #eee;
    padding-top: 1.5rem;
}

.household-leave {
    border-top: 1px solid #eee;
    padding-top: 1.5rem;
    margin-top: 2rem;
}

.household-leave .text-muted {
    color: #666;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin: 2rem 0;
}

.empty-state p {
    font-size: 1.25rem;
    color: #666;
    margin-bottom: 1rem;
}

/* Footer */
footer {
    background: #333;
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: 4rem;
}

/* Validation */
.text-danger {
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: block;
}

/* Responsive */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 2rem;
    }

    .hero .lead {
        font-size: 1.25rem;
    }

    .navbar .container {
        flex-direction: column;
        gap: 1rem;
    }

    .page-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .bills-grid {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-direction: column;
    }
}

/* Month Sections */
.month-section {
    margin-bottom: 3rem;
}

.month-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.5rem 2rem;
    border-radius: 10px 10px 0 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.month-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 0.75rem;
}

.month-header h2 {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 600;
}

.month-paid-toggle {
    display: inline-block;
}

.btn-month-paid {
    padding: 0.5rem 1.25rem;
    border: 2px solid white;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-month-paid.paid {
    background: rgba(40, 167, 69, 0.9);
    color: white;
    border-color: rgba(40, 167, 69, 0.9);
}

.btn-month-paid.paid:hover {
    background: rgba(40, 167, 69, 1);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.btn-month-paid.unpaid {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-color: white;
}

.btn-month-paid.unpaid:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.month-summary {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.summary-item {
    font-size: 0.95rem;
}

.summary-item strong {
    font-weight: 600;
}

.unpaid-badge {
    background: rgba(255, 193, 7, 0.9);
    color: #333;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-weight: 600;
}

.month-section .bills-grid {
    background: white;
    padding: 1.5rem;
    border-radius: 0 0 10px 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

@media (max-width: 768px) {
    .month-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .month-title-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .month-summary {
        gap: 1rem;
    }
}

/* Account Settings */
.settings-container {
    max-width: 800px;
    margin: 2rem auto;
    padding: 0 20px;
}

.settings-container h1 {
    color: #667eea;
    margin-bottom: 2rem;
}

.settings-section {
    background: white;
    border-radius: 10px;
    padding: 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.settings-section h2 {
    color: #333;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.danger-zone {
    border: 2px solid #dc3545;
    border-radius: 8px;
    padding: 1.5rem;
    background: #fff5f5;
}

.danger-zone h3 {
    color: #dc3545;
    margin-bottom: 1rem;
}

.danger-zone p {
    color: #666;
    margin-bottom: 1rem;
}

.danger-zone ul {
    margin: 1rem 0 1rem 2rem;
    color: #666;
}

.danger-zone ul li {
    margin-bottom: 0.5rem;
}

.warning-text {
    color: #721c24;
    font-weight: 500;
}

.danger-zone-actions {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #f5c6cb;
}

.settings-actions {
    display: flex;
    justify-content: center;
    margin-top: 2rem;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 1rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    margin: auto;
    padding: 2rem;
    border-radius: 10px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.modal-content h2 {
    color: #dc3545;
    margin-bottom: 1rem;
}

.modal-content p {
    margin-bottom: 1rem;
    color: #666;
}

.modal-content ul {
    margin: 1rem 0 1rem 2rem;
    color: #666;
}

.modal-content ul li {
    margin-bottom: 0.5rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

@media (max-width: 768px) {
    .settings-container {
        padding: 0 15px;
    }

    .modal-content {
        padding: 1.5rem;
        width: 95%;
    }

    .modal-actions {
        flex-direction: column;
    }

    .modal-actions button {
        width: 100%;
    }
}

/* ============================================================
   BILLS CALENDAR
   ============================================================ */

.calendar-container {
    max-width: 900px;
    margin: 0 auto;
    padding-bottom: 2rem;
}

/* Monthly summary bar */
.calendar-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 0.85rem 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.cal-summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1 1 100px;
    padding: 0.25rem 0.5rem;
    border-right: 1px solid #f0f0f0;
}

.cal-summary-item:last-child {
    border-right: none;
}

.cal-summary-item.unpaid .cal-summary-value {
    color: #e53e3e;
}

.cal-summary-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 700;
    color: #999;
    letter-spacing: 0.04em;
}

.cal-summary-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #333;
    margin-top: 2px;
}

/* Month navigation bar */
.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.calendar-month-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
    margin: 0;
}

/* 7-column calendar grid */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

/* Day-of-week header row */
.calendar-dow-header {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #888;
    padding: 6px 0;
    background: #f0f0f0;
    border-radius: 4px;
}

/* Individual day cell */
.calendar-day {
    min-height: 80px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: box-shadow 0.15s, border-color 0.15s;
}

.calendar-day.empty {
    background: transparent;
    border-color: transparent;
}

.calendar-day.today {
    border-color: #667eea;
    background: #f5f3ff;
}

.calendar-day.has-bills {
    cursor: pointer;
}

.calendar-day.has-bills:hover {
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.25);
    border-color: #667eea;
}

.calendar-day.selected {
    box-shadow: 0 0 0 2px #667eea;
    border-color: #667eea;
}

.calendar-day.all-paid {
    background: #f0fff4;
}

.calendar-day.has-unpaid {
    background: #fffaf0;
}

.day-number {
    font-size: 0.85rem;
    font-weight: 600;
    color: #555;
    line-height: 1;
}

.today .day-number {
    background: #667eea;
    color: #fff;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

/* Bill dot indicators */
.bill-dots {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.bill-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-paid {
    background: #48bb78;
}

.dot-unpaid {
    background: #f56565;
}

/* Mini total shown on day cell */
.day-total {
    font-size: 0.7rem;
    color: #888;
    margin-top: auto;
}

/* Legend */
.calendar-legend {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    justify-content: flex-end;
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: #555;
}

.calendar-legend span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-today {
    width: 22px;
    height: 22px;
    background: #667eea;
    color: #fff;
    border-radius: 50%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* Detail panel */
.calendar-detail-panel {
    margin-top: 1.5rem;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 1.25rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.detail-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 0.75rem;
}

.detail-panel-header h3 {
    margin: 0;
    font-size: 1.15rem;
    color: #333;
}

.detail-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: #999;
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.15s;
}

.detail-close:hover {
    color: #333;
}

.detail-bills {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}

/* Individual bill card inside detail panel */
.detail-bill-card {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 0.9rem;
    background: #fafafa;
}

.detail-bill-card.paid {
    border-left: 4px solid #48bb78;
    background: #f0fff4;
}

.detail-bill-card.unpaid {
    border-left: 4px solid #f56565;
    background: #fff5f5;
}

.detail-bill-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.6rem;
    gap: 0.5rem;
}

.detail-bill-name {
    font-size: 1rem;
    color: #333;
}

.detail-bill-card p {
    font-size: 0.85rem;
    color: #555;
    margin: 2px 0;
}

.detail-bill-actions {
    margin-top: 0.6rem;
    padding-top: 0.5rem;
    border-top: 1px solid #e8e8e8;
    display: flex;
    gap: 0.5rem;
}

/* Responsive tweaks */
@media (max-width: 600px) {
    .calendar-day {
        min-height: 56px;
        padding: 4px;
    }

    .day-number {
        font-size: 0.75rem;
    }

    .day-total {
        display: none;
    }

    .calendar-month-title {
        font-size: 1.1rem;
    }
}
