:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #60a5fa;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --white: #ffffff;
    --sidebar-width: 240px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.5;
    min-height: 100vh;
}

#app {
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

.screen {
    min-height: 100vh;
}

/* Login Screen */
#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--gray-900) 0%, var(--gray-800) 100%);
    min-height: 100vh;
}

.login-container {
    background: var(--white);
    padding: 48px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.logo {
    margin-bottom: 32px;
}

.logo h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.logo p {
    color: var(--gray-500);
    font-size: 14px;
}

#login-form {
    text-align: left;
}

#login-form label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

#login-form input {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    font-family: inherit;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    margin-bottom: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#login-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.turnstile-container {
    margin-bottom: 16px;
    min-height: 65px;
    display: flex;
    justify-content: center;
}

#login-form button {
    width: 100%;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    color: var(--white);
    background: var(--primary);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
}

#login-form button:hover {
    background: var(--primary-dark);
}

#login-form button:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
}

.message {
    margin-top: 16px;
    padding: 12px;
    border-radius: var(--radius);
    font-size: 14px;
}

.message:empty {
    display: none;
}

.message.success {
    background: #d1fae5;
    color: #065f46;
}

.message.error {
    background: #fee2e2;
    color: #991b1b;
}

/* Dashboard Layout */
#dashboard-screen {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--gray-900);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--gray-700);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-header h1 {
    font-size: 20px;
    font-weight: 700;
}

.admin-badge {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 8px;
    background: var(--primary);
    border-radius: 4px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--gray-400);
    text-decoration: none;
    border-radius: var(--radius);
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 500;
}

.nav-item:hover {
    color: var(--white);
    background: var(--gray-800);
}

.nav-item.active {
    color: var(--white);
    background: var(--primary);
}

.nav-icon {
    font-size: 18px;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--gray-700);
}

.logout-btn {
    width: 100%;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    color: var(--gray-400);
    background: transparent;
    border: 1px solid var(--gray-700);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    color: var(--white);
    border-color: var(--gray-500);
    background: var(--gray-800);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 24px;
    min-height: 100vh;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

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

.page-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
}

.header-date {
    font-size: 14px;
    color: var(--gray-500);
}

.page-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

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

.stat-card {
    background: var(--white);
    padding: 20px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-card.warning {
    border-left: 4px solid var(--warning);
}

.stat-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.2;
}

.stat-label {
    font-size: 13px;
    color: var(--gray-500);
    font-weight: 500;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
}

.view-all {
    font-size: 13px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.view-all:hover {
    text-decoration: underline;
}

/* Activity List */
.activity-list {
    padding: 16px 24px;
    max-height: 400px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-100);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 36px;
    height: 36px;
    background: var(--gray-100);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-client {
    font-weight: 600;
    color: var(--gray-900);
    font-size: 14px;
}

.activity-action {
    color: var(--gray-600);
    font-size: 13px;
    margin-top: 2px;
}

.activity-time {
    font-size: 12px;
    color: var(--gray-400);
    flex-shrink: 0;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.data-table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table tr:hover {
    background: var(--gray-50);
}

.data-table td {
    color: var(--gray-900);
}

.loading-text {
    color: var(--gray-500);
    padding: 24px;
    text-align: center;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 9999px;
}

.status-badge.active {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.inactive {
    background: var(--gray-200);
    color: var(--gray-600);
}

.status-badge.pending {
    background: #fef3c7;
    color: #92400e;
}

/* Buttons */
.btn-primary {
    display: inline-block;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    color: var(--white);
    background: var(--primary);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}

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

.btn-secondary {
    display: inline-block;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    color: var(--gray-700);
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-secondary-small {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    color: var(--gray-700);
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary-small:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.btn-danger {
    color: var(--error);
    border-color: var(--error);
}

.btn-danger:hover {
    background: var(--error);
    color: var(--white);
}

/* Form Inputs */
.search-input,
.filter-select {
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--gray-900);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus,
.filter-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.search-input {
    min-width: 200px;
}

.filter-select {
    min-width: 150px;
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 0;
    margin-bottom: 16px;
    font-size: 14px;
}

.breadcrumb-item {
    color: var(--gray-500);
    cursor: pointer;
}

.breadcrumb-item:hover {
    color: var(--primary);
}

.breadcrumb-item.active {
    color: var(--gray-900);
    font-weight: 500;
    cursor: default;
}

.breadcrumb-separator {
    color: var(--gray-400);
}

/* Files Grid */
.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.file-item {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
}

.file-item:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.file-icon {
    font-size: 40px;
}

.file-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-900);
    word-break: break-word;
}

.file-meta {
    font-size: 11px;
    color: var(--gray-500);
}

.folder-item {
    background: var(--gray-50);
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 20px;
}

.pagination-btn {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    color: var(--gray-700);
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-info {
    font-size: 14px;
    color: var(--gray-600);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-large {
    max-width: 700px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    background: var(--white);
    z-index: 1;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray-500);
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.modal-close:hover {
    color: var(--gray-900);
}

.modal-body {
    padding: 24px;
}

/* Client Detail Modal */
.client-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.client-detail-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.client-detail-field.full-width {
    grid-column: span 2;
}

.client-detail-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
}

.client-detail-value {
    font-size: 14px;
    color: var(--gray-900);
}

.client-modules {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--gray-200);
}

.client-modules h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 12px;
}

.module-status-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.module-status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--gray-50);
    border-radius: var(--radius);
}

.module-status-name {
    font-weight: 500;
    color: var(--gray-900);
    font-size: 13px;
}

/* Loading Overlay */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading p {
    margin-top: 16px;
    color: var(--gray-500);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: fixed;
        top: auto;
        bottom: 0;
        height: auto;
        flex-direction: row;
    }

    .sidebar-header {
        display: none;
    }

    .sidebar-nav {
        flex-direction: row;
        justify-content: space-around;
        padding: 8px;
        width: 100%;
    }

    .nav-item {
        flex-direction: column;
        gap: 4px;
        padding: 8px 12px;
        font-size: 10px;
    }

    .nav-label {
        display: block;
    }

    .sidebar-footer {
        display: none;
    }

    .main-content {
        margin-left: 0;
        margin-bottom: 80px;
        padding: 16px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .page-actions {
        flex-wrap: wrap;
        width: 100%;
    }

    .search-input,
    .filter-select {
        flex: 1;
        min-width: 0;
    }

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

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

    .client-detail-field.full-width {
        grid-column: span 1;
    }

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

    .login-container {
        margin: 16px;
        padding: 32px 24px;
    }

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

/* System Health Grid */
.health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.health-card {
    display: flex;
    flex-direction: column;
    padding: 16px;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    transition: all 0.2s;
}

.health-card:hover {
    border-color: var(--gray-400);
    box-shadow: var(--shadow-sm);
}

.health-card.healthy {
    border-color: var(--success);
    background: #f0fdf4;
}

.health-card.unhealthy {
    border-color: var(--error);
    background: #fef2f2;
}

.health-card.checking {
    border-color: var(--warning);
    background: #fffbeb;
}

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

.health-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-900);
}

.health-status-icon {
    font-size: 18px;
}

.health-status {
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.health-status.ok {
    color: var(--success);
}

.health-status.error {
    color: var(--error);
}

.health-status.checking {
    color: var(--warning);
}

.health-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: var(--gray-600);
}

.health-detail {
    display: flex;
    align-items: center;
    gap: 6px;
}

.health-detail-icon {
    font-size: 14px;
}

.health-url {
    font-size: 11px;
    color: var(--gray-500);
    margin-top: 8px;
    word-break: break-all;
}
