:root {
    /* DLRG Brand Colors */
    --dlrg-red: #E30613;
    --dlrg-red-dark: #B00510;
    --dlrg-red-light: #FF5A4F;
    --dlrg-yellow: #FFD100;
    --dlrg-yellow-dark: #C8A200;
    --dlrg-yellow-light: #FFE566;

    /* Theme Colors (Dark Mode Default for Premium Feel) */
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;

    /* Semantic & Accents */
    --accent-primary: var(--dlrg-red);
    --accent-secondary: var(--dlrg-yellow);
    --accent-green: #4ade80;
    --accent-red: #f87171;
    --accent-blue: #38bdf8;
    --accent-indigo: #818cf8;

    --sidebar-width: 280px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: radial-gradient(circle at top right, #1e293b, #0f172a);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar-header {
    margin-bottom: 3rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(to right, var(--dlrg-red), var(--dlrg-yellow));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.025em;
    text-transform: uppercase;
}

.nav-links {
    list-style: none;
    flex-grow: 1;
    overflow-y: auto;
    margin-right: -1rem;
    padding-right: 1rem;
}

.nav-item {
    margin-bottom: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    transform: translateX(4px);
}

.nav-link.active {
    background: rgba(227, 6, 19, 0.15);
    color: var(--dlrg-red-light);
    font-weight: 600;
    border-left: 3px solid var(--dlrg-red);
}

.nav-link i {
    width: 20px;
    margin-right: 12px;
}

/* Main Content */
.main-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 2.5rem;
    position: relative;
}

.page {
    display: none;
    animation: slideIn 0.4s cubic-bezier(0, 0, 0.2, 1);
    max-width: 1400px;
    margin: 0 auto;
}

.page.active {
    display: block;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

header {
    margin-bottom: 2.5rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.15rem;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.125rem;
}

.page header {
    position: sticky;
    top: -1.5rem;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    z-index: 10;
    padding-top: 1.5rem;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

/* Cards */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    margin-bottom: 2rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 25px 30px -5px rgba(0, 0, 0, 0.4);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

/* UI Elements */
.filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    align-items: center;
}

select,
input {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.875rem 1.25rem;
    border-radius: 14px;
    font-size: 0.9375rem;
    outline: none;
    transition: all 0.2s;
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);
}

select:focus,
input:focus {
    border-color: var(--dlrg-red);
    box-shadow: 0 0 0 4px rgba(227, 6, 19, 0.1);
}

.btn {
    padding: 0.875rem 1.75rem;
    border-radius: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    font-size: 0.875rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--dlrg-red) 0%, var(--dlrg-red-dark) 100%);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(227, 6, 19, 0.39);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(227, 6, 19, 0.45);
    background: linear-gradient(135deg, var(--dlrg-red-light) 0%, var(--dlrg-red) 100%);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Tables */
