:root {
    /* Notion Light Theme */
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-rgb: 255, 255, 255;
    --surface-hover: #f1f3f5;
    --text: #37352f;
    --text-muted: #787774;
    --border: #e9e9e6;
    --primary: #2383e2; /* Notion Blue */
    --accent: #eb5757; /* Notion Red */
    --holiday-bg: #fbe4e4;
    --holiday-text: #eb5757;
    --shadow: 0 1px 3px rgba(15, 15, 15, 0.1);
    
    /* Cover & Icon */
    --cover-height: 120px;
    --page-icon-size: 78px;
}

[data-theme='dark'] {
    /* Notion Dark Theme */
    --bg: #191919;
    --surface: #1e1e1e;
    --surface-rgb: 30, 30, 30;
    --surface-hover: #2d2d2d;
    --text: rgba(255, 255, 255, 0.9);
    --text-muted: rgba(255, 255, 255, 0.5);
    --border: rgba(255, 255, 255, 0.1);
    --primary: #4a90e2;
    --primary-rgb: 74, 144, 226;
    --accent: #ff6b6b;
    --holiday-bg: rgba(235, 87, 87, 0.15);
    --holiday-text: #ff7369;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.print-only, .only-print { display: none !important; }

@media print {
    .no-print { display: none !important; }
    .print-only, .only-print { display: block !important; }
}



* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

body {
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    transition: background-color 0.2s, color 0.2s;
}

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

/* Notion Cover & Icon */
.cover-container {
    position: relative;
    margin-bottom: calc(var(--page-icon-size) / 2);
}

.cover-image {
    height: var(--cover-height);
    background: linear-gradient(to right, #f8f9fa, #e9ecef);
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
}

[data-theme='dark'] .cover-image {
    background: linear-gradient(to right, #252525, #353535);
}

.page-icon {
    position: absolute;
    bottom: calc(var(--page-icon-size) / -2);
    left: 0;
    font-size: calc(var(--page-icon-size) * 0.8);
    width: var(--page-icon-size);
    height: var(--page-icon-size);
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    user-select: none;
}

.page-branding-icon {
    width: 64px;
    height: 64px;
    stroke-width: 1.5px;
    color: var(--primary);
    background: var(--surface);
    padding: 12px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

/* Role Visibility */
[data-role='viewer'] .admin-only {
    display: none !important;
}

[data-role='viewer'] .del-ev {
    display: none !important;
}

.badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#roleBadge {
    background: var(--surface-hover);
    color: var(--text-muted);
}

[data-role='admin'] #roleBadge {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

/* High-Fidelity Glassmorphic Navbar */
.main-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(var(--surface-rgb), 0.7) !important;
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin: 0 !important;
    padding: 0.6rem 0;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.05);
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-accent {
    font-weight: 800;
    font-size: 0.7rem;
    padding: 2px 6px;
    background: var(--primary);
    color: white;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.brand-name {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin: 0;
    color: var(--text);
}

.vertical-divider {
    width: 1px;
    height: 20px;
    background: rgba(var(--text-rgb), 0.1);
    margin: 0 0.5rem;
}

.view-toggle {
    display: flex;
    gap: 0.25rem;
    background: rgba(var(--text-rgb), 0.05);
    padding: 3px;
    border-radius: 8px;
}

/* Lucide Icon Styling */
.lucide {
    width: 18px;
    height: 18px;
    stroke-width: 2px;
    vertical-align: middle;
}

.btn-icon-alt .lucide {
    width: 20px;
    height: 20px;
}

.close-icon .lucide {
    width: 24px;
    height: 24px;
}

.meta-icon {
    width: 14px;
    height: 14px;
    stroke-width: 2.5px;
    margin-right: 4px;
    vertical-align: -2px;
}

.nav-btn {
    padding: 0.5rem 1.25rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-btn.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

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

.btn-icon-alt {
    background: transparent;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s, transform 0.2s;
}

.btn-icon-alt:hover {
    opacity: 1;
    transform: translateY(-1px);
}

.btn-primary-glass {
    background: var(--primary);
    color: white;
    padding: 0.5rem 1.2rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary-glass:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 16px rgba(var(--primary-rgb), 0.2);
}

/* Switcher / Toolbox */
.view-switcher {
    display: flex;
    gap: 4px;
}

.switch-btn {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: none;
    background: transparent;
    font-weight: 600;
    font-size: 0.7rem; /* Tiny but bold */
    cursor: pointer;
    transition: background 0.2s;
    color: var(--text);
}

.switch-btn:hover {
    background: var(--surface-hover);
}

.switch-btn.active {
    background: var(--surface-hover);
    font-weight: 600;
}

/* Buttons */
.btn {
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s;
    border: none;
}

.btn-icon {
    font-size: 0.95rem; /* Scaled down icons */
    opacity: 0.7;
    transition: opacity 0.2s, transform 0.2s;
    background: transparent; /* Keep original background */
    color: var(--text); /* Keep original color */
    display: flex; /* Keep original display */
    align-items: center; /* Keep original align-items */
    justify-content: center; /* Keep original justify-content */
}

.btn-icon:hover {
    opacity: 1;
    transform: scale(1.1);
    background: var(--surface-hover); /* Keep original background on hover */
}

.btn-outline {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    background: var(--surface-hover);
}

.btn-primary-alt {
    background: var(--primary);
    color: white;
    font-weight: 700;
    padding: 0.35rem 0.8rem; /* Slimmer */
    font-size: 0.75rem;
    border: none;
    border-radius: 5px;
    box-shadow: 0 4px 10px rgba(var(--primary-rgb), 0.2);
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary-alt:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(var(--primary-rgb), 0.3);
}

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

/* Notion Month Modules */
.planner-grid-system {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 2rem;
    padding: 0 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

@media screen {
    .view-summary .planner-grid-system {
        grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    }

    .view-roadmap .calendar-grid-container {
        display: block;
    }

    .view-summary .calendar-grid-container {
        display: none;
    }
}

.month-view {
    margin-bottom: 2.5rem;
    border-radius: 0;
    background: transparent;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    height: auto;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    margin-bottom: 2.5rem; /* Keep original margin-bottom */
}

.month-view:hover {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.month-accent {
    height: 220px;
    background-size: cover;
    background-position: center;
    position: relative;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.month-accent::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60%;
    background: linear-gradient(to top, var(--surface), transparent);
}

.month-header-content {
    padding: 1.5rem 1.5rem 1rem 1.5rem;
    position: relative;
    z-index: 1;
    margin-top: -40px;
}

.month-header-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.month-header-content h3 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text);
    margin: 0;
    letter-spacing: -1px;
    text-transform: capitalize;
}

/* Hide accents in print for clean archival look */
@media print {
    .month-accent { display: none !important; }
    .month-header-content { margin-top: 0 !important; padding: 1rem 0 !important; }
    .month-view { border: none !important; border-radius: 0 !important; box-shadow: none !important; }
}

/* Original .month-name and .event-count are now part of .month-header-content */
.month-name {
    font-weight: 600;
    font-size: 1.25rem;
    color: var(--text);
}

.event-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--surface-hover);
    padding: 2px 8px;
    border-radius: 12px;
}

/* Calendar Grid Notion Style */
.calendar-grid-container {
    padding: 0 1rem 1.25rem 1rem;
}

/* Calendar Header - Fix for Horizontal alignment */
.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--surface-hover);
    border-bottom: 2px solid var(--border);
}

