:root {
    --cake-green: #3ca368; 
    --cake-dark: #333333; 
    --cake-header-logo: #222222; 
    --cake-nav-bg: #404040; 
    --cake-sidebar-bg: #333333; 
    --cake-bg: #ececec; 
    --cake-border: #cccccc;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Arial, sans-serif; }

body { background-color: var(--cake-dark); display: flex; flex-direction: column; min-height: 100vh; }

/* --- Top Header Strip --- */
.top-bar { display: flex; height: 50px; background: var(--cake-dark); color: #888; font-size: 13px; align-items: center; justify-content: space-between; }
.logo-area { width: 280px; background: var(--cake-header-logo); height: 100%; display: flex; align-items: center; padding-left: 20px; color: #555; font-weight: bold; }
.user-area { padding-right: 20px; }
.user-area a { color: #ccc; text-decoration: none; margin: 0 5px; }
.user-area a:hover { color: #fff; }

/* Mobile toggle hidden globally by default */
.mobile-menu-toggle, .mobile-sandwich-menu { display: none; }

/* --- Main Layout Wrapper --- */
.main-wrapper { display: flex; flex: 1; min-width: 0; }

/* --- Left Sidebar --- */
.sidebar { width: 280px; background: var(--cake-sidebar-bg); display: flex; flex-direction: column; }

/* Sidebar Title Block */
.page-title-block { 
    background: var(--cake-green); 
    color: #fff; 
    padding: 0 20px; 
    height: 95px; 
    display: flex;
    align-items: center; 
    font-size: 24px; 
    font-weight: normal; 
    line-height: 1.3; 
    word-wrap: break-word;
}

/* Unified Dark Action Buttons */
.sidebar-actions { padding: 15px; }
.sidebar-action-btn, .info_button, .info_button.primary {
    display: flex;
    align-items: center;
    background: #2b2b2b; 
    color: #e0e0e0;
    padding: 12px 15px;
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 8px;
    border: 1px solid #1a1a1a;
    border-left: 3px solid #2b2b2b;
    transition: 0.2s;
    cursor: pointer;
    width: 100%;
}
.sidebar-action-btn:hover, .info_button:hover, .info_button.primary:hover { 
    background: #111; 
    color: #fff; 
    border-left: 3px solid var(--cake-green); 
}

.sidebar-action-btn i, .info_button i, .info_button.primary i { color: var(--cake-green); font-size: 20px; margin-right: 15px; font-weight: bold; }
.info_button.negative { background: #2b2b2b; }
.info_button.negative i { color: #d34836; }
.info_button.negative:hover { border-left-color: #d34836; }

/* --- Right Content Area --- */
.content-wrapper { flex: 1; background: var(--cake-bg); display: flex; flex-direction: column; min-width: 0; }

/* Top Navigation Icons */
.top-nav { 
    background: var(--cake-nav-bg); 
    display: flex; 
    justify-content: space-around; 
    align-items: center; 
    height: 95px; 
    border-bottom: 3px solid #2a2a2a; 
}
.nav-item { display: flex; flex-direction: column; align-items: center; text-decoration: none; color: #e0e0e0; font-size: 14px; transition: 0.2s; }
.nav-item i { color: var(--cake-green); font-size: 28px; margin-bottom: 5px; }
.nav-item:hover, .nav-item.active { color: #fff; }

/* Inner Content Area */
.inner-content { padding: 20px; }
h2.section-title { color: var(--cake-green); font-weight: normal; font-size: 22px; margin-bottom: 15px; }
h3.sub-title { color: #444; font-weight: normal; font-size: 16px; margin-bottom: 10px; }

/* Alerts */
.alert-bar { background: var(--cake-green); color: #fff; padding: 10px 15px; font-size: 14px; margin-bottom: 20px; }

/* Metric Boxes */
.metric-box-wrapper { display: flex; gap: 20px; margin-bottom: 30px; flex-wrap: wrap; }
.metric-box { flex: 1; min-width: 200px; background: #fff; padding: 20px; border: 1px solid var(--cake-border); box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.metric-box.green-top { border-top: 4px solid var(--cake-green); }
.metric-box.red-top { border-top: 4px solid #d34836; }
.metric-box.blue-top { border-top: 4px solid #3498db; }
.metric-title { font-size: 12px; color: #888; text-transform: uppercase; font-weight: bold; margin-bottom: 5px; }
.metric-value { font-size: 28px; font-weight: 300; color: #333; }

/* Tables */
.cake-table-wrapper { background: #fff; border: 1px solid var(--cake-border); margin-bottom: 30px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.cake-table-header { background: var(--cake-dark); color: #fff; padding: 10px 15px; font-size: 14px; }

table.cake-table, table.responsive_table { width: 100%; border-collapse: collapse; background: #fff; margin-bottom: 25px; border: 1px solid var(--cake-border); }
table.cake-table th, table.responsive_table th { background: var(--cake-dark); color: #fff; padding: 12px 15px; text-align: left; font-size: 13px; font-weight: normal; border-bottom: 2px solid #222; }
table.cake-table td, table.responsive_table td { padding: 12px 15px; font-size: 13px; color: #444; border-bottom: 1px solid #e0e0e0; }
table.cake-table tr:nth-child(even), table.responsive_table tr:nth-child(even) { background-color: #f9f9f9; }
table.cake-table tr:hover, table.responsive_table tr:hover { background-color: #f1f1f1; }

.btn-view { background: var(--cake-green); color: #fff; padding: 5px 10px; text-decoration: none; font-size: 12px; font-weight: bold; border-radius: 2px; white-space: nowrap;}
.btn-view:hover { background: #328c57; }
.status-paid { color: var(--cake-green); font-weight: bold; text-transform: uppercase; }

/* Form Fields */
form { margin-bottom: 30px; }
form label { display: block; margin-bottom: 5px; color: #333; font-size: 13px; font-weight: bold; }
form input[type="text"], form input[type="email"], form input[type="password"], form input[type="number"], form input[type="date"], form select, form textarea { width: 100%; padding: 10px 12px; margin-bottom: 15px; border: 1px solid #ccc; background-color: #fdfdfd; color: #333; font-size: 14px; border-radius: 2px; }
form input:focus, form select:focus, form textarea:focus { border-color: var(--cake-green); outline: none; background-color: #fff; }
form button[type="submit"] { background: var(--cake-green); color: #fff; border: none; padding: 12px 20px; font-size: 14px; cursor: pointer; font-weight: bold; border-radius: 2px; }
form button[type="submit"]:hover { background: #328c57; }


/* =========================================
   MOBILE RESPONSIVENESS (The Fixes)
   ========================================= */
@media (max-width: 768px) {
    
    /* 1. Perfect Top Bar Alignment */
    .top-bar { 
        flex-direction: row; /* Force side-by-side */
        height: 60px; /* Taller for touch */
        padding: 0; 
    }
    .logo-area { 
        flex: 1; /* Pushes the hamburger to the edge */
        width: auto;
        height: 100%;
        padding-left: 15px;
        font-size: 14px;
    }
    
    .desktop-user-area, .desktop-top-nav { display: none !important; }

    .mobile-menu-toggle { 
        display: flex; /* Centers the icon perfectly */
        align-items: center;
        justify-content: center;
        height: 100%;
        padding: 0 25px; 
        font-size: 28px; 
        color: var(--cake-green); 
        cursor: pointer;
        border-left: 1px solid #222; /* Creates separation */
    }

    /* 2. The Sandwich Menu Overlay (Clean Lists) */
    .mobile-sandwich-menu {
        display: none; 
        position: fixed;
        top: 60px; /* Precisely matches the top bar */
        left: 0;
        width: 100%;
        height: calc(100vh - 60px);
        background: #2a2a2a;
        z-index: 9999;
        flex-direction: column;
        justify-content: space-between; 
    }
    .mobile-sandwich-menu.show { display: flex; }

    /* Fresh custom class for mobile links to prevent desktop inheritance */
    .mobile-nav-item {
        display: flex;
        flex-direction: row; /* Forces horizontal list style */
        align-items: center;
        padding: 18px 25px;
        border-bottom: 1px solid #333;
        color: #fff;
        font-size: 16px;
        text-decoration: none;
    }
    .mobile-nav-item i { margin-right: 20px; font-size: 22px; color: var(--cake-green); }

    .mobile-user-area {
        background: #1a1a1a;
        padding: 25px;
        border-top: 2px solid var(--cake-green);
    }
    .mobile-user-area .welcome-text { color: var(--cake-green); font-weight: bold; margin-bottom: 15px; font-size: 15px; }
    .mobile-user-area a { display: flex; align-items: center; color: #ddd; text-decoration: none; margin-bottom: 15px; font-size: 16px; }
    .mobile-user-area a i { margin-right: 15px; color: #888; font-size: 18px; }
    .mobile-user-area .brand-text { margin-top: 25px; color: #555; font-size: 12px; }

    /* 3. Universal Table Horizontal Scroll Fix */
    table.cake-table, table.responsive_table {
        display: block; /* Turns the table into a block level element */
        overflow-x: auto; /* Enables swiping left/right */
        -webkit-overflow-scrolling: touch; /* Smooth scroll on iOS */
        white-space: nowrap; /* Prevents columns from squishing together */
        width: 100%;
        border-right: none;
    }

    /* Sidebar stacking */
    .main-wrapper { flex-direction: column; }
    .sidebar { width: 100%; }
    .page-title-block { height: auto; padding: 20px; text-align: center; font-size: 22px; }

    /* Side menu buttons turned into grid */
    .sidebar-actions { display: flex; flex-wrap: wrap; gap: 10px; padding: 15px; background: #222; }
    .sidebar-action-btn, .info_button, .info_button.primary {
        flex: 1; min-width: calc(50% - 10px);
        margin-bottom: 0; padding: 15px 5px;
        flex-direction: column; text-align: center; font-size: 12px;
        border-left: none; border-top: 3px solid #2b2b2b; border-radius: 4px;
    }
    .sidebar-action-btn i, .info_button i, .info_button.primary i { margin-right: 0; margin-bottom: 8px; font-size: 20px; }
    .sidebar-action-btn:hover, .info_button:hover, .info_button.primary:hover { border-left: none; border-top: 3px solid var(--cake-green); }
    .info_button.negative:hover { border-left: none; border-top: 3px solid #d34836; }
}