:root {
    /* --- COLOR PALETTE (REFINED) --- */
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-header: #ffffff;
    --bg-hover: #f1f5f9;

    /* Primary Brand - Soft Blue */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-active: #1e40af;
    --primary-light: #eff6ff;

    /* Text Colors */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-disabled: #cbd5e1;

    /* Borders */
    --border-color: #e2e8f0;
    --border-color-strong: #cbd5e1;
    --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.15);

    /* Status Colors */
    --success-bg: #dcfce7;
    --success-text: #166534;
    --success-border: #bbf7d0;
    --error-bg: #fee2e2;
    --error-text: #991b1b;
    --error-border: #fecaca;
    --warning-bg: #fef3c7;
    --warning-text: #92400e;
    --warning-border: #fde68a;
    --info-bg: #eff6ff;
    --info-text: #1e40af;
    --info-border: #bfdbfe;

    /* --- LAYOUT & SPACING --- */
    --header-height: 60px;
    --sidebar-width: 64px;
    /* Collapsed width */
    --sidebar-width-expanded: 240px;

    /* --- RADIUS --- */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-pill: 999px;

    /* --- SHADOWS --- */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);

    /* --- TYPOGRAPHY --- */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    /* --- TRANSITIONS --- */
    --transition-fast: 150ms ease-out;
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==============================
   RESET & GLOBAL
============================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

ul {
    list-style: none;
}

/* ==============================
   HEADER (FIXED)
============================== */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px 0 0;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    z-index: 1000;
}

.header-left {
    display: flex;
    align-items: center;
    height: 100%;
    background: #ffffff;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 100%;
}

.logo-container {
    height: var(--header-height);
    width: var(--header-height);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: #ffffff;
}

.app-logo {
    height: 100%;
    width: 100%;
    object-fit: contain;
    transform: scale(1.2);
    mix-blend-mode: multiply;
    transition: transform 0.3s ease;
}


.header-logo h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 29px;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(90deg, #2563EB 0%, #F59E0B 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: #2563EB;
    /* Fallback */
    filter: drop-shadow(0 2px 4px rgba(37, 99, 235, 0.1));
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ==============================
   SIDEBAR (PINTEREST STYLE)
============================== */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    /* Default collapsed */
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    z-index: 900;
    transition: width var(--transition-slow);
    overflow: hidden;
    /* Hide text label when collapsed */
    display: flex;
    flex-direction: column;
    padding-top: 12px;
}

/* Expansion on Hover (Desktop) */
@media (min-width: 1025px) {
    .sidebar:hover {
        width: var(--sidebar-width-expanded);
        box-shadow: var(--shadow-lg);
    }
}

.sidebar-menu {
    padding: 0 8px;
}

.sidebar-menu li {
    margin-bottom: 12px;
    /* Increased vertical spacing */
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    height: 52px;
    /* Taller for a more spacious feel */
    padding: 0 14px;
    /* Slightly more side padding */
    /* Prevents icon from shrinking */
    border-radius: var(--radius-pill);
    color: var(--text-secondary);
    white-space: nowrap;
    /* Prevent text wrap */
    overflow: hidden;
    transition: all var(--transition-fast);
}

.sidebar-menu a:hover {
    background-color: var(--bg-hover);
    color: var(--primary);
}

.sidebar-menu a.active {
    background-color: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.sidebar-menu a svg {
    flex-shrink: 0;
    width: 24px;
    /* Larger icons */
    height: 24px;
    margin-right: 16px;
}

.nav-label {
    opacity: 0;
    transition: opacity 0.1s;
    font-size: 14px;
    font-weight: 500;
}

@media (min-width: 1025px) {
    .sidebar:hover .nav-label {
        opacity: 1;
        transition-delay: 0.1s;
    }
}

/* ==============================
   MAIN CONTENT
============================== */
.app-body {
    padding-top: var(--header-height);
    min-height: 100vh;
    display: flex;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    /* Fixed margin clearing collapsed sidebar */
    padding: 24px;
    width: 100%;
    /* No transition on margin-left to prevent layout shift */
}

/* ==============================
   MOBILE RESPONSIVENESS
============================== */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-secondary);
}

@media (max-width: 1024px) {
    .menu-toggle {
        display: block;
    }

    .sidebar {
        width: 260px;
        /* Fixed drawer width on mobile */
        left: -260px;
        /* Hidden */
        box-shadow: var(--shadow-xl);
        transition: transform var(--transition);
        /* Use transform for mobile performance */
        transform: translateX(0);
        border-right: none;
    }

    .sidebar.active {
        left: 0;
        transform: translateX(0);
    }

    /* Overlay */
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(2px);
        z-index: 850;
        display: none;
        opacity: 0;
        transition: opacity var(--transition);
    }

    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }

    .nav-label {
        opacity: 1 !important;
    }

    /* Always show labels on mobile drawer */

    .main-content {
        margin-left: 0;
        /* Full width content */
        padding: 16px;
    }
}

/* ==============================
   COMPONENTS & UTILITIES
============================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition-fast);
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background-color: white;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-color-strong);
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

/* Card Styles */
.section-card,
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 24px;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.section-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Typography Helpers */
.page-header {
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-header h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Table Styles - Clean (Zoho) */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background: white;
}

th {
    text-align: left;
    padding: 12px 16px;
    background: var(--bg-hover);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

tr:hover td {
    background-color: #f8fafc;
}

tr:last-child td {
    border-bottom: none;
}

/* Status Badges */
.status-badge {
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.status-active {
    background: var(--success-bg);
    color: var(--success-text);
}

.status-closed {
    background: var(--error-bg);
    color: var(--error-text);
}

.status-extended {
    background: #f3e8ff;
    color: #6b21a8;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
    animation: fadeIn var(--transition);
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success-border);
}

.alert-error {
    background: var(--error-bg);
    color: var(--error-text);
    border: 1px solid var(--error-border);
}

/* Keyframes */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Inputs */
input,
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    background: white;
}

input:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
    outline: none;
}

/* ==============================
   CAMERA MODAL STYLES
============================== */
.camera-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    /* Controlled by JS flex */
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.camera-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: -1;
}

.camera-modal-panel {
    background: white;
    width: 100%;
    max-width: 500px;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-xl);
    position: relative;
    animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ==============================
   LAYOUT FRAMES (FOOTER)
   ============================== */
.view-action-footer {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width);
    right: 0;
    height: 80px;
    background: #ffffff;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -10px 25px -5px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    z-index: 1050;
    transition: left var(--transition-slow);
}

@media (max-width: 1024px) {
    .view-action-footer {
        left: 0;
    }
}

@keyframes modalPop {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.camera-modal-panel h3 {
    margin-top: 0;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 700;
}