:root {
    /* iOS Color Palette */
    --primary-color: #007AFF;
    --secondary-color: #8E8E93;
    --success-color: #34C759;
    --warning-color: #FF9500;
    --danger-color: #FF3B30;
    --indigo-color: #5856D6;
    --purple-color: #AF52DE;
    --teal-color: #30B0C7;

    /* Backgrounds */
    --bg-color: #F2F2F7;
    --card-bg: rgba(255, 255, 255, 0.75);
    --sidebar-bg: rgba(255, 255, 255, 0.85);

    /* Shadows & Radius */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;

    /* Layout */
    --sidebar-width: 280px;
}

body {
    background-color: var(--bg-color);
    color: #1c1c1e;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* --- Global iOS Overrides --- */

/* Cards / Containers */
.card-box,
.widget-card,
.table-container,
.login-box {
    background: var(--card-bg);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(255, 255, 255, 0.6);
    padding: 30px;
    transition: transform 0.2s, box-shadow 0.2s;
}

/* Inputs */
.form-control,
.form-select {
    background-color: rgba(118, 118, 128, 0.12);
    border: none;
    border-radius: 12px;
    /* iOS Text Field style */
    padding: 12px 16px;
    color: #1c1c1e;
    font-size: 16px;
    /* Prevents auto-zoom on mobile */
    transition: all 0.2s;
}

.form-control:focus,
.form-select:focus {
    background-color: rgba(255, 255, 255, 1);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.15);
    color: #000;
}

/* Buttons */
.btn {
    border-radius: 20px;
    /* Pill shape */
    padding: 10px 24px;
    font-weight: 600;
    letter-spacing: -0.2px;
    border: none;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.25);
}

.btn-primary:hover {
    background-color: #0062cc;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 122, 255, 0.35);
}

.btn-danger {
    background-color: var(--danger-color);
}

.btn-success {
    background-color: var(--success-color);
}

.btn-warning {
    background-color: var(--warning-color);
    color: white;
}

/* Tables */
.table {
    --bs-table-bg: transparent;
}

.table thead th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--secondary-color);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding-bottom: 15px;
}

.table tbody td {
    padding: 18px 12px;
    vertical-align: middle;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-weight: 500;
}

.table-hover tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

/* Sidebar Styling */
#sidebar {
    width: var(--sidebar-width);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    height: 100vh;
    background: var(--sidebar-bg);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    z-index: 1000;
    padding: 30px 20px;
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    /* Default: Desktop Visible */
    transform: translateX(0);
}

#sidebar ul.components {
    padding: 0;
    border: none;
}

#sidebar ul li {
    margin-bottom: 6px;
}

#sidebar ul li a {
    padding: 12px 18px;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    color: #1c1c1e;
    text-decoration: none;
    border-radius: 14px;
    transition: all 0.2s;
}

#sidebar ul li.active a,
#sidebar ul li a:hover {
    background: rgba(0, 122, 255, 0.12);
    color: var(--primary-color);
}

#sidebar ul li a i {
    width: 26px;
    text-align: center;
    margin-right: 12px;
    font-size: 18px;
}

/* Wrapper & Content */
.wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
}

.main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    padding: 40px;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Desktop Collapse State */
#sidebar.active {
    transform: translateX(-100%);
}

.main-content.active {
    margin-left: 0;
    width: 100%;
}

/* --- Pure iOS Widget Styles --- */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.widget-card {
    background: #fff;
    border-radius: 26px;
    /* iOS 16 large widgets */
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.02);
    position: relative;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.widget-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
}

.ios-icon-box {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    /* Squircle */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 18px;
}

.ios-blue {
    background: rgba(0, 122, 255, 0.1);
    color: #007AFF;
}

.ios-orange {
    background: rgba(255, 149, 0, 0.1);
    color: #FF9500;
}

.ios-green {
    background: rgba(52, 199, 89, 0.1);
    color: #34C759;
}

.ios-red {
    background: rgba(255, 59, 48, 0.1);
    color: #FF3B30;
}

.ios-purple {
    background: rgba(175, 82, 222, 0.1);
    color: #AF52DE;
}

.widget-title {
    font-size: 16px;
    font-weight: 600;
    color: #1c1c1e;
    text-transform: none;
    margin-bottom: 4px;
    opacity: 0.85;
}

.widget-value {
    font-size: 40px;
    font-weight: 700;
    letter-spacing: -1px;
    color: #000;
}