.calendar-header div {
    text-align: center;
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0.75rem 0.5rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.weekday {
    text-align: center;
    font-weight: 500;
    font-size: 0.75rem;
    padding: 0.5rem;
    color: var(--text-muted);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.day {
    aspect-ratio: 1 / 1;
    padding: 0.25rem;
    font-size: 0.85rem;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    position: relative;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
}

.day:nth-child(7n) { border-right: none; }

.day:hover:not(.empty) {
    background: var(--surface-hover);
}

.day.empty { cursor: default; }

.day.holiday, .day.sunday {
    color: var(--accent);
    font-weight: 600;
}

/* Category Color Coding - Friendly Palettes */
.day.has-event {
    color: #fff !important;
}

.day.cat-general { background-color: #64748b !important; } /* Slate */
.day.cat-mission { background-color: #10b981 !important; } /* Emerald */
.day.cat-social { background-color: #8b5cf6 !important; }  /* Violet */
.day.cat-internal { background-color: #f59e0b !important; } /* Amber */

/* Dark Mode Color Adjustments for better readability */
[data-theme='dark'] .day.has-event {
    filter: brightness(0.9);
}

.day.has-event::after {
    display: none; /* Hide old dot in favor of full fill */
}

@media screen {
    /* Summary List Notion Style (Grid Cards) */
    .view-summary .month-view {
        padding: 1.5rem;
        background: white !important;
        box-shadow: 0 4px 12px rgba(0,0,0,0.05);
        height: 100%;
        display: flex;
        flex-direction: column;
    }
}

[data-theme='dark'] .view-summary .month-view {
    background: var(--surface) !important;
}

.summary-events {
    margin-top: 1.5rem;
}

.summary-event-item {
    display: flex;
    align-items: flex-start;
    padding: 0.4rem 0.5rem;
    border-radius: 4px;
    transition: background 0.2s;
    cursor: pointer;
}

.summary-event-item:hover {
    background: var(--surface-hover);
}

.summary-day-num {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-muted);
    width: 24px;
    margin-right: 0.75rem;
}

.summary-title {
    font-size: 0.95rem;
    font-weight: 400;
}

.summary-tag {
    font-size: 0.7rem;
    font-weight: 500;
    margin-left: auto;
    padding: 1px 6px;
    border-radius: 3px;
}

/* Notion Pastels for Tags */
.summary-tag { background: #e2e2e2; color: #37352f; }
[data-theme='dark'] .summary-tag { background: #373737; color: #ffffff; }

@media screen {
    #plannerContent.view-roadmap .summary-events { display: none; }
    #plannerContent.view-summary .calendar-grid { display: none; }
}

/* Modal Notion Style */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 15, 15, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal-content {
    background: var(--surface);
    border-radius: 12px;
    padding: 2.5rem;
    width: 95%;
    max-width: 550px;
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    max-height: 90vh;
    overflow-y: auto;
}

.auth-modal-content {
    max-width: 400px;
    text-align: center;
}

.auth-message {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.error-text {
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 0.5rem;
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

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

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.close-icon {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.5rem;
    display: flex;
    align-items: center;
}

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

/* Event List Card Styling */
.event-list-container {
    margin-bottom: 2.5rem;
}

.modal-event-card {
    background: var(--surface-hover);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border-left: 4px solid var(--primary);
}

.modal-event-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.modal-event-title {
    font-weight: 700;
    font-size: 1.05rem;
}

.modal-event-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.budget-badge {
    color: #16a34a !important;
    font-weight: 600;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.modal-event-desc {
    font-size: 0.9rem;
    color: var(--text);
    margin-bottom: 0.75rem;
    white-space: pre-wrap;
}

.modal-event-actions {
    font-size: 0.8rem;
}

.modal-event-actions a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

/* Advanced Form Styling */
.entry-form {
    border-top: 1px solid var(--border);
    padding-top: 2rem;
}

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

.form-section.row {
    display: flex;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group.full-width { width: 100%; }
.form-group.flex-1 { flex: 1; }

.entry-form label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.entry-form input, .entry-form textarea, .entry-form select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    background: var(--surface-hover);
    color: var(--text);
    border: 1px solid var(--border);
    font-size: 0.95rem;
    transition: all 0.2s;
}

.entry-form input:focus, .entry-form textarea:focus {
    border-color: var(--primary);
    outline: none;
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(35, 131, 226, 0.1);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 2rem;
}

/* Summary Update for Details */
.summary-details {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.summary-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* View Toggling */
.on-screen-hidden {
    display: none !important;
}

/* Professional Report Branding */
.print-only, .only-print { display: none !important; }
.no-print { display: block; } /* Default */

@media print {
    .print-only, .only-print { display: block !important; }
    .no-print { display: none !important; }
    
    /* =========================================
       CONSOLIDATED TABLE REPORT (IMAGE-FREE)
       ========================================= */

    .report-official-header-minimal {
        margin-bottom: 2rem;
        padding-bottom: 1rem;
        border-bottom: 2px solid #000;
    }

    .report-title-minimal {
        font-size: 1.5rem !important;
        font-weight: 800 !important;
        color: #000 !important;
        margin: 0 0 0.5rem 0 !important;
        letter-spacing: -0.5px !important;
    }

    .report-meta-minimal {
        font-size: 9pt;
        color: #333;
    }

    .report-table-container {
        margin-top: 1rem;
        border: 0.5pt solid #ddd;
        border-radius: 12px;
        overflow: hidden; /* Ensures rounded corners clip the table inside */
    }

    .report-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 8.5pt;
        border-style: hidden; /* Prevent double borders at corners */
    }

    .report-table th, .report-table td {
        border: 0.5pt solid #ddd;
        padding: 8px 10px;
        text-align: left;
        vertical-align: top;
    }

    .report-table th {
        background: #f5f5f5 !important;
        font-weight: 700;
        text-transform: uppercase;
        border-bottom: 1.5pt solid #000;
    }

    .td-date {
        font-weight: 700;
        white-space: nowrap;
        background: #fafafa !important;
    }

    .td-title {
        font-weight: 700;
        font-size: 9pt;
        margin-bottom: 2px;
    }

    .td-meta-small {
        font-size: 7.5pt;
        color: #666;
        font-style: italic;
    }

    .td-desc {
        font-size: 8pt;
        color: #444;
        margin-top: 4px;
        line-height: 1.4;
    }

    .td-tag {
        font-size: 7pt;
        padding: 2px 6px;
        border: 0.5pt solid #888;
        border-radius: 4px;
        text-transform: uppercase;
        font-weight: 600;
        white-space: nowrap;
    }

    .td-budget {
        font-family: 'JetBrains Mono', 'Courier New', monospace;
        font-weight: 600;
        color: #2e7d32;
        text-align: right !important;
    }

    .report-total-row {
        background: #f0f7f0 !important;
    }

    .td-budget-total {
        font-family: 'JetBrains Mono', 'Courier New', monospace;
        font-size: 10pt;
        font-weight: 800;
        color: #1b5e20;
        text-align: right !important;
        border-top: 1.5pt solid #000 !important;
    }

    /* Print Signature Area */
    .report-signature {
        margin-top: 4rem;
        display: flex !important; /* Force flex to override .print-only display block */
        justify-content: space-between;
        align-items: flex-start;
        break-inside: avoid;
        padding: 0 2rem;
    }

    .sig-box {
        width: 240px; /* Consistent width for both boxes */
        text-align: center;
        font-size: 9pt;
    }

    .sig-label {
        font-size: 8.5pt;
        font-weight: 600;
        margin-bottom: 3.5rem; /* Consistent space for handwriting */
        color: #000;
        min-height: 1.2rem; /* Ensures alignment even if labels differ slightly */
    }

    .sig-line {
        border-top: 1pt solid #000;
        margin-bottom: 0.5rem;
    }

    .sig-name {
        font-weight: 700;
        color: #000;
    }
}

/* Official Report Print Precision */
@media print {
    @page {
        size: A4 portrait;
        margin: 15mm 15mm;
    }

    body { 
        padding: 0 !important;
        background: white !important; 
        color: #000 !important;
        font-family: 'Inter', system-ui, sans-serif;
    }

    .no-print, 
    .view-roadmap-only, 
    .calendar-grid-container, 
    .calendar-header, 
    .calendar-grid,
    .month-accent,
    .main-header,
    .brand,
    .header-actions,
    .tagline,
    .month-view { 
        display: none !important; 
    }
    
    .on-screen-hidden { 
        display: block !important; 
    }


    tr { break-inside: avoid; }
}

    /* Mobile Responsive Adjustments */
@media (max-width: 768px) {
    .navbar {
        padding: 0 1rem;
    }

    .vertical-divider, .badge {
        display: none;
    }

    .brand-name {
        font-size: 1.1rem;
    }

    .btn-primary-glass {
        padding: 0.4rem 0.8rem;
        font-size: 0.75rem;
    }
    
    .planner-grid-system {
        grid-template-columns: 1fr;
        padding: 0 0.75rem;
    }
}
