*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--krome-font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--krome-text-primary);
    background-color: var(--krome-bg);
}

a {
    color: var(--krome-primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-weight: 600;
}

button {
    font-family: inherit;
}

input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

/* Form elements */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="date"],
select,
textarea {
    padding: 8px 12px;
    border: 1px solid var(--krome-border);
    border-radius: var(--krome-radius-sm);
    outline: none;
    transition: border-color var(--krome-transition-fast);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
    border-color: var(--krome-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* ===== Common page utilities ===== */

.ess-page-header {
    margin-bottom: 24px;
}

.ess-page-header h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--krome-gray-900);
    margin: 0 0 4px;
}

.ess-page-header p {
    font-size: 14px;
    color: var(--krome-gray-500);
    margin: 0;
}

.ess-section-card {
    background: var(--krome-surface);
    border: 1px solid var(--krome-border);
    border-radius: var(--krome-radius-lg);
}

.ess-section-card .section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--krome-gray-100);
}

.ess-section-card .section-header .section-icon {
    font-size: 20px;
    color: var(--krome-primary);
}

.ess-section-card .section-header h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--krome-gray-900);
    margin: 0;
}

.ess-section-card .section-body {
    padding: 16px 20px;
}

/* Status badges */
.ess-status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.ess-status-badge.active { background: #dcfce7; color: #16a34a; }
.ess-status-badge.onleave { background: #fef3c7; color: #d97706; }
.ess-status-badge.suspended { background: #fee2e2; color: #dc2626; }
.ess-status-badge.terminated { background: #f1f5f9; color: #64748b; }
.ess-status-badge.resigned { background: #ede9fe; color: #7c3aed; }
.ess-status-badge.draft { background: #f1f5f9; color: #64748b; }
.ess-status-badge.expired { background: #fef3c7; color: #d97706; }
.ess-status-badge.renewed { background: #ede9fe; color: #7c3aed; }
.ess-status-badge.archived { background: #f1f5f9; color: #64748b; }
.ess-status-badge.submitted { background: #dbeafe; color: #2563eb; }
.ess-status-badge.approved { background: #dcfce7; color: #16a34a; }
.ess-status-badge.rejected { background: #fee2e2; color: #dc2626; }
.ess-status-badge.completed { background: #dcfce7; color: #16a34a; }
.ess-status-badge.cancelled { background: #f1f5f9; color: #64748b; }
.ess-status-badge.pending { background: #fef3c7; color: #d97706; }

/* Buttons */
.ess-btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--krome-primary);
    color: white;
    border: none;
    border-radius: var(--krome-radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--krome-transition-fast);
}

.ess-btn-primary:hover:not(:disabled) {
    background: var(--krome-primary-hover);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.ess-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ess-btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--krome-surface);
    color: var(--krome-text-primary);
    border: 1px solid var(--krome-border);
    border-radius: var(--krome-radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--krome-transition-fast);
}

.ess-btn-secondary:hover:not(:disabled) {
    background: var(--krome-gray-50);
    border-color: var(--krome-gray-300);
}

.ess-btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--krome-error);
    color: white;
    border: none;
    border-radius: var(--krome-radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--krome-transition-fast);
}

.ess-btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

/* Loading state */
.ess-loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 64px;
    color: var(--krome-gray-500);
    font-size: 14px;
}

.ess-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--krome-border);
    border-top-color: var(--krome-primary);
    border-radius: 50%;
    animation: ess-spin 0.8s linear infinite;
}

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

/* Empty state */
.ess-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 64px;
    color: var(--krome-gray-500);
    font-size: 14px;
}

.ess-empty-state .material-icons {
    font-size: 48px;
    color: var(--krome-gray-300);
}

/* Info grid — used across profile, detail pages */
.ess-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

.ess-info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ess-info-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--krome-gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ess-info-value {
    font-size: 14px;
    color: var(--krome-gray-900);
}

.ess-info-value code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
    color: var(--krome-primary);
    background: var(--krome-primary-light);
    padding: 2px 8px;
    border-radius: 4px;
}

/* Auth checking state */
.loading-auth {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    background: var(--krome-bg);
    z-index: 9998;
}

.loading-auth-spinner {
    position: relative;
    width: 48px;
    height: 48px;
}

.loading-auth-ring {
    position: absolute;
    border-radius: 50%;
    border: 3px solid transparent;
    animation: ess-spin 0.9s linear infinite;
}

.loading-auth-ring:nth-child(1) {
    inset: 0;
    border-top-color: var(--krome-primary);
}

.loading-auth-ring:nth-child(2) {
    inset: 6px;
    border-top-color: #818CF8;
    animation-delay: 0.3s;
}

.loading-auth-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--krome-gray-500);
    letter-spacing: 0.01em;
}

/* 404 Not Found page */
.not-found-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.not-found-content {
    text-align: center;
}

.not-found-content h1 {
    font-size: 72px;
    font-weight: 700;
    color: var(--krome-gray-300);
    line-height: 1;
    margin-bottom: 8px;
}

.not-found-content p {
    font-size: 16px;
    color: var(--krome-gray-500);
    margin: 0 0 24px;
}

.not-found-content a {
    color: var(--krome-primary);
    font-weight: 500;
}

/* Blazor error UI */
#blazor-error-ui {
    background: #fef2f2;
    bottom: 0;
    box-shadow: var(--krome-shadow-sm);
    display: none;
    left: 0;
    padding: 16px;
    position: fixed;
    right: 0;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 16px;
    top: 16px;
}

/* Responsive */
@media (max-width: 640px) {
    .ess-info-grid {
        grid-template-columns: 1fr;
    }
}
