* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 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);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
}

.language-toolbar {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 10px;
    box-shadow: var(--shadow);
}

body.view-dashboard .language-toolbar {
    top: 72px;
    right: 16px;
}

@media (max-width: 900px) {
    body.view-dashboard .language-toolbar {
        top: auto;
        bottom: calc(72px + env(safe-area-inset-bottom));
        right: 12px;
        border-radius: 999px;
        padding: 6px 8px;
        background: rgba(255, 255, 255, 0.96);
        box-shadow: var(--shadow-lg);
        z-index: 1200;
    }

    body.view-dashboard .language-toolbar label {
        display: none;
    }

    body.view-dashboard .language-toolbar select {
        min-width: 112px;
        padding: 6px 10px;
    }
}

.language-toolbar label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.language-toolbar select {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px 8px;
    background: #fff;
}

.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* Login Screen */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.login-card h1 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 2rem;
}

.login-card h2 {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1.25rem;
    font-weight: 400;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.error-message {
    color: var(--danger-color);
    margin-bottom: 1rem;
    padding: 0.75rem;
    background-color: #fee2e2;
    border-radius: 6px;
    display: none;
}

.error-message.show {
    display: block;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #1d4ed8;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #475569;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: #059669;
}

.btn-warning {
    background-color: var(--warning-color);
    color: white;
}

.btn-warning:hover {
    background-color: #d97706;
}

/* Navbar */
.navbar {
    background: var(--card-bg);
    padding: 1rem 2rem;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    min-height: 70px;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    flex-shrink: 1;
}

.nav-brand span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-logo {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    flex-shrink: 0;
}

.login-logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    vertical-align: middle;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

/* Container */
.container {
    display: flex;
    min-height: calc(100vh - 70px);
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: var(--card-bg);
    box-shadow: var(--shadow);
    padding: 1.5rem 0;
}

.nav-menu {
    list-style: none;
}

.nav-menu li {
    margin-bottom: 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
}

.nav-link:hover {
    background-color: var(--bg-color);
    color: var(--primary-color);
}

.nav-link.active {
    background-color: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
    border-right: 3px solid var(--primary-color);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2rem;
    color: var(--text-primary);
}

.filters {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Dashboard Welcome Bar */
.dashboard-welcome-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1.25rem;
    border-bottom: 2px solid var(--border-color);
    flex-wrap: wrap;
    gap: 1rem;
}

.dashboard-welcome-bar h1 {
    font-size: 1.875rem;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.dashboard-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0;
}

.dashboard-system-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-size: 0.8125rem;
    color: #15803d;
    font-weight: 500;
    white-space: nowrap;
}

.system-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    flex-shrink: 0;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.55; transform: scale(1.35); }
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    padding: 1.375rem 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1.25rem;
    border-top: 3px solid transparent;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.stat-card--blue   { border-top-color: #2563eb; }
.stat-card--purple { border-top-color: #7c3aed; }
.stat-card--amber  { border-top-color: #d97706; }
.stat-card--green  { border-top-color: #059669; }

.stat-icon {
    width: 58px;
    height: 58px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-icon--blue   { background: rgba(37, 99, 235, 0.1);  color: #2563eb; }
.stat-icon--purple { background: rgba(124, 58, 237, 0.1); color: #7c3aed; }
.stat-icon--amber  { background: rgba(217, 119, 6, 0.1);  color: #d97706; }
.stat-icon--green  { background: rgba(5, 150, 105, 0.1);  color: #059669; }

.stat-info {
    flex: 1;
    min-width: 0;
}

.stat-info h3 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
    line-height: 1;
}

.stat-info p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-card-arrow {
    color: var(--text-secondary);
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.stat-card:hover .stat-card-arrow {
    opacity: 1;
    transform: translateX(0);
}

/* Quick Actions */
.quick-actions-section {
    margin-top: 0.5rem;
}

.section-title {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 1rem;
}

.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.875rem;
}

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.625rem;
    padding: 1.25rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    color: var(--text-primary);
    font-weight: 500;
    text-align: center;
    line-height: 1.3;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.quick-action-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
    transform: translateY(-2px);
}

.quick-action-btn i {
    font-size: 1.375rem;
}

/* Table */
.table-container {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background-color: var(--bg-color);
}

.data-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.data-table tbody tr:hover {
    background-color: var(--bg-color);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    background-color: var(--bg-color);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

/* Image Lightbox */
.image-lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.image-lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    cursor: pointer;
}

.image-lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 10001;
}

.image-lightbox-content img {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.image-lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.image-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.image-lightbox-title {
    color: white;
    margin-top: 15px;
    font-size: 1.1rem;
    text-align: center;
}

/* Loading */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

/* Breadcrumb */
.breadcrumb {
    padding: 0.5rem 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.breadcrumb-item {
    color: var(--primary-color);
    cursor: pointer;
    text-decoration: underline;
}

.breadcrumb-item:hover {
    color: #1d4ed8;
}

.data-table tr[style*="cursor: pointer"]:hover {
    background-color: rgba(37, 99, 235, 0.05);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
    }

    .nav-menu {
        display: flex;
        overflow-x: auto;
    }

    .nav-menu li {
        margin-bottom: 0;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .filters {
        flex-direction: column;
        width: 100%;
    }

    .filters input {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 1rem;
    }

    .stat-info h3 {
        font-size: 1.625rem;
    }

    .quick-actions-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }

    .main-content {
        padding: 1.25rem;
    }
}

@media (max-width: 540px) {
    .navbar {
        padding: 0.75rem 1rem;
    }

    .nav-brand span {
        display: none;
    }

    .nav-user #currentUserInfo {
        display: none;
    }

    .nav-user {
        gap: 0.5rem;
    }

    .nav-user #changePasswordBtn,
    .nav-user #logoutBtn {
        padding: 0.6rem 0.7rem;
    }

    .nav-user #changePasswordButtonText,
    .nav-user #logoutButtonText {
        display: none;
    }

    .dashboard-welcome-bar {
        flex-direction: column;
        align-items: flex-start;
    }
}

