:root {
    --primary: hsl(220, 50%, 20%);
    --primary-light: hsl(220, 50%, 30%);
    --gold: hsl(45, 80%, 50%);
    --gold-dark: hsl(45, 80%, 40%);
    --accent: hsl(190, 70%, 45%);
    --bg: hsl(220, 20%, 97%);
    --sidebar-bg: hsl(220, 50%, 15%);
    --card-bg: rgba(255, 255, 255, 0.9);
    --text-main: hsl(220, 30%, 10%);
    --text-muted: hsl(220, 10%, 45%);
    --border: hsl(220, 20%, 90%);
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.05);
    --glass: rgba(255, 255, 255, 0.7);
    --radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
aside {
    width: 280px;
    background: var(--sidebar-bg);
    color: white;
    padding: 1.25rem 1rem 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    overflow: hidden;
}

aside nav {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 1rem;
}

aside::-webkit-scrollbar {
    width: 4px;
}

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

aside .logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding: 0 0.5rem;
    color: var(--gold);
}

aside .logo i {
    font-size: 2rem;
}

aside .logo strong {
    display: block;
    font-size: 1.2rem;
    letter-spacing: 1px;
    text-transform: uppercase;
}

aside .logo small {
    display: block;
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.55);
    letter-spacing: 0.01em;
    line-height: 1.35;
    text-transform: none;
}

.sidebar-footer {
    padding: 0.9rem 1rem 1rem;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.45);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-logout {
    margin-top: 0.75rem;
    color: #f87171 !important;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.menu-toggle {
    display: none;
    background: white;
    border: 1px solid var(--border);
    color: var(--primary);
    padding: 0.45rem 0.6rem;
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 1000;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem 1rem;
    overflow-y: auto;
}

.modal .close {
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}

.case-tabs, .settings-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

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

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

.breadcrumb {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.breadcrumb button {
    background: none;
    border: none;
    color: var(--primary);
    padding: 0;
    font-weight: 600;
    cursor: pointer;
}

.nav-label {
    font-size: 0.7rem;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.3);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin: 1.5rem 0 0.5rem 1rem !important;
    cursor: default !important;
    background: none !important;
}

nav ul {
    list-style: none;
}

nav li {
    padding: 0.7rem 1rem;
    margin-bottom: 0.2rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
    font-weight: 500;
}

nav li i {
    width: 20px;
    text-align: center;
}

nav li:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

nav li.active {
    background: var(--gold);
    color: var(--primary);
    font-weight: 700;
}

nav li.active i {
    color: var(--primary);
}

/* Main Content */
main {
    flex: 1;
    margin-left: 280px;
    padding: 2rem 3rem;
}

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

h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
}

/* Cards & Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.stat-card:hover {
    border-color: #cbd5e1;
}

.stat-card.kpi {
    text-align: left;
    background: white;
    cursor: pointer;
    width: 100%;
}

.stat-value.tone-alert {
    color: #b45309;
}

.stat-hint, .empty-note {
    margin-top: 0.45rem;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 500;
}

.dash-heading, .dash-actions, .card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.dash-heading {
    margin-bottom: 1.25rem;
}

.dash-heading p, .card-head span {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.dash-actions {
    justify-content: flex-end;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.9rem;
    margin-bottom: 1.25rem;
}

.dash-layout {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 1rem;
}

.chart-box {
    height: 240px;
    margin-top: 1rem;
}

.list-row {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: transparent;
    border-radius: 0;
    text-align: left;
    font-weight: 500;
}

.list-row:last-child {
    border-bottom: 0;
}

.list-row small, .search-hit small {
    display: block;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
}

.list-row:hover, .search-hit:hover {
    background: #f8fafc;
}

.global-search {
    position: relative;
    flex: 1;
    max-width: 420px;
    margin: 0 1rem;
}

.global-search i {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.global-search input {
    padding-left: 2.2rem;
    border-radius: 999px;
    background: #f8fafc;
}

.search-results {
    position: absolute;
    top: calc(100% + 0.4rem);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    z-index: 30;
    padding: 0.35rem;
}

.search-hit {
    width: 100%;
    display: block;
    text-align: left;
    background: transparent;
    border-radius: 8px;
    padding: 0.65rem 0.75rem;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    margin-top: 0.5rem;
}

.content-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 2rem;
    margin-bottom: 2rem;
}

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

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--primary);
}

input, select, textarea {
    width: 100%;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition);
    background: white;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(30, 144, 255, 0.1);
}

button {
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

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

.btn-primary:hover {
    background: var(--primary-light);
}

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

.btn-gold:hover {
    background: var(--gold-dark);
}

/* Settings Tabs */
.settings-tabs button {
    background: #f1f5f9;
    color: var(--text-muted);
}

.settings-tabs button.active {
    background: var(--primary);
    color: white;
}

.settings-tab-content {
    animation: fadeIn 0.3s ease-out;
}

.member-tab-content {
    animation: fadeIn 0.3s ease-out;
}

/* Status Badges */
.badge.pending { background: #fef3c7; color: #92400e; }
.badge.approved { background: #dcfce7; color: #166534; }
.badge.rejected { background: #fee2e2; color: #991b1b; }
.badge.paid { background: #dbeafe; color: #1e40af; }
.badge.in-waiting-period { background: #e0e7ff; color: #3730a3; }
.badge.lapsed { background: #fee2e2; color: #991b1b; font-weight: 700; }

.diary-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.75rem;
}

.diary-weekend {
    background: #fff7ed;
    border-color: #fdba74;
}
.badge.active { background: #dcfce7; color: #166534; }

.alert-card {
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 1rem;
    background: #f8fafc;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    font-weight: 700;
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

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

/* Badges & Status */
.badge {
    background: #e2e8f0;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
}

.badge-gold {
    background: #fef3c7;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--gold-dark);
}

.status-active {
    color: #059669;
    font-weight: 700;
    font-size: 0.85rem;
}

.btn-small {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
    background: #f1f5f9;
    color: var(--primary);
}

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

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: var(--radius);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.close-modal {
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

@media (max-width: 960px) {
    .menu-toggle {
        display: inline-flex;
        align-items: center;
    }

    aside {
        transform: translateX(-105%);
        transition: transform 0.2s ease;
        box-shadow: none;
    }

    body.nav-open aside {
        transform: translateX(0);
        box-shadow: 8px 0 30px rgba(0, 0, 0, 0.25);
    }

    main {
        margin-left: 0;
        padding: 1rem;
    }

    header {
        margin-bottom: 1.25rem;
    }

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

    .user-profile span {
        display: none;
    }

    header {
        flex-wrap: wrap;
    }

    .global-search {
        order: 3;
        max-width: none;
        flex: 1 1 100%;
        margin: 0.5rem 0 0;
    }

    .kpi-grid, .dash-layout, .diary-grid {
        grid-template-columns: 1fr;
    }
}
