:root {
    --bg-color: #f4f4f4;
    --box-bg: #ffffff;
    --accent: #000000;
    --border-radius: 15px;
}

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

body {
    background-color: var(--bg-color);
    color: var(--accent);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* ── Bottom crow footer ── */
.crow-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 280px;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
    background: url('/media/crows.png') repeat-x bottom;
    background-size: auto 100%;
    opacity: 0.85;
}

/* ── Falling cookie particles ── */
.cookie-fall {
    position: fixed;
    pointer-events: none;
    z-index: 1;
    opacity: 0.95;
    will-change: transform;
}

.container {
    background-color: var(--box-bg);
    border: 2px solid var(--accent);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: 4px 4px 10px rgba(0,0,0,0.1);
    position: relative;
    z-index: 10;
}

.dashboard-wrapper {
    display: flex;
    width: 92vw;
    max-width: 1600px;
    height: 85vh;
    gap: 20px;
    position: relative;
    z-index: 10;
}

.sidebar {
    width: 340px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: stretch;
}

.sidebar-section {
    width: 100%;
}

/* ── Desktop sidebar — >768px ── */
@media (min-width: 769px) {
    .sidebar {
        max-width: 380px;
    }
}

.main-content {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: auto auto repeat(5, 1fr);
    gap: 5px;
    align-content: start;
    min-width: 0;
    overflow: hidden;
}

.main-content.orders-content {
    display: block;
}

#month-header {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 5px 10px 5px;
    border-bottom: 2px solid var(--accent);
    margin-bottom: 5px;
}

#monthTitle {
    margin: 0;
    font-size: 1.2rem;
    user-select: none;
}

#prevMonth, #nextMonth {
    padding: 5px 12px;
    font-size: 1rem;
}

.calendar-cell {
    position: relative;
    border: 1px solid var(--accent);
    border-radius: 8px;
    min-height: 80px;
    font-size: 0.75rem;
    padding: 6px;
    overflow-y: auto;
}

.calendar-cell.cell-blank {
    background: #fafafa;
}

.calendar-cell.cell-today {
    border: 3px solid var(--accent) !important;
    background: #fff;
}

.calendar-cell strong {
    font-size: 0.8rem;
    color: #333;
}

button {
    background-color: var(--box-bg);
    color: var(--accent);
    border: 2px solid var(--accent);
    border-radius: var(--border-radius);
    padding: 10px 20px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

button:hover {
    background-color: var(--accent);
    color: var(--box-bg);
}

input, textarea, select {
    width: 100%;
    padding: 8px;
    margin: 5px 0;
    border: 1px solid var(--accent);
    border-radius: 5px;
    box-sizing: border-box;
}

.modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    width: 400px;
    max-width: calc(100vw - 40px);
    max-height: 80vh;
    overflow-y: auto;
}

.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 999;
}

.sidebar-alert {
    background: #fff3cd;
    border: 2px solid #856404;
    border-radius: 8px;
    color: #856404;
    font-size: 0.85rem;
    padding: 8px 12px;
    margin-bottom: 10px;
    text-align: center;
}

.sidebar-alert:empty {
    display: none;
}

/* Utility — hide on desktop, show on mobile */
.mobile-only {
    display: none;
}

/* Sidebar layout helpers */
.sidebar-header {
    text-align: center;
}

.sidebar-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 8px;
}

.sidebar-action-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.sidebar-action-buttons > a:last-child {
    margin-top: auto;
}

.sidebar-section {
    margin: 6px 0;
    padding-top: 8px;
    border-top: 1px solid rgba(0,0,0,0.08);
    text-align: left;
}

.sidebar-section:first-of-type {
    border-top: none;
    padding-top: 0;
}

/* Last section (Contact) stays centered */
.sidebar-section:last-of-type,
.sidebar-section--centered {
    text-align: center;
}

.sidebar-section--centered h4 {
    text-align: center;
}

.sidebar-section h4 {
    font-size: 0.85rem;
    margin: 0 0 6px 0;
    color: #333;
}

 /* ============================================================
    MOBILE — ≤768px: sidebar-first, calendar via button
    ============================================================ */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 30px;
}

/* ══════════════════════════════════════════
   MOBILE — ≤768px: centered button column + popups
   ══════════════════════════════════════════ */

/* Desktop: hide mobile-only elements */
.popup-overlay,
#mobileInfoPopup,
#mobileCalendarPopup,
.mobile-nav {
    display: none;
}

.popup-overlay.open {
    display: flex !important;
}

/* Popup overlay — backdrop (shared desktop + mobile) */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

/* Popup panel */
.popup-panel {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    width: 90%;
    max-width: 480px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

#mobileCalendarPopup .popup-panel .close-btn {
    position: relative;
    top: auto;
    right: auto;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #888;
    padding: 4px 8px;
    width: auto;
    box-shadow: none;
}

