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

:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --success-color: #10b981;
    --success-dark: #059669;
    --danger-color: #dc2626;
    --danger-dark: #b91c1c;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px 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);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #e5e7eb;
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Login Page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background-color: #e5e7eb;
}

.login-box {
    background: var(--bg-primary);
    padding: 48px 40px;
    border-radius: 16px;
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.login-logo {
    max-width: 80px;
    max-height: 80px;
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin: 0 auto 24px;
    display: block;
}

.login-box h1 {
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 28px;
    font-weight: 700;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 32px;
}

.pin-input-wrapper {
    margin-bottom: 8px;
}

.login-box input[type="password"] {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 20px;
    text-align: center;
    letter-spacing: 8px;
    font-weight: 600;
    transition: all 0.2s ease;
    background-color: var(--bg-secondary);
}

.login-box input[type="password"]:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.error-message {
    color: var(--danger-color);
    font-size: 13px;
    margin-bottom: 16px;
    min-height: 20px;
    font-weight: 500;
}

.login-box button {
    width: 100%;
    padding: 16px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
}

.login-box button:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.login-box button:active {
    transform: translateY(0);
}

/* Portal Page */
.portal-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

.portal-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 40px;
    text-align: center;
}

.logo-image {
    width: 64px;
    height: 64px;
    object-fit: contain;
}

.portal-header h1 {
    color: var(--text-primary);
    font-size: 32px;
    font-weight: 700;
    line-height: 1.2;
    margin: 0;
}

.tiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.tile {
    background: var(--bg-primary);
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    text-decoration: none;
    color: inherit;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.tile::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background-color: var(--primary-color);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.tile:hover::before {
    transform: scaleX(1);
}

.tile:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
    border-color: var(--primary-color);
}

.tile:active {
    transform: translateY(-1px);
}

.tile-icon {
    font-size: 28px;
    flex-shrink: 0;
    line-height: 1;
}

.tile-content {
    flex: 1;
}

.tile h2 {
    color: var(--text-primary);
    margin-bottom: 6px;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.3;
}

.tile p {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
}

