:root {
    --primary: #2563eb;
    --primary-light: #3b82f6;
    --primary-dark: #1d4ed8;

    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-active-bg: #1e293b;
    --sidebar-active-text: #f8fafc;

    --bg-body: #f1f5f9;
    --bg-card: #ffffff;

    --text-main: #0f172a;
    --text-muted: #64748b;

    --border: #e2e8f0;

    /* Status Colors */
    --status-draft: #94a3b8;
    --status-pending: #f59e0b;
    --status-confirmed: #10b981;
    --status-cancelled: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-font-smoothing: antialiased;
}

/* --- Layout Wrappers --- */
.app-layout,
.dashboard-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
}

/* --- Sidebar --- */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
}

/* Collapsed State (Desktop) */
.sidebar.collapsed {
    width: 70px;
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .menu li a span {
    display: none;
}

.sidebar.collapsed .logo {
    padding: 0;
    justify-content: center;
}

.sidebar.collapsed .menu li a {
    justify-content: center;
    padding: 0.75rem;
}

.sidebar.collapsed .menu li a i {
    margin-right: 0;
    font-size: 1.2rem;
}

.logo {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.logo span {
    color: var(--primary-light);
}

.desktop-collapse-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    font-size: 1.1rem;
    transition: color 0.2s;
    display: flex;
    align-items: center;
}

.desktop-collapse-btn:hover {
    color: #fff;
}

.menu {
    flex: 1;
    list-style: none;
    padding: 1.5rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    overflow-y: auto;
}

.menu li a {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 0.5rem;
    transition: all 0.2s;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
}

.menu li a i {
    width: 24px;
    margin-right: 0.5rem;
    font-size: 1.1rem;
    text-align: center;
    flex-shrink: 0;
}

.menu li a:hover,
.menu li a.active {
    background-color: #fff7ed;
    color: #f59e0b;
}

.menu li a.active i {
    color: #f59e0b;
}

.sidebar.collapsed .menu li a span {
    display: none;
}

.sidebar.collapsed .menu li a i {
    margin-right: 0;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: auto;
    min-height: 0;
    position: relative;
    /* Ensure stacking context */
}

.top-header {
    height: 70px;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.mobile-toggle {
    display: none;
}

.top-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- KPI Cards --- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    padding: 2rem;
    padding-bottom: 0;
}

.kpi-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.kpi-icon.blue {
    background: #eff6ff;
    color: #3b82f6;
}

.kpi-icon.green {
    background: #f0fdf4;
    color: #10b981;
}

.kpi-icon.orange {
    background: #fff7ed;
    color: #f59e0b;
}

.kpi-icon.purple {
    background: #f5f3ff;
    color: #8b5cf6;
}

.kpi-data {
    display: flex;
    flex-direction: column;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.kpi-label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* --- Tables --- */
.content-section {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    flex: 1;
    /* Take remaining height */
    overflow-y: auto;
    /* Prevent spill */
}

.section-header {
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-container {
    background: var(--bg-card);
    border-radius: 1rem;
    border: 1px solid var(--border);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    width: 100%;
}

.data-table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
}

.data-table th {
    position: sticky;
    top: 0;
    background: #f8fafc;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
}

/* Responsive helpers */
.tracking-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    width: 100%;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 120px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 1rem;
    display: grid;
    place-items: center;
    font-size: 1.25rem;
}

.stat-info h3 {
    margin: 0 0 0.35rem 0;
    font-size: 0.95rem;
    color: var(--text-main);
}

.stat-info p {
    margin: 0;
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-main);
}

.panel {
    background: var(--bg-card);
    border-radius: 1rem;
    border: 1px solid var(--border);
    padding: 1.25rem;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.panel-header input,
.panel-header .search-input {
    width: 250px;
    max-width: 100%;
}

.tab-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.tab-btn {
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.15s ease;
}

.tab-btn.active,
.tab-btn:hover {
    background: var(--primary);
    color: white;
    border-color: transparent;
}

.data-table-container {
    overflow-x: auto;
    width: 100%;
}

.data-table th,
.data-table td {
    white-space: normal;
}

img,
svg {
    max-width: 100%;
    height: auto;
}

button,
input,
select,
textarea {
    font-family: inherit;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-draft {
    background: #f1f5f9;
    color: #64748b;
}

.status-pending {
    background: #fffbeb;
    color: #d97706;
}

.status-confirmed {
    background: #ecfdf5;
    color: #059669;
}

.status-cancelled {
    background: #fef2f2;
    color: #ef4444;
}

.action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.5rem;
    transition: color 0.2s;
}

.action-btn:hover {
    color: var(--primary);
}

/* --- Mobile Sidebar Support --- */
.mobile-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-main);
    cursor: pointer;
    margin-right: 1rem;
}

