:root {
    /* Core Palette */
    --primary: #4f46e5;       /* Indigo 600 */
    --primary-light: #6366f1; /* Indigo 500 */
    --primary-dark: #4338ca;  /* Indigo 700 */
    --secondary: #64748b;     /* Slate 500 */
    
    /* Semantic Colors */
    --success: #10b981;       /* Emerald 500 */
    --success-bg: #ecfdf5;
    --warning: #f59e0b;       /* Amber 500 */
    --warning-bg: #fffbeb;
    --danger: #ef4444;        /* Red 500 */
    --danger-bg: #fef2f2;
    --info: #3b82f6;          /* Blue 500 */
    --info-bg: #eff6ff;

    /* Backgrounds & Surfaces */
    --bg-body: #f4f6fb;
    --bg-surface: #ffffff;
    --bg-panel: #f8fafc;
    
    /* Text */
    --text-main: #0f172a;     /* Slate 900 */
    --text-muted: #64748b;    /* Slate 500 */
    --text-light: #94a3b8;    /* Slate 400 */

    /* Borders & UI */
    --border: #e2e8f0;        /* Slate 200 */
    --border-hover: #cbd5e1;  /* Slate 300 */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    /* Effects */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-body);
    /* Subtle background gradient for depth */
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.08), transparent 25%), 
        radial-gradient(circle at 85% 30%, rgba(16, 185, 129, 0.08), transparent 25%);
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s ease;
}
a:hover {
    color: var(--primary-dark);
}

/* --- Layout Structure --- */
.app-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 50;
    transition: transform 0.3s ease;
}

.sidebar__brand {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.brand-meta {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--text-main);
    letter-spacing: -0.025em;
}

.brand-tag {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar__nav {
    flex: 1;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow-y: auto;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.925rem;
    transition: all 0.2s ease;
}

.sidebar__link:hover {
    background-color: var(--bg-body);
    color: var(--text-main);
}

.sidebar__link.is-active {
    background-color: var(--info-bg);
    color: var(--primary);
    font-weight: 600;
}

.sidebar__link .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: currentColor;
    opacity: 0.5;
}

.sidebar__footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
}

/* Main Content Area */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevent flex overflow */
    padding: 1.5rem 2rem;
    /* Adjust for mobile nav padding at bottom if needed */
}

.content-inner {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Topbar */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.topbar__search {
    flex: 1;
    max-width: 480px;
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-body);
    border-radius: var(--radius-md);
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.topbar__search:focus-within {
    background: var(--bg-surface);
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.topbar__search input {
    border: none;
    background: transparent;
    width: 100%;
    padding-left: 0.75rem;
    font-size: 0.925rem;
    color: var(--text-main);
}

.topbar__search input:focus {
    outline: none;
}

.topbar__actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* User Pill */
.user-pill {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem 0.5rem 0.5rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    transition: border-color 0.2s;
}

.user-pill:hover {
    border-color: var(--border-hover);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: var(--shadow-sm);
}

.user-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    padding-right: 0.5rem;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- Components --- */

/* Buttons */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.925rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    line-height: 1;
}

.button-small {
    padding: 0.5rem 0.875rem;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
}

.button-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}
.button-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.3);
}

.button-outline {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-main);
}
.button-outline:hover {
    border-color: var(--primary-light);
    color: var(--primary);
    background: var(--bg-body);
}

.button-danger {
    background: var(--danger);
    color: white;
}
.button-danger:hover {
    background-color: #dc2626;
}

.icon-button {
    padding: 0.5rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.icon-button:hover {
    background: var(--bg-body);
    color: var(--primary);
    border-color: var(--border);
}

/* Cards */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow 0.2s;
}
/* Hover effect only for interactive cards if needed, generally kept static for dashboard panels */

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-main);
}

.card-content {
    padding: 1.5rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.form-input, .form-textarea, .filter-select, .customer-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.form-input:focus, .form-textarea:focus, .filter-select:focus, .customer-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-md);
}