.logout-btn {
    display: block;
    margin: 0 auto;
    padding: 12px 32px;
    background-color: var(--danger-color);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.logout-btn:hover {
    background-color: var(--danger-dark);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.logout-btn:active {
    transform: translateY(0);
}

/* Form Pages */
.form-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.form-header {
    margin-bottom: 24px;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary-color);
    text-decoration: none;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.back-btn:hover {
    background-color: rgba(37, 99, 235, 0.1);
}

.back-arrow {
    font-size: 18px;
}

.form-header h1 {
    color: var(--text-primary);
    font-size: 28px;
    font-weight: 700;
}

.portal-form {
    background: var(--bg-primary);
    padding: 32px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
}

.form-section {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.form-section:last-of-type {
    border-bottom: none;
    margin-bottom: 24px;
}

.form-section h3 {
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: 600;
}

.form-group {
    margin-bottom: 0;
}

.form-input,
.form-select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 15px;
    transition: all 0.2s ease;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-input:disabled {
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.6;
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

/* Incident Selection Mini Tiles */
.incident-selection-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.mini-tile {
    background-color: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 14px;
}

.mini-tile:hover {
    border-color: var(--primary-color);
    background-color: var(--bg-secondary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.mini-tile:active {
    transform: translateY(0);
}

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

.mini-tile-content {
    flex: 1;
}

.mini-tile-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.mini-tile-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

.mini-tile.selected {
    border-color: var(--success-color);
    background-color: #ecfdf5;
}

.selected-info {
    margin-top: 16px;
    padding: 14px 0;
    font-size: 14px;
    display: none;
}

.selected-info.active {
    display: block;
}

.selected-info .date-bold {
    display: block;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    font-size: 15px;
}

.selected-info .description-text {
    display: block;
    color: var(--text-secondary);
    font-size: 14px;
}

.selected-info .incident-detail {
    color: var(--text-primary);
    font-size: 14px;
}

/* Checkbox Groups */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    cursor: pointer;
    padding: 12px 0;
    border-radius: 10px;
    transition: background-color 0.2s ease;
}

.checkbox-label:hover {
    background-color: var(--bg-secondary);
}

.checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
}

.checkbox-custom {
    width: 22px;
    height: 22px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    margin-right: 12px;
    margin-top: 2px;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
    border-color: var(--success-color);
    background-color: var(--success-color);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 6px;
    width: 6px;
    height: 11px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-text {
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.5;
}

/* Form Actions */
.form-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.submit-btn {
    width: 100%;
    padding: 16px;
    background-color: var(--success-color);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
}

.submit-btn:hover {
    background-color: var(--success-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.submit-btn:active {
    transform: translateY(0);
}

.cancel-btn {
    width: 100%;
    padding: 16px;
    background-color: var(--danger-color);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
}

.cancel-btn:hover {
    background-color: var(--danger-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.cancel-btn:active {
    transform: translateY(0);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.2s ease;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: var(--bg-primary);
    border-radius: 16px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.3s ease;
}

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

.modal-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 32px;
    color: var(--text-secondary);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
    line-height: 1;
}

.modal-close:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px 24px 24px;
    overflow-y: auto;
}

.loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.incident-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: var(--bg-primary);
}

.incident-item:hover {
    border-color: var(--primary-color);
    background-color: var(--bg-secondary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.incident-item:active {
    transform: translateY(0);
}

.incident-icon-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 60px;
}

.incident-icon {
    font-size: 32px;
}

.incident-number {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.incident-details {
    flex: 1;
}

.incident-type {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.incident-location {
    font-size: 14px;
    color: var(--text-secondary);
}

.no-incidents {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

/* Other Occurrence Modal Form */
.modal-form-group {
    margin-bottom: 20px;
}

.modal-form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
}

.modal-form-group input[type="date"] {
    width: 100%;
    padding: 10px 16px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 15px;
    transition: all 0.2s ease;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
    box-sizing: border-box;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.modal-form-group input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 15px;
    transition: all 0.2s ease;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
    box-sizing: border-box;
}

.modal-form-group input[type="date"]:focus,
.modal-form-group input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.modal-save-btn {
    width: 100%;
    padding: 14px;
    background-color: var(--success-color);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 8px;
}

.modal-save-btn:hover {
    background-color: var(--success-dark);
    transform: translateY(-1px);
}

.modal-save-btn:active {
    transform: translateY(0);
}

/* Responsive Design */
@media (max-width: 768px) {
    .portal-container {
        padding: 24px 20px 40px;
    }
    
    .portal-header {
        margin-bottom: 32px;
    }
    
    .portal-header h1 {
        font-size: 28px;
    }
    
    .logo-image {
        width: 56px;
        height: 56px;
    }
    
    .tiles-grid {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 0 20px;
    }
    
    .tile {
        padding: 16px;
    }
    
    .tile-icon {
        font-size: 24px;
    }
    
    .tile h2 {
        font-size: 16px;
    }
    
    .tile p {
        font-size: 12px;
    }
    
    .portal-form {
        padding: 24px 20px;
    }
    
    .form-header h1 {
        font-size: 24px;
    }
    
    .modal-content {
        max-height: 90vh;
    }
}

@media (max-width: 480px) {
    .login-box {
        padding: 40px 28px;
    }
    
    .portal-container {
        padding: 20px 12px 32px;
    }
    
    .tiles-grid {
        padding: 0 12px;
    }
    
    .form-container {
        padding: 12px;
    }
    
    .login-logo {
        width: 64px;
        height: 64px;
    }
    
    .login-box h1 {
        font-size: 24px;
    }
    
    .portal-header {
        padding: 12px;
    }
    
    .incident-item {
        padding: 12px;
    }
    
    .incident-icon {
        font-size: 28px;
    }
}

/* Touch improvements for mobile */
@media (hover: none) and (pointer: coarse) {
    .tile {
        -webkit-tap-highlight-color: transparent;
    }
    
    .tile:active {
        transform: scale(0.98);
    }
    
    .checkbox-label {
        min-height: 48px;
    }
}