:root {
    /* ── Color Palette ─────────────────────────────────────── */
    --primary: #10b981;
    --primary-hover: #059669;
    --primary-light: rgba(16, 185, 129, 0.1);
    --primary-subtle: #ecfdf5;
    --accent: #0ea5e9;
    --accent-hover: #0284c7;
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --info: #0ea5e9;

    /* ── Neutral Tones ──────────────────────────────────────── */
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --bg-subtle: #f8fafc;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --border-focus: #10b981;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-subtle: #94a3b8;

    /* ── Dimensions ─────────────────────────────────────────── */
    --sidebar-width: 260px;
    --navbar-height: 60px;

    /* ── Typography Scale ───────────────────────────────────── */
    --font-xs: 0.75rem;      /* 12px */
    --font-sm: 0.8125rem;    /* 13px */
    --font-base: 0.875rem;   /* 14px */
    --font-md: 0.9375rem;    /* 15px */
    --font-lg: 1.125rem;     /* 18px */
    --font-xl: 1.25rem;      /* 20px */
    --font-2xl: 1.4rem;      /* 22.4px */

    /* ── Radii ──────────────────────────────────────────────── */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-pill: 9999px;

    /* ── Shadows ────────────────────────────────────────────── */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
    --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
}

/* ── Base Reset ─────────────────────────────────────────────── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

body, html {
    background: var(--bg-main);
    color: var(--text-main);
    font-size: 14px;
    line-height: 1.5;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    color-scheme: light;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout Framework ───────────────────────────────────────── */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar & Accordion Navigation ─────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    position: fixed;
    height: 100vh;
    z-index: 50;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 1.15rem 1.25rem 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-light);
}

.logo-circle {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.15rem;
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
    flex-shrink: 0;
}

.app-name {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0.65rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    overflow-y: auto;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.22);
}

/* ── Nav Item (Direct) ──────────────────────────────────────── */
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    text-decoration: none;
    font-size: var(--font-base);
    font-weight: 500;
    transition: all 0.15s ease-in-out;
}

.nav-item:hover {
    color: var(--text-main);
    background: var(--bg-card-hover);
}

.nav-item.active {
    color: var(--primary-hover);
    background: var(--primary-light);
    font-weight: 600;
}

.nav-item i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

/* ── Nav Accordion Group (Parent/Child) ───────────────────────── */
.nav-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 0.15rem;
}

.nav-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: var(--font-base);
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s ease-in-out;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
}

.nav-group-header:hover {
    color: var(--text-main);
    background: var(--bg-card-hover);
}

.nav-group-header.active-parent {
    color: var(--text-main);
    font-weight: 600;
}

.nav-group-title {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.nav-group-title i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.nav-chevron {
    font-size: 0.75rem;
    color: var(--text-subtle);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-chevron.rotated {
    transform: rotate(90deg);
}

.nav-group-children {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding-left: 1.85rem;
    padding-top: 0.2rem;
    padding-bottom: 0.25rem;
    overflow: hidden;
}

.nav-child-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.65rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: var(--font-sm);
    font-weight: 500;
    transition: all 0.15s ease-in-out;
}

.nav-child-item:hover {
    color: var(--text-main);
    background: var(--bg-card-hover);
}

.nav-child-item.active {
    color: var(--primary-hover);
    background: var(--primary-light);
    font-weight: 600;
}

.nav-child-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-subtle);
    transition: background 0.15s;
    flex-shrink: 0;
}

.nav-child-item:hover .nav-child-dot,
.nav-child-item.active .nav-child-dot {
    background: var(--primary);
}

/* ── Sidebar Section Divider ────────────────────────────────── */
.nav-section-label {
    padding: 0.75rem 0.75rem 0.25rem 0.75rem;
    font-size: var(--font-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-subtle);
}

/* ── Main Content Area ──────────────────────────────────────── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: calc(100% - var(--sidebar-width));
}

/* ── Top Navbar ─────────────────────────────────────────────── */
.navbar {
    height: var(--navbar-height);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 40;
}

.navbar-title {
    font-size: var(--font-md);
    font-weight: 600;
    color: var(--text-main);
    margin: 0;
}

.page-container {
    padding: 1.5rem;
    flex: 1;
    min-width: 0;
    width: 100%;
}