.table {
    width: 100%;
    border-collapse: separate; /* Allows border radius on rows/cells if needed */
    border-spacing: 0;
    font-size: 0.925rem;
}

.table th {
    background: var(--bg-panel);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.875rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
    vertical-align: middle;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover td {
    background-color: var(--bg-body);
}

/* Badges & Pills */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-success, .pill--success { background: var(--success-bg); color: var(--success); }
.badge-pending, .badge-warning, .pill--warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger, .badge-overdue, .pill--error { background: var(--danger-bg); color: var(--danger); }
.badge-active, .badge-info, .pill--neutral { background: var(--info-bg); color: var(--info); }
.badge-completed { background: var(--success-bg); color: var(--success); }

/* Status Select (Dropdown inside table) */
select.status-select {
    border: none;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    padding-right: 1.5rem; /* space for arrow */
    appearance: none;
    /* Custom arrow handled by background-image in original or we add here */
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='10' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 9L12 15L18 9' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
}

/* --- Dashboard Specifics --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.metric-card {
    background: var(--bg-surface);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.2s;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}
.metric-icon--blue { background: linear-gradient(135deg, #60a5fa, #3b82f6); color: white; }
.metric-icon--purple { background: linear-gradient(135deg, #a78bfa, #7c3aed); color: white; }
.metric-icon--green { background: linear-gradient(135deg, #34d399, #10b981); color: white; }
.metric-icon--orange { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: white; }
.metric-icon--pink { background: linear-gradient(135deg, #f472b6, #ec4899); color: white; }

.metric-label { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.metric-value { font-size: 1.5rem; font-weight: 700; color: var(--text-main); }

/* Quick Actions */
.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.quick-action-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.25rem;
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-weight: 500;
    transition: all 0.2s;
    text-align: center;
}

.quick-action-button:hover {
    background: white;
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: var(--shadow-md);
}

/* Modals */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex; /* flex by default, toggled via .hidden */
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal.hidden { display: none !important; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-surface);
    width: 100%;
    max-width: 500px;
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 1001;
    margin: 1rem;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.modal-header h3 { font-size: 1.25rem; font-weight: 600; }

.close-button {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
}
.close-button:hover { color: var(--text-main); }

.modal-footer {
    margin-top: 2rem;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Utilities */
.text-right { text-align: right; }
.mt-2 { margin-top: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }

/* Mobile Navigation */
.mobile-nav {
    display: none; /* Hidden by default on desktop */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    padding: 0.5rem;
    z-index: 900;
    justify-content: space-around;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.05);
}

.mobile-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-decoration: none;
    border-radius: var(--radius-sm);
}

.mobile-nav__item.is-active {
    color: var(--primary);
    background: var(--info-bg);
}
.mobile-nav__item svg {
    width: 24px;
    height: 24px;
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
    font-size: 0.875rem;
    margin-top: auto;
}

/* --- Media Queries --- */

@media (max-width: 1024px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .topbar__search { max-width: none; }
}

@media (max-width: 768px) {
    /* Hide Sidebar on mobile */
    .sidebar {
        display: none; 
    }
    
    /* Show Mobile Nav */
    .mobile-nav {
        display: flex;
    }
    
    .content-area {
        padding: 1rem;
        padding-bottom: 80px; /* Space for mobile nav */
    }
    
    .topbar {
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
    }
    
    .topbar__search {
        margin-bottom: 0.75rem;
    }
    
    .topbar__actions {
        justify-content: space-between;
    }

    .user-pill {
        border: none;
        background: transparent;
        padding: 0;
    }
    
    .user-meta {
        display: none; /* Hide name/role on mobile topbar to save space */
    }

    .metrics-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .quick-actions-grid {
        grid-template-columns: 1fr;
    }
    
    .table th, .table td {
        padding: 0.75rem 1rem;
    }
}

@media (max-width: 480px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }
}