.widget-subtitle {
    font-size: 13px;
    color: #8E8E93;
    font-weight: 500;
    margin-top: auto;
    padding-top: 10px;
}

/* Hide old widget icon */
.widget-icon {
    display: none;
}

/* Alerts */
.alert {
    border-radius: 16px;
    border: none;
    font-weight: 500;
}

/* --- Vertical Timeline CSS (Creative Design) --- */
.timeline-vertical {
    position: relative;
    max-width: 1000px;
    margin: 0 auto;
}

.timeline-vertical::after {
    content: '';
    position: absolute;
    width: 4px;
    background-color: #e5e5ea;
    top: 0;
    bottom: 0;
    left: 24px;
    /* Line position */
    border-radius: 2px;
}

.timeline-step {
    position: relative;
    background-color: transparent;
    width: 100%;
    margin-bottom: 30px;
    padding-left: 60px;
    /* Space for line */
}

.timeline-marker {
    position: absolute;
    width: 24px;
    height: 24px;
    left: 14px;
    background-color: #fff;
    border: 4px solid #e5e5ea;
    border-radius: 50%;
    z-index: 1;
    top: 15px;
    /* Alignment */
}

.timeline-step.completed .timeline-marker {
    border-color: var(--success-color);
    background: var(--success-color);
}

.timeline-step.ready .timeline-marker {
    border-color: var(--primary-color);
}

.timeline-step.waiting .timeline-marker {
    border-color: var(--warning-color);
}

.timeline-step.locked .timeline-marker {
    border-color: #d1d1d6;
}

.timeline-content {
    background: #fff;
    /* Fallback */
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(15px);
    padding: 24px;
    border-radius: 18px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.8);
    position: relative;
}

.timeline-step.completed .timeline-content {
    border-left: 5px solid var(--success-color);
}

.timeline-step.ready .timeline-content {
    border-left: 5px solid var(--primary-color);
    box-shadow: 0 8px 24px rgba(0, 122, 255, 0.15);
}

.timeline-step.waiting .timeline-content {
    border-left: 5px solid var(--warning-color);
}

.step-date {
    position: absolute;
    top: 24px;
    right: 24px;
    font-weight: 600;
    color: var(--secondary-color);
}


/* --- Mobile Responsive Overrides --- */

@media (max-width: 768px) {

    /* 1. Global Layout: Sidebar off-canvas by default */
    #sidebar {
        transform: translateX(-100%);
        /* Hidden by default on Mobile */
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.1);
    }

    #sidebar.active {
        transform: translateX(0);
        /* Slide in when active */
    }

    /* Main Content spans full width always on mobile */
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 20px;
        /* Smaller padding */
    }

    /* When sidebar opens, content stays put (overlay) or could move. Overlay is better for modern apps. */
    .main-content.active {
        margin-left: 0;
        /* Override JS desktop logic if any */
    }

    /* 2. Typography & Density */
    h2,
    h3 {
        font-size: 1.5rem;
    }

    .widget-value {
        font-size: 32px;
    }

    /* 3. Bento Grid: 1 Column */
    .bento-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .widget-card {
        padding: 20px;
    }

    /* 4. Tables: Card View transformation */
    /* Force table to not be like tables anymore */
    .table-responsive .table thead {
        display: none;
        /* Hide headers */
    }

    .table-responsive .table tbody,
    .table-responsive .table tr,
    .table-responsive .table td {
        display: block;
        width: 100%;
    }

    .table-responsive .table tr {
        margin-bottom: 15px;
        background: #fff;
        border-radius: 18px;
        padding: 15px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
        border: 1px solid rgba(0, 0, 0, 0.02);
    }

    .table-responsive .table td {
        padding: 5px 0;
        text-align: left;
        border: none;
    }

    /* Small label for data if needed, or just rely on visual hierarchy implemented in view.php */

    /* 5. Timeline Mobile */
    .timeline-vertical::after {
        left: 15px;
        /* Shift line closer to edge */
    }

    .timeline-step {
        padding-left: 45px;
        /* Less indentation */
    }

    .timeline-marker {
        left: 5px;
        /* Shift marker */
    }

    .timeline-content {
        padding: 20px;
    }

    .step-date {
        position: relative;
        top: 0;
        right: 0;
        display: block;
        margin-bottom: 5px;
        font-size: 0.85rem;
    }

    /* Hide specific non-critical elements */
    .d-none-mobile {
        display: none !important;
    }
}