.mobile-close-btn {
    display: none;
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 9998;
}

@media (max-width: 1024px) {
    body {
        overflow-y: auto !important;
        height: auto !important;
    }
    
    .dashboard-container {
        display: block !important;
        height: auto !important;
        min-height: 100vh;
    }

    .sidebar {
        position: fixed;
        left: -300px;
        top: 0;
        width: 280px;
        height: 100vh;
        z-index: 9999;
        box-shadow: 10px 0 30px rgba(0,0,0,0.2);
        transition: left 0.3s ease;
    }

    .main-content {
        overflow: visible !important;
        display: block !important;
        height: auto !important;
    }

    .sidebar.active {
        left: 0;
    }

    .sidebar.collapsed {
        width: 280px;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .mobile-toggle {
        display: block;
        background: none;
        border: none;
        color: #1e293b;
        font-size: 1.5rem;
        cursor: pointer;
        padding: 5px;
        margin-right: 15px;
        transition: color 0.2s;
    }

    .mobile-toggle:hover {
        color: var(--primary);
    }

    .mobile-close-btn {
        display: flex;
    }

    .logo {
        justify-content: space-between;
    }

    .top-header {
        padding: 0 1rem;
        position: sticky;
        top: 0;
    }

    .top-header h2 {
        font-size: 1.1rem;
    }

    .content-section, .kpi-grid {
        padding: 1rem;
        height: auto !important;
        overflow: visible !important;
    }

    .desktop-collapse-btn {
        display: none;
    }

    /* Prevent body scroll when sidebar is open */
    body.sidebar-open {
        overflow: hidden !important;
    }
}

@media (max-width: 768px) {
    .top-header {
        padding: 0.75rem 1rem;
    }

    .top-header h2 {
        font-size: 1rem;
    }

    .user-profile {
        gap: 0.5rem;
        justify-content: flex-end;
    }

    .kpi-grid {
        padding: 0.75rem;
        gap: 1rem;
    }

    .kpi-card {
        padding: 1rem;
        gap: 0.75rem;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .panel-header {
        flex-direction: column;
        align-items: stretch;
        flex-wrap: wrap;
    }

    .panel-header input,
    .panel-header .search-input {
        width: 100% !important;
        max-width: 100% !important;
    }

    .tab-group {
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .tab-btn {
        flex: 1 1 160px !important;
        min-width: 140px !important;
        text-align: center;
    }

    /* Table card mode for mobile */
    .data-table,
    .data-table thead,
    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block !important;
    }

    .data-table thead {
        display: none !important;
    }

    .data-table tr {
        background: white !important;
        margin-bottom: 12px !important;
        border: 1px solid #e2e8f0 !important;
        border-radius: 10px !important;
        padding: 10px !important;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
    }

    .data-table td {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
        gap: 0.5rem !important;
        padding: 8px 6px !important;
        border-bottom: 1px solid #f1f5f9 !important;
    }

    .data-table td:last-child {
        border-bottom: none !important;
        justify-content: flex-start !important;
    }

    .data-table td::before {
        content: attr(data-label);
        display: block !important;
        width: 100% !important;
        margin: 0 0 4px 0 !important;
        font-weight: 700 !important;
        color: #64748b !important;
        font-size: 0.7rem !important;
        text-transform: uppercase !important;
        letter-spacing: 0.3px !important;
    }

    .mobile-toggle {
        margin-right: 0;
    }
}

@media (max-width: 640px) {
    .top-header {
        padding: 0.75rem 0.75rem;
    }

    .top-header h2 {
        font-size: 0.95rem;
    }

    .content-section,
    .kpi-grid,
    .panel,
    .table-container {
        padding: 0.75rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.8rem 0.9rem;
    }

    .kpi-grid {
        gap: 0.75rem;
    }

    .stat-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .stat-info p {
        font-size: 1.35rem;
    }

    .tracking-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1024px) {
    html, body {
        height: auto !important;
        min-height: 100vh !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }

    .dashboard-container,
    .main-content,
    .content-section,
    .costing-container,
    .wizard-container {
        height: auto !important;
        min-height: 100vh !important;
        overflow: visible !important;
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .wizard-steps {
        flex-wrap: wrap !important;
    }

    .task-grid,
    .stats-grid,
    .booking-detail-grid {
        grid-template-columns: 1fr !important;
    }
}
