:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --bg-color: #F3F4F6;
    --text-main: #111827;
    --text-muted: #6B7280;
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.08);
    --danger: #EF4444;
    --success: #10B981;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
}

input, textarea {
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
}

html {
    width: 100%;
    margin: 0;
    padding: 0;
    font-size: 12px !important;
}

body {
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, hsla(253,16%,7%,0.04) 0, transparent 50%), 
        radial-gradient(at 50% 0%, hsla(225,39%,30%,0.06) 0, transparent 50%), 
        radial-gradient(at 100% 0%, hsla(339,49%,30%,0.06) 0, transparent 50%);
    color: var(--text-main);
    min-height: 100vh;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    font-size: 12px !important;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--glass-shadow);
}

.screen {
    display: none;
    min-height: 100vh;
    width: 100%;
}

.screen.active {
    display: flex;
    animation: fadeIn 0.4s ease-out;
}

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

/* --- LOGIN SCREEN --- */
#login-screen {
    min-height: 100vh;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}

.login-card {
    width: 100%;
    max-width: 380px !important;
    padding: 24px 28px !important;
    text-align: center;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
}

.login-header {
    margin-bottom: 16px;
}

.login-header img {
    max-width: 190px !important;
    height: auto;
    margin: 0 auto 10px;
    display: block;
}

.logo-circle {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary), #818CF8);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    color: white;
}

.logo-circle svg {
    width: 32px;
    height: 32px;
}

.login-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.4;
}

.input-group {
    margin-bottom: 14px;
    text-align: left;
}

.input-group {
    margin-bottom: 20px;
    text-align: left;
}

.input-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-muted);
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid #D1D5DB;
    background: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    outline: none;
    transition: all 0.2s;
}

.input-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

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

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary-small {
    padding: 10px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.error-msg {
    color: var(--danger);
    font-size: 0.85rem;
    margin-bottom: 16px;
    background: rgba(239, 68, 68, 0.1);
    padding: 8px;
    border-radius: 6px;
}

.hidden {
    display: none !important;
}

.hidden-input {
    display: none;
}

/* --- DASHBOARD SCREEN --- */
#dashboard-screen {
    display: flex;
}

.sidebar {
    width: 165px;
    height: 100vh;
    border-radius: 0;
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 20px 8px;
    position: fixed;
    z-index: 10;
}

.sidebar-brand h2 {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 30px;
    letter-spacing: -0.5px;
    padding-left: 4px;
}

.sidebar-nav {
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 6px;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.74rem;
    transition: all 0.2s;
}

.nav-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.nav-item:hover, .nav-item.active {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary);
}

