:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #64748b;
    --bg: #f8fafc;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger: #ef4444;
    --header-height: 64px;
}

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    padding: 2rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo {
    display: flex;
    align-items: center;
}

.logo img {
    height: 32px;
    width: 32px;
    display: block;
    object-fit: contain;
}

.brand-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
}

.sidebar-nav {
    flex: 1;
    padding: 0 1rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    text-decoration: none;
    color: var(--text-muted);
    border-radius: 0.75rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
    transition: all 0.2s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: #f1f5f9;
    color: var(--primary);
}

.sidebar-nav a.active ion-icon {
    color: var(--primary);
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: #e2e8f0;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-email {
    font-size: 0.8rem;
    font-weight: 600;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.btn-logout {
    color: var(--text-muted);
    font-size: 1.25rem;
    display: flex;
    transition: color 0.2s;
}

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

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

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

.content-header h1 {
    font-size: 1.75rem;
    margin: 0;
}

.tenant-badge {
    background: #eef2ff;
    color: var(--primary);
    padding: 0.4rem 0.8rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Generic Layout Elements */
.section {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Grids */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

@media (max-width: 1200px) {

    .grid-4,
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Forms (reusable) */
input,
select,
textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-family: inherit;
    font-size: 0.95rem;
    background: #fff;
}

button.primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

button.primary:hover {
    background: var(--primary-dark);
}

/* Responsive */
/* Responsive & Mobile Shell */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }

    .sidebar.active {
        transform: translateX(0);
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.1);
    }

    .mobile-header {
        display: flex;
    }

    .main-content {
        margin-left: 0;
        padding: 1.25rem;
        padding-top: calc(var(--header-height) + 1.5rem);
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
    }

    .sidebar .brand-name,
    .sidebar .user-details {
        display: block;
    }
}

.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    align-items: center;
    justify-content: space-between;
    z-index: 900;
}

.bottom-nav ion-icon {
    font-size: 1.6rem;
}

.menu-toggle {
    background: none;
    border: none;
    font-size: 1.75rem;
    color: var(--text);
    cursor: pointer;
    display: flex;
}

@media (max-width: 1024px) {
    .mobile-header {
        display: flex;
    }

    .content-header {
        display: none;
        /* Page title moved to mobile-header or inside page-content */
    }

    /* Table Cards */
    .responsive-table-container .data-table thead {
        display: none;
    }

    .responsive-table-container .data-table,
    .responsive-table-container .data-table tbody,
    .responsive-table-container .data-table tr,
    .responsive-table-container .data-table td {
        display: block;
        width: 100%;
    }

    .responsive-table-container .data-table tr {
        background: #fff;
        border: 1px solid var(--border);
        border-radius: 1rem;
        margin-bottom: 1rem;
        padding: 1rem;
    }

    .responsive-table-container .data-table td {
        border: none;
        padding: 0.5rem 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
    }

    .responsive-table-container .data-table td::before {
        content: attr(data-label);
        font-weight: 700;
        text-align: left;
        font-size: 0.75rem;
        color: var(--text-muted);
        text-transform: uppercase;
    }

    /* Global Grid Stacking */
    .grid-4,
    .grid-3,
    .grid-2 {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .section {
        padding: 1.25rem;
        margin-left: 0;
        margin-right: 0;
        width: 100%;
        box-sizing: border-box;
    }

    .grid-4,
    .grid-3,
    .grid-2 {
        grid-template-columns: 1fr !important;
        width: 100%;
    }
}

/* Footer */
.app-footer {
    margin-top: 4rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: left;
    line-height: 1.6;
}

.app-footer p {
    margin: 0.25rem 0;
}

.app-footer a {
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 1px dotted var(--border);
}

.app-footer a:hover {
    color: var(--text);
    border-bottom-style: solid;
}