.table-container {
    max-height: 65vh;
    overflow-y: auto;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th {
    position: sticky;
    top: 0;
    background: #1e293b;
    z-index: 5;
    text-align: left;
    color: var(--dlrg-yellow);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 1.25rem 1rem;
    border-bottom: 2px solid var(--border-color);
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
}

th:hover {
    background: #2d3e5a;
}

th::after {
    content: '\f0dc';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    margin-left: 8px;
    opacity: 0.3;
    font-size: 0.7rem;
}

th.sort-asc::after {
    content: '\f0de';
    opacity: 1;
    color: var(--dlrg-red-light);
}

th.sort-desc::after {
    content: '\f0dd';
    opacity: 1;
    color: var(--dlrg-red-light);
}

td {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.9375rem;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.badge {
    display: inline-flex;
    padding: 0.35rem 0.85rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-in {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.badge-out {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Status Indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.pulse-active {
    background-color: #22c55e;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(34, 197, 94, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}

/* Chips */
.group-chips {
    display: flex;
    overflow-x: auto;
    gap: 0.75rem;
    padding: 0.75rem 0;
    margin-bottom: 1rem;
    scrollbar-width: none;
    position: sticky;
    top: 4.5rem;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    z-index: 8;
    border-bottom: 1px solid var(--border-color);
}

.chip {
    padding: 0.625rem 1.25rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.chip:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.chip.active {
    background: var(--dlrg-red);
    border-color: var(--dlrg-red);
    color: white;
    box-shadow: 0 4px 12px rgba(227, 6, 19, 0.3);
}

/* Member Cards & Compact Group Overview */
.group-stats-bar {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.55rem 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.group-sections-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
}

.group-sections-grid.single-column {
    grid-template-columns: 1fr;
}

.compact-group-card {
    padding: 0.85rem 1rem !important;
    margin-bottom: 0 !important;
    border-radius: 16px !important;
}

.member-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

.member-grid.compact-grid {
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 0.5rem;
}

.member-card {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.member-card.compact-member {
    padding: 0.55rem 0.7rem;
    border-radius: 10px;
}

.member-card.compact-member .member-name {
    font-size: 0.88rem;
    margin-bottom: 0.1rem;
}

.member-card.compact-member .member-stats {
    margin-top: 0.35rem;
    padding-top: 0.35rem;
}

.member-card.compact-member .stat-row {
    font-size: 0.73rem;
    margin-bottom: 0.15rem;
}

.member-card.compact-member .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.68rem;
    border-radius: 8px;
    margin-top: 0.35rem;
    min-height: auto;
}

.member-card:hover {
    transform: translateY(-4px);
    background: rgba(15, 23, 42, 0.8);
    border-color: var(--dlrg-yellow);
}

.member-card.present {
    border-left: 5px solid #22c55e;
}

.member-card.absent {
    border-left: 5px solid var(--text-secondary);
}

.member-name {
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.member-id {
    font-size: 0.75rem;
    color: var(--dlrg-yellow);
    font-family: monospace;
    letter-spacing: 0.05em;
}

.member-stats {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8125rem;
    margin-bottom: 0.5rem;
}

.stat-label {
    color: var(--text-secondary);
}

.stat-value {
    color: var(--text-primary);
    font-weight: 600;
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #1e293b 0%, #080c14 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.login-card {
    background: rgba(30, 41, 59, 0.5);
    backdrop-filter: blur(30px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 32px;
    padding: 4rem 3rem;
    width: 90%;
    max-width: 440px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
}

.login-form input {
    width: 100%;
    text-align: center;
    font-size: 1.25rem;
    padding: 1rem;
    border-radius: 16px;
    margin-bottom: 1.5rem;
    background: rgba(0, 0, 0, 0.3);
    letter-spacing: 0.2em;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--dlrg-red);
}

/* Drop Zone */
#ga-drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 20px;
    padding: 4rem 2rem;
    background: rgba(15, 23, 42, 0.3);
    transition: all 0.3s;
}

#ga-drop-zone:hover {
    border-color: var(--dlrg-yellow);
    background: rgba(255, 209, 0, 0.05);
}

#ga-drop-zone i {
    font-size: 3.5rem;
    color: var(--dlrg-red);
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 0 10px rgba(227, 6, 19, 0.2));
}

.scrollable-grid-container {
    max-height: 65vh;
    overflow-y: auto;
    padding-right: 0.75rem;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.modal-content {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 2.5rem;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: modalIn 0.3s ease-out;
}

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

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

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
}

.form-group input,
.form-group select {
    width: 100%;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    body {
        flex-direction: column;
        overflow: auto;
    }

    .sidebar {
        width: 100%;
        padding: 1rem;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        height: auto;
        z-index: 20;
    }

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

    .nav-links {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        margin-right: 0;
        padding-right: 0;
        gap: 0.5rem;
        padding-bottom: 0.5rem;
    }

    .nav-item {
        margin-bottom: 0;
    }

    .nav-link {
        white-space: nowrap;
        padding: 0.5rem 0.75rem;
    }

    .sidebar-footer {
        display: none;
    }

    .main-content {
        padding: 1rem;
        overflow-y: visible; /* Since body scrolls now */
    }

    .page header {
        position: relative;
        top: auto;
        padding-top: 1rem;
        margin-bottom: 1rem;
    }

    h1 {
        font-size: 1.75rem;
    }

    .card {
        padding: 1.25rem;
        margin-bottom: 1.25rem;
    }

    .btn, input, select {
        min-height: 44px;
    }

    .modal-content {
        padding: 1.5rem;
    }

    .filters {
        flex-direction: column;
        align-items: stretch;
    }

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

    .table-container {
        overflow-x: auto;
    }

    table {
        display: table;
        white-space: nowrap;
        width: max-content; /* Minimize column width stretching */
    }

    th, td {
        padding: 0.5rem 0.25rem; /* Minimal horizontal padding */
        font-size: 0.85rem;
    }

    .group-chips {
        top: 0; /* Adjust sticky top for chips if necessary */
    }

    .login-card {
        padding: 2.5rem 1.5rem;
        width: 95%;
    }

    .group-sections-grid {
        grid-template-columns: 1fr;
    }

    /* Group Overview Card Mobile Tuning */
    .member-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 0.4rem;
    }

    .member-card {
        padding: 0.5rem;
    }

    .member-name {
        font-size: 0.85rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .member-stats {
        margin-top: 0.35rem;
        padding-top: 0.35rem;
    }

    .stat-row {
        margin-bottom: 0.15rem;
        font-size: 0.7rem;
    }
}