.btn-secondary {
    padding: 6px 8px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.74rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.btn-secondary:hover {
    background: #F3F4F6;
    color: var(--text-main);
}

.btn-danger-text {
    color: var(--danger) !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
}

.btn-danger-text:hover {
    background: rgba(239, 68, 68, 0.1) !important;
}

.main-content {
    flex: 1;
    margin-left: 165px;
    padding: 16px 20px;
    min-width: 0;
    width: calc(100% - 165px) !important;
    max-width: calc(100% - 165px) !important;
    box-sizing: border-box !important;
}

.content-wrapper {
    width: 100% !important;
    max-width: 100% !important;
}

.table-card {
    overflow: hidden;
    width: 100% !important;
}

.table-container {
    background: white;
    border-radius: 12px;
    display: block !important;
    overflow-x: auto !important;
    overflow-y: auto !important;
    max-height: 65vh;
    width: 100% !important;
    max-width: 100% !important;
    scrollbar-width: auto;
    scrollbar-color: var(--primary) #F1F5F9;
    cursor: grab;
}

.table-container:active {
    cursor: grabbing;
}

.table-container::-webkit-scrollbar {
    height: 10px;
}

.table-container::-webkit-scrollbar-track {
    background: #F1F5F9;
    border-radius: 10px;
}

.table-container::-webkit-scrollbar-thumb {
    background: linear-gradient(90deg, var(--primary), #818CF8);
    border-radius: 10px;
    border: 2px solid #F1F5F9;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.topbar h1 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 2px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-profile span {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
}

.avatar {
    width: 34px;
    height: 34px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.82rem;
}

/* Google Drive Bar */
.drive-config-bar {
    padding: 16px;
    margin-bottom: 20px;
}

.drive-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.drive-header h3 {
    font-size: 0.88rem;
    font-weight: 700;
}

.drive-input-group {
    display: flex;
    gap: 10px;
}

.drive-input-group input {
    flex: 1;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #D1D5DB;
    outline: none;
    font-size: 0.80rem;
}

/* Upload Dropzone */
.upload-zone {
    padding: 18px 16px;
    text-align: center;
    border: 2px dashed #CBD5E1;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.03);
}

.drop-icon {
    width: 36px;
    height: 36px;
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
}

.drop-icon svg {
    width: 18px;
    height: 18px;
}

.upload-zone h2 {
    font-size: 0.88rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.upload-zone p {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

/* KPIs & Grid */
.bi-dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.kpi-card {
    padding: 10px 12px;
    text-align: center;
}

.kpi-title {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 2px;
}

.kpi-value {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-main);
}

.text-success { color: var(--success); }
.text-danger { color: #dc2626; }

/* Data Table Header & Actions */
.table-card-header {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.alerts-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.table-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-left: auto;
}

.data-table, .modern-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    min-width: 1000px;
}

.data-table th, .modern-table th {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #F8FAFC;
    color: var(--text-muted);
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 6px 8px;
    border-bottom: 2px solid #E2E8F0;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.data-table td, .modern-table td {
    padding: 5px 8px;
    border-bottom: 1px solid #E2E8F0;
    color: var(--text-main);
    font-size: 0.72rem;
    font-weight: 500;
    vertical-align: middle;
}

.data-table tbody tr:hover, .modern-table tbody tr:hover {
    background-color: #F1F5F9;
}

/* Sticky Columns for Admin Table */
#view-admin .data-table {
    border-collapse: separate !important;
    border-spacing: 0 !important;
}

#view-admin .sticky-col-1, .sticky-col-1 {
    position: sticky !important;
    left: 0px !important;
    z-index: 25 !important;
    background-color: #F8FAFC !important;
}

#view-admin td.sticky-col-1, td.sticky-col-1 {
    background-color: #FFFFFF !important;
}

#view-admin .sticky-col-2, .sticky-col-2 {
    position: sticky !important;
    left: 36px !important;
    z-index: 25 !important;
    background-color: #F8FAFC !important;
    box-shadow: 4px 0 8px -2px rgba(0, 0, 0, 0.12) !important;
    border-right: 2px solid #CBD5E1 !important;
}

#view-admin td.sticky-col-2, td.sticky-col-2 {
    background-color: #FFFFFF !important;
}

#view-admin tr:hover td.sticky-col-1,
#view-admin tr:hover td.sticky-col-2,
tr:hover td.sticky-col-1,
tr:hover td.sticky-col-2 {
    background-color: #F1F5F9 !important;
}

.badge-auth {
    font-family: monospace;
    font-size: 0.78rem;
    background: #F1F5F9;
    padding: 4px 8px;
    border-radius: 6px;
    color: #334155;
    word-break: break-all;
    display: inline-block;
    max-width: 220px;
}

.empty-state {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
}

/* Loaders */
.loader {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.large-loader {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(79, 70, 229, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 992px) {
    .sidebar { width: 80px; padding: 16px; }
    .sidebar-brand h2, .sidebar-footer button, .nav-item span { display: none; }
    .main-content { margin-left: 80px; padding: 16px; }
    .kpi-row { grid-template-columns: repeat(2, 1fr); }
}
