:root {
    --dash-nav-height: 70px;
    --dash-primary: #007bff;
    --dash-bg: #0a0a0b;
    --dash-card-bg: rgba(255, 255, 255, 0.03);
    --dash-border: rgba(255, 255, 255, 0.08);
    --dash-text: #e0e0e0;
    --dash-text-muted: rgba(224, 224, 224, 0.6);
}

* {
    box-sizing: border-box;
}

body.dashboard-body {
    background: var(--dash-bg);
    color: var(--dash-text);
    margin: 0;
    font-family: 'Inter', -apple-system, sans-serif;
    display: block;
}

/* Top Navigation */
.top-nav {
    width: 100%;
    height: var(--dash-nav-height);
    background: #000;
    border-bottom: 1px solid var(--dash-border);
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    z-index: 1000;
}

.nav-brand {
    display: flex;
    align-items: center;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #fff;
    font-weight: 700;
    font-size: 1.2rem;
}

.nav-links-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.top-row-nav {
    list-style: none;
    padding: 0;
    display: flex;
    gap: 10px;
    margin: 0;
}

.nav-item {
    margin: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    color: var(--dash-text-muted);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.nav-link:hover, .nav-link.active {
    background: var(--dash-card-bg);
    color: #fff;
}

.nav-link.active {
    background: rgba(0, 123, 255, 0.1);
    color: var(--dash-primary);
}

/* Main Content */
.main-content {
    margin-top: var(--dash-nav-height);
    flex: 1;
    min-height: calc(100vh - var(--dash-nav-height));
    padding: 30px;
}

/* Header */
.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.dash-title h1 {
    font-size: 1.8rem;
    margin: 0;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--dash-card-bg);
    border: 1px solid var(--dash-border);
    padding: 24px;
    border-radius: 16px;
    backdrop-filter: blur(10px);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
}

.stat-label {
    color: var(--dash-text-muted);
    font-size: 0.9rem;
}

/* Content Card */
.content-card {
    background: var(--dash-card-bg);
    border: 1px solid var(--dash-border);
    border-radius: 20px;
    padding: 30px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

/* Table */
.dash-table {
    width: 100%;
    border-collapse: collapse;
}

.dash-table th {
    text-align: left;
    padding: 15px;
    border-bottom: 1px solid var(--dash-border);
    color: var(--dash-text-muted);
    font-weight: 500;
}

.dash-table td {
    padding: 15px;
    border-bottom: 1px solid var(--dash-border);
}

/* Logout Button */
.btn-logout {
    margin-top: auto;
}

@media (max-width: 991px) {
    .nav-links-center { justify-content: flex-end; margin-right: 15px; }
    .sidebar-logo span, .nav-link span { display: none; }
    .top-nav { padding: 0 15px; }
}

@media (max-width: 768px) {
    .grid-2 { grid-template-columns: 1fr; }
    .main-content { padding: 20px 15px; }
    .content-card { padding: 20px; border-radius: 12px; }
    .dash-header { flex-direction: column; align-items: flex-start; gap: 15px; margin-bottom: 30px; }
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
    .stat-card { padding: 18px; }
    .stat-value { font-size: 1.5rem; }
    
    .user-profile span { display: none; } /* Hide email on small screens */
    .top-nav { height: 60px; }
    .main-content { margin-top: 60px; }
    :root { --dash-nav-height: 60px; }
}

@media (max-width: 480px) {
    .top-row-nav { gap: 5px; }
    .nav-link { padding: 8px 12px; }
    .btn { padding: 8px 12px; font-size: 0.8rem; }
    .dash-title h1 { font-size: 1.5rem; }
}

/* Scroll Indicators for Tables */
.table-responsive {
    overflow-x: auto;
    position: relative;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
}

.table-responsive::-webkit-scrollbar { height: 6px; }
.table-responsive::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 3px; }

/* Editable Table Styles */
.editable-cell { cursor: pointer; position: relative; }
.editable-cell:focus { outline: 1px solid var(--dash-primary); background: rgba(0, 123, 255, 0.05); }
.saving { animation: saving-fade 0.5s ease-in-out; }
@keyframes saving-fade {
    0% { background: rgba(40, 167, 69, 0.3); }
    100% { background: transparent; }
}
.error-cell { border: 1px solid #ff4d4d !important; }

/* Email Specifics */
.email-container { overflow: hidden; }
.email-list { height: 100%; }
.email-item { transition: all 0.2s; border-left: 3px solid transparent; }
.email-item:hover { background: rgba(255, 255, 255, 0.03); }
.email-item.active { background: rgba(0, 123, 255, 0.08); border-left-color: var(--dash-primary); }

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--dash-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

#viewBody { font-size: 0.95rem; line-height: 1.6; }
#viewBody b, #viewBody strong { color: #fff; }
#viewBody a { color: var(--dash-primary); text-decoration: none; }
#viewBody a:hover { text-decoration: underline; }

/* Chrome Autofill Dark Mode Fix */
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus, 
input:-webkit-autofill:active{
    -webkit-box-shadow: 0 0 0 30px #202124 inset !important;
    -webkit-text-fill-color: white !important;
    transition: background-color 5000s ease-in-out 0s;
}