.popup-panel .close-btn {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: #888;
    box-shadow: none;
    padding: 4px 8px;
    width: auto;
}

@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
        height: 100%;
    }

    body {
        min-height: 100vh;
    }

    /* Hide sidebar and calendar — replaced by centered column */
    .sidebar,
    .main-content {
        display: none !important;
        position: absolute !important;
        clip: rect(0, 0, 0, 0) !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
    }

    .dashboard-wrapper {
        display: none !important;
        position: absolute !important;
        clip: rect(0, 0, 0, 0) !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
    }

    .main-content.orders-content {
        display: none !important;
        position: absolute !important;
        clip: rect(0, 0, 0, 0) !important;
    }

    /* Show mobile nav — above cookie animation */
    .mobile-nav {
        display: flex !important;
        flex-direction: column;
        align-items: center !important;
        justify-content: flex-start;
        width: 100vw;
        max-width: 300px;
        margin-left: auto !important;
        margin-right: auto !important;
        padding-top: 40px;
        padding-bottom: 60px;
        box-sizing: border-box;
        position: relative;
        z-index: 15;
    }

    .mobile-nav * {
        margin-left: auto !important;
        margin-right: auto !important;
    }

    .mobile-orders {
        display: block !important;
        padding: 16px;
        width: 100%;
        box-sizing: border-box;
        z-index: 15;
        position: relative;
        padding-bottom: 80px;
    }

    .mobile-orders .order-card {
        margin-bottom: 20px !important;
    }

    .mobile-orders .order-details {
        grid-template-columns: 1fr !important;
    }

    .mobile-nav .crowkies-title {
        text-align: center;
        margin-bottom: 20px;
        background: rgba(255,255,255,0.85);
        padding: 16px 24px;
        border-radius: 12px;
        width: 100%;
        max-width: 240px;
    }

    .mobile-nav .crowkies-title h1 {
        text-align: center;
        color: #111;
        margin: 0 0 4px 0;
    }

    .mobile-nav .crowkies-title p {
        text-align: center;
        color: #444;
        margin: 0;
        font-size: 0.9rem;
    }

    .mobile-nav button {
        width: 220px;
        margin: 0 auto 10px auto;
        padding: 10px 16px;
        font-size: 0.95rem;
        border-radius: 10px;
        border: 1px solid rgba(0,0,0,0.15);
        background: #fff;
        cursor: pointer;
        box-shadow: 0 2px 6px rgba(0,0,0,0.08);
        transition: background 0.15s;
        text-align: center;
        display: block;
    }

    .mobile-nav button:hover {
        background: #f0f0f0;
    }

    .mobile-nav a {
        display: block;
        text-align: center;
        width: 100%;
    }

    .mobile-nav a button {
        width: 220px;
        margin: 0 auto 10px auto;
    }

    .mobile-nav a:last-child button {
        margin-bottom: 0;
    }

    /* Popup panel — mobile gets smaller max-width */
    .popup-panel {
        max-width: 360px;
    }

    .popup-panel h3 {
        margin: 0 0 12px 0;
        font-size: 1rem;
        padding-right: 30px;
    }

    .popup-panel .sidebar-section {
        margin: 12px 0;
        padding-top: 10px;
        border-top: 1px solid rgba(0,0,0,0.08);
        text-align: left;
    }

    .popup-panel .sidebar-section:first-of-type {
        border-top: none;
        padding-top: 0;
    }

    .popup-panel .sidebar-section:last-of-type {
        text-align: center;
    }

    .popup-panel .sidebar-section h4 {
        font-size: 0.85rem;
        margin: 0 0 6px 0;
        color: #333;
    }

    /* Mobile calendar popup */
    #mobileCalendarPopup .popup-panel {
        max-width: 400px;
    }

    #mobileCalendarPopup .calendar-grid {
        display: grid;
        grid-template-columns: repeat(7, 1fr);
        gap: 4px;
        margin-top: 10px;
    }

    #mobileCalendarPopup .day-headers {
        display: grid;
        grid-template-columns: repeat(7, 1fr);
        gap: 4px;
        margin-bottom: 4px;
    }

    #mobileCalendarPopup .day-headers span {
        text-align: center;
        font-size: 0.7rem;
        font-weight: 600;
        color: #888;
        padding: 2px;
    }

    #mobileCalendarPopup .calendar-cell {
        border: 1px solid #ddd;
        border-radius: 6px;
        padding: 4px;
        min-height: 50px;
        font-size: 0.75rem;
        position: relative;
    }

    #mobileCalendarPopup .calendar-cell.today {
        border: 2px solid var(--accent);
    }

    #mobileCalendarPopup .cell-date {
        font-weight: 600;
        font-size: 0.75rem;
    }

    #mobileCalendarPopup .cell-orders {
        margin-top: 2px;
    }

    #mobileCalendarPopup .cell-orders a {
        display: block;
        font-size: 0.65rem;
        color: #666;
        text-decoration: none;
    }
}