/* ── Standard Page Header ───────────────────────────────────── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.page-title {
    font-size: var(--font-2xl);
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.015em;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.page-subtitle {
    font-size: var(--font-base);
    color: var(--text-muted);
    margin: 0;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.breadcrumb-nav {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: var(--font-xs);
    color: var(--text-subtle);
    margin-bottom: 0.35rem;
}

.breadcrumb-nav a {
    color: var(--text-muted);
    text-decoration: none;
}
.breadcrumb-nav a:hover {
    color: var(--primary-hover);
}

/* ── Cards & Panels ─────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-card);
}

.card-title {
    font-size: var(--font-md);
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ── Metric / KPI Stat Cards ────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.dashboard-charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.dashboard-lists-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.15rem;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.stat-value {
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-main);
    line-height: 1.2;
    margin-bottom: 0.2rem;
}

.stat-label {
    font-size: var(--font-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: var(--font-base);
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    text-decoration: none;
    border: 1px solid transparent;
    line-height: 1.35;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.25);
}

.btn-outline {
    background: #ffffff;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-outline:hover {
    background: var(--bg-card-hover);
    border-color: #cbd5e1;
}

.btn-secondary {
    background: var(--bg-alt);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.btn-danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger-hover);
    border-color: var(--danger-hover);
}

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: var(--font-xs);
    border-radius: var(--radius-sm);
}

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}

/* ── Tables & Lists ─────────────────────────────────────────── */
.table-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table, .data-table {
    width: 100%;
    border-collapse: collapse;
    vertical-align: middle;
    margin: 0;
}

.table th, .data-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    color: var(--text-muted);
    font-size: var(--font-xs);
    text-transform: uppercase;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.table td, .data-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: var(--font-base);
    color: var(--text-main);
}

.table tr:last-child td, .data-table tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover, .data-table tbody tr:hover {
    background: rgba(248, 250, 252, 0.8);
}

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-pill);
    font-size: var(--font-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.2;
}

.badge-success { background: rgba(16, 185, 129, 0.12); color: #059669; }
.badge-warning { background: rgba(245, 158, 11, 0.12); color: #d97706; }
.badge-danger  { background: rgba(239, 68, 68, 0.12); color: #dc2626; }
.badge-info    { background: rgba(14, 165, 233, 0.12); color: #0284c7; }
.badge-neutral { background: rgba(100, 116, 139, 0.12); color: #475569; }
.badge-purple  { background: rgba(139, 92, 246, 0.12); color: #7c3aed; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: var(--font-sm);
    font-weight: 600;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    height: 40px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.85rem;
    color: var(--text-main);
    font-size: var(--font-base);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    color-scheme: light;
}

textarea.form-control {
    height: auto;
    min-height: 80px;
    padding: 0.65rem 0.85rem;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    background-size: 1rem;
    padding-right: 2.25rem;
    cursor: pointer;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.form-text {
    font-size: var(--font-xs);
    color: var(--text-muted);
    margin-top: 0.3rem;
}

/* ── Filter Bars ────────────────────────────────────────────── */
.filter-bar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-bottom: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    box-shadow: var(--shadow-xs);
}

/* ── Empty States ───────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.empty-state-icon {
    font-size: 2.25rem;
    color: var(--text-subtle);
    margin-bottom: 0.75rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--bg-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-state-title {
    font-size: var(--font-md);
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.empty-state-text {
    font-size: var(--font-sm);
    color: var(--text-muted);
    max-width: 380px;
    margin-bottom: 1.25rem;
}

/* ── Kanban & Tabs ──────────────────────────────────────────── */
.kanban-container {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 1.5rem;
    width: 100%;
    height: calc(100vh - 200px);
}

.kanban-col {
    flex: 0 0 290px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.85rem;
}

.tab-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    background: var(--bg-subtle);
    padding: 0.35rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.tab-pill {
    padding: 0.45rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: var(--font-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    background: transparent;
    color: var(--text-muted);
}

.tab-pill:hover {
    color: var(--text-main);
}

.tab-pill.active {
    background: var(--bg-card);
    color: var(--primary-hover);
    box-shadow: var(--shadow-xs);
}

/* ── Responsive Queries ─────────────────────────────────────── */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }
    .main-content {
        margin-left: 240px;
        width: calc(100% - 240px);
    }
    .dashboard-charts-grid,
    .dashboard-lists-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        width: 280px;
        box-shadow: none;
    }

    .sidebar.sidebar-open {
        transform: translateX(0);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.25);
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: rgba(15, 23, 42, 0.5);
        backdrop-filter: blur(4px);
        z-index: 45;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .mobile-menu-toggle {
        display: block !important;
    }

    .navbar {
        padding: 0 1rem;
    }

    .page-container {
        padding: 1rem;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .stat-grid {
        grid-template-columns: 1fr 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .page-actions {
        width: 100%;
    }

    .page-actions .btn {
        flex: 1;
    }

    .hide-on-mobile {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .stat-grid {
        grid-template-columns: 1fr;
    }
}
